mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-11-10 11:21:50 +03:00
Test disabled state works. Add _enabled_ combinator (enabled/disabled having different purposes is confusing, think better names)
This commit is contained in:
parent
e0d743e5d5
commit
4bdbc2836b
@ -287,7 +287,7 @@ buildUI wenv model = trace "Creating UI" widgetTree where
|
||||
radioV (model ^. fruit) RadioSt Pear
|
||||
] `key` "radio hstack",
|
||||
hgrid [
|
||||
button "Show Alert" ShowAlert,
|
||||
button "Show Alert" ShowAlert `enabled` False,
|
||||
mainButton "Show Confirm" ShowConfirm
|
||||
],
|
||||
hgrid [
|
||||
|
@ -180,11 +180,17 @@ class CmbResizeFactorDim t where
|
||||
resizeFactorH :: Double -> t
|
||||
|
||||
-- Style
|
||||
infixl 5 `enabled`
|
||||
infixl 5 `style`
|
||||
infixl 5 `hover`
|
||||
infixl 5 `focus`
|
||||
infixl 5 `focusHover`
|
||||
infixl 5 `active`
|
||||
infixl 5 `disabled`
|
||||
|
||||
class CmbEnabled t where
|
||||
enabled :: t -> Bool -> t
|
||||
|
||||
class CmbStyle t where
|
||||
style :: t -> [StyleState] -> t
|
||||
|
||||
@ -194,6 +200,12 @@ class CmbHover t where
|
||||
class CmbFocus t where
|
||||
focus :: t -> [StyleState] -> t
|
||||
|
||||
class CmbFocusHover t where
|
||||
focusHover :: t -> [StyleState] -> t
|
||||
|
||||
class CmbActive t where
|
||||
active :: t -> [StyleState] -> t
|
||||
|
||||
class CmbDisabled t where
|
||||
disabled :: t -> [StyleState] -> t
|
||||
|
||||
|
@ -66,11 +66,24 @@ instance CmbFocus Style where
|
||||
state = mconcat states
|
||||
newStyle = oldStyle & L.focus ?~ state
|
||||
|
||||
instance CmbFocusHover Style where
|
||||
focusHover oldStyle states = newStyle where
|
||||
state = mconcat states
|
||||
newStyle = oldStyle & L.focusHover ?~ state
|
||||
|
||||
instance CmbActive Style where
|
||||
active oldStyle states = newStyle where
|
||||
state = mconcat states
|
||||
newStyle = oldStyle & L.active ?~ state
|
||||
|
||||
instance CmbDisabled Style where
|
||||
disabled oldStyle states = newStyle where
|
||||
state = mconcat states
|
||||
newStyle = oldStyle & L.disabled ?~ state
|
||||
|
||||
instance CmbEnabled (WidgetNode s e) where
|
||||
enabled node state = node & L.info . L.enabled .~ state
|
||||
|
||||
instance CmbStyle (WidgetNode s e) where
|
||||
style node states = node & L.info . L.style .~ newStyle where
|
||||
state = mconcat states
|
||||
@ -89,6 +102,18 @@ instance CmbFocus (WidgetNode s e) where
|
||||
oldStyle = node ^. L.info . L.style
|
||||
newStyle = oldStyle & L.focus ?~ state
|
||||
|
||||
instance CmbFocusHover (WidgetNode s e) where
|
||||
focusHover node states = node & L.info . L.style .~ newStyle where
|
||||
state = mconcat states
|
||||
oldStyle = node ^. L.info . L.style
|
||||
newStyle = oldStyle & L.focusHover ?~ state
|
||||
|
||||
instance CmbActive (WidgetNode s e) where
|
||||
active node states = node & L.info . L.style .~ newStyle where
|
||||
state = mconcat states
|
||||
oldStyle = node ^. L.info . L.style
|
||||
newStyle = oldStyle & L.active ?~ state
|
||||
|
||||
instance CmbDisabled (WidgetNode s e) where
|
||||
disabled node states = node & L.info . L.style .~ newStyle where
|
||||
state = mconcat states
|
||||
|
@ -177,3 +177,12 @@ darkActive = darkHover
|
||||
|
||||
darkDisabled :: ThemeState
|
||||
darkDisabled = darkBasic
|
||||
& L.btnMainStyle . L.text . non def . L.fontColor ?~ darkGray
|
||||
& L.btnMainStyle . L.bgColor ?~ silver
|
||||
& L.btnMainStyle . L.border ?~ border 1 lightGray
|
||||
& L.btnStyle . L.text . non def . L.fontColor ?~ darkGray
|
||||
& L.btnStyle . L.bgColor ?~ silver
|
||||
& L.btnStyle . L.border ?~ border 1 lightGray
|
||||
& L.dropdownStyle . L.text . non def . L.fontColor ?~ darkGray
|
||||
& L.dropdownStyle . L.bgColor ?~ silver
|
||||
& L.dropdownStyle . L.border ?~ border 1 lightGray
|
||||
|
10
tasks.md
10
tasks.md
@ -386,6 +386,11 @@
|
||||
- When hover is lost, size is not reduced/recalculated
|
||||
- Handle Window Lost Focus
|
||||
- Not needed; I thought it was part of the previous issue
|
||||
- Rethink, again, order of style merging (focus/hover)
|
||||
- Focus border gets lost
|
||||
- Maybe a FocusHover style is needed?
|
||||
- Merged as: focus <> hover <> focusHover
|
||||
- Maybe having Active style is a good idea?
|
||||
|
||||
- Pending
|
||||
- Add header in all files, indicating license and documenting what the module does
|
||||
@ -398,11 +403,6 @@
|
||||
- Add user documentation
|
||||
|
||||
Maybe postponed after release?
|
||||
- Rethink, again, order of style merging (focus/hover)
|
||||
- Focus border gets lost
|
||||
- Maybe a FocusHover style is needed?
|
||||
- Merged as: focus <> hover <> focusHover
|
||||
- Maybe having Active style is a good idea?
|
||||
- Test disabled state on widgets
|
||||
- Check Single/Container flags (can some be removed?)
|
||||
- Add serialization logic for Widget Tree
|
||||
|
Loading…
Reference in New Issue
Block a user