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

Documentation improvements #222

Merged
merged 6 commits into from
Nov 8, 2022
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
6 changes: 3 additions & 3 deletions src/Monomer/Core/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Maintainer : fjvallarino@gmail.com
Stability : experimental
Portability : non-portable

Combinator typeclasses used for style and widget configutation. The reason for
Combinator typeclasses used for style and widget configuration. The reason for
using typeclasses is for the ability to reuse names such as onClick.

Boolean combinators in general have two versions:

- combinatorName: uses the default value, normally True, and is derived from the
combinator with _ suffix.
- combinatorName_: receives a boolean parameter. This is the function that needs
to be overriden in widgets.
to be overridden in widgets.
-}
{-# LANGUAGE FunctionalDependencies #-}

Expand Down Expand Up @@ -615,7 +615,7 @@ infixl 5 `styleDisabledSet`
Basic style combinator, mainly used infix with widgets.

Represents the default style of a widget. It serves as the base for all the
other style states when an attribute is not overriden.
other style states when an attribute is not overridden.
-}
class CmbStyleBasic t where
-- | Merges the new basic style states with the existing ones.
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Core/StyleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ is used as the base for all other states, which override values as needed.
- Focus-Hover: The widget has keyboard focus and mouse is on top. Without this
state one of Hover or Focus would take precedence and it would not be possible
to specify the desired behavior.
- Active: The mouse button is currently presed and the pointer is within the
- Active: The mouse button is currently pressed and the pointer is within the
boundaries of the widget.
- Disabled: The widget is disabled.
-}
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Core/StyleUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ subtractBorder rect border = nRect where
(bl, br, bt, bb) = borderWidths border
nRect = subtractFromRect rect bl br bt bb

-- | Subbtracts padding from the given rect.
-- | Subtracts padding from the given rect.
subtractPadding :: Rect -> Maybe Padding -> Maybe Rect
subtractPadding rect Nothing = Just rect
subtractPadding rect (Just (Padding l r t b)) = nRect where
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Core/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ isRunTask _ = False
{-|
Similar to RunTask, but can generate unlimited messages. This is useful for
WebSockets and similar data sources. It receives a function that with which to
send messagess to the producer owner.
send messages to the producer owner.
-}
isRunProducer :: WidgetRequest s e -> Bool
isRunProducer RunProducer{} = True
Expand Down
4 changes: 2 additions & 2 deletions src/Monomer/Core/WidgetTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import Monomer.Graphics.Types

