Commit Graph

760 Commits

Author SHA1 Message Date
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
Olivier FAURE e7ed917ca8
Implement very basic widget inspector (#820) 2025-01-15 17:10:20 +00:00
Daniel McNab 2e92e89ba1
Document the IME cursor area workaround (#826) 2025-01-15 11:31:12 +00:00
Daniel McNab d724b1e667
Make `xilem::Pod` more flexible (#806)
Previously, the use of `WidgetPod` made it impossible to create
"wrapper" widgets for certain properties. This new design "decomposes"
that `WidgetPod` for use in `Xilem`.

Open question: Is this new type more widely useful to other users of
Masonry? Xilem would need a wrapper
Open question: How will having multiple event handlers for a single
widget work? I imagine they would all use the same view path, and pass
on the event if it's not relevant.

Follow-up work:
- Splitting `Button` so that the handlers are wrappers
- Maybe: Splitting `TextArea` so that the handlers are wrappers (ooh, we
can probably properly support different binding models!)
- Removing the unnecessary and bloated `transform` field from each
Widget.
2025-01-15 11:15:40 +00:00
Daniel McNab 83cb00d011
Depend on `libegl-mesa0` instead of `libegl1-mesa` (#825)
`libegl1-mesa` seems to have been an old name, which is no longer
accurate, and is not published for Ubuntu 24.

I don't know where this was publicised, but hopefully this change fixes
CI?
2025-01-15 11:02:13 +00:00
Olivier FAURE 4cf365334f
Document RenderRoot fields (#824)
Remove duplicate CursorIcon field.
2025-01-14 17:51:02 +00:00
Olivier FAURE ba68c26ece
Move cursor to end of text area when text is changed (#823)
This matches the behavior of other frameworks in similar situations.
2025-01-14 17:41:09 +00:00
Olivier FAURE d49b06a8e2
Make pointer events affect focus (#822)
Clear the focus when user clicks outside of the focused widget
Add `most_recently_clicked_widget` value, so that clicking influences
which widget will be focused by future Tab events.
2025-01-14 17:10:26 +00:00
Philipp Mildenberger 9bb33dd1c6
Support transforms for each widget (#753)
Adds basic support for transforms (`kurbo::Affine`) of widgets in
Masonry and Xilem, similarly as CSS transforms.
A new example `transforms` shows this in a playful way.
The pointer-intersection logic needed a core change to handle now
possibly overlapping widgets.

Checkout
[this](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Add.20.60Affine.60.20transform.20to.20.60Widget.60.20trait.3F)
zulip thread for more info/discussion.
2025-01-14 09:59:31 +00:00
Daniel McNab 8fd5bde369
Make `DriverCtx` publicly constructable again (#821)
Follow-up to #808

Also adds a test to limit the risk of future regression.
2025-01-14 09:39:17 +00:00
Olivier FAURE 51a355615f
Document most items in Masonry (#815)
Move `#[allow(missing_docs)]` to two modules. Missing docs now warn
everywhere else by default.

Remove `#[expect(rustdoc::broken_intra_doc_links)]` and fix all broken
links.
2025-01-13 17:36:31 +00:00
Olivier FAURE 522dfd4433
Add links to documentation in pass code (#811) 2025-01-13 10:49:29 +00:00
Olivier FAURE 5ed3178789
Remove last references to debug logger (#814)
Code has been unused for a long time.
Widgets weren't even logging to it.
2025-01-13 10:48:37 +00:00
Olivier FAURE be9fc8730b
Rename `WidgetArena::widget_states` to `WidgetArena::states` (#816) 2025-01-13 10:48:23 +00:00