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 for configuration options of some widgets #253

Merged
merged 8 commits into from Feb 1, 2023
8 changes: 4 additions & 4 deletions src/Monomer/Core/Combinators.hs
Expand Up @@ -303,7 +303,7 @@ class CmbFitWidth t where
class CmbFitHeight t where
fitHeight :: t

-- | Either fitWidth or fitHeight such that image does not overflow viewport
-- | Either fitWidth or fitHeight such that image does not overflow viewport.
class CmbFitEither t where
fitEither :: t

Expand Down Expand Up @@ -350,7 +350,7 @@ class CmbThumbFactor t where
class CmbThumbRadius t where
thumbRadius :: Double -> t

-- | Whether the thumb is visible, for example in a scroll.
-- | Whether the thumb is visible, for example in a slider.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was correct! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, only SliderCfg is an instance of the CmbThumbVisible class.

class CmbThumbVisible t where
thumbVisible :: t
thumbVisible = thumbVisible_ True
Expand Down Expand Up @@ -746,7 +746,7 @@ class CmbAlignLeft t where
alignLeft = alignLeft_ True
alignLeft_ :: Bool -> t

-- | Align object to the center (not text).
-- | Align object to the horizontal center (not text).
class CmbAlignCenter t where
alignCenter :: t
alignCenter = alignCenter_ True
Expand All @@ -764,7 +764,7 @@ class CmbAlignTop t where
alignTop = alignTop_ True
alignTop_ :: Bool -> t

-- | Align object to the middle (not text).
-- | Align object to the vertical middle (not text).
class CmbAlignMiddle t where
alignMiddle :: t
alignMiddle = alignMiddle_ True
Expand Down
14 changes: 13 additions & 1 deletion src/Monomer/Widgets/Containers/Box.hs
Expand Up @@ -94,12 +94,24 @@ Configuration options for box:
- 'alignCenter': aligns the inner widget to the horizontal center.
- 'alignRight': aligns the inner widget to the right.
- 'alignTop': aligns the inner widget to the top.
- 'alignMiddle': aligns the inner widget to the left.
- 'alignMiddle': aligns the inner widget to the vertical middle.
- 'alignBottom': aligns the inner widget to the bottom.
- '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.
- 'onEnter': on mouse enter event.
- 'onEnterReq': generates a WidgetRequest on mouse enter.
- 'onLeave': on mouse leave event.
- 'onLeaveReq': generates a WidgetRequest on mouse leave.
- 'onClick': click event.
- 'onClickReq': generates a WidgetRequest on click.
- 'onClickEmpty': click event on empty area.
- 'onClickEmptyReq': generates a WidgetRequest on click in empty area.
- 'onBtnPressed': on button pressed event.
- 'onBtnPressedReq': generates a WidgetRequest when button is pressed.
- 'onBtnReleased': on button released event.
- 'onBtnReleasedReq': generates a WidgetRequest when button is released.
- 'expandContent': if the inner widget should use all the available space. To be
able to use alignment options, this must be False (the default).
- 'boxFilterEvent': allows filtering or modifying a 'SystemEvent'.
Expand Down
8 changes: 4 additions & 4 deletions src/Monomer/Widgets/Containers/Confirm.hs
Expand Up @@ -72,7 +72,7 @@ Configuration options for confirm:

