Commit graph

49 commits

Author SHA1 Message Date
Jonathan Johnson
4e145d7f35
Removed UnwindSafe bounds
appit wasn't supposed to pass along this requirement
2023-12-20 11:35:19 -08:00
Jonathan Johnson
4959296e07
Fixed callback invocation from multiple threads
Closes #97

There was a potential race condition described in #97 that I realized I
had seen occasionally when interacting with an element that was
currently being animated. These were in complex situations, so I thought
I had a situation that could have legitimately caused the warning.

However, this warning is preventing a very specific coding "error", and
that program did not have it. The existing implementation would
potentially prevent one thread's change from invoking its callbacks
because another thread was already executing its callbacks.

This change moves that state into a Mutex/Condvar pair that allows
detecting reentry while allowing other threads to block until its their
turn. When it becomes their turn, they can check whether the callbacks
were invoked with the current value or not to prevent callbacks from
being invoked in quick succeession with the same value by multiple
threads.
2023-12-19 11:41:21 -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
0fd7c8fd5c
Implemented Wrap
Closes #59
2023-12-14 10:48:35 -08:00
Jonathan Johnson
35576f9214
Image widget
Closes #23

(Feels good to close a 3 year old issue!)
2023-12-09 13:18:46 -08:00
Jonathan Johnson
2fe08fc9e9
Added hover support to OverlayLayer 2023-12-07 09:51:07 -08:00
Jonathan Johnson
0e6796318b
Added Widget::summarize
Debug printing widgets was quite verbose. While developing a widget, you
often want to see a full debug printout, but this feature assumes that
debug printing a WidgetInstance should show a summary of the widget, not
a full debug printout containing cached glyph information of every
label.

By default, summarize just calls Debug, but this extra layer allows
widgets to provide a more condensed summary and exclude details like
caches.

Originally, adding dbg!() around the theme example's UI yielded a
whopping 20,324 lines of text. The summary code only prints 3,858
lines.
2023-12-03 06:40:19 -08:00
Jonathan Johnson
d1e21178e0
WeakDynamic<T> 2023-12-02 07:05:18 -08:00
Jonathan Johnson
9ee00106a3
Updated alot + Eq for CallbackHandle 2023-12-02 06:51:19 -08:00
Jonathan Johnson
3f8885efbe
Callback handles are now managed
Installing a callback now returns a CallbackHandle. All map-style APIs
install this handle automatically on the created dynamic, which keeps
the callback installed until the dynamic is freed. All other APIs
return the handle for the caller to either call persist() or store
somewhere.

Now, the dynamic system can be used for application-long data with
almost no fear of leaking data due to how callbacks are being installed.
Technically cycles are still possible by moving clones into the
callbacks, so a WeakDynamic type might be worth exposing.
2023-12-01 13:31:42 -08:00
Jonathan Johnson
a3e45d1d86
Small improvements
- Caching font family resolution to avoid scanning the database over and
  over. The db should still be cached, but this makes repeated setting
  free.
- into_switcher rename for Dynamic<WidgetInstance> to avoid conflicting
  with Switchable::switcher()
