Commit Graph

773 Commits

Author SHA1 Message Date
Olivier FAURE 1a73b9526b Fix clippy lints 2025-03-18 17:31:56 +01:00
Olivier FAURE 406d4b9932 Refactor example tests to run more efficiently 2025-03-18 17:24:26 +01:00
Viktor Strate Kløvedal 6d1d6b9217
Add Xilem view for the Split widget (#887)
### Highlights

- Make the Masonry Split widget generic over its children (fixes a todo)
- Adds a new Xilem view for the widget
- Updated the `http_cats` example to use it for the main divider.

---

I'm unsure how exactly the `message` function works on a Xilem view as
it was hard to find documentation on that, so I've tried my best to
implement it, by looking at other views. Please double check that I did
it right.

I also changed some defaults on the split widget. First, I changed
`draggable` to default to true, since I believe this is the intended
behaviour for the view, similar to how a button is not disabled by
default.

I changed the constructors of the widget to not include the `split_axis`
but rather let it be optional with vertical (row) being the default
axis. I feel this made it more ergonomic to integrate with Xilem.
2025-03-18 09:48:29 +00:00
platlas fcc1c4a6f2
Resolving remaining `Label::message` artifacts. (#894)
Sorry, I should have done this already in #889.
2025-03-17 16:07:44 +00:00
Olivier FAURE 8d322b63a8
Change how some widgets are rendered (#886)
Update the code for Button, Textbox and ProgressBar.

Make the border and background disjoint.
Correctly interpret the border width.
2025-03-17 14:22:46 +00:00
Olivier FAURE aa56ea7633
Fix accessibility documentation (#859) 2025-03-17 14:10:36 +00:00
Olivier FAURE d9e2efffc0
Add note about `split-debuginfo="unpacked"` in README (#890)
(Co-authored by Daniel McNab)
2025-03-17 13:52:44 +00:00
platlas aaa84034ef
Fixing minor artifact. (#889)
edit(jplatte): Closes #888
2025-03-15 19:29:16 +00:00
Daniel McNab f98987f34c
Free properties as well (#885)
I found in #882 that properties (as introduced in #873) are never freed.
2025-03-14 14:52:53 +00:00
Matt Campbell 711135027f
Update to parley 0.3 (#883)
This update requires us to handle one breaking API change in parley.
2025-03-10 17:43:42 +00:00
Olivier FAURE 93e000d9c1
Improve bounding rect code (#874)
Document concepts of "layout rect" and "bounding rect".
Deprecate `local_layout_rect()` method.
Add `global_layout_rect()` method.
Remove `transform_changed()` method.
Improve bounding rect merging code.
Tweak `TestHarness::mouse_move_to`.
Tweak WidgetState doc.
2025-03-06 12:58:51 +00:00
Olivier FAURE 60c037dc1f
Add arbitrary properties to widgets (#873)
Add `Properties[Mut]` argument to widget methods.
Add a third TreeArena to sort per-widget arbitrary property values.

For the type-to-value map, I considered the following crates:
- https://docs.rs/typemap/latest/typemap/
- https://crates.io/crates/typemap_rev
- https://crates.io/crates/typemap-ors
- https://github.com/chris-morgan/anymap
- https://github.com/reivilibre/anymap3

Of these, anymap3 is the only one actively maintained (last commit less
than 12 months ago). The code source itself is extremely light and
simple; we may or may not decide to roll out our own implementation down
the line.

Add a BackgroundBrush property used by SizedBox as a proof of concept.

Note that SizedBox still has its `background` field, but we should
expect future widgets to use almost *exclusively* properties; properties
usually shouldn't be redundant with local fields.

To get there, we'll first need to better integrate properties in Xilem.
2025-03-06 11:32:06 +00:00
Daniel McNab 4e23dc5425
Refactor LFS handling (#881)
See https://github.com/linebender/vello/pull/833
2025-03-05 14:56:28 +00:00
Olivier FAURE bc8e9fecd2
Switch to Edition 2024 (#880)
I've ignored most of the changes and the projects still compile and test
fine. Changes I did commit:

Add `+ use<>` after functions.
Remove `ref mut` from some patterns.
Bump MSRV.
Apply new rustfmt format.
2025-03-05 13:15:47 +00:00
Daniel McNab 8147465350
Make Xilem Core unconditionally `no_std` (#877)
This removes the need to ignore `unused_qualifications`.

The `extern crate std` isn't *strictly* needed, but it will make future
debugging easier (you can do `println` or `dbg!`, for example).
2025-02-24 16:21:58 +00:00
Daniel McNab 24c18686ae
Bump the CI latest stable Rust to 1.85, typos 1.29.9 (#876)
Note that this doesn't do the update to the 2024 edition

This has also lead to
https://github.com/linebender/linebender.github.io/pull/90
2025-02-24 15:08:14 +00:00
Matt Campbell 642818dcee
Add missing `request_render` call when setting text selection from AccessKit (#803)
Without this, the updated text selection is neither painted nor
reflected in an updated accessibility tree until the user presses a key.
2025-02-21 16:34:16 +00:00
Evgeny 5e854382b2
Add DPI scale factor to the render root state (#872)
so that it's available to widgets that can fix blurry lines due to bad
overlapping positioning of its internal elements

partially addresses https://github.com/linebender/xilem/issues/869

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-02-20 15:12:43 +00:00
Bruce Mitchener f63e7096dd
Update to current `parley` `main` (#870)
This updates to the version using the updated objc2 and binding crates
for Fontique.

It also has a minor API change.
2025-02-19 02:50:26 +00:00
Olivier FAURE f8a7690d54
Update ARCHITECTURE.md file (#849) 2025-02-17 21:07:18 +00:00
Bruce Mitchener 2f580a1f3d
Update `float-cmp` and `pollster` (#871)
These are the direct dependencies that have non-semver compatible
updates (apart from wgpu).
2025-02-17 17:44:36 +00:00
Daniel McNab 3fe3ef6150
Migrate to v5 of the Linebender lint set (#867)
See linebender/linebender.github.io#88 (and some other earlier PRs)

A follow up like https://github.com/linebender/vello/pull/806 will also
be needed, but that can come later.
2025-02-17 09:54:29 +00:00
Daniel McNab de92da4320
Fix `clippy::default_trait_access` (#868)
This is a new addition to the "editor period lints". See #867 for
context.
2025-02-14 18:22:29 +00:00
Richard Dodd b89d9b16fe
expose winit (#860)
I don't think there is a reason not to, and you need winit for some
types so currently you must define the crate yourself, which risks
version errors etc.
2025-02-12 22:28:22 +00:00
Evgeny 25b12ad385
masonry: make util pub to allow customizing buttons in an app (#862)
Similar to https://github.com/linebender/xilem/pull/861 this would help
creating custom elements while relying on the already used/tested
library utilities
2025-02-10 11:28:18 +00:00
Evgeny de1d88c1a6
xilem: make a Pod method pub to allow creating custom buttons in an app (#861)
I wanted to create a custom button view, but when needing to pass to the
masonry type could not convert the pod to a widgetpod.
So I'd like to make this method pub to allow that

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-02-10 11:02:52 +00:00
Bruce Mitchener 8d59974f2f
Remove extraneous `#[warn(...)]` (#855)
These are no longer suppressed above it in the crate, so this isn't
needed now.

Related to #449.
2025-01-30 10:20:50 +00:00
Olivier FAURE d77b31b892
Reorganize Masonry modules (#848) 2025-01-24 11:24:31 +00:00
Olivier FAURE df3107e1d4
Add screenshots to documentation (#832)
Create include_screenshot macro
2025-01-23 18:21:53 +00:00
Olivier FAURE 8342d8f3d5
Remove cruft from #841 (#846) 2025-01-22 16:14:34 +00:00
Olivier FAURE 4674f6c77d
Remove some cruft (#842)
Remove outdated TODO comments.
Rewrite some other TODO comments.
Remove references to tarpaulin.

(cargo-tarpaulin is a tool used for code coverage. Masonry hasn't used
it for years, and anyway we'll probably use `#[coverage]` annotations
once they stabilize.)

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-01-22 11:29:23 +00:00
Olivier FAURE df1efa472b
Add tests to Masonry's examples (#844) 2025-01-22 11:18:29 +00:00
ArtyomSinyugin 73d574a1d9
xilem: Docs updating (#818)
**Draft**
This PR is the proposal for xilem docs starting page. But I think I will
be able to make some more commits to improve documentation.
![2025-01-12
16-37-44](https://github.com/user-attachments/assets/ebd5aed8-66d9-4b4c-ac73-6d70783001a4)

---------

Co-authored-by: Artyom Sinyugin <writers@altlinux.org>
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Co-authored-by: Tom Churchman <thomas@kepow.org>
2025-01-22 10:17:41 +00:00
Olivier FAURE 042030215b
Add features to help test Textbox (#841) 2025-01-21 17:57:26 +00:00
Olivier FAURE 8276e757bb
Refactor TreeArena (#827)
Make tests more spread out and more readable.
Add comments detailing the state of the arena being tested.
Fix a lifetime error in unsafe API.

Rename Arena[Ref/Mut]Children to Arena[Ref/Mut]List
Rename a lot of methods.
Rework documentation.
Unify safe and unsafe APIs.
2025-01-21 13:33:04 +00:00
Bruce Mitchener 46170faddb
Update to Vello 0.4, Peniko 0.3.1, Color 0.2.3 (#840)
This also lets us update to using `Color::from_rgb8()` when there is no
need for alpha to be specified.
2025-01-21 09:13:07 +00:00
Jared O'Connell a6ba563b73
Emoji picker example improvements (#833)
This PR includes improvements to page selector.

Specifically it now shows the full percentage range instead of just the
start of it, and it hides the buttons when you reach the end of the
range.

For some reason it panics when I get to the end.
2025-01-20 17:00:22 +00:00
Olivier FAURE e179a1a33a
Fix `single_use_lifetimes` in Masonry (#744) 2025-01-20 14:34:21 +00:00
Olivier FAURE 0b4e10c003
More fmt changes (#839) 2025-01-20 14:33:35 +00:00
Olivier FAURE 066d4319e8
Use nightly rustfmt to format imports (#838) 2025-01-20 13:19:26 +00:00
Olivier FAURE fc0acae98e
Write tutorial for testing in Masonry (#835) 2025-01-20 13:15:10 +00:00
Olivier FAURE 9ffc650983
Remove `Box<dyn Widget>` from a few places (#837)
Having `Box<dyn Widget>` implement the `Widget` trait is a crutch that
makes a bunch of things more complicated.

It leads to double-boxing in cases when the `dyn Widget` is itself a
`Box<dyn Widget>` (especially since the arena's current implementation
boxes all widgets by default), makes it harder to reason about
downcasting, and ends up producing a lot of code to handle the edge
cases.

On the xilem side, `Box<dyn Widget>` is slightly redundant with
`DynWidget`.

This PR still leaves a lot of boxing. On the long term, we'd like for
the arena to pack arbitrary widgets efficiently using some kind of
archetype scheme, but in the meantime, boxing will have to do.

Changes in this PR:
- New `FromDynWidget` trait that maybe-downcasts widgets to a
maybe-sized `Widget` type.
- Most places that accept `Widget` now accept `Widget + ?Sized`.
- Remove `impl Widget for Box<dyn Widget>`.
- Replace all instances of `WidgetPod<Box<dyn Widget>>` with
`WidgetPod<dyn Widget>`.
- Replace all instances of `xilem::Pod<Box<dyn Widget>>` with
`xilem::Pod<dyn Widget>`.
- Rename WidgetPod to WidgetBox in xilem_core example to avoid
ambiguity.
2025-01-20 12:52:08 +00:00
Olivier FAURE d03873d9d7
Rewrite tutorial (#813)
Rewrite "Creating a new Widget" tutorial to interleave description of
the Widget trait with example.
Go into more details.
Rewrite tutorials to use current WidgetMut syntax (the one with free
functions instead of methods).
2025-01-19 12:56:03 +00:00
Olivier FAURE d09c5885fa
Fix `run_single_update_pass` to avoid crashes (#834) 2025-01-19 11:27:17 +00:00
Daniel McNab 66ced07c17
Move the `transform` related boilerplate in Xilem to a single View (#828)
Also significantly reduces the overhead from each View for supporting
transforms.

Follow-up from #806
2025-01-17 17:42:29 +00:00
Daniel McNab ecdd12b19c
Emoji picker/selector example (#420)
![Xilem Emoji
Picker.](https://github.com/linebender/xilem/assets/36049421/4f9b418f-c9b3-4971-9711-587f21010e47)

Some notes:
1) The accessibility of this example probably isn't great. Not sure what
to do about this.
2) Our layout primitives aren't great; we use a grid, but ideally the
number of rows would be reactive to the available space.
3) The pagination is slightly hacked together - it should really try and
give you page numbers. I'm not planning to address this, unless someone
provides the algorithm

This was originally created to act as a screenshot for
https://github.com/linebender/linebender.github.io/pull/56
2025-01-17 17:38:12 +00:00
Olivier FAURE 320159b669
Apply is/has naming convention for flags and methods (#831)
Rename has_pointer_capture to is_pointer_capture_target.
Rename has_focus to has_focus_target.
Rename is_focused to is_focus_target.
Add has_hovered flag.
Add ChildHoverChanged event.
2025-01-16 15:17:39 +00:00
Olivier FAURE eb63bf6b09
Improve handling of window focus (#830)
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-01-16 14:39:45 +00:00
Olivier FAURE f0e553a088
Document iteration order of some passes (#829) 2025-01-16 14:21:34 +00:00
Marco Melorio 2172d4dd01
Expose line break parameter in label widget (#817)
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-01-16 14:09:52 +00:00