{-# LANGUAGE StrictData #-} --{-# LANGUAGE DeriveGeneric #-} --{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE TemplateHaskell #-} module Dodge.Data.SelectionList where import Dodge.Data.DoubleTree import Color import Control.Lens import Data.IntMap.Strict (IntMap) import Dodge.Data.CardinalPoint import Dodge.Data.ScreenPos import Picture.Data --import Data.Aeson --import Data.Aeson.TH data ListDisplayParams = ListDisplayParams { _ldpPos :: ScreenPos , _ldpScale :: Float , _ldpVerticalGap :: Float , _ldpCursorSides :: [CardinalPoint] , _ldpWidth :: SelectionWidth } data SelectionList a = SelectionList { _slItems :: [SelectionItem a] , _slSelPos :: Maybe Int , _slRegex :: String , _slRegexInput :: Bool , _slRegexList :: [(SelectionItem a, Maybe Int)] } --deriving (Eq, Ord, Show, Read) --Generic, Flat) data SelectionSections a = SelectionSections { _sssSections :: IntMap (SelectionSection a) , _sssExtra :: SSSExtra } -- note that filters are arbitrary: the sssFilters point to the lower of -- a pair of ints (i,i+1) such that the lower is the regex section, the higher -- is the items section. data SSSExtra = SSSExtra { _sssSelPos :: Maybe (Int, Int) , _sssFilters :: IntMap (Maybe String) } data SectionCursor = SectionCursor { _scurPos :: Int , _scurSize :: Int , _scurColor :: Color } data SelectionSection a = SelectionSection { _ssItems :: IntMap (SelectionItem a) , _ssCursor :: Maybe SectionCursor , _ssMinSize :: Int , _ssOffset :: Int , _ssShownItems :: [Picture] , _ssIndent :: Int , _ssDescriptor :: String } | SelectionTreeSection { _stsItems :: DoubleTree (SelectionItem a) , _ssCursor :: Maybe SectionCursor , _ssMinSize :: Int , _ssOffset :: Int , _ssShownItems :: [Picture] , _ssIndent :: Int , _ssDescriptor :: String } data SelectionWidth = FixedSelectionWidth Int | VariableSelectionWidth (Int -> Int) | UseMaxSelectionItemWidth data CursorType = NoCursor | BorderCursor [CardinalPoint] data SelectionItem a = SelectionItem { _siPictures :: [String] , _siHeight :: Int , _siIsSelectable :: Bool , _siColor :: Color , _siOffX :: Int , _siPayload :: a } | SelectionInfo { _siPictures :: [String] , _siHeight :: Int , _siIsSelectable :: Bool , _siColor :: Color , _siOffX :: Int } makeLenses ''ListDisplayParams makeLenses ''SelectionList makeLenses ''SelectionItem makeLenses ''SelectionSection makeLenses ''SelectionSections makeLenses ''SSSExtra makeLenses ''SectionCursor --deriveJSON defaultOptions ''SelectionItem --deriveJSON defaultOptions ''SelectionList