- Dynamic debugging is less verbose
- IntoDynamic<Validation> for Result<T,E>
- Input no longer blinks cursor when disabled.
2023-12-01 12:52:46 -08:00
Jonathan Johnson
8a4c66e73b
Refactored to MakeWidgetWithId 2023-11-30 09:14:19 -08:00
Jonathan Johnson
03e93adb15
Select buttons 2023-11-29 17:14:42 -08:00
Jonathan Johnson
589c3dbc7f
MakeWidget for Dynamic<WidgetInstance> + option 2023-11-29 11:42:51 -08:00
Jonathan Johnson
3f2aace55e
Debouncing 2023-11-27 10:09:42 -08:00
Jonathan Johnson
aeb55e0b94
run_in_bg and Dynamic<&'static str> 2023-11-27 09:27:37 -08:00
Jonathan Johnson
0fd8a9487f
Validations 2023-11-25 07:43:04 -08:00
Jonathan Johnson
f107267409
Validations 2023-11-24 14:29:06 -08:00
Jonathan Johnson
b2fdf06e60
Dynamic now requires PartialEq
This reduces the complexity of operations capable with Dynamic, and also
makes it easier to shortcut deadlocking operations.
2023-11-23 11:53:59 -08:00
Jonathan Johnson
c9566fe1bd
Radio, Checkbox refactor 2023-11-22 10:48:26 -08:00
Jonathan Johnson
801337ab7a
Progress bars, repeating animations
Closes #70
2023-11-21 09:53:08 -08:00
Jonathan Johnson
bb66803653
Custom widget, layout size rounding
Closes #56
2023-11-20 10:11:10 -08:00
Jonathan Johnson
01d45a836f
Fixing Gooey compilation on MacOS
After trying to run Gooey again on my Mac for the first time in a few
weeks, I found that I ran into the Condvar issue again. Rather than
pasting AssertUnwindSafe in those files, I've both reported the
discrepency in unwind safety (rust-lang/rust#118009) and moved the
workaround into a type that only uses AssertUnwindsafe when compiling
for Apple.
2023-11-17 06:20:20 -08:00
Jonathan Johnson
c39f8f33ad
Rewrote text input
Also implemnted secure/masked input

Closes #58
2023-11-16 15:34:26 -08:00
Jonathan Johnson
54e01f1911
Checkbox, ButtonKind, linked/linked_string + more 2023-11-14 20:39:29 -08:00
Jonathan Johnson
89c8805924
Refactored switcher to use Dynamic<WidgetInstance> 2023-11-14 13:24:23 -08:00
Jonathan Johnson
4a4bc5de1a
Added slidable enum demo
Also moved into_button to MakeWidget
2023-11-14 11:44:32 -08:00
Jonathan Johnson
4c7c3be5ba
Helpers galore 2023-11-14 09:31:56 -08:00
Jonathan Johnson
a04619a279
Layout caching, Lerp underflow fix, label fix 2023-11-14 07:38:39 -08:00
Jonathan Johnson
96d407ddc2
Container, query_parent_style 2023-11-12 13:37:32 -08:00
Jonathan Johnson
d07dcdc9aa
Paired dynamics are now possible
Also sliders look better
2023-11-11 16:51:07 -08:00
Jonathan Johnson
eb4b24f4a9
Slider 2023-11-11 09:42:53 -08:00
Jonathan Johnson
d7384b63d8
Added WIP theming system 2023-11-10 09:39:33 -08:00
Jonathan Johnson
897880de25
Dynamic into/to helpers 2023-11-09 10:15:13 -08:00
Jonathan Johnson
a2e28cb522
Dynamic::take, align helpers, scroll fix
Scroll was previously taking the graphics region as its control size as
opposed to the constraints. This was due to this code originally living
in redraw. This fixes scroll areas being able to scroll their contents
fully when sharing window space with other widgts.
2023-11-09 10:04:09 -08:00
Jonathan Johnson
58b98a9a16
LinearInterpolation now requires PartialEq
This also means that if an animation is animating over discrete values
and the actual value has not changed, the Dynamic will no longer detect
a change because it's now using update instead of set.
2023-11-09 07:46:02 -08:00
Jonathan Johnson
22fb955dca
More combinators
Maybe I went overboard.
2023-11-08 20:10:01 -08:00
Jonathan Johnson
8e268615a1
WrapperWidget, Space 2023-11-08 19:09:59 -08:00
Jonathan Johnson
ad57e02e4f
Generic ForEach/MapEach 2023-11-08 15:32:51 -08:00
Jonathan Johnson
b27b9db380
IntoDynamic<T> 2023-11-08 07:44:10 -08:00
Jonathan Johnson
57a689b8c8
Window focus/occlusion, recursive focus/activation 2023-11-07 20:16:59 -08:00
Jonathan Johnson
d766d906a6
Added async value test 2023-11-06 06:41:49 -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
126b324b55
Animation docs, on_complete 2023-11-03 09:37:22 -07:00
Jonathan Johnson
501eecd7a5
Async, better scroll, Input::on_key 2023-11-03 07:15:34 -07:00
Jonathan Johnson
ed31805693
Tuple animations 2023-11-02 07:48:30 -07:00
Jonathan Johnson
64f46a46e2
Button animations, hover fixes, ComponentType 2023-11-01 20:11:05 -07:00
Jonathan Johnson
c9c4c9aeed
Documentation 2023-10-30 21:12:04 -07:00
Renamed from src/dynamic.rs (Browse further)