Commit Graph

745 Commits

Author SHA1 Message Date
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
Olivier FAURE 78fb169d32
Reorder context impl blocks (#810)
This makes it so that each context types has its most relevant, unique
methods appear earlier in the documentation.
2025-01-11 11:05:59 +00:00
Olivier FAURE cad61d5c22
Tweak documentation for readability (#787)
Apply many small tweaks I found while going over the documentation.
Rename some variables.
Add asserts to `BoxConstraints::constrain_aspect_ratio`.
Flesh out the WidgetState documentation.
Introduce the concept of "zombie flags".
2025-01-10 15:44:29 +00:00
Olivier FAURE 5e3383ad80
Improve documentation of TestHarness (#809)
Add scale_factor parameter.
Add links to doc module.
2025-01-10 15:31:37 +00:00
Olivier FAURE c1e0c83b0b
Have AppDriver take a reference to RenderRoot for more flexibility (#808) 2025-01-10 14:16:37 +00:00
Olivier FAURE 6da98ae5ef
Remove redundant code in calc_masonry example (#807)
Fixes #796
2025-01-10 14:09:24 +00:00
Viktor Strate Kløvedal 84dce887f9
Add `zstack` view to compose views on top of each other (#737)
Adds a new `zstack` Xilem view (along with an accompanied Masonry
widget).
The view is inspired by the [ZStack view in
SwiftUI](https://developer.apple.com/documentation/swiftui/zstack),
which composes the child view on top of each other.

This pull-request is still work-in-progress.

- [x] It doesn't allow for changing the layout when BoxConstraints of
the children are different.
(top-left, top-right, bottom-left, bottom-right, center).
- [x] I want to update `http_cat` to put copyright on top of image like
seen below.
<img width="500" alt="Screenshot 2024-11-10 at 17 46 45"
src="https://github.com/user-attachments/assets/004d5779-142e-45a2-92d2-bdd5ddd9e2d1">
2025-01-08 21:34:20 +00:00
Bruce Mitchener cb58d7b4e9
Remove unused `SizedBox::width_and_height` (#805)
This isn't used, is marked as dead code, and is not public outside of
the crate.
2025-01-06 22:44:01 +00:00
Bruce Mitchener 4957070589
Fix `clippy::unnecessary_map_or` lint (#802) 2024-12-28 05:40:51 +00:00
Bruce Mitchener c1ef637309
Use `palette` and `Color` from top level Xilem and Masonry (#800) 2024-12-20 16:34:11 +00:00
Bruce Mitchener adcbafbd8e
Update to git Parley and Vello. (#798)
This brings the new releases of Color and Peniko and start making sure
things are good for the upcoming releases of Parley and Vello.
2024-12-20 14:52:05 +00:00
ArtyomSinyugin 8f7ef7dde5
xilem: Button with customisable label(text) (#797)
Co-authored-by: Artyom Sinyugin <writers@altlinux.org>
2024-12-20 13:40:38 +00:00
Olivier FAURE 8e12858827
Tweak TestHarness API and docs (#790) 2024-12-19 16:48:36 +00:00
Bruce Mitchener ee4411467c
Fix and un-allow `clippy::use_self` lints (#799) 2024-12-19 13:45:57 +00:00
Bruce Mitchener 326cb2bdbe
ci: Update stable Rust and typos (#793) 2024-12-18 23:37:11 +00:00
Bruce Mitchener c4d5950c37
Sized Box: Use a brush for the border (#795)
This allows for a richer appearance by using any valid brush for the
border.
2024-12-17 15:48:58 +00:00