monomer

A GUI library for writing native Haskell applications.

https://github.com/fjvallarino/monomer#readme

Version on this page:1.3.0.0@rev:3
LTS Haskell 22.14:1.6.0.1
Stackage Nightly 2023-12-26:1.6.0.0
Latest on Hackage:1.6.0.1

See all snapshots monomer appears in

BSD-3-Clause licensed by Francisco Vallarino
Maintained by [email protected]
This version can be pinned in stack with:monomer-1.3.0.0@sha256:82bb1ab764d0ff621073ddcea4d9b4fe56410977c819ffcec4a00d823817e1cb,16184

Module documentation for 1.3.0.0

Monomer

An easy to use, cross platform, GUI library for writing native Haskell applications.

It provides a framework similar to the Elm Architecture, allowing the creation of GUIs using an extensible set of widgets with pure Haskell.

Screenshot

Project’s screenshot

Objectives

  • Be easy to learn and use.
  • Be extensible with custom widgets.
  • Run on Windows, Linux and macOS.
  • Have good documentation.
  • Have good examples.

These are not objectives for this project

  • Have a native look and feel.

Why would you want to use this library?

  • You want to write your application in Haskell.
  • You want to write a native, not web based, application.

Documentation

Setup

You can read how to setup your environment here.

Tutorials

Introductory tutorials are available:

Examples

Beyond the tutorials, a few real world like examples are available:

Haddock

You can read the source code’s documentation here.

Design decisions

In case you wonder why some choices were made, you can read here.

Roadmap

  • Stability and performance.
  • Mobile support.

Contributing

PRs are welcome!

If possible, keep them small and focused. If you are planning on making a large change, please submit an issue first so we can agree on a solution.

Questions?

If you are not sure how something works or you have a usage question, feel free to open an issue!

License

This library is licensed under the BSD-3 license.

Fonts used in the examples:

Acknowledgments

Changes

1.3.0.0

Added

  • Export drawArrowUp from Drawing module.
  • The image widget now supports a fitEither option (PR #56). Thanks @Kyarigwo!
  • The scroll widget now raises onChange events, providing the current ScrollStatus (PR #51).
  • The grid, stack, labeledCheckbox and labeledRadio widgets now support a childSpacing/childSpacing_ option (PR #67). Thanks @Dretch!

Fixed

  • Widgets that receive polymorphic types now append the handled type to their WidgetType. This is done to avoid issues if the handled type is later changed (#46).
  • If the WidgetType of the root item in a Composite changes during merge, initialize the new widget instead of merging with the old one (#50).
  • The arrow position in dropdown is now correct when a dropdown is taller than one line (PR #55). Thanks @Dretch!
  • The middle button click is now handled by convertEvents, and in turn reported to widgets (#63).
  • Add tolerance to width comparison in text clipping functions (#54).
  • Call pumpEvents before pollEvents. The pumpEvents call is implied by pollEvent, but starting on SDL2 2.0.20 it seems to be required to call it explicitly (#66). Thanks @JD95!

Changed

  • Relaxed upper bounds of dependencies for Stackage inclusion.

1.2.0.1

Fixed

  • The scroll and split widgets now avoid unexpected behaviour when visibility is toggled.

1.2.0.0

Added

  • Add customModelBuilder in Composite, for custom models support. These can consume information from the parent model.
  • Add containerCreateContainerFromModel to workaround issue when updating offset during merge.
  • Add appDisableCompositing to allow requesting compositing to be disabled on startup.
  • Add optionButton and toggleButton widgets.
  • Add SetFocusOnKey and MoveFocusFromKey actions in Composite. Deprecate setFocusOnKey function. This function depended on information in WidgetEnv, which can become stale if several actions are returned at once. This change reduces confusion regarding order of operations and widget tree state.

Fixed

  • Keep old Composite root if model has not changed. This does not affect previous code, it is only relevant with new features.
  • Generate IgnoreParentEvents request from widgets that handle Wheel event (avoids issues with scroll widget moving the content).
  • Do not run tests which depend on SDL’s video subsystem to be available unless an environment variable is defined. This allows for (hopefully) running tests on Hackage and, later on, deploying to Stackage.

Changed

  • Composite requests RenderOnce when model changes.
  • Composite now renders decorations if a style is set.
  • ZStack’s onlyTopActive now follows the same pattern as other boolean combinators.
  • Shortened labels for ColorPicker.
  • Changed _weFindByPath to _weFindBranchByPath, now returning the complete branch up to the given path.
  • Change SDL’s default of requesting compositing to be disabled on startup (compositing is now left unchanged).
  • Filter following TextInput event if a single letter binding matched previously on keystroke.

1.1.1.0

Added

  • appInvertWheelX and appInvertWheelY configuration options.

Fixed

  • Horizontal wheel/trackpad scrolling on Linux.
  • Scroll: do not use direction argument to modify wheel/trackpad direction (event provides correct value).
  • Only replace composite model with user model on init and merge.

1.1.0.0

Added

  • sizeUpdater helpers. Support multiple handlers in box, grid and stack.
  • dpr field to WidgetEnv.
  • RunInRenderThread to support initialization of low level OpenGL resources.
  • OpenGL example.
  • containerDrawDecorations. Simplify button/externalLink internals.
  • ThemeState entries for future optionButton and toggleButton widgets.
  • singleDrawDecorations. Make it consistent with Container.

Fixed

  • Reduce memory usage by sharing wreq session among image widget instances.
  • Set correct WidgetEnv viewport from scroll (it looked good because of scissoring).
  • Fix issue with scrollbars using child coordinates for detecting clicks.

1.0.0.3

Added

  • Add Nix and GitHub Actions support (thanks @smunix!).

Fixed

  • Consume and forward all available messages from Producers on each cycle.
  • Fix space leak when rebuilding the UI or handling events.

1.0.0.2

Added

  • Add appRenderOnMainThread option.

Changed

  • Use the recently published nanovg-0.8.0.0 from Hackage, instead of the version from the PR’s commit.

1.0.0.1

Fixed

  • Fix Haddocks for widget configuration types.

1.0.0.0

Initial public release

  • Supports Windows, Linux and macOS