{-|
Time expressed in milliseconds. Useful for representing the time of events,
length of intervals, start time of the application and ellapsed time since its
length of intervals, start time of the application and elapsed time since its
start.

It can be converted from/to other numeric types using the standard functions.
Expand Down Expand Up @@ -313,7 +313,7 @@ data WidgetEnv s e = WidgetEnv {
_weDpr :: Double,
-- | The timestamp in milliseconds when the application started.
_weAppStartTs :: Millisecond,
-- | Provides helper funtions for calculating text size.
-- | Provides helper functions for calculating text size.
_weFontManager :: FontManager,
-- | Returns the node info, and its parents', given a path from root.
_weFindBranchByPath :: Path -> Seq WidgetNodeInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Event/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ data SystemEvent
-- the main mouse button has been pressed.
| Leave Point
-- | A drag action is active and the mouse is inside the current viewport. The
-- messsage can be used to decide if it applies to the current widget. This
-- message can be used to decide if it applies to the current widget. This
-- event is not received by the widget which initiated the drag action, even
-- if dragging over it.
| Drag Point Path WidgetDragMsg
Expand Down
4 changes: 2 additions & 2 deletions src/Monomer/Event/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Monomer.Event.Core
import Monomer.Event.Keyboard
import Monomer.Event.Types

-- | Checks if Winddows/Cmd key is pressed.
-- | Checks if Windows/Cmd key is pressed.
isGUIPressed :: KeyMod -> Bool
isGUIPressed mod = _kmLeftGUI mod || _kmRightGUI mod

Expand Down Expand Up @@ -118,7 +118,7 @@ isOnDrop :: SystemEvent -> Bool
isOnDrop Drop{} = True
isOnDrop _ = False

-- | Appplies a provided function to test a KeyAction event
-- | Applies a provided function to test a KeyAction event
checkKeyboard :: SystemEvent -> (KeyMod -> KeyCode -> KeyStatus -> Bool) -> Bool
checkKeyboard (KeyAction mod code motion) testFn = testFn mod code motion
checkKeyboard _ _ = False
2 changes: 1 addition & 1 deletion src/Monomer/Graphics/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fitTextToSize fontMgr style ovf mode trim mlines !size !text = newLines where
| ellipsisReq = addEllipsisToTextLine fontMgr style cw <$> firstLine
| otherwise = clipTextLine fontMgr style trim cw <$> firstLine

-- | Fits a single line of text to the given width, potencially spliting into
-- | Fits a single line of text to the given width, potentially splitting into
-- several lines.
fitTextToWidth
:: FontManager -- ^ The fontManager.
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Graphics/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ data TextMode
| MultiLine
deriving (Eq, Show, Generic)

-- | Text flags for trimming or keeping sapces.
-- | Text flags for trimming or keeping spaces.
data TextTrim
= TrimSpaces
| KeepSpaces
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Maintainer : fjvallarino@gmail.com
Stability : experimental
Portability : non-portable

Module grouping all the diferent lens modules. Useful import to avoid duplicate
Module grouping all the different lens modules. Useful import to avoid duplicate
instance errors.
-}
module Monomer.Lens (
Expand Down
10 changes: 5 additions & 5 deletions src/Monomer/Main/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ startApp model eventHandler uiBuilder configs = do
let monomerCtx = initMonomerCtx window channel vpSize dpr epr model

runStateT (runAppLoop window glCtx channel appWidget config) monomerCtx
detroySDLWindow window
destroySDLWindow window
where
config = mconcat configs
compCfgs
Expand Down Expand Up @@ -254,7 +254,7 @@ mainLoop
mainLoop window fontManager config loopArgs = do
let MainLoopArgs{..} = loopArgs

startTs <- getEllapsedTimestampSince _mlAppStartTs
startTs <- getElapsedTimestampSince _mlAppStartTs
events <- SDL.pumpEvents >> SDL.pollEvents

windowSize <- use L.windowSize
Expand Down Expand Up @@ -344,7 +344,7 @@ mainLoop window fontManager config loopArgs = do
handleResizeWidgets (seWenv, seRoot, Seq.empty)
else return (seWenv, seRoot, Seq.empty)

endTs <- getEllapsedTimestampSince _mlAppStartTs
endTs <- getElapsedTimestampSince _mlAppStartTs

-- Rendering
renderCurrentReq <- checkRenderCurrent startTs _mlLatestRenderTs
Expand Down Expand Up @@ -590,7 +590,7 @@ getCurrentTimestamp = toMs <$> liftIO getCurrentTime
where
toMs = floor . (1e3 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds

getEllapsedTimestampSince :: MonadIO m => Millisecond -> m Millisecond
getEllapsedTimestampSince start = do
getElapsedTimestampSince :: MonadIO m => Millisecond -> m Millisecond
getElapsedTimestampSince start = do
ts <- getCurrentTimestamp
return (ts - start)
6 changes: 3 additions & 3 deletions src/Monomer/Main/Platform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Helper functions for SDL platform related operations.
module Monomer.Main.Platform (
defaultWindowSize,
initSDLWindow,
detroySDLWindow,
destroySDLWindow,
getCurrentMousePos,
getDrawableSize,
getWindowSize,
Expand Down Expand Up @@ -171,8 +171,8 @@ setWindowIcon (SIT.Window winPtr) config =
"Failed to set window icon. Does the file exist?\n\t" ++ show err ++ "\n"

-- | Destroys the provided window, shutdowns the video subsystem and SDL.
detroySDLWindow :: SDL.Window -> IO ()
detroySDLWindow window = do
destroySDLWindow :: SDL.Window -> IO ()
destroySDLWindow window = do
SDL.destroyWindow window
Raw.quitSubSystem Raw.SDL_INIT_VIDEO
SDL.quit
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Main/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data DragAction = DragAction {
} deriving (Eq, Show)

{-|
Asychronous widget task. Results must be provided as user defined, Typeable,
Asynchronous widget task. Results must be provided as user defined, Typeable,
types. Error handling should be done inside the task and reporting handled as
part of the user type.
-}
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Widgets/Composite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Portability : non-portable

Composite widget. Main glue between all the other widgets, also acts as the main
app widget. Composite allows to split an application into reusable parts without
the need to implement a lower level widget. It can comunicate with its parent
the need to implement a lower level widget. It can communicate with its parent
component by reporting events.

Requires two functions:
Expand Down
10 changes: 5 additions & 5 deletions src/Monomer/Widgets/Container.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ type ContainerMergePostHandler s e a
Disposes the current node. Only used by widgets which allocate resources during
/init/ or /merge/, and will usually involve requests to the runtime.

An example can be found "Monomer.Widgets.Containers.Dropdown".
An example can be found in "Monomer.Widgets.Containers.Dropdown".
-}
type ContainerDisposeHandler s e
= WidgetEnv s e -- ^ The widget environment.
Expand All @@ -259,7 +259,7 @@ type ContainerFindNextFocusHandler s e
Returns the currently hovered widget, if any. If the widget is rectangular and
uses the full content area, there is not need to override this function.

An example can be found "Monomer.Widgets.Containers.Dropdown".
An example can be found in "Monomer.Widgets.Containers.Dropdown".
-}
type ContainerFindByPointHandler s e
= WidgetEnv s e -- ^ The widget environment.
Expand Down Expand Up @@ -353,7 +353,7 @@ type ContainerResizeHandler s e

{-|
Renders the widget's content using the given Renderer. In general, this method
needs to be overriden. There are two render methods: one runs before children,
needs to be overridden. There are two render methods: one runs before children,
the other one after.

Examples can be found in "Monomer.Widgets.Containers.Draggable" and
Expand Down Expand Up @@ -432,9 +432,9 @@ data Container s e a = Container {
containerGetSizeReq :: ContainerGetSizeReqHandler s e,
-- | Resizes the widget to the provided size.
containerResize :: ContainerResizeHandler s e,
-- | Renders the widget's content. This runs before childrens' render.
-- | Renders the widget's content. This runs before children's render.
containerRender :: ContainerRenderHandler s e,
-- | Renders the widget's content. This runs after childrens' render.
-- | Renders the widget's content. This runs after children's render.
containerRenderAfter :: ContainerRenderHandler s e
}

Expand Down
4 changes: 2 additions & 2 deletions src/Monomer/Widgets/Containers/Grid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ makeFixedGrid isHorizontal config = widget where
newSizeReqH = getDimSizeReq isVertical (_wniSizeReqH . _wnInfo) vchildren
newSizeReq = applyFnList sizeReqFns (newSizeReqW, newSizeReqH)

getDimSizeReq mainAxis accesor vchildren
getDimSizeReq mainAxis accessor vchildren
| Seq.null vreqs = fixedSize 0
| mainAxis = foldl1 sizeReqMergeSum (Seq.replicate nreqs maxSize) & L.fixed %~ (+ totalSpacing)
| otherwise = maxSize
where
vreqs = accesor <$> vchildren
vreqs = accessor <$> vchildren
nreqs = Seq.length vreqs
~maxSize = foldl1 sizeReqMergeMax vreqs
totalSpacing = fromIntegral (nreqs - 1) * childSpacing
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Widgets/Containers/Popup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ When the popup is open, events will not reach the widgets below it.

In addition to the content that is displayed when open, a popup requires a
boolean lens or value to indicate if the content should be visible. This flag
can be used to programatically open/close the popup. The popup can also be
can be used to programmatically open/close the popup. The popup can also be
closed by clicking outside its content.

In general, it is a good idea to set a background color to the top level content
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Widgets/Containers/Scroll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ makeScroll config state = widget where
containerChildrenOffset = Just offset
}

-- This is overriden to account for space used by scroll bars
-- This is overridden to account for space used by scroll bars
updateCWenv wenv node cnode cidx = newWenv where
theme = currentTheme wenv node
barW = fromMaybe (theme ^. L.scrollBarWidth) (_scBarWidth config)
Expand Down
2 changes: 1 addition & 1 deletion src/Monomer/Widgets/Containers/Split.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Configuration options for split:
- 'splitIgnoreChildResize': whether to ignore changes in size to its children
(otherwise, the handle position may change because of this).
- 'onChange': raises an event when the handle is moved.
- 'onChangeReq': generates a WidgetReqest when the handle is moved.
- 'onChangeReq': generates a WidgetRequest when the handle is moved.
-}
data SplitCfg s e = SplitCfg {
_spcHandlePos :: Maybe (WidgetData s Double),
Expand Down
4 changes: 2 additions & 2 deletions src/Monomer/Widgets/Containers/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ makeStack isHorizontal config = widget where
newSizeReqH = getDimSizeReq isVertical (_wniSizeReqH . _wnInfo) vchildren
newSizeReq = applyFnList sizeReqFns (newSizeReqW, newSizeReqH)

getDimSizeReq mainAxis accesor vchildren
getDimSizeReq mainAxis accessor vchildren
| Seq.null vreqs = fixedSize 0
| mainAxis = foldl1 sizeReqMergeSum vreqs & L.fixed %~ (+ totalSpacing)
| otherwise = foldl1 sizeReqMergeMax vreqs
where
vreqs = accesor <$> vchildren
vreqs = accessor <$> vchildren
totalSpacing = fromIntegral (Seq.length vchildren - 1) * childSpacing

resize wenv node viewport children = resized where
Expand Down
10 changes: 5 additions & 5 deletions src/Monomer/Widgets/Containers/Tooltip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Stability : experimental
Portability : non-portable

Displays a text message above its child node when the pointer is on top and the
delay, if any, has ellapsed.
delay, if any, has elapsed.

Tooltip styling is a bit unusual, since it is applied to the overlaid element.
This means padding will not be shown for the contained child element, but only
on the message when the tooltip is active. If padding around the child element
is needed, "Monomer.Widgets.Containers.Box" can be used to wrap it.

@
tooltip "Click the button" (buttom \"Accept\" AcceptAction)
tooltip "Click the button" (button \"Accept\" AcceptAction)
\`styleBasic\` [textSize 16, bgColor steelBlue, paddingH 5, radius 5]
@
-}
Expand Down Expand Up @@ -183,7 +183,7 @@ makeTooltip caption config state = widget where

_ -> Nothing

-- Padding/border is not removed. Styles are only considerer for the overlay
-- Padding/border is not removed. Styles are only considered for the overlay
resize wenv node viewport children = resized where
resized = (resultNode node, Seq.singleton viewport)

Expand Down Expand Up @@ -234,5 +234,5 @@ makeTooltip caption config state = widget where
ts = wenv ^. L.timestamp
viewport = node ^. L.info . L.viewport
inViewport = pointInRect lastPos viewport
delayEllapsed = ts - lastPosTs >= delay
displayed = inViewport && delayEllapsed
delayElapsed = ts - lastPosTs >= delay
displayed = inViewport && delayElapsed
4 changes: 2 additions & 2 deletions src/Monomer/Widgets/Containers/ZStack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ makeZStack config state = widget where
newSizeReqW = getDimSizeReq (_wniSizeReqW . _wnInfo) vchildren
newSizeReqH = getDimSizeReq (_wniSizeReqH . _wnInfo) vchildren

getDimSizeReq accesor vchildren
getDimSizeReq accessor vchildren
| Seq.null vreqs = fixedSize 0
| otherwise = foldl1 sizeReqMergeMax vreqs
where
vreqs = accesor <$> vchildren
vreqs = accessor <$> vchildren

resize wenv node viewport children = resized where
style = currentStyle wenv node
Expand Down
11 changes: 5 additions & 6 deletions src/Monomer/Widgets/Single.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type SingleMergeHandler s e a
Disposes the current node. Only used by widgets which allocate resources during
/init/ or /merge/, and will usually involve requests to the runtime.

An example can be found "Monomer.Widgets.Singles.Image".
An example can be found in "Monomer.Widgets.Singles.Image".
-}
type SingleDisposeHandler s e
= WidgetEnv s e -- ^ The widget environment.
Expand All @@ -151,7 +151,7 @@ type SingleFindNextFocusHandler s e
Returns the currently hovered widget, if any. If the widget is rectangular and
uses the full content area, there is not need to override this function.

An example can be found "Monomer.Widgets.Singles.Radio".
An example can be found in "Monomer.Widgets.Singles.Radio".
-}
type SingleFindByPointHandler s e
= WidgetEnv s e -- ^ The widget environment.
Expand Down Expand Up @@ -182,8 +182,7 @@ requests to the runtime. There is no validation regarding the message type, and
the widget should take care of _casting_ to the correct type using
"Data.Typeable.cast"

Examples can be found in "Monomer.Widgets.Singles.Button" and
"Monomer.Widgets.Singles.Slider".
An example can be found in "Monomer.Widgets.Singles.Image".
-}
type SingleMessageHandler s e
= forall i . Typeable i
Expand All @@ -209,7 +208,7 @@ type SingleGetSizeReqHandler s e

{-|
Resizes the widget to the provided size. If the widget state does not depend
on the viewport size, this function does not need to be overriden.
on the viewport size, this function does not need to be overridden.

Examples can be found in "Monomer.Widgets.Singles.Label".
-}
Expand All @@ -221,7 +220,7 @@ type SingleResizeHandler s e

{-|
Renders the widget's content using the given Renderer. In general, this method
needs to be overriden.
needs to be overridden.

Examples can be found in "Monomer.Widgets.Singles.Checkbox" and
"Monomer.Widgets.Singles.Slider".
Expand Down
Loading