Commit Graph

310 Commits

Author SHA1 Message Date
Francisco Vallarino
5b90aebae9
Improve development time application reload (#239)
* Consider SDL.TextEditingEvent as an action event

* When a frame requires rendering, make sure the next one is also rendered to avoid artifacts. It still does not render every frame

* Fix lint

* Fix typo

* Add foreign-store dependency

* Reuse window and avoid reinitializing SDL when running on ghci and code is reloaded

* Restore previous model and widget root on code changes

* Attempt to check if model's type changed (failed, since fingerprinting is not reliable)

* Add Show instances to various widgets

* Add configuration for fingerprint functions

* Merge new root with stored root, to account for code changes in new root and data in old

* Store the complete MonomerCtx type for app reload

* Use recover-rtti for model change detection

* Process WidgetResult when merging reloaded widget root

* Validate model changes in Composite

* Fix lint

* Fix unit tests

* Force hpack version in monomer.cabal

* Add appDisableModelReuse configuration option to always ignore previous model version

* Minor setup docs update

* Revert to AppConfig only being parameterized by e

* Restore recover-rtti dependency

* Revert "Revert to AppConfig only being parameterized by e"

This reverts commit 0a66513807.

* Revert to previous version without restore-rtti dependency

* Try to overcome build issue by enforcing ubuntu-20.04

* Do not commit .dylib files

* For hpack version

* Fix docs

* Fix missing imports

* Fix typo
2023-02-24 18:14:08 +01:00
Darin Minamoto
cb7bb0ad4e
Add renderBezierTo to Renderer for rendering cubic bezier curves (#259) 2023-02-18 21:09:40 +01:00
Ruslan Gadeev
b8d3b82b50
Fix animation widget raising onFinished event when it is no longer relevant (#252)
* fix animation bug

* update animation tests
2023-02-01 03:00:53 +01:00
Ruslan Gadeev
2c52bc891a
Modify tests for selectList and dropdown (#245) 2023-01-25 14:19:00 +01:00
Francisco Vallarino
908de6f48e
Trigger ResizeWidgets when user defined size requests change (#229) 2022-11-17 01:27:24 +01:00
Ruslan Gadeev
d4270caafe
Documentation improvements (#222)
* fix typos

* fix haddock link

* fix example link

* fix typos

* fix spelling

* fix typos in tests
2022-11-08 13:24:51 +01:00
Francisco Vallarino
9856bd66fe
Fix copyright in new modules (#208) 2022-10-09 22:17:56 +02:00
Gareth Smith
38391f7bfc
Add a BoxShadow component (#205)
* Add a BoxShadow component.

* Use the correct type for boxShadow config

* Allow configuring shadow direction.
2022-10-02 17:42:34 +02:00
Francisco Vallarino
7b1d59d754
Add popup widget (#191)
* Import popup widget

* Add popupOffset configuration option

* Add popupDisableClose config option

* Add alignment options to popup widget

* Improve Haddocks

* Add window compensation offset directly to node; remove related code, simplify

* Improve Haddocks

* Add popup unit tests

* Generate onChange events when opened/closed status changes

* Replace fdescribe with describe

* Update Changelog

* Delegate visibility check to each widget

* Consider scroll offset when aligning to widget

* Request a non zero size to avoid having an invisible node

* Add note to Container's init and merge documentation

* Add support for an anchor widget

* Do not apply active style if widget is not in the active overlay

* Add popupAlignToOuter option

* Add separate horizontal/vertical alignToOuter options

* Make sure BtnReleased is sent to overlay in case findWidgetByPoint returns Nothing

* Block events happening at the same instant the popup is closed, to avoid widgets below it being activated accidentally

* Use cursor location when validating if popup should be closed

* Increase timestamp on each group of events for nodeHandleEvents_. Add helper

* Fix unit tests

* Add anchor alignment options

* Attempt to position popup in the opposite border when using outer, if it does not fit in the main border

* Always Attempt to position popup in the opposite border, both for inner and outer border alignment

* Compensate offset when calculating border alignment

* Fix regression in window alignment. Haddock fixes
2022-08-09 23:27:43 -03:00
Francisco Vallarino
84e37dcbfa
Fix Composite's onDispose event handler (#176)
* Add minNumericValue helper. Add attribution note

* Process Composite's onDispose events in its own dispose handler, since RaiseEvent will not have a handler after the Composite's disposal
2022-06-18 20:41:01 -03:00
Francisco Vallarino
dc848e8ddb
Fix memory leak in NanoVGRenderer's image initialization. Dispose unused images in image widget (#149)
* Initialize new images with count = 1; they were not released if extra references were added

* Dispose previous version of an image if it was not memory based

* Use strict versions of Map

* Update unit tests

* Update Changelog
2022-05-12 10:59:34 -03:00
Francisco Vallarino
d6def462d1
Add boxFilterEvent config option, exposing Container's filterEvent functionality (#146)
* Add boxFilterEvent to box, exposing Container's filterEvent functionality

* Add unit tests

* Update Changelog
2022-05-10 22:43:08 -03:00
Francisco Vallarino
80fa65831e
Add support for switching vertical wheel scrolling to horizontal in scroll widget by pressing the shift key (#137)
* Add support for switching vertical wheel scrolling to horizontal scrolling by pressing the shift key

* Update Changelog

* Update Changelog
2022-05-07 12:06:20 -03:00
Francisco Vallarino
90153a32b9
Make radio and optionButton only trigger onChange when the value changes (#134)
* Make optionButton's onChange trigger only once if value did not change. Add onClick to keep previous behavior

* Make radios's onChange trigger only once if value did not change. Add onClick to keep previous behavior

* Update Changelog
2022-04-30 12:53:08 -03:00
Francisco Vallarino
574c08ac9a
Fix text scaling and positioning problems in FontManager (#125)
* Remove scaling logic from FontManager (rely on also existing one in .c file). This fixes the weird positioning issues also seen previously

* Store x coordinate of the glyph, which should be used for rendering operations instead of posMinX

* Do not reset glyph position size

* Set correct field in inputField/textArea when calculating selection

* Fix unit tests

* Update Changelog
2022-04-19 10:26:48 -03:00
Francisco Vallarino
d4445105c4
Button widget improvements (#123)
* Add D_ option to button without the requirement of an explicit event

* Add ignoreParentEvts to button widget

* Add new note to keystroke widget

* Add unit tests for keystroke's/button's options for ignoring child/parent events respectively

* Update Changelog
2022-04-17 16:03:51 -03:00
Francisco Vallarino
af0456ccf1
Add extra argument to mergeRequired; in most cases, it will be WidgetEnv (#122)
* Add extra argument to mergeRequired; in most cases, it will be WidgetEnv

* Update Changelog
2022-04-17 15:06:55 -03:00
Francisco Vallarino
1972e8cce3
Allow using symbols for keystroke definitions (#117)
* Allow using symbols for keystroke definitions. Add Dash to allow using the - character as part of a combination

* Log when an invalid sequence is provided

* Revert test changes to Tutorial02

* Be more explicit about restrictions

* Add missing keyCode definitions

* Handle Dash as text and add support for KpEnter

* Update Changelog
2022-04-14 13:51:34 -03:00
Francisco Vallarino
c1a15f6959
Make style... family of functions combine styles instead of replacing them. Add style...Set family of functions. (#104)
* Adds style...Set family of functions for replacing a Style/WidgetNode StyleState. The existing style... family of functions now merge with the previous StyleState

* Add style...Set to tutorials and improve styling section. Make several small improvements

* Improve StyleState documentation

* Improve naming of Core's utility function

* Update Changelog
2022-03-26 18:13:57 -03:00
Francisco Vallarino
b6f1ad2e8d
Add appStartTs to WidgetEnv. Make Timestamp a newtype (#103)
* Add _weAppStartTs to WidgetEnv, indicating the time in ms when the application started

* Use Timestamp type instead of Int to make signatures clearer

* Retrieve correct startup timestamp

* Use newtype instead of type for Timestamp

* Update Changelog

* Add utility function currentTimeMs, returning the absolute current timestamp (not from app start)

* Use currentTimeMs in examples

* Replace SDL.ticks call with utcTimeToPOSIXSeconds

* Restore nodeKey of description field in Tutorial 03
2022-03-26 17:23:53 -03:00
Francisco Vallarino
187ad94b78
Allow setting minimum thumb size in scroll widget (#100)
* Remove unneded liftIO calls from Ticker example

* Allow setting minimum thumb size in scroll widget. Improve thumb handling.

* Consider secondary axis' thumb width when calculating thumb size ratio if both vertical and horizontal bars need to be shown

* Add test cases for thumb drag

* Update Changelog

* Remove unneeded variables
2022-03-17 13:46:40 -03:00
Gareth Smith
2ad5012732
Give various widgets a readOnly mode (#93)
* Give various widgets a readOnly mode

This mode allows text to be selected (and copied), but does not allow
editing. See issue #87

* Use a neater readOnly to editable conversion.
2022-03-07 16:30:28 -03:00
Francisco Vallarino
cd8d3f4a6f
Check if a dragHandler exists before applying fromJust in inputField (#92)
* Check if a dragHandler exists before applying fromJust in inputField

* Do not change cursor when pressing shift if input widget does not implement dragging
2022-03-05 13:02:49 -03:00
Hiroki Tokunaga
7c6777decd
Add the lineBreak option (#86)
* feat: add the `lineBreak` option

This commit adds `lineBreak` option to specify how to break texts into
lines. `OnSpaces` is the default and breaks texts at spaces. `OnCharacters`
breaks texts at characters, even in the middle of a word. This is useful
for handling CJK texts, though it does not follow [the line breaking
rules](https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages).

* fix: implement for `TextStyle`

Not to create instance of each widget.

* test: add for `OnCharacters`

* perf: make `fitLineToW` faster
2022-02-24 14:37:31 -03:00
Francisco Vallarino
5f551d6213
Rename utility functions for retrieving WidgetNode information (#75)
* Improve naming of utility functions that retrieve WidgetNode information

* Update Changelog

* Add deprecation notice on renamed functions
2022-02-04 11:23:58 -03:00
Francisco Vallarino
8af45ca777
Make Composite's onChange event part of its event queue (#71)
* Send Composite's onChange event to its own handleEvent, not to its parent. Widgets can use Report/RequestParent if needed (check ColorPicker)

* Update Changelog

* Generalize onInit and onDispose to also support WidgetRequests

* Add Composite's onInit and onDispose unit tests

* Pass oldModel to Composite's onChange event

* Update Changelog
2022-01-23 19:18:34 -03:00
Francisco Vallarino
5d70174e62
Reduce dependencies on unused or lightly used packages (#70)
* Remove dependency on OpenGL package (keep only OpenGLRaw)

* Remove scientific dependency

* Remove unused unordered-containers dependency

* Remove dependency on Safe package

* Remove directory, HUnit and silently packages dependency from tests section
2022-01-23 17:55:56 -03:00
Gareth Smith
85e70cea17
Add a CmbChildSpacing combinator and implement it for Grid, Stack and LabeledCheckbox/LabeledRadio (#67)
* Add a CmbChildSpacing combinator and implement it for Grid, Stack and LabeledCheckbox/LabeledRadio

* Fix a bug where childSpacing was applied to both dimensions in a grid, rather than just the primary dimension.

* Document the childSpacing combinators.

* Remove redundant divs (rows/cols always equals 1)
2022-01-23 10:39:44 -03:00
Francisco Vallarino
a9a7bf33f9
Add onChange event to scroll widget (#51)
* Add onChange event to scroll widget

* Generalize helper test functions

* Add unit tests for scroll's onChange event

* Update Changelog
2022-01-08 17:09:15 -03:00
Francisco Vallarino
1f4fb932be
Initialize new widget if widgetType changed when model is updated in Composite (#53)
* Initialize new widget if widgetType changed when model is updated in Composite

* Add test cases
2021-12-28 16:22:14 -03:00
Francisco Vallarino
1caf361f20
Append handled type name to widgetType in polymorphic widgets to allow switching to different model types (#49)
* Append underlying type name to widgetType in polymorphic widgets to allow switching to different model types

* Add tests for polymorphic widgetTypes

* Make the widgetType of selectList and dropdown consider the contained type

* Update Changelog.md
2021-12-27 18:25:18 -03:00
Francisco Vallarino
188e621d93
Add optionButton and toggleButton widgets (#36)
* Add optionButton and toggleButton widgets

* Improve colors for buttons in base themes

* Update themes for new widgets

* Highlight focused row buttons on Todo and Ticker examples

* Add missing docs
2021-10-28 15:23:42 -03:00
Francisco Vallarino
4accc0cb82
Do not run tests involving copy/paste unless environment variable USE_SDL_VIDEO_SUBSYSTEM = 1 (#35) 2021-10-28 11:49:00 -03:00
Francisco Vallarino
9f02be85ca
Generate IgnoreParentEvents request from widgets that handle Wheel event (avoids issues with scroll widget moving the content) (#34) 2021-10-27 14:06:11 -03:00
Francisco Vallarino
bb77f4256d
Filter following TextInput event if a single letter binding matched previously on keystroke (#33) 2021-10-26 09:06:03 -03:00
Francisco Vallarino
5c42bb743a Increase ColorPicker spacing 2021-10-25 20:03:57 -03:00
Francisco Vallarino
d4c52e9d62 Make ZStack's 'onlyTopActive' follow the same pattern as other boolean combinators 2021-10-25 14:47:07 -03:00
Francisco Vallarino
f0934b476d
Replace composite model with user model only on init and merge (#29)
* Use previous model version when calling dispose (current model may make prisms/indexed invalid, causing issues when using singular)

* Only replace composite model with user model on init and merge

* Add new unit test to composite

* Update/improve Changelog

* Bump version
2021-10-06 18:19:15 -03:00
Francisco Vallarino
cbaa62ad5a Scroll to location when button is pressed instead of released. Refactor ButtonAction handling 2021-09-23 22:20:37 -03:00
Francisco Vallarino
d6d2cc211e Fix issue with scrollbars using mouse position in child coordinates 2021-09-23 21:18:49 -03:00
Francisco Vallarino
76d74a89f4 Add support for RunInRenderThread. Add dpr field to WidgetEnv 2021-09-22 18:21:19 -03:00
Francisco Vallarino
0fb982d3e8 Add sizeUpdater helpers. Support multiple handlers in box, grid and stack. 2021-09-13 13:13:29 -03:00
Francisco Vallarino
2bfe8a8fe8
Fix space leak when rebuilding UI and handling events (#19)
* Basic tests with Strict/StrictData. These will be progressively replaced by strict fields/bang patterns, and also squashed before merging.

* Change pragmas, reduce Strict, replace with StrictData/BangPatterns in containers. Reduce space leaks

* Format package.yaml

* Remove unneeded bangs, restore tutorial main

* Bump version and update Changelog
2021-08-28 21:37:10 -03:00
Francisco Vallarino
a587282473 Make resize process smarter. Only resize if viewport size changed or widget requested it 2021-08-01 23:17:29 -03:00
Francisco Vallarino
b4d92f279f Add node prefix to key, enabled, visible and focusable 2021-07-31 13:42:42 -03:00
Francisco Vallarino
da1a9ba726 Rename multiLine to multiline 2021-07-31 13:12:52 -03:00
Francisco Vallarino
44109ca217 Add style prefix to the six style combinators (avoid reserving some common names) 2021-07-31 12:48:22 -03:00
Francisco Vallarino
918ffc2086 Rename activeStyle/activeTheme to currentStyle/currentTheme (avoid ambiguity with active style state) 2021-07-26 19:51:48 -03:00
Francisco Vallarino
1a051519f0 Standardize order of arguments for node related helper functions 2021-07-26 13:26:55 -03:00
Francisco Vallarino
49fb421780 Add anim suffix to animation widgets 2021-07-26 11:18:55 -03:00