@@ -8,12 +8,12 @@ Description: Monad transformer and tools for arranging widgets and building scre
88{-# LANGUAGE GeneralizedNewtypeDeriving #-}
99{-# LANGUAGE LambdaCase #-}
1010{-# LANGUAGE MultiParamTypeClasses #-}
11+{-# LANGUAGE RankNTypes #-}
1112{-# LANGUAGE RecordWildCards #-}
1213{-# LANGUAGE RecursiveDo #-}
14+{-# LANGUAGE ScopedTypeVariables #-}
15+{-# LANGUAGE TypeApplications #-}
1316{-# LANGUAGE UndecidableInstances #-}
14−{-# LANGUAGE TypeApplications #-}
15−{-# LANGUAGE RankNTypes #-}
16−{-# LANGUAGE ScopedTypeVariables #-}
1717
1818
1919module Reflex.Vty.Widget.Layout
@@ -50,7 +50,7 @@ import Data.Bimap (Bimap)
5050import qualified Data.Bimap as Bimap
5151import Data.Default (Default (..))
5252import qualified Data.Dependent.Map as DMap
53−import Data.Dependent.Sum (DSum((:=>)))
53+import Data.Dependent.Sum (DSum ((:=>)))
5454import Data.Functor.Misc
5555import Data.Map (Map)
5656import qualified Data.Map as Map
@@ -68,20 +68,20 @@ import Reflex.Vty.Widget
6868
6969-- | The main-axis orientation of a 'Layout' widget
7070data Orientation = Orientation_Column
71− | Orientation_Row
72− deriving (Show, Read, Eq, Ord)
71+ | Orientation_Row
72+ deriving (Show, Read, Eq, Ord)
7373
7474data LayoutSegment = LayoutSegment
75− { _layoutSegment_offset :: Int
76− , _layoutSegment_size :: Int
77− }
75+ { _layoutSegment_offset :: Int
76+ , _layoutSegment_size :: Int
77+ }
7878
7979data LayoutCtx t = LayoutCtx
80− { _layoutCtx_regions :: Dynamic t (Map NodeId LayoutSegment)
81− , _layoutCtx_focusSelfDemux :: Demux t (Maybe NodeId)
82− , _layoutCtx_orientation :: Dynamic t Orientation
83− , _layoutCtx_focusChildSelector :: EventSelector t (Const2 NodeId (Maybe Int))
84− }
80+ { _layoutCtx_regions :: Dynamic t (Map NodeId LayoutSegment)
81+ , _layoutCtx_focusSelfDemux :: Demux t (Maybe NodeId)
82+ , _layoutCtx_orientation :: Dynamic t Orientation
83+ , _layoutCtx_focusChildSelector :: EventSelector t (Const2 NodeId (Maybe Int))
84+ }
8585
8686
8787-- | The Layout monad transformer keeps track of the configuration (e.g., 'Orientation') and
@@ -138,7 +138,7 @@ fanFocusEv :: (Reflex t) => Behavior t (Maybe (NodeId, Int)) -> Event t (Maybe (
138138fanFocusEv focussed focusReqIx = fan $ attachWith attachfn focussed focusReqIx where
139139 attachfn mkv0 mkv1 = case mkv1 of
140140 Nothing -> case mkv0 of
141− Nothing -> DMap.empty
141+ Nothing -> DMap.empty
142142 Just (k0,_) -> DMap.fromList [Const2 k0 :=> Identity Nothing]
143143 Just (k1,v1) -> case mkv0 of
144144 Nothing -> DMap.fromList [Const2 k1 :=> Identity (Just v1)]
@@ -307,11 +307,11 @@ tile = tile_
307307
308308-- | Configuration options for and constraints on 'tile_'
309309data TileConfig t = TileConfig
310− { _tileConfig_constraint :: Dynamic t Constraint
310+ { _tileConfig_constraint :: Dynamic t Constraint
311311 -- ^ 'Constraint' on the tile_'s size
312− , _tile_Config_focusable :: Dynamic t Bool
312+ , _tile_Config_focusable :: Dynamic t Bool
313313 -- ^ Whether the tile_ is focusable
314− }
314+ }
315315
316316instance Reflex t => Default (TileConfig t) where
317317 def = TileConfig (pure $ Constraint_Min 0) (pure True)
@@ -430,8 +430,8 @@ askOrientation = Layout $ asks _layoutCtx_orientation
430430
431431-- | Datatype representing constraints on a widget's size along the main axis (see 'Orientation')
432432data Constraint = Constraint_Fixed Int
433− | Constraint_Min Int
434− deriving (Show, Read, Eq, Ord)
433+ | Constraint_Min Int
434+ deriving (Show, Read, Eq, Ord)
435435
436436-- | Compute the size of each widget "@k@" based on the total set of 'Constraint's
437437computeSizes
@@ -460,7 +460,8 @@ computeEdges = fst . Map.foldlWithKey' (\(m, offset) k (a, sz) ->
460460-- TODO FINISH
461461-- but it's weird cuz a leaf node won't know it's PosDim until combined with a Region...
462462-- | Dynamic sizing information on a layout hierarchy (intended for testing)
463−data LayoutDebugTree t = LayoutDebugTree_Branch [LayoutDebugTree t] | LayoutDebugTree_Leaf
463+data LayoutDebugTree t = LayoutDebugTree_Branch [LayoutDebugTree t]
464+ | LayoutDebugTree_Leaf
464465
465466emptyLayoutDebugTree :: LayoutDebugTree t
466467emptyLayoutDebugTree = LayoutDebugTree_Leaf
@@ -471,12 +472,12 @@ class IsLayoutReturn t b a where
471472 getLayoutFocussedDyn :: b -> Dynamic t (Maybe Int)
472473 getLayoutTree :: b -> LayoutDebugTree t
473474
474−data LayoutReturnData t a = LayoutReturnData {
475− _layoutReturnData_tree :: LayoutDebugTree t
476− , _layoutReturnData_focus :: Dynamic t (Maybe Int)
475+data LayoutReturnData t a = LayoutReturnData
476+ { _layoutReturnData_tree :: LayoutDebugTree t
477+ , _layoutReturnData_focus :: Dynamic t (Maybe Int)
477478 , _layoutReturnData_children :: Int
478− , _layoutReturnData_value :: a
479− }
479+ , _layoutReturnData_value :: a
480+ }
480481
481482instance IsLayoutReturn t (LayoutReturnData t a) a where
482483 getLayoutResult lrd = _layoutReturnData_value lrd