darcs patch: The start of a LayoutCombinator class with a CombinedL...

Hi,
this is a step forward in the direction of the type classes cleanup
I've been proposing recently.
The basic idea is to completely hide the Layout implementation to
LayoutModifiers and LayoutCombinators. This way we can extend the
LayoutClass without messing up the whole repository.
This should also let us remove a lot of duplicate code and let the
developers not to rewrite always the same stuff with high probability
of bugs.
This way we could also reject any code that has a (wrs,ml) <- doLayout
in a LayoutClass instance...;)
While there seems to be not much use for such a class (well,
PerWorksapce, ToggleLayouts, MultiToggle, LayoutCombinators, the
layout selector, and so on...;), while implementing it I had the
feeling it could be quite a powerful tool. Imagine to run 2 layouts
and then combine their results with pure code with "combineResult"...
I don't know, but that could be fun.
Still I have some troubles in implementing the handleMessage methond
for CombinedLayout - and in deciding the type of comboHandleMessage.
If we switch layout, the first one should receive an Hide. Should I
take care of that in the class? In the instance?
David, any idea?
That following would be the implementation of a simple Toggle layout
combinator. It works (sendMessage Toogle will make it switch), but I
still have to find a clean solution to hide the first layout,
otherwise decorations will be floating around d forever...;)
Any idea?
TIA
Andrea
data ToggleLayout a = TL Bool deriving (Read,Show)
instance LayoutCombinator ToggleLay a where
chooser (TL b) = if b then DoFirst else DoSecond
comboHandleMess (TL b) _ _ m
| Just Togg <- fromMessage m = return $ TL (not b)
| otherwise = return (TL b)
data ToggleLayoutMsg = Toggle deriving (Read,Show,Typeable)
instance Message ToggleLayoutMsg
toggle :: l1 a -> l2 a -> CombinedLayout ToggleLayout l1 l2 a
toggle = CombinedLayout (TL True)
to use as: toggle Full tabbed
Tue Jan 29 18:25:24 CET 2008 Andrea Rossato
participants (1)
-
Andrea Rossato