Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Option button widget, used for choosing one value from a fixed set. Each instance of optionButton is associated with a single value.
optionButton "First option" Option1 optionLens
Its behavior is equivalent to Monomer.Widgets.Singles.Radio and Monomer.Widgets.Singles.LabeledRadio, with a different visual representation.
This widget, and the associated Monomer.Widgets.Singles.ToggleButton, uses two
separate styles for the On and Off states which can be modified individually for
the theme. If you use any of the standard style functions (styleBasic,
styleHover, etc) in an optionButton/toggleButton these changes will apply to
both On and Off states, except for the color related styles. The reason is that,
in general, the font and padding will be the same for both states, but the
colors will differ. The optionButtonOffStyle
option, which receives a Style
instance, can be used to change the colors of the Off state. The values set with
this option are higher priority than any inherited style from the theme or node
text style.
Style
instances can be created this way:
newStyle :: Style = def `styleBasic` [textSize 20] `styleHover` [textColor white]
Synopsis
- type OptionButtonValue a = (Eq a, Typeable a)
- data OptionButtonCfg s e a
- optionButtonOffStyle :: Style -> OptionButtonCfg s e a
- optionButton :: OptionButtonValue a => Text -> a -> ALens' s a -> WidgetNode s e
- optionButton_ :: OptionButtonValue a => Text -> a -> ALens' s a -> [OptionButtonCfg s e a] -> WidgetNode s e
- optionButtonV :: (OptionButtonValue a, WidgetEvent e) => Text -> a -> a -> (a -> e) -> WidgetNode s e
- optionButtonV_ :: (OptionButtonValue a, WidgetEvent e) => Text -> a -> a -> (a -> e) -> [OptionButtonCfg s e a] -> WidgetNode s e
- optionButtonD_ :: OptionButtonValue a => Text -> a -> WidgetData s a -> [OptionButtonCfg s e a] -> WidgetNode s e
- makeOptionButton :: OptionButtonValue a => Lens' ThemeState StyleState -> Lens' ThemeState StyleState -> WidgetData s a -> Text -> (a -> Bool) -> (a -> a) -> OptionButtonCfg s e a -> Widget s e
Configuration
type OptionButtonValue a = (Eq a, Typeable a) Source #
Constraints for numeric types accepted by the optionButton widget.
data OptionButtonCfg s e a Source #
Configuration options for optionButton:
ignoreTheme
: whether to load default style from theme or start empty.optionButtonOffStyle
: style to use when the option is not active.trimSpaces
: whether to remove leading/trailing spaces in the caption.ellipsis
: if ellipsis should be used for overflown text.multiline
: if text may be split in multiple lines.maxLines
: maximum number of text lines to show.resizeFactor
: flexibility to have more or less space assigned.resizeFactorW
: flexibility to have more or less horizontal space assigned.resizeFactorH
: flexibility to have more or less vertical space assigned.onFocus
: event to raise when focus is received.onFocusReq
:WidgetRequest
to generate when focus is received.onBlur
: event to raise when focus is lost.onBlurReq
:WidgetRequest
to generate when focus is lost.onClick
: event to raise when the value is clicked.onClickReq
:WidgetRequest
to generate when the value is clicked.onChange
: event to raise when the value changes.onChangeReq
:WidgetRequest
to generate when the value changes.
Instances
optionButtonOffStyle :: Style -> OptionButtonCfg s e a Source #
Sets the style for the Off state of the option button.
Constructors
:: OptionButtonValue a | |
=> Text | The caption. |
-> a | The option value. |
-> ALens' s a | The lens into the model. |
-> WidgetNode s e | The created option button. |
Creates an optionButton using the given lens.
:: OptionButtonValue a | |
=> Text | The caption. |
-> a | The option value. |
-> ALens' s a | The lens into the model. |
-> [OptionButtonCfg s e a] | The config options. |
-> WidgetNode s e | The created option button. |
Creates an optionButton using the given lens. Accepts config.
:: (OptionButtonValue a, WidgetEvent e) | |
=> Text | The caption. |
-> a | The option value. |
-> a | The current value. |
-> (a -> e) | The event to raise on change. |
-> WidgetNode s e | The created option button. |
Creates an optionButton using the given value and onChange
event handler.
:: (OptionButtonValue a, WidgetEvent e) | |
=> Text | The caption. |
-> a | The option value. |
-> a | The current value. |
-> (a -> e) | The event to raise on change. |
-> [OptionButtonCfg s e a] | The config options. |
-> WidgetNode s e | The created option button. |
Creates an optionButton using the given value and onChange
event handler.
Accepts config.
:: OptionButtonValue a | |
=> Text | The caption. |
-> a | The option value. |
-> WidgetData s a | The |
-> [OptionButtonCfg s e a] | The config options. |
-> WidgetNode s e | The created option button. |
Creates an optionButton providing a WidgetData
instance and config.
Internal
:: OptionButtonValue a | |
=> Lens' ThemeState StyleState | The on style lens. |
-> Lens' ThemeState StyleState | The off style lens. |
-> WidgetData s a | The |
-> Text | The caption. |
-> (a -> Bool) | Set the on or off state depending on the value. |
-> (a -> a) | How to change the value on click. |
-> OptionButtonCfg s e a | The config. |
-> Widget s e | The created widget. |
Helper function for creating a button associated to a value. Used by _optionButton_ and _toggleButton_.