on develop help sign in
Add a splitH to complement splitV!
512aceaEamon Olive
src/Reflex/Vty/Widget.hs+30
@@ -43,6 +43,7 @@ module Reflex.Vty.Widget
43 , mouseScroll
43 , mouseScroll
44 , pane
44 , pane
45 , splitV
45 , splitV
46+ , splitH
46 , splitVDrag
47 , splitVDrag
47 , box
48 , box
48 , boxStatic
49 , boxStatic
@@ -474,6 +475,35 @@ splitV sizeFunD focD wA wB = do
474 rb <- pane regB (snd <$> focD) wB
475 rb <- pane regB (snd <$> focD) wB
475 return (ra,rb)
476 return (ra,rb)
476
477
478+-- | A plain split of the available space into horizontally stacked panes.
479+-- No visual separator is built in here.
480+splitH :: (Reflex t, Monad m, MonadNodeId m)
481+ => Dynamic t (Int -> Int)
482+ -- ^ Function used to determine size of first pane based on available size
483+ -> Dynamic t (Bool, Bool)
484+ -- ^ How to focus the two sub-panes, given that we are focused.
485+ -> VtyWidget t m a
486+ -- ^ Widget for first pane
487+ -> VtyWidget t m b
488+ -- ^ Widget for second pane
489+ -> VtyWidget t m (a,b)
490+splitH sizeFunD focD wA wB = do
491+ dw <- displayWidth
492+ dh <- displayHeight
493+ let regA = DynRegion
494+ { _dynRegion_left = pure 0
495+ , _dynRegion_top = pure 0
496+ , _dynRegion_width = sizeFunD <*> dw
497+ , _dynRegion_height = dh
498+ }
499+ regB = DynRegion
500+ { _dynRegion_left = _dynRegion_width regA
501+ , _dynRegion_top = pure 0
502+ , _dynRegion_width = liftA2 (-) dw (_dynRegion_width regA)
503+ , _dynRegion_height = dh
504+ }
505+ liftA2 (,) (pane regA (fmap fst focD) wA) (pane regB (fmap snd focD) wB)
506+
477-- | A split of the available space into two parts with a draggable separator.
507-- | A split of the available space into two parts with a draggable separator.
478-- Starts with half the space allocated to each, and the first pane has focus.
508-- Starts with half the space allocated to each, and the first pane has focus.
479-- Clicking in a pane switches focus.
509-- Clicking in a pane switches focus.