Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation #249

Merged
merged 5 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/Monomer/Widgets/Animation/Fade.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,35 @@ instance Default FadeState where
}

-- | Animates a widget from not visible state to fully visible.
animFadeIn :: WidgetEvent e => WidgetNode s e -> WidgetNode s e
animFadeIn
:: WidgetEvent e
=> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animFadeIn managed = animFadeIn_ def managed

-- | Animates a widget from not visible state to fully visible. Accepts config.
animFadeIn_ :: WidgetEvent e => [FadeCfg e] -> WidgetNode s e -> WidgetNode s e
animFadeIn_
:: WidgetEvent e
=> [FadeCfg e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animFadeIn_ configs managed = makeNode "animFadeIn" widget managed where
config = mconcat configs
widget = makeFade True config def

-- | Animates a widget from visible state to not visible.
animFadeOut :: WidgetEvent e => WidgetNode s e -> WidgetNode s e
animFadeOut
:: WidgetEvent e
=> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animFadeOut managed = animFadeOut_ def managed

-- | Animates a widget from visible state to not visible. Accepts config.
animFadeOut_ :: WidgetEvent e => [FadeCfg e] -> WidgetNode s e -> WidgetNode s e
animFadeOut_
:: WidgetEvent e
=> [FadeCfg e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animFadeOut_ configs managed = makeNode "animFadeOut" widget managed where
config = mconcat configs
widget = makeFade False config def
Expand Down
32 changes: 23 additions & 9 deletions src/Monomer/Widgets/Animation/Slide.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Messages:
module Monomer.Widgets.Animation.Slide (
-- * Configuration
SlideCfg,
slideLeft,
slideRight,
slideTop,
slideBottom,
-- * Constructors
animSlideIn,
animSlideIn_,
animSlideOut,
animSlideOut_,
slideLeft,
slideRight,
slideTop,
slideBottom
animSlideOut_
) where

import Control.Applicative ((<|>))
Expand Down Expand Up @@ -132,23 +132,37 @@ instance Default SlideState where
}

-- | Animates a widget from the left to fully visible.
animSlideIn :: WidgetEvent e => WidgetNode s e -> WidgetNode s e
animSlideIn
:: WidgetEvent e
=> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animSlideIn managed = animSlideIn_ def managed

-- | Animates a widget from the provided direction to fully visible (defaults
-- to left). Accepts config.
animSlideIn_ :: WidgetEvent e => [SlideCfg e] -> WidgetNode s e -> WidgetNode s e
animSlideIn_
:: WidgetEvent e
=> [SlideCfg e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animSlideIn_ configs managed = makeNode "animSlideIn" widget managed where
config = mconcat configs
widget = makeSlide True config def

-- | Animates a widget to the left from visible to not visible.
animSlideOut :: WidgetEvent e => WidgetNode s e -> WidgetNode s e
animSlideOut
:: WidgetEvent e
=> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animSlideOut managed = animSlideOut_ def managed

-- | Animates a widget to the the provided direction from visible to not
-- visible (defaults to left). Accepts config.
animSlideOut_ :: WidgetEvent e => [SlideCfg e] -> WidgetNode s e -> WidgetNode s e
animSlideOut_
:: WidgetEvent e
=> [SlideCfg e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created animation container.
animSlideOut_ configs managed = makeNode "animSlideOut" widget managed where
config = mconcat configs
widget = makeSlide False config def
Expand Down
16 changes: 8 additions & 8 deletions src/Monomer/Widgets/Containers/Alert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ alert
:: (WidgetModel s, WidgetEvent e)
=> e -- ^ The event to raise when the dialog is closed.
-> WidgetNode () e -- ^ The content to display in the dialog.
-> WidgetNode s e -- ^ The created dialog.
-> WidgetNode s e -- ^ The created dialog.
alert evt dialogBody = alert_ evt def dialogBody

-- | Creates an alert dialog with the provided content. Accepts config.
alert_
:: (WidgetModel s, WidgetEvent e)
=> e -- ^ The event to raise when the dialog is closed.
-> [AlertCfg] -- ^ The config options for the dialog.
-> [AlertCfg] -- ^ The config options for the dialog.
-> WidgetNode () e -- ^ The content to display in the dialog.
-> WidgetNode s e -- ^ The created dialog.
-> WidgetNode s e -- ^ The created dialog.
alert_ evt configs dialogBody = newNode where
config = mconcat configs
createUI = buildUI (const dialogBody) evt config
Expand All @@ -122,17 +122,17 @@ alert_ evt configs dialogBody = newNode where
-- | Creates an alert dialog with a text message as content.
alertMsg
:: (WidgetModel s, WidgetEvent e)
=> Text -- ^ The message to display.
-> e -- ^ The event to raise when the dialog is closed.
=> Text -- ^ The message to display.
-> e -- ^ The event to raise when the dialog is closed.
-> WidgetNode s e -- ^ The created dialog.
alertMsg message evt = alertMsg_ message evt def

-- | Creates an alert dialog with a text message as content. Accepts config.
alertMsg_
:: (WidgetModel s, WidgetEvent e)
=> Text -- ^ The message to display.
-> e -- ^ The event to raise when the dialog is closed.
-> [AlertCfg] -- ^ The config options for the dialog.
=> Text -- ^ The message to display.
-> e -- ^ The event to raise when the dialog is closed.
-> [AlertCfg] -- ^ The config options for the dialog.
-> WidgetNode s e -- ^ The created dialog.
alertMsg_ message evt configs = newNode where
config = mconcat configs
Expand Down
14 changes: 7 additions & 7 deletions src/Monomer/Widgets/Containers/Base/LabeledItem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ the click events received. Positioning is configurable.
-}
labeledItem
:: WidgetEvent e
=> WidgetType
-> RectSide
-> Maybe Double
-> Text
-> LabelCfg s e
-> WidgetNode s e
-> WidgetNode s e
=> WidgetType -- ^ The 'WidgetType' of the provided widget.
-> RectSide -- ^ The side of the label.
-> Maybe Double -- ^ The child spacing.
-> Text -- ^ The caption.
-> LabelCfg s e -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created stack.
labeledItem wtype textSide childSpacing caption labelCfg itemNode = labeledNode where
widget = makeLabeledItem textSide childSpacing caption labelCfg itemNode
labeledNode = defaultWidgetNode wtype widget
Expand Down
17 changes: 10 additions & 7 deletions src/Monomer/Widgets/Containers/Box.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ clickableItem = box_ [onClick ItemClicked] content
module Monomer.Widgets.Containers.Box (
-- * Configuration
BoxCfg,
expandContent,
boxFilterEvent,
-- * Constructors
box,
box_,
expandContent,
boxFilterEvent
box_
) where

import Control.Applicative ((<|>))
Expand Down Expand Up @@ -314,15 +314,18 @@ newtype BoxState s = BoxState {
}

-- | Creates a box widget with a single node as child.
box :: (WidgetModel s, WidgetEvent e) => WidgetNode s e -> WidgetNode s e
box
:: (WidgetModel s, WidgetEvent e)
=> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created box container.
box managed = box_ def managed

-- | Creates a box widget with a single node as child. Accepts config.
box_
:: (WidgetModel s, WidgetEvent e)
=> [BoxCfg s e]
-> WidgetNode s e
-> WidgetNode s e
=> [BoxCfg s e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created box container.
box_ configs managed = makeNode (makeBox config state) managed where
config = mconcat configs
state = BoxState Nothing
Expand Down
14 changes: 9 additions & 5 deletions src/Monomer/Widgets/Containers/Draggable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,20 @@ draggableRender render = def {
}

-- | Creates a draggable container with a single node as child.
draggable :: DragMsg a => a -> WidgetNode s e -> WidgetNode s e
draggable
:: DragMsg a
=> a -- ^ The identifying value.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created draggable container.
draggable msg managed = draggable_ msg def managed

-- | Creates a draggable container with a single node as child. Accepts config.
draggable_
:: DragMsg a
=> a
-> [DraggableCfg s e]
-> WidgetNode s e
-> WidgetNode s e
=> a -- ^ The identifying value.
-> [DraggableCfg s e] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created draggable container.
draggable_ msg configs managed = makeNode widget managed where
config = mconcat configs
widget = makeDraggable msg config
Expand Down
13 changes: 8 additions & 5 deletions src/Monomer/Widgets/Containers/DropTarget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,20 @@ dropTargetStyle styles = def {

-- | Creates a drop target container with a single node as child.
dropTarget
:: (DragMsg a, WidgetEvent e) => (a -> e) -> WidgetNode s e -> WidgetNode s e
:: (DragMsg a, WidgetEvent e)
=> (a -> e) -- ^ The event to raise on drop.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created drop target container.
dropTarget dropEvt managed = dropTarget_ dropEvt def managed

-- | Creates a drop target container with a single node as child. Accepts
-- config.
dropTarget_
:: (DragMsg a, WidgetEvent e)
=> (a -> e)
-> [DropTargetCfg]
-> WidgetNode s e
-> WidgetNode s e
=> (a -> e) -- ^ The event to raise on drop.
-> [DropTargetCfg] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created drop target container.
dropTarget_ dropEvt configs managed = makeNode widget managed where
config = mconcat configs
widget = makeDropTarget dropEvt config
Expand Down
22 changes: 18 additions & 4 deletions src/Monomer/Widgets/Containers/Grid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,36 @@ instance CmbSizeReqUpdater GridCfg where
}

-- | Creates a grid of items with the same width.
hgrid :: Traversable t => t (WidgetNode s e) -> WidgetNode s e
hgrid
:: Traversable t
=> t (WidgetNode s e) -- ^ The list of items.
-> WidgetNode s e -- ^ The created grid.
hgrid children = hgrid_ def children

-- | Creates a grid of items with the same width. Accepts config.
hgrid_ :: Traversable t => [GridCfg] -> t (WidgetNode s e) -> WidgetNode s e
hgrid_
:: Traversable t
=> [GridCfg] -- ^ The config options.
-> t (WidgetNode s e) -- ^ The list of items.
-> WidgetNode s e -- ^ The created grid.
hgrid_ configs children = newNode where
config = mconcat configs
newNode = defaultWidgetNode "hgrid" (makeFixedGrid True config)
& L.children .~ foldl' (|>) Empty children

-- | Creates a grid of items with the same height.
vgrid :: Traversable t => t (WidgetNode s e) -> WidgetNode s e
vgrid
:: Traversable t
=> t (WidgetNode s e) -- ^ The list of items.
-> WidgetNode s e -- ^ The created grid.
vgrid children = vgrid_ def children

-- | Creates a grid of items with the same height. Accepts config.
vgrid_ :: Traversable t => [GridCfg] -> t (WidgetNode s e) -> WidgetNode s e
vgrid_
:: Traversable t
=> [GridCfg] -- ^ The config options.
-> t (WidgetNode s e) -- ^ The list of items.
-> WidgetNode s e -- ^ The created grid.
vgrid_ configs children = newNode where
config = mconcat configs
newNode = defaultWidgetNode "vgrid" (makeFixedGrid False config)
Expand Down
14 changes: 9 additions & 5 deletions src/Monomer/Widgets/Containers/Keystroke.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,20 @@ makeLensesWith abbreviatedFields ''KeyStroke
makeLensesWith abbreviatedFields ''KeyStrokeState

-- | Creates a keystroke container with a single node as child.
keystroke :: WidgetEvent e => [(Text, e)] -> WidgetNode s e -> WidgetNode s e
keystroke
:: WidgetEvent e
=> [(Text, e)] -- ^ The list of key combinations and events.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created keystroke container.
keystroke bindings managed = keystroke_ bindings def managed

-- | Creates a keystroke container with a single node as child. Accepts config,
keystroke_
:: WidgetEvent e
=> [(Text, e)]
-> [KeystrokeCfg]
-> WidgetNode s e
-> WidgetNode s e
=> [(Text, e)] -- ^ The list of key combinations and events.
-> [KeystrokeCfg] -- ^ The config options.
-> WidgetNode s e -- ^ The child node.
-> WidgetNode s e -- ^ The created keystroke container.
keystroke_ bindings configs managed = makeNode widget managed where
config = mconcat configs
newBindings = fmap (first textToStroke) bindings
Expand Down
Loading