Commit graph

43 commits

Author SHA1 Message Date
Jonathan Johnson
20ae2b7c72
map_each deadlock prevention
map_each previously was written such that if a chain of mappings fed
each other, a deadlock could occur because while the first one was
mapped, the second callback gets invoked and tries to update the first
value while it's still being held.

This refactor switches from std Mutex to parking_lot, allowing me to
remove a workaround for needing to run drop callbacks in a separate
thread during the drop of a DynamicGuard.

In addition to that change, the lower level `map_generational` calls now
take a DynamicGuard as their parameter. This allows these functions to
drop ownership of the referenced data during the callback.

The map_each implementation takes advantage of this by ensuring that the
guard is dropped before set is invoked, minimizing potential lock overlaps.

With this refactor, some old code of mine with complex validations now works
again.
2024-04-05 16:14:26 -07:00
Jonathan Johnson
9c4ae939e1
Implemented nested widget unmounted events
Closes #138

This implementation works around most of the locking issues that arose
the first few times I tried fixing this. Unfortunately it's been just
long enough for me to forget how I triggered some catastrophic issues in
the past, but all of the current examples that would invoke this
behavior continue to work, and some of the side projects that have some
weird usages also still work.
2024-03-06 09:50:29 -08:00
Jonathan Johnson
be483a92bd
Fix clippy warning 2023-12-31 07:51:10 -08:00
Jonathan Johnson
9e4e079bf5
WindowLocal + Custom Observers
This cascaded into a lot more work than expected. However, in general,
if one clones a `WidgetInstance` and shares it between two windows, it
should now work. Widget authors must ensure that when they cache
information, they do so with either a `WidgetCacheKey` or use a
`WindowLocal<T>` if per-window state is desired.

This is demonstrated in the debug-window example, where the counter of
open windows is next to a clone of the same button from the main window
that opens a new window.
2023-12-29 13:21:39 -08:00
Jonathan Johnson
285c92f82b
Root tab order fix, Spacebar widget activiation
Closes #99

Disclose now accepts focus and responds to spacebar as a result of this.
2023-12-28 15:48:34 -08:00
Jonathan Johnson
2fe28729df
Directly depending on figures
While this was a workaround for a docs.rs issue (Px/Lp are not
linked), I decided having the shorter import path would look better in
the examples.

It probably wasn't necessary to update all of the references in the
internal code, but I decided it was worth the consistency.
2023-12-28 09:35:24 -08:00
Jonathan Johnson
76528ee374
Merged internal and public WindowHandle types 2023-12-27 09:04:29 -08:00
Jonathan Johnson
6b33b0f686
Fixed reference cyle in ManagedWidget 2023-12-22 09:51:06 -08:00
Jonathan Johnson
02d6b343f1
Widget docs + refactoring
- MakeWidgetWithId::make_with_id -> MakeWidgetWithTag::make_With_tag
- ManagedWidget -> MountedWidget
- *_refresh -> *_redraw, standardized on terminology
- get_tracked -> get_tracking_redraw
2023-12-17 07:38:31 -08:00
Jonathan Johnson
1ea9938198
Fixing style inheritance 2023-12-13 12:51:43 -08:00
Jonathan Johnson
0adb43a234
Implemented local styles
Closes #86
2023-12-13 10:44:34 -08:00
Jonathan Johnson
0d34924ddf
OverlayLayer
Refs #37
2023-12-06 15:53:25 -08:00
Jonathan Johnson
15480ba68b
Added Collapse widget
Also tweaked progress bar animation
2023-11-22 15:46:58 -08:00
Jonathan Johnson
c9566fe1bd
Radio, Checkbox refactor 2023-11-22 10:48:26 -08:00
Jonathan Johnson
bb66803653
Custom widget, layout size rounding
Closes #56
2023-11-20 10:11:10 -08:00
Jonathan Johnson
294b1350c4
Fixing button animations being "slow"
The issue was that my last set of changes were causing the animations to
restart, causing the animation to keep being extended to another 150ms.

