Commit graph

227 commits

Author SHA1 Message Date
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
63fd92eea6
Added changelog 2023-12-18 20:14:01 -08:00
Jonathan Johnson
75eb96b5f5
Preparing v0.1.2 2023-12-18 17:15:21 -08:00
Jonathan Johnson
a1e3082527
Fixing compilation on Windows
Condvar isn't UnwindSafe on Windows either. See
rust-lang/rust#118009
2023-12-18 17:10:04 -08:00
Jonathan Johnson
7dc00f27e0
Fixing links in readme
I somehow lost my variables at some point.
2023-12-18 11:40:45 -08:00
Jonathan Johnson
5be40e7271
Preparing gooey-macros for publish 2023-12-18 11:25:38 -08:00
Jonathan Johnson
62ad57b17f
Updating to released kludgine/figures/appit 2023-12-18 11:18:43 -08:00
Jonathan Johnson
309dad95b3
Moving readme changes to the right location 2023-12-18 10:00:53 -08:00
Jonathan Johnson
4a68fa08f8
Updated README and Cargo.toml
Also removed example that wasn't ever completed.
2023-12-18 09:56:37 -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
01e04a4eb9
Improving the readmes a bit 2023-12-15 14:31:44 -08:00
Jonathan Johnson
7ae4374411
ColorSource picker 2023-12-15 14:01:31 -08:00
Jonathan Johnson
2b46b0b34c
Fixing scrollbar showing/hiding + hit detection 2023-12-15 14:00:31 -08:00
Jonathan Johnson
10d3ef401f
Updating Kludgine 2023-12-15 14:00:19 -08:00
Jonathan Johnson
b4caa38b83
Fixing grid gutter calculations
The space for fractional children's gutters was being doubled.
2023-12-15 13:59:09 -08:00
Jonathan Johnson
d7d06e41fa
Fixing various mouse selection bugs
Realized that I was skipping invisible glyphs during construction of
MeasuredText. Once those were in, most of the issues vanished. A few
small tweaks and now it works surprisingly well.
2023-12-14 19:59:27 -08:00
Jonathan Johnson
d7d0d6eb56
Squashed some todos 2023-12-14 17:30:40 -08:00
Jonathan Johnson
eb91e73a6e
Scrollbars are now clickable 2023-12-14 16:55:02 -08:00
Jonathan Johnson
0fd7c8fd5c
Implemented Wrap
Closes #59
2023-12-14 10:48:35 -08:00
Jonathan Johnson
c4200e6009
Added MountedChildren 2023-12-14 07:48:56 -08:00
Jonathan Johnson
aa996a090b
Tooltips
Closes #37
2023-12-13 16:30:34 -08:00
Jonathan Johnson
cd4bb5130f
Widget::full_control_redraw
+ transparent containers show their shadows properly
2023-12-13 14:45:56 -08:00
Jonathan Johnson
353db9dc39
Added Opacity component
Closes #87
2023-12-13 14:02:39 -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
b1177e7c25
Gutter is now a property on Stack 2023-12-13 09:38:12 -08:00
Jonathan Johnson
5c720e6009
Align + Overlay + Shadow fixes
- Blur no longer expands the shadow geometry, but instead is clamped to
  avoid overlapping drawing calls.
- Overlay now handles hit tests correctly with regards to the original
  relative widget.
- Align was using an Into conversion that wasn't actually correct,
  causing the contents to not actually get aligned in some situations.
2023-12-13 08:26:09 -08:00
Jonathan Johnson
79a09ee614
Shadow blur now can cause expansion
Rather than clip or cause shadows to be weirdly shaped, the shape is
adjusted if the blur radius is too large for the given geometry. This
ensures the shadows always draw correctly, but it also forces shadows to
render their full blur + spread gradients.
2023-12-12 19:27:41 -08:00
Jonathan Johnson
a7efe9a3d5
Container Shadows 2023-12-12 13:49:03 -08:00
Jonathan Johnson
87fa4a3478
Moved arc path generation to Kludgine 2023-12-10 15:43:02 -08:00
Jonathan Johnson
c4151d649c
Added Spinner widget
Closes #80
2023-12-10 15:05:59 -08:00
Jonathan Johnson
a526dc000b
Fixing doc link 2023-12-10 07:21:28 -08:00
Jonathan Johnson
09a1590c7e
Finished font support
Font families are now cached. There probably should be a mechanism to
refresh the cache, but we don't currently have a "signal" to notify us
when a font is installed. Presumably, this could be something that
fontdb would eventually add, rather than us building our own.

Closes #48
2023-12-10 07:19:32 -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
95555ce928
Tilemap updates 2023-12-09 08:20:18 -08:00
Jonathan Johnson
16af20269e
Updated figures + kludgine 2023-12-07 15:49:03 -08:00
Jonathan Johnson
2fe08fc9e9
Added hover support to OverlayLayer 2023-12-07 09:51:07 -08:00
Jonathan Johnson
0d34924ddf
OverlayLayer
Refs #37
2023-12-06 15:53:25 -08:00
Jonathan Johnson
288119a831
Added Layers 2023-12-05 08:51:55 -08:00
Jonathan Johnson
17847d6947
Various fixes/improvements
- On Linux, `fm-match` is used to query for the default fonts.
- DynamicComponents now have their own trait and can now be specified
  with a constant or dynamic.
- Roboto Flex is now always loaded when the feature is enabled.
  Overriding the default sans serif font prefers the overridden value,
  then roboto, then the result of fc-match/fontdb's default.
- Button now supports background colors being set on a transparent
  button.
2023-12-03 15:35:37 -08:00
Jonathan Johnson
55eea5fad3
Added Copy to Clipboard to theme editor
This also wires up the beginnings of the application type
2023-12-03 07:38:56 -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
8f99ae19fd
Implemented a basic grid
Refs #14
2023-11-30 18:19:53 -08:00
Jonathan Johnson
8a4c66e73b
Refactored to MakeWidgetWithId 2023-11-30 09:14:19 -08:00
Jonathan Johnson
a826b91173
Fixing gutter calculations + scroll canvas sizing 2023-11-30 08:46:41 -08:00
Jonathan Johnson
bd37279282
Resizable windows now expand automatically
This expansion only triggers if the root widget measures larger than the
window's current size. We can't set a minimum size explicitly unless a
Resize widget is present, as we don't have enough knowledge to ensure
that the exact measurement we received was indeed the smallest layout in
any given direction. We only know that given the current constraints,
the returned measurement was the smallest possible. All future queries
will have to still be done again, as any change to the constraints could
impact the measured size.
2023-11-29 19:05:43 -08:00