{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# Language GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Strict #-}
module Monomer.Core.WidgetTypes where
import Control.Concurrent (MVar)
import Control.Lens (ALens')
import Data.Default
import Data.Map.Strict (Map)
import Data.Sequence (Seq)
import Data.String (IsString(..))
import Data.Text (Text)
import Data.Typeable (Typeable, typeOf)
import Data.Word (Word64)
import GHC.Generics
import TextShow
import qualified Data.Text as T
import Monomer.Common
import Monomer.Core.StyleTypes
import Monomer.Core.ThemeTypes
import Monomer.Event.Types
import Monomer.Graphics.Types
newtype Millisecond = Millisecond {
Millisecond -> Word64
unMilliseconds :: Word64
} deriving newtype (Millisecond -> Millisecond -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Millisecond -> Millisecond -> Bool
$c/= :: Millisecond -> Millisecond -> Bool
== :: Millisecond -> Millisecond -> Bool
$c== :: Millisecond -> Millisecond -> Bool
Eq, Eq Millisecond
Millisecond -> Millisecond -> Bool
Millisecond -> Millisecond -> Ordering
Millisecond -> Millisecond -> Millisecond
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Millisecond -> Millisecond -> Millisecond
$cmin :: Millisecond -> Millisecond -> Millisecond
max :: Millisecond -> Millisecond -> Millisecond
$cmax :: Millisecond -> Millisecond -> Millisecond
>= :: Millisecond -> Millisecond -> Bool
$c>= :: Millisecond -> Millisecond -> Bool
> :: Millisecond -> Millisecond -> Bool
$c> :: Millisecond -> Millisecond -> Bool
<= :: Millisecond -> Millisecond -> Bool
$c<= :: Millisecond -> Millisecond -> Bool
< :: Millisecond -> Millisecond -> Bool
$c< :: Millisecond -> Millisecond -> Bool
compare :: Millisecond -> Millisecond -> Ordering
$ccompare :: Millisecond -> Millisecond -> Ordering
Ord, Int -> Millisecond
Millisecond -> Int
Millisecond -> [Millisecond]
Millisecond -> Millisecond
Millisecond -> Millisecond -> [Millisecond]
Millisecond -> Millisecond -> Millisecond -> [Millisecond]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Millisecond -> Millisecond -> Millisecond -> [Millisecond]
$cenumFromThenTo :: Millisecond -> Millisecond -> Millisecond -> [Millisecond]
enumFromTo :: Millisecond -> Millisecond -> [Millisecond]
$cenumFromTo :: Millisecond -> Millisecond -> [Millisecond]
enumFromThen :: Millisecond -> Millisecond -> [Millisecond]
$cenumFromThen :: Millisecond -> Millisecond -> [Millisecond]
enumFrom :: Millisecond -> [Millisecond]
$cenumFrom :: Millisecond -> [Millisecond]
fromEnum :: Millisecond -> Int
$cfromEnum :: Millisecond -> Int
toEnum :: Int -> Millisecond
$ctoEnum :: Int -> Millisecond
pred :: Millisecond -> Millisecond
$cpred :: Millisecond -> Millisecond
succ :: Millisecond -> Millisecond
$csucc :: Millisecond -> Millisecond
Enum, Millisecond
forall a. a -> a -> Bounded a
maxBound :: Millisecond
$cmaxBound :: Millisecond
minBound :: Millisecond
$cminBound :: Millisecond
Bounded, Integer -> Millisecond
Millisecond -> Millisecond
Millisecond -> Millisecond -> Millisecond
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Millisecond
$cfromInteger :: Integer -> Millisecond
signum :: Millisecond -> Millisecond
$csignum :: Millisecond -> Millisecond
abs :: Millisecond -> Millisecond
$cabs :: Millisecond -> Millisecond
negate :: Millisecond -> Millisecond
$cnegate :: Millisecond -> Millisecond
* :: Millisecond -> Millisecond -> Millisecond
$c* :: Millisecond -> Millisecond -> Millisecond
- :: Millisecond -> Millisecond -> Millisecond
$c- :: Millisecond -> Millisecond -> Millisecond
+ :: Millisecond -> Millisecond -> Millisecond
$c+ :: Millisecond -> Millisecond -> Millisecond
Num, Num Millisecond
Ord Millisecond
Millisecond -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: Millisecond -> Rational
$ctoRational :: Millisecond -> Rational
Real, Enum Millisecond
Real Millisecond
Millisecond -> Integer
Millisecond -> Millisecond -> (Millisecond, Millisecond)
Millisecond -> Millisecond -> Millisecond
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: Millisecond -> Integer
$ctoInteger :: Millisecond -> Integer
divMod :: Millisecond -> Millisecond -> (Millisecond, Millisecond)
$cdivMod :: Millisecond -> Millisecond -> (Millisecond, Millisecond)
quotRem :: Millisecond -> Millisecond -> (Millisecond, Millisecond)
$cquotRem :: Millisecond -> Millisecond -> (Millisecond, Millisecond)
mod :: Millisecond -> Millisecond -> Millisecond
$cmod :: Millisecond -> Millisecond -> Millisecond
div :: Millisecond -> Millisecond -> Millisecond
$cdiv :: Millisecond -> Millisecond -> Millisecond
rem :: Millisecond -> Millisecond -> Millisecond
$crem :: Millisecond -> Millisecond -> Millisecond
quot :: Millisecond -> Millisecond -> Millisecond
$cquot :: Millisecond -> Millisecond -> Millisecond
Integral, ReadPrec [Millisecond]
ReadPrec Millisecond
Int -> ReadS Millisecond
ReadS [Millisecond]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Millisecond]
$creadListPrec :: ReadPrec [Millisecond]
readPrec :: ReadPrec Millisecond
$creadPrec :: ReadPrec Millisecond
readList :: ReadS [Millisecond]
$creadList :: ReadS [Millisecond]
readsPrec :: Int -> ReadS Millisecond
$creadsPrec :: Int -> ReadS Millisecond
Read, Int -> Millisecond -> ShowS
[Millisecond] -> ShowS
Millisecond -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Millisecond] -> ShowS
$cshowList :: [Millisecond] -> ShowS
show :: Millisecond -> String
$cshow :: Millisecond -> String
showsPrec :: Int -> Millisecond -> ShowS
$cshowsPrec :: Int -> Millisecond -> ShowS
Show, Millisecond
forall a. a -> Default a
def :: Millisecond
$cdef :: Millisecond
Default, Int -> Millisecond -> Builder
Int -> Millisecond -> Text
Int -> Millisecond -> Text
[Millisecond] -> Builder
[Millisecond] -> Text
[Millisecond] -> Text
Millisecond -> Builder
Millisecond -> Text
Millisecond -> Text
forall a.
(Int -> a -> Builder)
-> (a -> Builder)
-> ([a] -> Builder)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> TextShow a
showtlList :: [Millisecond] -> Text
$cshowtlList :: [Millisecond] -> Text
showtl :: Millisecond -> Text
$cshowtl :: Millisecond -> Text
showtlPrec :: Int -> Millisecond -> Text
$cshowtlPrec :: Int -> Millisecond -> Text
showtList :: [Millisecond] -> Text
$cshowtList :: [Millisecond] -> Text
showt :: Millisecond -> Text
$cshowt :: Millisecond -> Text
showtPrec :: Int -> Millisecond -> Text
$cshowtPrec :: Int -> Millisecond -> Text
showbList :: [Millisecond] -> Builder
$cshowbList :: [Millisecond] -> Builder
showb :: Millisecond -> Builder
$cshowb :: Millisecond -> Builder
showbPrec :: Int -> Millisecond -> Builder
$cshowbPrec :: Int -> Millisecond -> Builder
TextShow)
deriving (forall x. Rep Millisecond x -> Millisecond
forall x. Millisecond -> Rep Millisecond x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Millisecond x -> Millisecond
$cfrom :: forall x. Millisecond -> Rep Millisecond x
Generic)
type WidgetModel s = Typeable s
type WidgetEvent e = Typeable e
type WidgetKeyMap s e = Map WidgetKey (WidgetNode s e)
data FocusDirection
= FocusFwd
| FocusBwd
deriving (FocusDirection -> FocusDirection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FocusDirection -> FocusDirection -> Bool
$c/= :: FocusDirection -> FocusDirection -> Bool
== :: FocusDirection -> FocusDirection -> Bool
$c== :: FocusDirection -> FocusDirection -> Bool
Eq, Int -> FocusDirection -> ShowS
[FocusDirection] -> ShowS
FocusDirection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FocusDirection] -> ShowS
$cshowList :: [FocusDirection] -> ShowS
show :: FocusDirection -> String
$cshow :: FocusDirection -> String
showsPrec :: Int -> FocusDirection -> ShowS
$cshowsPrec :: Int -> FocusDirection -> ShowS
Show)
data WindowRequest
= WindowSetTitle Text
| WindowSetFullScreen
| WindowMaximize
| WindowMinimize
| WindowRestore
| WindowBringToFront
deriving (WindowRequest -> WindowRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WindowRequest -> WindowRequest -> Bool
$c/= :: WindowRequest -> WindowRequest -> Bool
== :: WindowRequest -> WindowRequest -> Bool
$c== :: WindowRequest -> WindowRequest -> Bool
Eq, Int -> WindowRequest -> ShowS
[WindowRequest] -> ShowS
WindowRequest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WindowRequest] -> ShowS
$cshowList :: [WindowRequest] -> ShowS
show :: WindowRequest -> String
$cshow :: WindowRequest -> String
showsPrec :: Int -> WindowRequest -> ShowS
$cshowsPrec :: Int -> WindowRequest -> ShowS
Show)
newtype WidgetType
= WidgetType Text
deriving (WidgetType -> WidgetType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WidgetType -> WidgetType -> Bool
$c/= :: WidgetType -> WidgetType -> Bool
== :: WidgetType -> WidgetType -> Bool
$c== :: WidgetType -> WidgetType -> Bool
Eq, Int -> WidgetType -> ShowS
[WidgetType] -> ShowS
WidgetType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WidgetType] -> ShowS
$cshowList :: [WidgetType] -> ShowS
show :: WidgetType -> String
$cshow :: WidgetType -> String
showsPrec :: Int -> WidgetType -> ShowS
$cshowsPrec :: Int -> WidgetType -> ShowS
Show, forall x. Rep WidgetType x -> WidgetType
forall x. WidgetType -> Rep WidgetType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WidgetType x -> WidgetType
$cfrom :: forall x. WidgetType -> Rep WidgetType x
Generic)
instance IsString WidgetType where
fromString :: String -> WidgetType
fromString = Text -> WidgetType
WidgetType forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
data WidgetData s a
= WidgetValue a
| WidgetLens (ALens' s a)
data WidgetId = WidgetId {
WidgetId -> Millisecond
_widTs :: Millisecond,
WidgetId -> Path
_widPath :: Path
} deriving (WidgetId -> WidgetId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WidgetId -> WidgetId -> Bool
$c/= :: WidgetId -> WidgetId -> Bool
== :: WidgetId -> WidgetId -> Bool
$c== :: WidgetId -> WidgetId -> Bool
Eq, Int -> WidgetId -> ShowS
[WidgetId] -> ShowS
WidgetId -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WidgetId] -> ShowS
$cshowList :: [WidgetId] -> ShowS
show :: WidgetId -> String
$cshow :: WidgetId -> String
showsPrec :: Int -> WidgetId -> ShowS
$cshowsPrec :: Int -> WidgetId -> ShowS
Show, Eq WidgetId
WidgetId -> WidgetId -> Bool
WidgetId -> WidgetId -> Ordering
WidgetId -> WidgetId -> WidgetId
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: WidgetId -> WidgetId -> WidgetId
$cmin :: WidgetId -> WidgetId -> WidgetId
max :: WidgetId -> WidgetId -> WidgetId
$cmax :: WidgetId -> WidgetId -> WidgetId
>= :: WidgetId -> WidgetId -> Bool
$c>= :: WidgetId -> WidgetId -> Bool
> :: WidgetId -> WidgetId -> Bool
$c> :: WidgetId -> WidgetId -> Bool
<= :: WidgetId -> WidgetId -> Bool
$c<= :: WidgetId -> WidgetId -> Bool
< :: WidgetId -> WidgetId -> Bool
$c< :: WidgetId -> WidgetId -> Bool
compare :: WidgetId -> WidgetId -> Ordering
$ccompare :: WidgetId -> WidgetId -> Ordering
Ord, forall x. Rep WidgetId x -> WidgetId
forall x. WidgetId -> Rep WidgetId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WidgetId x -> WidgetId
$cfrom :: forall x. WidgetId -> Rep WidgetId x
Generic)
instance Default WidgetId where
def :: WidgetId
def = Millisecond -> Path -> WidgetId
WidgetId Millisecond
0 Path
emptyPath
newtype WidgetKey
= WidgetKey Text
deriving (WidgetKey -> WidgetKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WidgetKey -> WidgetKey -> Bool
$c/= :: WidgetKey -> WidgetKey -> Bool
== :: WidgetKey -> WidgetKey -> Bool
$c== :: WidgetKey -> WidgetKey -> Bool
Eq, Int -> WidgetKey -> ShowS
[WidgetKey] -> ShowS
WidgetKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WidgetKey] -> ShowS
$cshowList :: [WidgetKey] -> ShowS
show :: WidgetKey -> String
$cshow :: WidgetKey -> String
showsPrec :: Int -> WidgetKey -> ShowS
$cshowsPrec :: Int -> WidgetKey -> ShowS
Show, Eq WidgetKey
WidgetKey -> WidgetKey -> Bool
WidgetKey -> WidgetKey -> Ordering
WidgetKey -> WidgetKey -> WidgetKey
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: WidgetKey -> WidgetKey -> WidgetKey
$cmin :: WidgetKey -> WidgetKey -> WidgetKey
max :: WidgetKey -> WidgetKey -> WidgetKey
$cmax :: WidgetKey -> WidgetKey -> WidgetKey
>= :: WidgetKey -> WidgetKey -> Bool
$c>= :: WidgetKey -> WidgetKey -> Bool
> :: WidgetKey -> WidgetKey -> Bool
$c> :: WidgetKey -> WidgetKey -> Bool
<= :: WidgetKey -> WidgetKey -> Bool
$c<= :: WidgetKey -> WidgetKey -> Bool
< :: WidgetKey -> WidgetKey -> Bool
$c< :: WidgetKey -> WidgetKey -> Bool
compare :: WidgetKey -> WidgetKey -> Ordering
$ccompare :: WidgetKey -> WidgetKey -> Ordering
Ord, forall x. Rep WidgetKey x -> WidgetKey
forall x. WidgetKey -> Rep WidgetKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WidgetKey x -> WidgetKey
$cfrom :: forall x. WidgetKey -> Rep WidgetKey x
Generic)
instance IsString WidgetKey where
fromString :: String -> WidgetKey
fromString = Text -> WidgetKey
WidgetKey forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack
data WidgetState
= forall i . WidgetModel i => WidgetState i
instance Show WidgetState where
show :: WidgetState -> String
show (WidgetState i
state) = String
"WidgetState: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall a. Typeable a => a -> TypeRep
typeOf i
state)
data WidgetShared
= forall i . Typeable i => WidgetShared i
instance Show WidgetShared where
show :: WidgetShared -> String
show (WidgetShared i
shared) = String
"WidgetShared: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall a. Typeable a => a -> TypeRep
typeOf i
shared)
data WidgetRequest s e
= IgnoreParentEvents
| IgnoreChildrenEvents
| ResizeWidgets WidgetId
| ResizeWidgetsImmediate WidgetId
| MoveFocus (Maybe WidgetId) FocusDirection
| SetFocus WidgetId
| GetClipboard WidgetId
| SetClipboard ClipboardData
| StartTextInput Rect
| StopTextInput
| SetOverlay WidgetId Path
| ResetOverlay WidgetId
| SetCursorIcon WidgetId CursorIcon
| ResetCursorIcon WidgetId
| StartDrag WidgetId Path WidgetDragMsg
| StopDrag WidgetId
| RenderOnce
| RenderEvery WidgetId Millisecond (Maybe Int)
| RenderStop WidgetId
| RemoveRendererImage Text
| ExitApplication Bool
| UpdateWindow WindowRequest
| UpdateModel (s -> s)
| SetWidgetPath WidgetId Path
| ResetWidgetPath WidgetId
| WidgetEvent e => RaiseEvent e
| forall i . Typeable i => SendMessage WidgetId i
| forall i . Typeable i => RunTask WidgetId Path (IO i)
| forall i . Typeable i => RunProducer WidgetId Path ((i -> IO ()) -> IO ())
| forall i . Typeable i => RunInRenderThread WidgetId Path (IO i)
instance Eq e => Eq (WidgetRequest s e) where
WidgetRequest s e
IgnoreParentEvents == :: WidgetRequest s e -> WidgetRequest s e -> Bool
== WidgetRequest s e
IgnoreParentEvents = Bool
True
WidgetRequest s e
IgnoreChildrenEvents == WidgetRequest s e
IgnoreChildrenEvents = Bool
True
ResizeWidgets WidgetId
w1 == ResizeWidgets WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
ResizeWidgetsImmediate WidgetId
w1 == ResizeWidgetsImmediate WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
MoveFocus Maybe WidgetId
w1 FocusDirection
fd1 == MoveFocus Maybe WidgetId
w2 FocusDirection
fd2 = (Maybe WidgetId
w1, FocusDirection
fd1) forall a. Eq a => a -> a -> Bool
== (Maybe WidgetId
w2, FocusDirection
fd2)
SetFocus WidgetId
w1 == SetFocus WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
GetClipboard WidgetId
w1 == GetClipboard WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
SetClipboard ClipboardData
c1 == SetClipboard ClipboardData
c2 = ClipboardData
c1 forall a. Eq a => a -> a -> Bool
== ClipboardData
c2
StartTextInput Rect
r1 == StartTextInput Rect
r2 = Rect
r1 forall a. Eq a => a -> a -> Bool
== Rect
r2
WidgetRequest s e
StopTextInput == WidgetRequest s e
StopTextInput = Bool
True
SetOverlay WidgetId
w1 Path
p1 == SetOverlay WidgetId
w2 Path
p2 = (WidgetId
w1, Path
p1) forall a. Eq a => a -> a -> Bool
== (WidgetId
w2, Path
p2)
ResetOverlay WidgetId
w1 == ResetOverlay WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
SetCursorIcon WidgetId
w1 CursorIcon
c1 == SetCursorIcon WidgetId
w2 CursorIcon
c2 = (WidgetId
w1, CursorIcon
c1) forall a. Eq a => a -> a -> Bool
== (WidgetId
w2, CursorIcon
c2)
ResetCursorIcon WidgetId
w1 == ResetCursorIcon WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
StartDrag WidgetId
w1 Path
p1 WidgetDragMsg
m1 == StartDrag WidgetId
w2 Path
p2 WidgetDragMsg
m2 = (WidgetId
w1, Path
p1, WidgetDragMsg
m1) forall a. Eq a => a -> a -> Bool
== (WidgetId
w2, Path
p2, WidgetDragMsg
m2)
StopDrag WidgetId
w1 == StopDrag WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
WidgetRequest s e
RenderOnce == WidgetRequest s e
RenderOnce = Bool
True
RenderEvery WidgetId
p1 Millisecond
c1 Maybe Int
r1 == RenderEvery WidgetId
p2 Millisecond
c2 Maybe Int
r2 = (WidgetId
p1, Millisecond
c1, Maybe Int
r1) forall a. Eq a => a -> a -> Bool
== (WidgetId
p2, Millisecond
c2, Maybe Int
r2)
RenderStop WidgetId
p1 == RenderStop WidgetId
p2 = WidgetId
p1 forall a. Eq a => a -> a -> Bool
== WidgetId
p2
ExitApplication Bool
e1 == ExitApplication Bool
e2 = Bool
e1 forall a. Eq a => a -> a -> Bool
== Bool
e2
UpdateWindow WindowRequest
w1 == UpdateWindow WindowRequest
w2 = WindowRequest
w1 forall a. Eq a => a -> a -> Bool
== WindowRequest
w2
SetWidgetPath WidgetId
w1 Path
p1 == SetWidgetPath WidgetId
w2 Path
p2 = (WidgetId
w1, Path
p1) forall a. Eq a => a -> a -> Bool
== (WidgetId
w2, Path
p2)
ResetWidgetPath WidgetId
w1 == ResetWidgetPath WidgetId
w2 = WidgetId
w1 forall a. Eq a => a -> a -> Bool
== WidgetId
w2
RaiseEvent e
e1 == RaiseEvent e
e2 = e
e1 forall a. Eq a => a -> a -> Bool
== e
e2
WidgetRequest s e
_ == WidgetRequest s e
_ = Bool
False
data WidgetResult s e = WidgetResult {
forall s e. WidgetResult s e -> WidgetNode s e
_wrNode :: WidgetNode s e,
forall s e. WidgetResult s e -> Seq (WidgetRequest s e)
_wrRequests :: Seq (WidgetRequest s e)
}
instance Semigroup (WidgetResult s e) where
WidgetResult s e
er1 <> :: WidgetResult s e -> WidgetResult s e -> WidgetResult s e
<> WidgetResult s e
er2 = WidgetResult {
_wrNode :: WidgetNode s e
_wrNode = forall s e. WidgetResult s e -> WidgetNode s e
_wrNode WidgetResult s e
er2,
_wrRequests :: Seq (WidgetRequest s e)
_wrRequests = forall s e. WidgetResult s e -> Seq (WidgetRequest s e)
_wrRequests WidgetResult s e
er1 forall a. Semigroup a => a -> a -> a
<> forall s e. WidgetResult s e -> Seq (WidgetRequest s e)
_wrRequests WidgetResult s e
er2
}
data LayoutDirection
= LayoutNone
| LayoutHorizontal
| LayoutVertical
deriving (LayoutDirection -> LayoutDirection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LayoutDirection -> LayoutDirection -> Bool
$c/= :: LayoutDirection -> LayoutDirection -> Bool
== :: LayoutDirection -> LayoutDirection -> Bool
$c== :: LayoutDirection -> LayoutDirection -> Bool
Eq, Int -> LayoutDirection -> ShowS
[LayoutDirection] -> ShowS
LayoutDirection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LayoutDirection] -> ShowS
$cshowList :: [LayoutDirection] -> ShowS
show :: LayoutDirection -> String
$cshow :: LayoutDirection -> String
showsPrec :: Int -> LayoutDirection -> ShowS
$cshowsPrec :: Int -> LayoutDirection -> ShowS
Show, forall x. Rep LayoutDirection x -> LayoutDirection
forall x. LayoutDirection -> Rep LayoutDirection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LayoutDirection x -> LayoutDirection
$cfrom :: forall x. LayoutDirection -> Rep LayoutDirection x
Generic)
data WidgetEnv s e = WidgetEnv {
forall s e. WidgetEnv s e -> Text
_weOs :: Text,
forall s e. WidgetEnv s e -> Double
_weDpr :: Double,
forall s e. WidgetEnv s e -> Millisecond
_weAppStartTs :: Millisecond,
forall s e. WidgetEnv s e -> FontManager
_weFontManager :: FontManager,
forall s e. WidgetEnv s e -> Path -> Seq WidgetNodeInfo
_weFindBranchByPath :: Path -> Seq WidgetNodeInfo,
forall s e. WidgetEnv s e -> Button
_weMainButton :: Button,
forall s e. WidgetEnv s e -> Button
_weContextButton :: Button,
forall s e. WidgetEnv s e -> Theme
_weTheme :: Theme,
forall s e. WidgetEnv s e -> Size
_weWindowSize :: Size,
forall s e. WidgetEnv s e -> MVar (Map Text WidgetShared)
_weWidgetShared :: MVar (Map Text WidgetShared),
forall s e. WidgetEnv s e -> WidgetKeyMap s e
_weWidgetKeyMap :: WidgetKeyMap s e,
forall s e. WidgetEnv s e -> Maybe Path
_weHoveredPath :: Maybe Path,
forall s e. WidgetEnv s e -> Path
_weFocusedPath :: Path,
forall s e. WidgetEnv s e -> Maybe Path
_weOverlayPath :: Maybe Path,
forall s e. WidgetEnv s e -> Maybe (Path, WidgetDragMsg)
_weDragStatus :: Maybe (Path, WidgetDragMsg),
forall s e. WidgetEnv s e -> Maybe (Path, Point)
_weMainBtnPress :: Maybe (Path, Point),
forall s e. WidgetEnv s e -> Maybe (Path, CursorIcon)
_weCursor :: Maybe (Path, CursorIcon),
forall s e. WidgetEnv s e -> s
_weModel :: s,
forall s e. WidgetEnv s e -> InputStatus
_weInputStatus :: InputStatus,
forall s e. WidgetEnv s e -> Millisecond
_weTimestamp :: Millisecond,
forall s e. WidgetEnv s e -> Bool
_weThemeChanged :: Bool,
forall s e. WidgetEnv s e -> Point -> Bool
_weInTopLayer :: Point -> Bool,
forall s e. WidgetEnv s e -> LayoutDirection
_weLayoutDirection :: LayoutDirection,
forall s e. WidgetEnv s e -> Rect
_weViewport :: Rect,
forall s e. WidgetEnv s e -> Point
_weOffset :: Point
}
data WidgetNodeInfo =
WidgetNodeInfo {
WidgetNodeInfo -> WidgetType
_wniWidgetType :: WidgetType,
WidgetNodeInfo -> WidgetId
_wniWidgetId :: WidgetId,
WidgetNodeInfo -> Maybe WidgetKey
_wniKey :: Maybe WidgetKey,
WidgetNodeInfo -> Path
_wniPath :: Path,
WidgetNodeInfo -> SizeReq
_wniSizeReqW :: SizeReq,
WidgetNodeInfo -> SizeReq
_wniSizeReqH :: SizeReq,
WidgetNodeInfo -> Bool
_wniEnabled :: Bool,
WidgetNodeInfo -> Bool
_wniVisible :: Bool,
WidgetNodeInfo -> Bool
_wniFocusable :: Bool,
WidgetNodeInfo -> Rect
_wniViewport :: Rect,
WidgetNodeInfo -> Style
_wniStyle :: Style
} deriving (WidgetNodeInfo -> WidgetNodeInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WidgetNodeInfo -> WidgetNodeInfo -> Bool
$c/= :: WidgetNodeInfo -> WidgetNodeInfo -> Bool
== :: WidgetNodeInfo -> WidgetNodeInfo -> Bool
$c== :: WidgetNodeInfo -> WidgetNodeInfo -> Bool
Eq, Int -> WidgetNodeInfo -> ShowS
[WidgetNodeInfo] -> ShowS
WidgetNodeInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WidgetNodeInfo] -> ShowS
$cshowList :: [WidgetNodeInfo] -> ShowS
show :: WidgetNodeInfo -> String
$cshow :: WidgetNodeInfo -> String
showsPrec :: Int -> WidgetNodeInfo -> ShowS
$cshowsPrec :: Int -> WidgetNodeInfo -> ShowS
Show, forall x. Rep WidgetNodeInfo x -> WidgetNodeInfo
forall x. WidgetNodeInfo -> Rep WidgetNodeInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WidgetNodeInfo x -> WidgetNodeInfo
$cfrom :: forall x. WidgetNodeInfo -> Rep WidgetNodeInfo x
Generic)
instance Default WidgetNodeInfo where
def :: WidgetNodeInfo
def = WidgetNodeInfo {
_wniWidgetType :: WidgetType
_wniWidgetType = Text -> WidgetType
WidgetType (String -> Text
T.pack String
""),
_wniWidgetId :: WidgetId
_wniWidgetId = forall a. Default a => a
def,
_wniKey :: Maybe WidgetKey
_wniKey = forall a. Maybe a
Nothing,
_wniPath :: Path
_wniPath = Path
emptyPath,
_wniSizeReqW :: SizeReq
_wniSizeReqW = forall a. Default a => a
def,
_wniSizeReqH :: SizeReq
_wniSizeReqH = forall a. Default a => a
def,
_wniEnabled :: Bool
_wniEnabled = Bool
True,
_wniVisible :: Bool
_wniVisible = Bool
True,
_wniFocusable :: Bool
_wniFocusable = Bool
False,
_wniViewport :: Rect
_wniViewport = forall a. Default a => a
def,
_wniStyle :: Style
_wniStyle = forall a. Default a => a
def
}
data WidgetNode s e = WidgetNode {
forall s e. WidgetNode s e -> Widget s e
_wnWidget :: Widget s e,
forall s e. WidgetNode s e -> WidgetNodeInfo
_wnInfo :: WidgetNodeInfo,
forall s e. WidgetNode s e -> Seq (WidgetNode s e)
_wnChildren :: Seq (WidgetNode s e)
}
data WidgetInstanceNode = WidgetInstanceNode {
WidgetInstanceNode -> WidgetNodeInfo
_winInfo :: WidgetNodeInfo,
WidgetInstanceNode -> Maybe WidgetState
_winState :: Maybe WidgetState,
WidgetInstanceNode -> Seq WidgetInstanceNode
_winChildren :: Seq WidgetInstanceNode
} deriving (Int -> WidgetInstanceNode -> ShowS
[WidgetInstanceNode] -> ShowS
WidgetInstanceNode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WidgetInstanceNode] -> ShowS
$cshowList :: [WidgetInstanceNode] -> ShowS
show :: WidgetInstanceNode -> String
$cshow :: WidgetInstanceNode -> String
showsPrec :: Int -> WidgetInstanceNode -> ShowS
$cshowsPrec :: Int -> WidgetInstanceNode -> ShowS
Show, forall x. Rep WidgetInstanceNode x -> WidgetInstanceNode
forall x. WidgetInstanceNode -> Rep WidgetInstanceNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WidgetInstanceNode x -> WidgetInstanceNode
$cfrom :: forall x. WidgetInstanceNode -> Rep WidgetInstanceNode x
Generic)
data Widget s e =
Widget {
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> WidgetResult s e
widgetInit
:: WidgetEnv s e
-> WidgetNode s e
-> WidgetResult s e,
forall s e.
Widget s e
-> WidgetEnv s e
-> WidgetNode s e
-> WidgetNode s e
-> WidgetResult s e
widgetMerge
:: WidgetEnv s e
-> WidgetNode s e
-> WidgetNode s e
-> WidgetResult s e,
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> WidgetResult s e
widgetDispose
:: WidgetEnv s e
-> WidgetNode s e
-> WidgetResult s e,
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> Maybe WidgetState
widgetGetState
:: WidgetEnv s e
-> WidgetNode s e
-> Maybe WidgetState,
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> WidgetInstanceNode
widgetGetInstanceTree
:: WidgetEnv s e
-> WidgetNode s e
-> WidgetInstanceNode,
forall s e.
Widget s e
-> WidgetEnv s e
-> WidgetNode s e
-> FocusDirection
-> Path
-> Maybe WidgetNodeInfo
widgetFindNextFocus
:: WidgetEnv s e
-> WidgetNode s e
-> FocusDirection
-> Path
-> Maybe WidgetNodeInfo,
forall s e.
Widget s e
-> WidgetEnv s e
-> WidgetNode s e
-> Path
-> Point
-> Maybe WidgetNodeInfo
widgetFindByPoint
:: WidgetEnv s e
-> WidgetNode s e
-> Path
-> Point
-> Maybe WidgetNodeInfo,
forall s e.
Widget s e
-> WidgetEnv s e -> WidgetNode s e -> Path -> Seq WidgetNodeInfo
widgetFindBranchByPath
:: WidgetEnv s e
-> WidgetNode s e
-> Path
-> Seq WidgetNodeInfo,
forall s e.
Widget s e
-> WidgetEnv s e
-> WidgetNode s e
-> Path
-> SystemEvent
-> Maybe (WidgetResult s e)
widgetHandleEvent
:: WidgetEnv s e
-> WidgetNode s e
-> Path
-> SystemEvent
-> Maybe (WidgetResult s e),
forall s e.
Widget s e
-> forall i.
Typeable i =>
WidgetEnv s e
-> WidgetNode s e -> Path -> i -> Maybe (WidgetResult s e)
widgetHandleMessage
:: forall i . Typeable i
=> WidgetEnv s e
-> WidgetNode s e
-> Path
-> i
-> Maybe (WidgetResult s e),
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> (SizeReq, SizeReq)
widgetGetSizeReq
:: WidgetEnv s e
-> WidgetNode s e
-> (SizeReq, SizeReq),
forall s e.
Widget s e
-> WidgetEnv s e
-> WidgetNode s e
-> Rect
-> (Path -> Bool)
-> WidgetResult s e
widgetResize
:: WidgetEnv s e
-> WidgetNode s e
-> Rect
-> (Path -> Bool)
-> WidgetResult s e,
forall s e.
Widget s e -> WidgetEnv s e -> WidgetNode s e -> Renderer -> IO ()
widgetRender
:: WidgetEnv s e
-> WidgetNode s e
-> Renderer
-> IO ()
}
instance Show (WidgetRequest s e) where
show :: WidgetRequest s e -> String
show WidgetRequest s e
IgnoreParentEvents = String
"IgnoreParentEvents"
show WidgetRequest s e
IgnoreChildrenEvents = String
"IgnoreChildrenEvents"
show (ResizeWidgets WidgetId
wid) = String
"ResizeWidgets: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (ResizeWidgetsImmediate WidgetId
wid) = String
"ResizeWidgetsImmediate: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (MoveFocus Maybe WidgetId
start FocusDirection
dir) = String
"MoveFocus: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (Maybe WidgetId
start, FocusDirection
dir)
show (SetFocus WidgetId
path) = String
"SetFocus: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
path
show (GetClipboard WidgetId
wid) = String
"GetClipboard: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (SetClipboard ClipboardData
_) = String
"SetClipboard"
show (StartTextInput Rect
rect) = String
"StartTextInput: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Rect
rect
show WidgetRequest s e
StopTextInput = String
"StopTextInput"
show (SetOverlay WidgetId
wid Path
path) = String
"SetOverlay: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (WidgetId
wid, Path
path)
show (ResetOverlay WidgetId
wid) = String
"ResetOverlay: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (SetCursorIcon WidgetId
wid CursorIcon
icon) = String
"SetCursorIcon: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (WidgetId
wid, CursorIcon
icon)
show (ResetCursorIcon WidgetId
wid) = String
"ResetCursorIcon: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (StartDrag WidgetId
wid Path
path WidgetDragMsg
info) = String
"StartDrag: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (WidgetId
wid, Path
path, WidgetDragMsg
info)
show (StopDrag WidgetId
wid) = String
"StopDrag: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show WidgetRequest s e
RenderOnce = String
"RenderOnce"
show (RenderEvery WidgetId
wid Millisecond
ms Maybe Int
repeat) = String
"RenderEvery: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (WidgetId
wid, Millisecond
ms, Maybe Int
repeat)
show (RenderStop WidgetId
wid) = String
"RenderStop: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show (RemoveRendererImage Text
name) = String
"RemoveRendererImage: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
name
show ExitApplication{} = String
"ExitApplication"
show (UpdateWindow WindowRequest
req) = String
"UpdateWindow: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WindowRequest
req
show UpdateModel{} = String
"UpdateModel"
show (SetWidgetPath WidgetId
wid Path
path) = String
"SetWidgetPath: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (WidgetId
wid, Path
path)
show (ResetWidgetPath WidgetId
wid) = String
"ResetWidgetPath: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show WidgetId
wid
show RaiseEvent{} = String
"RaiseEvent"
show SendMessage{} = String
"SendMessage"
show RunTask{} = String
"RunTask"
show RunProducer{} = String
"RunProducer"
show RunInRenderThread{} = String
"RunInRenderThread"
instance Show (WidgetResult s e) where
show :: WidgetResult s e -> String
show WidgetResult s e
result = String
"WidgetResult "
forall a. [a] -> [a] -> [a]
++ String
"{ _wrRequests: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetResult s e -> Seq (WidgetRequest s e)
_wrRequests WidgetResult s e
result)
forall a. [a] -> [a] -> [a]
++ String
", _wrNode: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetResult s e -> WidgetNode s e
_wrNode WidgetResult s e
result)
forall a. [a] -> [a] -> [a]
++ String
" }"
instance Show (WidgetEnv s e) where
show :: WidgetEnv s e -> String
show WidgetEnv s e
wenv = String
"WidgetEnv "
forall a. [a] -> [a] -> [a]
++ String
"{ _weOs: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetEnv s e -> Text
_weOs WidgetEnv s e
wenv)
forall a. [a] -> [a] -> [a]
++ String
", _weWindowSize: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetEnv s e -> Size
_weWindowSize WidgetEnv s e
wenv)
forall a. [a] -> [a] -> [a]
++ String
", _weFocusedPath: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetEnv s e -> Path
_weFocusedPath WidgetEnv s e
wenv)
forall a. [a] -> [a] -> [a]
++ String
", _weTimestamp: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetEnv s e -> Millisecond
_weTimestamp WidgetEnv s e
wenv)
forall a. [a] -> [a] -> [a]
++ String
" }"
instance Show (WidgetNode s e) where
show :: WidgetNode s e -> String
show WidgetNode s e
node = String
"WidgetNode "
forall a. [a] -> [a] -> [a]
++ String
"{ _wnInfo: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetNode s e -> WidgetNodeInfo
_wnInfo WidgetNode s e
node)
forall a. [a] -> [a] -> [a]
++ String
", _wnChildren: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show (forall s e. WidgetNode s e -> Seq (WidgetNode s e)
_wnChildren WidgetNode s e
node)
forall a. [a] -> [a] -> [a]
++ String
" }"