I think the only way for this to work is to switch to an event
mechanism to notify widgets once they've been invalidated. This event
could include a parameter stating whether it was a direct invalidation
or an invalidation due to another widget in the hierarchy. Button
doesn't really care about the rest of the hierarchy, it only cares about
its own state, and the cache key was including too many changes.
2023-11-15 13:04:28 -08:00
Jonathan Johnson
42840b950c
Hover updates after widget removal
This also fixes some inconsistencies that arose when the focus widget
was "stuck" on a removed widget. Button previously handled it hackily in
a redraw function, but now Gooey handles it automatically without
needing to wait for a repaint.
2023-11-15 12:41:41 -08:00
Jonathan Johnson
5506a24dae
Added WidgetCacheKey 2023-11-15 10:36:00 -08:00
Jonathan Johnson
534f676ef0
Enable/disable is now handled for all widgets
Closes #66
2023-11-15 10:23:42 -08:00
Jonathan Johnson
577e97908d
Optimizing widgets at point
Given the goal of this function, I'm not sure it can get more optimal
than this even with specialized data structures like KD-trees. The
problem is that we want all widgets that are hovered, not just some, and
that makes nearest neighbor useless.

The main optimizations here are simple:

- Group up all the render data we need in a single vec to help cache.
- Precompute the rect's extents to make the contains check at most 4
  comparisons.

This had a noticable effect on the "wiggle the mouse frantically"
performance, where Gooey isn't actually repainting but is routing mouse
events.
2023-11-15 07:53:31 -08:00
Jonathan Johnson
eb063c82f0
Explicit focus order is now fully supported 2023-11-14 14:12:12 -08:00
Jonathan Johnson
a04619a279
Layout caching, Lerp underflow fix, label fix 2023-11-14 07:38:39 -08:00
Jonathan Johnson
ee3813f44d
Switcher, h/v expand 2023-11-13 09:14:38 -08:00
Jonathan Johnson
07b93397c5
Optimizations 2023-11-12 19:54:10 -08:00
Jonathan Johnson
96d407ddc2
Container, query_parent_style 2023-11-12 13:37:32 -08:00
Jonathan Johnson
2a50bb32d4
define_components embrace, sanitize, docs, export 2023-11-12 09:21:49 -08:00
Jonathan Johnson
27d5baef5d
ThemeMode 2023-11-11 13:41:34 -08:00
Jonathan Johnson
d7384b63d8
Added WIP theming system 2023-11-10 09:39:33 -08:00
Jonathan Johnson
1714948174
Styles are now reactive 2023-11-09 10:42:56 -08:00
Jonathan Johnson
22fb955dca
More combinators
Maybe I went overboard.
2023-11-08 20:10:01 -08:00
Jonathan Johnson
6d41902002
Fixing more edge cases around widget removal 2023-11-08 15:30:11 -08:00
Jonathan Johnson
ab4e4022ea
Fixing issues when widgets are removed 2023-11-08 14:43:55 -08:00
Jonathan Johnson
bf9836a82b
Default + Cancel widgets 2023-11-08 11:03:17 -08:00
Jonathan Johnson
ca42ecc956
Fixed mouse events + docs 2023-11-07 16:43:19 -08:00
Jonathan Johnson
5e5d826267
Checkpoint
Progress on tab focus
2023-11-07 15:16:29 -08:00
Jonathan Johnson
8a2dae3f76
Next-focus progress
gameui no longer needs next_focus for the input to be focused
automatically
2023-11-07 08:39:35 -08:00
Jonathan Johnson
fbf6134a0a
Initial window focus 2023-11-06 06:19:41 -08:00
Jonathan Johnson
0f6d3838b1
LayoutContext
measure() now is layout(). LayoutContext can either persist layout
information or be used temporarily for measurement. While this caching
is constantly thrown out currently, this is a step towards being able to
only re-layout widgets if they've been invalidated.
2023-11-05 11:50:59 -08:00
Jonathan Johnson
64f46a46e2
Button animations, hover fixes, ComponentType 2023-11-01 20:11:05 -07:00
Jonathan Johnson
79be9a063b
Scroll and Animations
Scroll is only working to the absolute barest of requirements.
2023-11-01 15:15:14 -07:00
Jonathan Johnson
c9c4c9aeed
Documentation 2023-10-30 21:12:04 -07:00
Jonathan Johnson
87578e5c76
Progress towards an input widget 2023-10-18 15:44:13 -07:00
Jonathan Johnson
fc707835f5
Initial commit 2023-10-18 08:22:41 -07:00