--{-# LANGUAGE DeriveGeneric #-} --{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE StrictData #-} module Dodge.Data.SelectionList where import Picture.Data import Color import Control.Lens import Dodge.Data.CardinalPoint import Data.IntMap.Strict (IntMap) --import Data.Aeson --import Data.Aeson.TH data ListDisplayParams = ListDisplayParams { _ldpPosX :: Float , _ldpPosY :: Float , _ldpScale :: Float , _ldpVerticalGap :: Float , _ldpCursorType :: CursorType , _ldpWidth :: SelectionWidth -- , _ldpSizeRestriction :: SelectionSizeRestriction } 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) -- this is projected to be VERY arbitrary: the fssFilters 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 FilterableSections a = FilterableSections { _fssFilters :: IntMap (Maybe String) , _fssSections :: SelectionSections a } data SelectionSections a = SelectionSections { _sssSections :: IntMap (SelectionSection a) , _sssSelPos :: Maybe (Int,Int) } data SectionCursor = SectionCursor --{ _scurSel :: Int { _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 } 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 } | SelectionRegex { _siPictures :: [String] , _siHeight :: Int , _siIsSelectable :: Bool , _siColor :: Color , _siOffX :: Int } --deriving (Eq, Ord, Show, Read) --Generic, Flat) makeLenses ''ListDisplayParams makeLenses ''SelectionList makeLenses ''SelectionItem makeLenses ''SelectionSection makeLenses ''SelectionSections makeLenses ''FilterableSections makeLenses ''SectionCursor --deriveJSON defaultOptions ''SelectionItem --deriveJSON defaultOptions ''SelectionList