Commit Graph

105 Commits

Author SHA1 Message Date
Daniel McNab 7be4dd2a2f
Xilem example for http cats API, requiring `worker`s and `image` component (#571)
This example is inspired by:
https://troz.net/post/2024/swiftui-mac-2024/

Current status:
- Lists status code
- Can select status code
- Downloads image from status code
- Shows image from status code

This adds two new features to Xilem:
- The worker view, which is the obvious extension to `task` for multiple
operations
- The `image` view, which just uses Masonry `Image`.

It also fixes a the Masonry Image view's layout to use the already
extant but unused method.
2024-09-03 19:02:07 +00:00
Olivier FAURE 07c908a426
Remove bloom filter (#536)
The filter was only used for RouteFocusChanged which is about to be
removed. Since it was a performance feature, we can remove it early.
2024-08-25 08:51:02 +00:00
Daniel McNab 455b614769
Improve tracing for use of Android GPU Inspector (#534)
- Adds tracing_android_trace
- Correct the span for VariableLabel
- Make the created apps "debuggable"
- Enable spans for `wgpu`'s `profiling` results
- Add a span around the Vello rendering to show when that is
2024-08-22 14:36:07 +00:00
Daniel McNab 3fd3903eae
Label with animated variable font parameters (#507)
This adds a new `VariableLabel` widget, which animates its weight to a
target value in a linear fashion (over a fixed time period). Also adds
support for this in Xilem, and a new `variable_clock` example. This
example also runs on Android.


[Screencast_20240812_171138.webm](https://github.com/user-attachments/assets/5df623f9-f4ca-4b55-b6a9-2047d2581b56)

Current status: The code in Xilem and Masonry library crates is final.
I'm planning on significantly updating the actual example.

Outstanding issues:

- [X] Hacks in support for "Roboto Flex", by always loading it from the
local file - resolved
- [X] It's not clear what subset of Roboto Flex we should use - still
open to bikeshedding
- [ ] The variable font animation support is not really as generic as it
should be. This starts to drift quite close to a styling question,
however.
- [ ] The only supported variable axis is `wgth`
2024-08-16 14:06:42 +00:00
Bruce Mitchener 052ac39667
masonry: Use Kurbo via Vello. (#223)
Rather than have to keep a dependency on `kurbo` at the correct version,
always use it via `vello`.

This makes this match how `peniko` is already used within `masonry`.
2024-08-16 13:53:09 +00:00
Markus Kohlhase 5b6ebc324f
xilem_web: Add an `AfterBuild`, `AfterRebuild` and `BeforeTeardown` view, which reflects `Ref` in React (#481)
Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-08-08 22:44:49 +00:00
Markus Kohlhase 2eda5a2a50
xilem_web: Add async_repeat (#485)
Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-08-08 17:51:04 +00:00
Daniel McNab e27b3ce0c2
Run tests in CI, and fix fonts for snapshot testing (#233)
See also linebender/vello#439

This should open the door to doing much more comprehensive testing at
higher level in the nearish future (including e.g. in `xilem_masonry`)
2024-08-05 13:01:47 +00:00
Markus Kohlhase 727d696488
xilem_web: Use separate FetchState in fetch example (#454) 2024-07-28 10:30:26 +00:00
Philipp Mildenberger 981fcc4b5a
xilem_web: Add a `MemoizedAwait` view (#448)
This is the `rerun_on_change` view described in #440, I named it
`MemoizedAwait` as I think that fits its functionality.

It got also additional features `debounce_ms` (default `0`) and
`reset_debounce_on_update` (default `true`) as I think that's quite
useful, in case a lot of updates are happening.

When `reset_debounce_on_update == false`, `debounce` is more a throttle
than an actual debounce.

This also adds a more heavily modified version of the example added in
#427, also showing `OneOf` in xilem_web (which didn't have an example
yet).

This *could* be considered as alternative to #440 (at the very least the
example) but those approaches could also well live next to each other.

---------

Co-authored-by: Markus Kohlhase <markus.kohlhase@slowtec.de>
2024-07-26 16:11:34 +00:00
Daniel McNab d70076262d
Update dependencies and bump to Rust 1.80 (#450)
There is one "semi-false-positive" lint triggered, which I have fixed.
Otherwise, the required
```
cargo upgrade --ignore-rust-version
cargo update
```
2024-07-26 13:02:41 +00:00
Daniel McNab 7f40266bd8
Integrate `tokio` for async communication with Xilem (#423)
Supercedes https://github.com/linebender/xilem/pull/411

This is designed with #417 in mind, to not lock-in to our event loop.

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-07-18 07:38:28 +00:00
Daniel McNab f913a3882b
Update to Vello 0.2.1 and wgpu 0.20.1 (#430)
Mostly to double check that the new release is suitable, but formalising
the update can't hurt
2024-07-17 07:42:20 +00:00
Bruce Mitchener b83a7ef41f
[masonry] Update to accesskit 0.16 (#426)
There was a breaking change in this release that renamed
`role::StaticText` to `role::Label`.
2024-07-16 08:18:51 +00:00
Markus Kohlhase 62c06c9f98
xilem_web: Add Elm Architecture example (#425)
I have intentionally left out the `xilem_core::adapt` variant here in
order to have a clear classic Elm example. I would rather show the
`adapt` variant in a separate example.
2024-07-12 11:39:37 +00:00
Philipp Mildenberger b33a2a680d
Rewrite xilem_web to support new xilem_core (#403)
This ports xilem_web to the new xilem_core.

There's also a lot of cleanup internally:
* Get rid of all of the complex macros to support DOM interfaces, and
instead use associated type bounds on the `View::Element`.
* Introduce an extendable modifier based system, which should also work
on top of memoization (`Arc`, `Memoize`) and `OneOf` views with an
intersection of the modifiable properties.
* This modifier based system gets rid of the hacky way to propagate
attributes to elements, and takes inspiration by masonrys `WidgetMut`
type to apply changes.
* Currently that means `Attributes`, `Classes` and `Styles` to reflect
what xilem_web previously offered.

Downsides (currently, needs some investigation):

~~Due to more internal type complexity via associated types this suffers
from https://github.com/rust-lang/rust/issues/105900. The new trait
solver should hopefully mitigate some of that, but it seems currently it
completely stalls in the todomvc example (not in other examples).~~
~~The deep, possibly completely static composition via associated
type-bounds of the view and element tree unfortunately can take some
time to compile, this gets (already) obvious in the todomvc example. The
other examples don't seem to suffer that bad yet from that issue,
probably because they're quite simple.~~

~~I really hope we can mitigate this mostly, because I think this is the
idiomatic (and more correct) way to implement what the previous API has
offered.~~

One idea is to add a `Box<dyn AnyViewSequence>`, as every element takes
a "type-erased" `ViewSequence` as parameter, so this may solve most of
the issues (at the slight cost of dynamic dispatch/allocations).

Edit: idea was mostly successful, see comment right below.

I think it also closes #274

It's a draft, as there's a lot of changes in xilem_core that should be
upstreamed (and cleaned up) via separate PRs and I would like to
(mostly) fix the slow-compile time issue.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-06-28 08:30:18 +00:00
Philipp Mildenberger 5284082523
xilem_core: Provide a way to add `View` implementations for external types (#402)
Since we're suffering from the orphan rule with the new xilem_core
implementation, we cannot use `View` in downstream crates for external
types such as a `WidgetView` implementation for `&'static str` in Xilem.

This PR adds an `OrphanView` trait which the `Context` of the `View` has
to implement for the type which has an implementation in xilem_core for
this. The `View` impl for these types is basically a proxy for
`OrphanView` (which in turn has the same method signature as `View`), so
downstream crates can achieve the same as with the `View`.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-06-24 18:14:00 +00:00
Bruce Mitchener 32c365a42f
Update to winit 0.30.2 (#400)
A fix was in winit 0.30.1 to fix a crash on exit on macOS (among other
things).

Fixes #239.
2024-06-16 07:14:04 +00:00
Bruce Mitchener 1be18aeff0
deps: Update accesskit to 0.15, accesskit_winit to 0.21 (#382) 2024-06-10 08:45:18 +00:00
Bruce Mitchener 1ddff7be92
deps: Update `wgpu`, `vello`, `peniko` (#381)
This brings us to the 0.2 release of Vello, which brings the 0.20
release of wgpu.
2024-06-10 08:29:53 +00:00
Daniel McNab 86d9592a3e
Move `xilem` onto a new `xilem_core`, which uses a generic View trait (#310)
This:
1) Renames the current/old `xilem_core` to `xilem_web_core` and moves it
to the `xilem_web/xilem_web_core` folder
2) Creates a new `xilem_core`, which does not use (non-tuple) macros and
instead contains a `View` trait which is generic over the `Context` type
3) Ports `xilem` to this `xilem_core`, but with some functionality
missing (namely a few of the extra views; I expect these to
straightforward to port)
4) Ports the `mason` and `mason_android` examples to this new `xilem`,
with less functionality.

This continues ideas first explored in #235 

The advantages of this new View trait are:
1) Improved support for ad-hoc views, such as views with additional
attributes.
This will be very useful for layout algorithms, and will also enable
native *good* multi-window (and potentially menus?)
2) A lack of macros, to better enable using go-to-definition and other
IDE features on the traits

Possible disadvantages:
1) There are a few more traits to enable the flexibility
2) It can be less clear what `Self::Element::Mut` is in the `rebuild`
function, because of how the resolution works
3) When implementing `View`, you need to specify the context (i.e.
`impl<State, Action> View<State, Action, [new] ViewCtx> for
Button<State, Action>`.

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-06-06 15:16:36 +00:00
Olivier FAURE a1ed84ea6a
Bump accesskit sub-dependency version (#330)
This bumps the `accesskit_consumer` version in `Cargo.lock` to the next
minor version (`0.19.1`).

That version includes better error messages when AccessKit panics.
2024-06-03 14:17:03 +00:00
Bruce Mitchener 6adcf746f4
masonry: Use `web-time` instead of `instant` (#323)
Recently, `instant` has been marked as unmaintained by the maintainer. A
suggested replacement is `web-time`, which is used by `winit` and is
already in our dependency tree.
2024-06-03 11:30:55 +00:00
Bruce Mitchener 2ab7c824cc
xilem,masonry: Use `dpi` crate directly (#320)
This removes a class of dependencies from within both `masonry` and
`xilem` on the `winit` crate where we can just use `dpi` directly
instead.

The `dpi` crate is meant (like `cursor_icon`) to be a shared ecosystem
crate rather than only for usage with `winit`.
2024-05-29 07:52:04 +00:00
Bruce Mitchener 99688a6eef
`masonry`: Use `cursor_icon` crate directly. (#300)
`cursor_icon` is a crate that is used by `winit` to provide its
`CursorIcon` type separately from the `winit` crate.

This re-exports the `CursorIcon` from `masonry` and then uses that
rather than via `winit:🪟:CursorIcon`, allowing the use of the
`CursorIcon` without having to independently discover its provenance.

This is also one step towards not requiring `winit` within the `masonry`
internals apart from the actual window / event loop management.
2024-05-12 05:53:53 +00:00
Bruce Mitchener 300b22ce74
xilem_web: Remove unused direct dep on `kurbo`. (#293)
This is always used via `peniko`.
2024-05-08 14:45:26 +00:00
Bruce Mitchener 139395bb67
Remove `xilem_classic` (#290)
This can be accessed in the git history and has been replaced by the
version using `masonry`.
2024-05-08 09:09:49 +00:00
Kaur Kuut 392c3c1fc9
Update dependencies. (#283)
These are the results of running

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

in preparation for the upcoming release.

These are semver compatible updates.
2024-05-07 19:38:40 +00:00
Bruce Mitchener 8829daa39f
deps: Update `image`, make workspace, turn off default features. (#279)
The `image` crate has a number of dependencies which aren't needed in
the core masonry crate, so we can turn off the default image format
support and only enable "png" when used as a dev dependency.

Also, make it a workspace dependency at the same time so that the
version is only stated in a single location.
2024-05-07 12:57:55 +00:00
Bruce Mitchener f6930242b8
deps: Update `float-cmp` (#280) 2024-05-07 11:37:41 +00:00
Olivier FAURE b3540a0453
Improve formatting of logs (#254) 2024-05-04 12:39:35 +00:00
Olivier FAURE 6880515b95
Add initial accessibility support (#244)
Add AccessKit dependency.
Add accesskit_winit dependency.
Add methods to the Widget trait which create the accessibility tree and
react to accessibility events.
2024-05-04 10:17:49 +00:00
Olivier FAURE df761959e5
Add default subscriber to Masonry (#252)
This subscriber uses EnvFilter to change its value depending on the
RUST_LOG env variable, so log levels can be changed without recompiling
the app.
2024-05-03 22:42:47 +00:00
Kaur Kuut 294bb441b0
Prepare `Cargo.toml` files for release. (#249)
* Rename classic `xilem` to `xilem_classic` and the new `xilem_masonry`
to `xilem`.
No directory structure changes yet to avoid merge conflicts before
RustNL.
* Base common dependencies on workspace dependencies.
* Bump `masonry` version to `0.2.0`.
* Remove some legacy docs.rs configuration inherited from Druid/Glazier
that is no longer needed.
* Unify ordering of properties.
2024-05-03 20:07:12 +00:00
Daniel McNab 52bbfa047e
A foundation for text editing and selection in Masonry (#241)
This brings in a lot of the old work from Druid and Masonry (prior to
linebender/masonry#56) on text, as well as some types from Glazier.

Needed work:
- [X] Text display using abstract types
- [x] Text selection with mouse
- [x] Text input with keyboard
- [ ] IME integration (of the kind winit understands)

Follow up work:
- [ ] Keyboard control of the selection area (hard-coded hotkeys)
- [ ] [Proper
placement](https://raphlinus.github.io/text/2020/10/26/text-layout.html#shaping-cluster)
of cursor
- [ ] Input methods
- [ ] Proper hotkey handling
- [ ] Copy and/or paste
2024-05-03 15:53:52 +00:00
Kaur Kuut 205a9a28a4
Revert to `vello` v0.1.0. (#248)
As discussed at office hours we're going with Vello v0.1.0 for now, as
using the git dependency blocks publishing and Vello 0.2 isn't ready.
2024-05-03 15:43:42 +00:00
Bruce Mitchener d25d624d79
deps: Use workspace vello, release parley. (#238)
`xilem` now uses the same `vello` as others (git for now) and everyone
uses the new released version of `parley`.
2024-05-01 15:52:42 +00:00
Aaron Muir Hamilton 30c838b400
Port Xilem and Masonry to winit 0.30.0 (#237) 2024-05-01 11:58:21 +00:00
Bruce Mitchener 38ef8d9bf8
deps: Remove unused `open` dependency. (#236) 2024-04-30 16:58:22 +00:00
Bruce Mitchener d513e33a6d
deps: Use `raw-window-handle` 0.6.0 (#227)
We don't need to force the usage of 0.5.0.
2024-04-28 02:46:50 +00:00
Bruce Mitchener 571c20d73e
deps: Update parley. (#221)
This version of parley has fontique as a separate crate and has updated
dependencies (as well as a removal of clap as a transitive dep).
2024-04-26 14:41:02 +00:00
Bruce Mitchener d01ec396ab
xilem_web: Update gloo, remove "utils" feature. (#215) 2024-04-26 12:16:04 +00:00
Bruce Mitchener 8b3ee7d7f7
masonry: Remove unused deps. (#219) 2024-04-26 10:33:11 +00:00
Bruce Mitchener ebb4d55f12
parley: Use via workspace dependency. (#210)
This will help us keep everyone using the same version. This also
makes both `xilem` and `masonry` use the same version now.
2024-04-26 00:23:57 +00:00
Daniel McNab 69ac0807b9
Create a minimal xilem_masonry (#205)
* Create a minimal xilem_masonry

* Add a first draft of view sequences

* Implement a flex view

* Fix clippy

Some of these suggestions are kind of bad
but that's by-the-by

* Update CI to 1.77

* Skip masonry docs in CI

* Clippy, again

* Fix clippy

* Skip render snapshot tests

* Skip testing which needs rendering on CI

* Add tuple sequences

* Address review comments and clippy
2024-04-25 12:27:37 +00:00
Bruce Mitchener 041ea0df9f
Remove `test-log` and `env_logger`. (#201)
`test-log` is used with logging to set up `env_logger` for each
test and was only used in the box constraints code. This code
doesn't actually use logging, so this wasn't doing much.
2024-04-16 08:35:46 +00:00
Bruce Mitchener 8b2949831e
[deps] Use release of peniko. (#200)
This also lets us stop building a separate version of kurbo for
xilem_web.
2024-04-15 02:45:25 +00:00
Chad Brokaw 24423aa8f7
Update parley dependency to bring in new font fallback support (#196)
* testing fontique integration

* new text to test font fallback

* restore wgpu patch

* update to new parley git rev

* update rev again
2024-04-02 22:19:51 +00:00
Daniel McNab 072358e293
Use released versions of Vello and wgpu (#190)
* Use released versions of Vello and wgpu

Partially reverts #177

Fixes #189

* Revert auto format of comment
2024-03-19 14:20:03 +00:00
Aaron Muir Hamilton 21a84d6973
Bump vello and remove wgpu override. (#179) 2024-03-02 22:09:27 +00:00