- 'titleCaption': the title of the alert dialog.
- 'acceptCaption': the caption of the accept button.
- 'closeCaption': the caption of the close button.
- 'cancelCaption': the caption of the cancel button.
-}
data ConfirmCfg = ConfirmCfg {
_cfcTitle :: Maybe Text,
Expand Down Expand Up @@ -132,7 +132,7 @@ confirm
confirm acceptEvt cancelEvt dialogBody = newNode where
newNode = confirm_ acceptEvt cancelEvt def dialogBody

-- | Creates an alert dialog with the provided content. Accepts config.
-- | Creates a confirm dialog with the provided content. Accepts config.
confirm_
:: (WidgetModel s, WidgetEvent e)
=> e -- ^ The accept button event.
Expand All @@ -146,7 +146,7 @@ confirm_ acceptEvt cancelEvt configs dialogBody = newNode where
compCfg = [compositeMergeReqs mergeReqs]
newNode = compositeD_ "confirm" (WidgetValue ()) createUI handleEvent compCfg

-- | Creates an alert dialog with a text message as content.
-- | Creates a confirm dialog with a text message as content.
confirmMsg
:: (WidgetModel s, WidgetEvent e)
=> Text -- ^ The message to display in the dialog.
Expand All @@ -155,7 +155,7 @@ confirmMsg
-> WidgetNode s e -- ^ The created dialog.
confirmMsg msg acceptEvt cancelEvt = confirmMsg_ msg acceptEvt cancelEvt def

-- | Creates an alert dialog with a text message as content. Accepts config.
-- | Creates a confirm dialog with a text message as content. Accepts config.
confirmMsg_
:: (WidgetModel s, WidgetEvent e)
=> Text -- ^ The message to display in the dialog.
Expand Down
4 changes: 2 additions & 2 deletions src/Monomer/Widgets/Containers/Popup.hs
Expand Up @@ -138,9 +138,9 @@ Configuration options for popup:
- 'popupDisableClose': do not close the popup when clicking outside the content.
- 'alignLeft': left align relative to the widget location or main window.
- 'alignRight': right align relative to the widget location or main window.
- 'alignCenter': center align relative to the widget location or main window.
- 'alignCenter': horizontal center align relative to the widget location or main window.
- 'alignTop': top align relative to the widget location or main window.
- 'alignMiddle': middle align relative to the widget location or main window.
- 'alignMiddle': vertical middle align relative to the widget location or main window.
- 'alignBottom': bottom align relative to the widget location or main window.
- 'onChange': event to raise when the popup is opened/closed.
- 'onChangeReq': 'WidgetRequest' to generate when the popup is opened/closed.
Expand Down
2 changes: 2 additions & 0 deletions src/Monomer/Widgets/Singles/DateField.hs
Expand Up @@ -145,6 +145,8 @@ type FormattableDate a
{-|
Configuration options for dateField:

- 'caretWidth': the width of the caret.
- 'caretMs': the blink period of the caret.
- 'validInput': field indicating if the current input is valid. Useful to show
warnings in the UI, or disable buttons if needed.
- 'resizeOnChange': Whether input causes 'ResizeWidgets' requests.
Expand Down
14 changes: 8 additions & 6 deletions src/Monomer/Widgets/Singles/Image.hs
Expand Up @@ -96,12 +96,14 @@ Configuration options for image:
- 'fitFill': stretches the image to match the viewport.
- 'fitWidth': stretches the image to match the viewport width. Maintains ratio.
- 'fitHeight': stretches the image to match the viewport height. Maintains ratio.
- 'alignLeft': aligns left if extra space is available.
- 'alignRight': aligns right if extra space is available.
- 'alignCenter': aligns center if extra space is available.
- 'alignTop': aligns top if extra space is available.
- 'alignMiddle': aligns middle if extra space is available.
- 'alignBottom': aligns bottom if extra space is available.
- 'fitEither': stretches the image to match either the viewport width or height
such that image does not overflow viewport. Maintains ratio.
- 'alignLeft': aligns to the left if extra space is available.
- 'alignRight': aligns to the right if extra space is available.
- 'alignCenter': aligns to the horizontal center if extra space is available.
- 'alignTop': aligns to the top if extra space is available.
- 'alignMiddle': aligns to the vertical middle if extra space is available.
- 'alignBottom': aligns to the bottom if extra space is available.
-}
data ImageCfg e = ImageCfg {
_imcLoadError :: [ImageLoadError -> e],
Expand Down
2 changes: 2 additions & 0 deletions src/Monomer/Widgets/Singles/NumericField.hs
Expand Up @@ -117,6 +117,8 @@ type FormattableNumber a
{-|
Configuration options for numericField:

- 'caretWidth': the width of the caret.
- 'caretMs': the blink period of the caret.
- 'validInput': field indicating if the current input is valid. Useful to show
warnings in the UI, or disable buttons if needed.
- 'resizeOnChange': Whether input causes ResizeWidgets requests.
Expand Down
2 changes: 2 additions & 0 deletions src/Monomer/Widgets/Singles/TextArea.hs
Expand Up @@ -67,6 +67,8 @@ defCaretMs = 500
{-|
Configuration options for textArea:

- 'caretWidth': the width of the caret.
- 'caretMs': the blink period of the caret.
- 'maxLength': the maximum length of input text.
- 'maxLines': the maximum number of lines of input text.
- 'acceptTab': whether to handle tab and convert it to spaces (cancelling change
Expand Down
3 changes: 3 additions & 0 deletions src/Monomer/Widgets/Singles/TextField.hs
Expand Up @@ -55,6 +55,9 @@ import qualified Monomer.Lens as L
{-|
Configuration options for textField:

- 'caretWidth': the width of the caret.
- 'caretMs': the blink period of the caret.
- 'placeholder': the placeholder to use when main value is empty.
- 'validInput': field indicating if the current input is valid. Useful to show
warnings in the UI, or disable buttons if needed.
- 'resizeOnChange': Whether input causes ResizeWidgets requests.
Expand Down
2 changes: 2 additions & 0 deletions src/Monomer/Widgets/Singles/TimeField.hs
Expand Up @@ -141,6 +141,8 @@ type FormattableTime a
{-|
Configuration options for timeField:

- 'caretWidth': the width of the caret.
- 'caretMs': the blink period of the caret.
- 'validInput': field indicating if the current input is valid. Useful to show
warnings in the UI, or disable buttons if needed.
- 'resizeOnChange': Whether input causes ResizeWidgets requests.
Expand Down