Commit Graph

168 Commits

Author SHA1 Message Date
Olivier FAURE 32503ec1ea
Add rudimentary clipboard support (#1237)
This only supports copy-pasting strings, not rich text. And the way
Ctrl+V is detected is somewhat dubious.

But it does effectively add clipboard support to Masonry apps.

Ideally, on the long term, we may want to be able to programmatically
request clipboard contents; I'm not sure how to implement that cleanly
given RenderRoot's architecture, without making masonry_core depend
directly on a clipboard-handling library.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-07-28 13:30:26 +00:00
Bruce Mitchener 23259a3ecb
Re-export `CursorIcon` from `masonry_core::core` (#1222)
Instead of re-exporting `cursor_icon` from `masonry_core` and `masonry`,
we can re-export the single type that matters (`CursorIcon`) from
`masonry_core::core` / `masonry::core`.
2025-07-24 03:08:25 +00:00
Olivier FAURE 50d83d7904
Add ChildrenIds type alias to avoid spelling out SmallVec size. (#1190)
Use type alias in various places.
Avoid referencing smallvec from widget code.

Fixes #1141.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2025-07-21 19:18:39 +00:00
Bruce Mitchener 27ca077f2c
xilem: Get `accesskit` and `smallvec` from masonry (#1165) 2025-07-18 18:03:20 +00:00
Matt Campbell 68dff90ead
Update Parley and AccessKit (#1172) 2025-07-17 13:47:24 +00:00
Daniel McNab dff89db260
Migrate Xilem Core and Masonry to Anymore (#1170)
[Anymore](https://github.com/linebender/anymore) is a new crate which
we're developing for use in Xilem and Masonry. This crate contains the
`AnyDebug` trait, which is a supertrait of both Any and Debug. We are
developing this because Xilem Core and Masonry both want support for
dynamically typed messages with introspection for debugging, but those
have to use the same trait to allow proper interoperability.

See also [#rust ui >
Anymore](https://xi.zulipchat.com/#narrow/channel/422907-rust-ui/topic/Anymore/with/528892562)

This crate has not yet published to crates.io; I intend for us to do so
once we have migrated Masonry's `Action` to being only a wrapper around
`Box<dyn AnyDebug + Send>`. See also discussion in #1105
2025-07-17 07:49:45 +00:00
Daniel McNab cb28daead5
Initial support for an environment system (#1142)
This is not very far fleshed out, but should give an idea of the
strategy.

```rust
#[derive(Debug)]
struct MyResource(&'static str);
impl Resource for MyResource {}

fn app_logic(...)-> impl View<...> {
    provides(
            |app_state: &mut AppState| MyResource("abc"),
            with_context(|res: &mut MyResource, app_state: &mut AppState| { /* res.0 is "abc"*/ })
    )
}
```

You can run `mason` to see this working

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2025-07-14 15:10:12 +00:00
Bruce Mitchener d989e402aa
Use `masonry_testing` in masonry examples (#1156)
Currently, the examples live in `masonry_winit` and use `masonry` with
the `testing` feature enabled. Once these examples move back into
`masonry`, then this becomes more annoying and it is easiest if they
just depend separately on `masonry` and `masonry_testing`.
2025-07-13 09:37:40 +00:00
Bruce Mitchener 0a8656d8ed
masonry: Get `wgpu` from `vello` (#1149)
This simplifies updating things as it is one less sibling dependency
version to keep in sync.
2025-07-12 16:29:42 +00:00
Bruce Mitchener 673611f119
`masonry_winit`: Depend on `masonry_core` not `masonry` (#1148)
Now that we don't use `masonry::theme::default_property_set()` and we
have the re-exports in place from `masonry_core`, we can remove our
dependency on `masonry` itself.
2025-07-11 10:15:20 +00:00
Bruce Mitchener c5d64d1436
Re-export from `masonry_core`, use in `masonry_testing` (#1147)
We have things that are deps of `masonry_core`, `masonry`, and
`masonry_testing` and if you use `masonry_core`, you need to know that
and use the right versions.

Instead, we should be exporting these things from `masonry_core` and
using them from there.

This updates `masonry_testing` to use things from `masonry_core` instead
and subsequent commits can further improve upon this with the `masonry`
crate and so on.
2025-07-11 02:55:05 +00:00
Bruce Mitchener d5788d027e
`masonry_testing`: Remove unused dep on `parley` (#1120) 2025-07-08 02:41:18 +00:00
Bruce Mitchener e0b8f1e26c
Remove unused direct deps on `web-time` (#1110)
This is handled in `masonry_core` and re-exported types from there so
these direct dependencies are not used.
2025-06-26 01:14:03 +00:00
Daniel McNab b074348319
Placehero: Load avatars for statuses (#1091)
Current state:

![image](https://github.com/user-attachments/assets/58e1012d-32af-4bb3-a554-b90f35e8dd18)

Note that this doesn't include #1089, as that is awaiting review.
2025-06-20 14:05:06 +00:00
Daniel McNab f2a6e57f81
Placehero: Strip simple Mastodon HTML of tags (#1089)
This doesn't support any rich text formatting, and only turns them from
HTML soup (#1087) into readable text. Current state:

![image](https://github.com/user-attachments/assets/4bd0e378-d766-4cda-9dc4-83fedc14782d)

See also [#xilem > Hero Mastodon Client @
💬](https://xi.zulipchat.com/#narrow/channel/354396-xilem/topic/Hero.20Mastodon.20Client/near/524860368)
2025-06-20 13:45:50 +00:00
Daniel McNab 9bafb2dacd
Placehero: Get initial list of statuses for first exploration (#1087)
![image](https://github.com/user-attachments/assets/b2a0ca3b-b47f-49df-865f-9797bca49caa)

This is an exploration into using the Mastodon API, continuing work on
the hero app.
The actual changes here won't be all that useful, in the long term, but
it's helpful for getting an understanding of how to use the API.

One big, unfortunate surprise is that we really need some HTML parsing
(although only as described [in the
docs](https://docs.joinmastodon.org/spec/activitypub/#sanitization)).
That is something I'm not looking forward to!

One discovery in this PR is that our logging isn't set-up for the first
`build` in Xilem. That makes sense with how logging is owned, but it's
also very unfortunate).

I do intend to land this, to keep progress moving in a piecemeal way,
and potentially to allow collaboration. It might be that hero app PRs
should be largely rubber-stamped. Note that there are "real" changes to
Xilem in this PR (limited to new re-exports)
2025-06-19 09:59:06 +00:00
Martin Fischer 7c555d43de
test: make TestHarness validate TreeUpdates returned by redraw (#1086)
If you don't have the accessibility feature enabled in your OS then you
don't run the accesskit_consumer code which can lead to accessibility
being broken without you noticing.

Of course you should still do manual accessibility testing but this
change ensures that the accesskit_consumer code at least doesn't crash
if your app is tested with the TestHarness.
2025-06-18 14:58:26 +00:00
Daniel McNab b0c8571c1f
Create placeholder of hero app Mastodon client (#1075)
This is a very rough starting setup, with some necessary infrastructure.
Current screenshot:

![image](https://github.com/user-attachments/assets/adb965f9-af22-4e26-9c02-2b145ac8b698)

I'm expecting to land things piecemeal, so this is a PR intended for
landing/discussion.
2025-06-17 08:16:45 +00:00
Olivier FAURE 47722f4357
Split off testing into masonry_testing crate (#1048) 2025-06-11 13:12:05 +00:00
Bruce Mitchener 0fe979e03b
`masonry_winit`: Remove most dev dependencies (#1064)
Some of the dev dependencies were unused or could be made to be unused
by using the re-exports from `masonry`.
2025-06-10 13:02:56 +00:00
Bruce Mitchener c9c2c23066
`masonry_winit`: Use `vello` via `masonry` (#1058)
`masonry_winit` and its examples shouldn't have a direct dependency on
`vello`. This is especially true for example code as it should be able
to be copied and pasted without having to add its own dependency upon
`vello`.
2025-06-10 02:41:57 +00:00
Bruce Mitchener 94832a09d6
`masonry_winit`: Remove dev dependency on `smallvec` (#1060)
This wasn't used or needed.
2025-06-10 02:41:35 +00:00
Bruce Mitchener 2207a65659
`masonry_winit`: Stop exporting `masonry` (#1046)
People should use `masonry` for all of the general purpose stuff and
only use `masonry_winit` for the Winit integration.

Further cleanups to the `masonry_winit` crate can come after this.
2025-06-08 09:55:41 +00:00
Olivier FAURE fcbcfeda7b
Split off core masonry modules into masonry_core crate (#1044) 2025-06-08 09:45:40 +00:00
Bruce Mitchener 6be3661d7f
Update to parley 0.5 (#1037) 2025-06-07 15:24:06 +00:00
Kaur Kuut 417346a9da
Update dependencies. (#980)
This is a result of:

```
cargo update --ignore-rust-version
cargo upgrade --ignore-rust-version
```

Most notably this gets us `color` 0.3.1 which fixes nightly compilation.
2025-05-19 09:17:17 +00:00
Kaur Kuut 079fcf9aa9
Prepare to release 0.3.0. (#973)
We skip Xilem 0.2.0 and go straight to 0.3.0 in order to synchronize the
version with its companion packages that are expected to be updated in
lock-step for now.

[The one exception is
`tree_arena`](https://xi.zulipchat.com/#narrow/channel/419691-linebender/topic/Xilem.20version.20sync/with/517174026),
which will retain its own version pacing, because it's likely to see
fewer updates.
2025-05-10 20:03:16 +00:00
Kaur Kuut df88cef1ca
Update dependencies. (#969)
The result of:

```sh
cargo upgrade --ignore-rust-version
cargo update --ignore-rust-version
```
2025-05-09 13:24:57 +00:00
Kaur Kuut 7b22484aa2
Rename `masonry_core`, `masonry` to `masonry`, `masonry_winit`. (#966)
[Matt
proposed](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Proposed.20change.20to.20the.20split.20between.20core.20and.20winit.20integrat/with/516903214)
renaming the Masonry crates again. The proposal received positive
feedback and so now is the time to do it, before we publish.

The proposal goes deeper than just renaming. However, in the interest of
time and review scope, this PR implements just the renaming part.
Getting the crate names right for publishing is paramount. API changes
can happen later as follow-up work and delays there won't block
publishing.

---

For git blame benefit we wanted to split #965 into two parts. This PR is
the first part that renames the crates. A follow-up PR will rename the
directories.
2025-05-09 10:41:12 +00:00
Daniel McNab 4ae737ae5b
Update Vello to 0.5.0 (#955) 2025-05-08 17:10:12 +00:00
Kaur Kuut 42e3ef3cbc
Depend on published Parley 0.4.0. (#956)
Parley is out so we can stop depending on git.
2025-05-08 15:42:29 +00:00
Aaron Muir Hamilton 6c15d78da9
Use ui-events for keyboard and pointer events. (#950)
- Remove file hover/drop events from `PointerEvent` because they were
never mapped and could never be mapped (since they relied on pointer
positions which are not available in file hover on winit.

- Remove modifier change events from `TextEvent`, since nobody uses them
anywhere, and new `PointerEvent` and `KeyboardEvent` include them.

- Remove pointer state from events that are unlikely to have new state
when they occur (enter/leave/cancel).

 - Remove redundant default widget event handlers and imports.
2025-05-08 15:02:13 +00:00
Kaur Kuut 7d423cb403
Update to latest Parley version. (#953)
This is basically the upcoming Parley 0.4.0, but right now pointing
towards the latest git rev.

The snapshots have changed because line height layout code improved in
Parley.

Fixes #933
Closes #936
2025-05-08 10:40:51 +00:00
Daniel McNab 4a3de37bf1
Update AccessKit Winit to version 25 (#951)
This includes https://github.com/AccessKit/accesskit/pull/524
2025-05-08 09:14:04 +00:00
Bruce Mitchener 9c969edc31
Update to `keyboard-types` 0.8 (#940)
With W3C specs, I think we should be mapping meta / super differently
than we were before. This will change again with winit 0.31 where the
names of those keys on the winit side will have changed. (And also, much
of this particular mapping won't be necessary.)

The bulk of this change is that in `keyboard-types` 0.8, the `Key`
enumeration has changed to have a separate enumeration for `NamedKey`
values.

---------

Co-authored-by: Mads Marquart <mads@marquart.dk>
2025-05-05 01:39:06 +00:00
Kaur Kuut 17aea51632
Update to Parley 2025-03-25. (#941)
With #936 stalling but Matt wanting AccessKit changes I decided to split
out parts of #936 into this PR. This brings in Parley from March 25th,
2025 and that gets us the AccessKit update.
2025-04-29 17:01:13 +00:00
Olivier FAURE c004207c61
Change filename scheme of screenshot tests (#937)
Have all screenshot tests store their reference file in
`<CRATE_ROOT>/screenshots/<TEST-NAME>.png`.
Move all existing screenshot tests accordingly.
Add namespace to most test names to avoid filename collisions.
Document the changes.
Remove serde dependency from `masonry_core`, as previously it was only
used to look up the path to store the test in.
2025-04-29 09:45:36 +00:00
Olivier FAURE 7ce67b606b
Remove once cell (#931) 2025-04-25 15:02:32 +00:00
Olivier FAURE 5c32f5c44b
Split winit dependency from masonry_core (#915)
Builds on top of #914.

This is the final step to splitting masonry_core from masonry.
2025-03-28 16:13:17 +00:00
Olivier FAURE c8b3985226
Rename `masonry` crate to `masonry_core` and `masonry_winit` crate to `masonry` (#914)
The main change is to change the names of the crates as registered in
the `Cargo.toml` files. The folders these projects are in aren't
renamed, but since most snapshot test files include their crate name, a
lot of files end up being renamed as well.
2025-03-27 11:10:26 +00:00
Olivier FAURE 6fe84201b0
Split most of the masonry crate into masonry_core sub-crate. (#910)
This change is done very carefully to minimize the number of changed
files, and use almost only file renames.
This is both for avoiding merge conflicts, keeping file history
unbroken, and keeping the PR easy to review.

A future PR will rename masonry to masonry_core, masonry_winit to
masonry change all the doc tests and snapshots that depend on those
names, etc.

After *that*, future PRs will have actual code changes splitting winit
away from masonry_core.
2025-03-26 12:00:46 +00:00
Olivier FAURE 8002eecbcd
Tighten screenshot testing (#904)
Remove nv-flip dependency and use pixel-by-pixel comparison instead.
Reduce error tolerance in tests.
Update a few outdated screenshots.

Create `assert_failing_render_snapshot` macro to make sure our diffing
infrastructure catches regressions.

Fixes #893.
2025-03-23 19:19:25 +00:00
Olivier FAURE 25a446029f
Isolate winit imports to `app` module (#908)
This is the first step towards #907.

This doesn't split the crate yet, but adds a translation layer between
winit and Masonry to facilitate that split.
2025-03-23 10:21:35 +00:00
Olivier FAURE ab341367b0
Remove tempfile direct dependency (#905)
`tempfile` on Unix pulls `rustix`, which has a 9.19s single-core build
time on my machine, and was unused in our code.

`tempfile` is still a indirect dependency through `uds_windows`, which
is fine because in that dependency path (windows-only) doesn't pull
`rustix`.
2025-03-21 14:49: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 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
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
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
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
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