Commit Graph

514 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
Tom Churchman 5944aa5d0b
masonry: add docs for `TreeArena::get_id_path` (#573)
beats reading the implementation to know the order :-)
2024-09-03 18:27:38 +00:00
Tom Churchman e337cf745a
masonry: fix updating Portal on scrollbar drag (#563)
Fixes scrolling `Portal` on scrollbar drag by recomposing instead of
relayouting.

Regression probably caused in 59ee615651
(https://github.com/linebender/xilem/pull/488) or
ff7635e4c2
(https://github.com/linebender/xilem/pull/522).
2024-09-02 16:14:03 +00:00
Richard Dodd (dodj) a1c7d74257
feat: add progress bar widget (#513)
@PoignardAzur I wanted to have a play with masonry, so I had a go at
building a progress bar. I've made a PR in case you want it, but I won't
be offended if you close the PR. I'm happy to make changes if you see
anything you'd like to change.

---------

Co-authored-by: Olivier FAURE <couteaubleu@gmail.com>
Co-authored-by: jaredoconnell <jared.oc321@gmail.com>
2024-08-30 21:15:34 +00:00
Bruce Mitchener 6c4951635d
xilem calc: Use Unicode minus sign. (#566)
This lets it get read out correctly by VoiceOver in accessibility code
rather than read as a hyphen or dash.
2024-08-30 04:18:25 +00:00
Daniel McNab ac95f2524a
Add the `Portal` view to Xilem (#561)
This is also added to `variable_clocks` as needed.

This could also be added to `mason`, but I see a worrying amount of lag
if I do...
I could do with some help tracking this down.
2024-08-29 05:53:50 +00:00
Daniel McNab 251f42ae87
Fix the handling of `Flex::gap` (#560)
Fixes https://github.com/linebender/xilem/issues/559

See comment on the fix for an explanation. Essentially, the `major`
value was used for multiple purposes, and this corrects into the
expected "direction".
2024-08-28 14:49:12 +00:00
Tom Churchman 923c0fb8ca
Remove manual recursion to child `paint` and `accessibility` (#557)
Recursing is done inside the paint and accessibility passes since
ff7635e4c2. I believe this is the correct
continuation of #522, with the removal of these methods "left for later"
as mentioned in
https://github.com/linebender/xilem/pull/522#issuecomment-2298610203.

One note is that Flex now debug-paints its baseline under its children,
rather than over them.
2024-08-28 13:41:36 +00:00
Muhammad Ragib Hasin 92fc669493
Enable BackgroundBrush in SizedBox view (#541)
The `SizedBox` widget in Masonry had the option to set a background
brush that was not exposed in its corresponding view in Xilem. The
`SizedBox` view now exposes the option.

Incidentally, `BackgroundBrush::PainterFn` variant had the wrong type,
as such it was not usable. A `scene` parameter is added and the closure
now requires to be `Send + Sync`.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-27 10:57:16 +00:00
Philipp Mildenberger 04a8e8ec74
masonry: Use `||` instead of `|` in update pass for boolean expression (#555)
Unfortunately this lint is very conservative in its detection, it hasn't
detected the other fix in this PR...
I manually checked, if we had any other bitwise or/and for booleans, and
indeed this was the only case.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-26 20:31:46 +00:00
Muhammad Ragib Hasin 7591c2a9a4
Fix inference of wrapper views (#554) 2024-08-26 14:10:32 +00:00
Bruce Mitchener 7bd572b9a3
Fix typos. (#556) 2024-08-26 13:55:55 +00:00
Daniel McNab 4cb2552e3a
Reduce duplicated logic in `tracing_backend`, and add some docs (#530)
The calculation of the levels was previously duplicated for both web and
native, and the `WARN` level was not used properly on WASM for tests.
2024-08-26 10:24:31 +00:00
Olivier FAURE 4cddfc5157
Implement update_disabled pass (#540) 2024-08-25 13:23:38 +00:00
Olivier FAURE 414b36019b
Remove stray marker comment (#552) 2024-08-25 12:48:26 +00:00
Bruce Mitchener 991a485bd1
masonry: Re-enable `clippy::doc_markdown` (#549)
This is work towards #449.
2024-08-25 11:56:34 +00:00
Bruce Mitchener d084f0bc86
masonry: Remove 2 references to tutorials. (#546) 2024-08-25 11:43:21 +00:00
Bruce Mitchener a84791a404
masonry: Fix a dangling sentence in test comment. (#548)
Also, wrap a URL in angle brackets to satisfy `clippy::doc_markdown`
2024-08-25 11:13:54 +00:00
Olivier FAURE 3cceb60f72
Improve lints for debug prints (#551) 2024-08-25 11:10:50 +00:00
Bruce Mitchener 1d87fce293
masonry: Use `kurbo::Rect::scale_from_origin()` (#542) 2024-08-25 09:41:21 +00:00
Bruce Mitchener 0914079d0c
xilem: Remove lingering `cx` (use `ctx`) (#547) 2024-08-25 09:41:10 +00:00
Bruce Mitchener c1732f401e
masonry: Better markdown in comment for `check_render_snapshot` (#544) 2024-08-25 09:41:01 +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
Bruce Mitchener 81b3aee40d
Don't use doc comments for VSCode markers. (#543) 2024-08-25 08:00:17 +00:00
Bruce Mitchener 62dd54b238
masonry: Add some missing backticks. (#545) 2024-08-25 07:59:53 +00:00
Daniel McNab c77c6ecb68
Disable hinting whilst a `VariableLabel` animation is ongoing (#535)
If using hinting during an animation, a shimmering effect can occur.
2024-08-23 17:34:11 +00:00
Olivier FAURE ff7635e4c2
Implement paint and accessibility passes (#522)
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-23 08:47: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
Matt Armstrong dba9742481
Run doctests in ci (#533)
Fixes #500
2024-08-22 07:36:12 +00:00
Olivier FAURE bd83ed25b8
Fix Flex widget (#532)
This fixes a regression in the Mason example.
2024-08-21 14:34:36 +00:00
Olivier FAURE 6c59ceddf8
Add trace span to AnyView (#531) 2024-08-21 13:59:12 +00:00
Olivier FAURE 7a10210e85
Fix Portal widget (#527)
One of the problems we ran into with the `to_do_list` example was that
we had a `Flex` inside a `Portal`: the `Portal` widget is designed to
display scrollbars and provide scrolling if the child is larger than its
constraints... but then Flex's `layout` method always clipped the
returned size so it wasn't ever larger than its constraints. Hence, no
scrolling. Removing the `bc.constrain(my_size)` part makes the example
have scrolling behavior again.

This PR also tweaks scrolling code and adds `#[track_caller]` attributes
to help with debugging.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-20 09:51:38 +00:00
Andrii Zymohliad f90772a0d2
Rename async_repeat into task (#528)
Following [the discussion in
Zulip](https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/.60async_repeat.60.20name.20brainstorming),
this PR renames `async_repeat` view into `task`, and its `future_future`
argument into `init_future`. I also assumed we would want to do a
corresponding rename in `xilem_web` for consistency.
2024-08-20 08:50:47 +00:00
Olivier FAURE 42a6a320da
Fix visual bug in masonry_calc example (#526) 2024-08-19 15:13:26 +00:00
Crockeo 522d42cf0c
masonry: add Pinch to PointerEvent (#476)
I opened https://github.com/linebender/xilem/issues/473 earlier today,
but I realized after looking at the code that it would be super simple
to implement!

Copying over some context from that issue:

- I'm working on a graph renderer using Vello.
- I'm porting it over to a Masonry widget, so that I can build a UI
around it.
- In doing so I noticed there wasn't support for winit's `PinchGesture`,
which I had been using before when messing around with this on my macOS
device.

Please let me know if y'all feel like this is appropriate to include
inside of `PointerEvent`!
2024-08-18 11:52:49 +00:00
Olivier FAURE 7842fd98df
Add per-widget trace spans to compose pass (#523) 2024-08-17 12:10:30 +00:00
Olivier FAURE 652ee68ae5
Implement compose pass (#512)
Add `Widget::compose` method.
Add `ComposeCtx` type.
Add `needs_compose`, `request_compose`, `translation_changed` flags to
WidgetState.
Add `window_origin` attribute to WidgetState.
Add convenience methods to TreeArena.
Remove `needs_window_origin` flag and `parent_window_origin` attribute.
2024-08-16 17:06:00 +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
Bruce Mitchener c6c1b71640
masonry: More efficient set of PointerButtons. (#334)
This brings code over from glazier for a set of PointerButtons that just
uses a single value and bit flags rather than a `HashSet`.
2024-08-16 13:28:34 +00:00
Bruce Mitchener c380d8a2b6
masonry: Fix a couple of broken doc links. (#520) 2024-08-16 11:20:15 +00:00
Philipp Mildenberger 88cc3eed3d
xilem_web: Apply props when the element type changes in `replace_inner` (#519)
Fixes #518
2024-08-16 10:42:33 +00:00
Philipp Mildenberger 5ae36200b3
xilem_web: Document a lot and remove `start_<modifier>` as it doesn't do anything in `View::build` and may be misleading (#517)
I think I've covered every pub item at the top level.

It also renames (taking `Attributes` as example)
`start_attribute_modifier` -> `rebuild_attribute_modifier`,
and `end_attribute_modifier` -> `mark_end_of_attribute_modifier`, as I
think that makes it more clear what these methods do.
`start_attribute_modifier` was a noop in `View::build` and may lead to
buggy behavior when `DomNode::apply_props` is called before every parent
`View::build` has done modifying the props. This should make
`DomNode::apply_props` robust. And `AfterBuild` is fixed now with that.
2024-08-16 09:51:33 +00:00
Olivier FAURE cb7e9e605c
Reduce logs in tests (#511)
Stop debug log lines from showing up between test indicators when
running `cargo test`.
2024-08-15 16:41:28 +00:00
Philipp Mildenberger 411acc12aa
xilem_web: Add hydration support, and a new view using it `Templated` (#495)
This is mostly a first step towards SSR.
But we can use hydration to speed up creation of long (non-virtualized)
lists with the `Templated` view.
`Templated` stores a deep copy of the DOM node of the first occurence of
its `impl DomView` based on the `TypeId` in the `ViewCtx`,
and reuses it on every further invocation, where it will be hydrated and
updated based on the new attributes.
As it uses an `Rc` to achieve this, it also supports memoization,
similar to an `Arc<impl View>`.

Hydration is currently feature-gated, as it produces a little bit more
binary bloat. Though it's little enough to this being justified as
default.

---------

Co-authored-by: Markus Kohlhase <markus.kohlhase@slowtec.de>
2024-08-15 15:37:57 +00:00
Bruce Mitchener 7607ffd13f
masonry: tweak docs: typos and linking. (#516) 2024-08-15 15:26:34 +00:00
Olivier FAURE e0d6a309d1
Implement mutate pass from pass spec RFC (#510)
This is part of the "Pass Specification" RFC:
https://github.com/linebender/rfcs/pull/7

Rename WidgetCtx to MutateCtx.
Add a mutate pass.
Add a `mutate_later` context method to trigger that pass.
Refactor `edit_root_widget` to use a version of that pass.
Add a separate constructor for the synthetic WidgetState created in
RenderRoot.

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-14 20:06:01 +00:00
Philipp Mildenberger 0c80c0fb62
masonry: reuse redundant `ArenaRef/Mut` creation code (#509)
@PoignardAzur this is what I meant with the redundancy.
2024-08-13 12:13:11 +00:00
rustui 574ac7dc8f
Fix view overflow in the calc example on mobile (#508)
On mobile platforms, setting the logical width of the window to 400 can
cause the view to overflow on phones with smaller screen widths (such as
the iPhone SE 2nd generation).
<details>
  <summary>screenshot of the view overflow</summary>
<img
src="https://github.com/user-attachments/assets/d47c1c88-ace6-4059-a0ed-b5384dcfa207"
alt="screenshot of the view overflow" width="400" />
</details>

It is more intuitive not to manually set the window size. Additionally,
winit does not support set_title and set_resizable on iOS and Android
(calling them does not have any effect).
2024-08-13 10:21:45 +00:00
Olivier FAURE 59ee615651
Implement event and update_pointer passes from pass spec RFC (#488)
This is a first step in implementing the "Pass Specification" RFC:
https://github.com/linebender/rfcs/pull/7

Create a `passes` module.
Create event passes.
Create the update_pointer pass.

Remove `WidgetPod::update_hot_state` method.
Move mouse-cursor-handling code to update_pointer pass.
Implement pointer capture.
Refactor the TreeArena code.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-13 08:52:27 +00:00