@@ -43,6 +43,7 @@ module Reflex.Vty.Widget
4343 , mouseScroll
4444 , pane
4545 , splitV
46+ , splitH
4647 , splitVDrag
4748 , box
4849 , boxStatic
@@ -474,6 +475,35 @@ splitV sizeFunD focD wA wB = do
474475 rb <- pane regB (snd <$> focD) wB
475476 return (ra,rb)
476477
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+
477507-- | A split of the available space into two parts with a draggable separator.
478508-- Starts with half the space allocated to each, and the first pane has focus.
479509-- Clicking in a pane switches focus.