Commit Graph

536 Commits

Author SHA1 Message Date
Olivier FAURE 25218291d0
Reserve ability to create Pod to ViewCtx (#597)
This is another intermediary PR for the "restrict widget creation to
Mutate pass" feature.

The basic idea is that, in the near future, it will be impossible to
create a WidgetPod without a handle to the arena. In my current WIP
code, that handle is passed through ViewCtx. Therefore, this PR changes
all the sites in xilem that create a Pod and has them use a ViewCtx
method instead.

I've tested most xilem examples and they all worked (except for
variable_clock, which currently panics in the last main commit).
2024-09-18 20:53:31 +00:00
Olivier FAURE 6c91b74e97
Fix accessibility crash with stashed children (#598) 2024-09-18 14:58:15 +00:00
Daniel McNab 0d56c592f5
Add the `lens` component (#587)
See
https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/Lens.20View

Usage:
```rust
fn app_logic(state: &mut FlightPlanner) -> impl WidgetView<FlightPlanner> {
    lens(date_picker, state, |state| &mut state.date)
}

struct FlightPlanner {
    date: Date,
    available_flights: Vec<Flight>,
}
```

Also extends the docs features in Xilem Core, and increases the
complexity threshold

---------

Co-authored-by: Kaur Kuut <strom@nevermore.ee>
Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-09-18 08:10:50 +00:00
Philipp Mildenberger 2ccd9d4712
xilem_web: Optimize element casting, and intern often used strings (e.g. "div") (#594)
Some micro-optimizations, e.g. avoids a js call `instanceof` (via
`dyn_into`/`dyn_ref`) when constructing elements.

Leads to a small speed increase when constructing/visiting elements
(roughly 2%) and more importantly a leaner wasm binary (around 5 %),
respectively tested with the js-framework-benchmark suite.
2024-09-17 18:49:15 +00:00
Olivier FAURE d758ae508e
Fix update_focus_chain pass (#595) 2024-09-17 15:39:19 +00:00
Olivier FAURE 7679e7c75e
Fix tab focus when no widget is currently focused (#593) 2024-09-17 08:52:59 +00:00
Olivier FAURE 09d9ad555d
Make `Textbox` focusable and trigger redraw in response to `request_layout` (#537)
Fixes #301.
2024-09-16 15:31:37 +00:00
Olivier FAURE a56d1e2467
Refactor arena code (#588)
Rewrite doc comments
Move find methods to ArenaRef/MutChildren
Create ArenaMapref/Mut in anticipation of future work.
2024-09-16 15:21:56 +00:00
Olivier FAURE 01cca4610c
Add temporary passes and remove most of lifecycle method (#589)
Add update_focus_chain pass.
Add update_new_widgets pass.
Remove RenderRoot::root_lifecycle.
Move call_widget_method_with_checks out of Widgetpod.

These new passes aren't intended to stay long-term, but are meant to
make future refactors easier and more concise.
The other goal is to remove almost all the remaining code in the
lifecycle method.
2024-09-16 12:30:41 +00:00
Spencer C. Imbleau b54266d605
docs: fix deps discrepency between Fedora/Ubuntu (#299)
Slight discrepancy between the instructions for Fedora and Ubuntu.

In the Fedora instructions, it doesn't include `pkg-config`, in Ubuntu,
it does.
2024-09-13 15:00:32 +00:00
Richard Dodd c1da921af5
add checkbox to widget example (#568)
This PR adds another widget to the widgets example, and also draws boxes
around each widget to separate them visually. I wanted to use flex wrap
to display them, but I don't think that's implemented yet in Xilem, and
the layout I did use isn't bad.

It also provides a simple example of the use of `Adapt`

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-09-13 14:48:49 +00:00
Jared O'Connell c563029372
Fix minor grammar error in sequence (#586) 2024-09-13 04:13:34 +00:00
Olivier FAURE 4746766d89
Implement update_focus pass (#538)
Make Textbox Widget tab-focusable.

This is part of the Pass Specification RFC:
https://github.com/linebender/rfcs/pull/7
2024-09-12 11:29:21 +00:00
Olivier FAURE 2fa8a055bd
Implement update_anim pass (#539)
This is part of the Pass Specification RFC:
https://github.com/linebender/rfcs/pull/7

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-09-12 11:06:33 +00:00
Jared O'Connell 3726e91a48
Grid layout (#570)
This PR adds a basic grid layout to Masonry and Xilem.

The way this layout works is it has a fixed grid based on the initial
size passed in, and grid items are placed based on the position
requested. Grid items are allowed to span more than one cell, if
requested.

There are potential improvements that could be done, like the use of
intrinsic sizing for varied column width based on content size. Though
that could be done in the future taffy layout if we want to keep this
one simple.


~~This PR is still a draft because of one remaining concern. I was not
able to successfully optimize with conditional calls to child widgets
for layout. It led to crashes about the paint rects not being within the
widget's paint rect. `Error in 'Grid' #16: paint_rect Rect { x0: 0.0,
y0: 0.0, x1: 800.0, y1: 610.0 } doesn't contain paint_rect Rect { x0:
400.5, y0: 0.0, x1: 800.5, y1: 150.0 } of child widget 'Button' #5`. My
failed attempt at fixing it is commented out.~~

Since I am rusty on View Sequences, a lot of that code is based on the
Flex implementation. Let me know if I did anything incorrectly or if any
of it is unnecessary, or if anything is missing.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-09-11 14:55:19 +00:00
Tom Churchman 9a3c8e308c
masonry: replace `set_active` and `is_active` with pointer capture (#564)
Also improve documentation of pointer capture.

Continuation of 59ee615651
(https://github.com/linebender/xilem/pull/488).

Makes `has_pointer_capture` available on all context types except
`LayoutCtx`, like `is_active` used to be.
2024-09-10 11:55:51 +00:00
Olivier FAURE dcea01a4a9
Migrate layout pass (#529) 2024-09-09 12:35:36 +00:00
Olivier FAURE 2ae73268a8
Implement update_scrolls pass (#550)
This is part of the Pass Specification RFC:
https://github.com/linebender/rfcs/pull/7

Note: This PRs comes with a lot of new TODO items. Addressing most of
these items is difficult without major refactors, because Portal code
deals with accessing values across multiple widgets, which is still hard
to do elegantly.
2024-09-09 11:28:32 +00:00
failingprovince 75d515617a
docs(#581): fix missing char in `ARCHITECTURE.md` (#582)
Fix issue #581.
2024-09-06 13:56:36 +00:00
Matt Campbell 0133b6c24a
Interim accessibility for Textbox (#580)
This is just enough to allow the current content of the textbox to be
read with a screen reader, until we implement full accessibility later.
2024-09-05 20:15:51 +00:00
Daniel McNab 60e5aca155
Setup `to_do_mvc` for Android (#578)
I'm finding these cargo warnings exceptionally annoying...
2024-09-05 14:46:00 +00:00
Matt Campbell 786ab633ba
Request accessibility update when checkbox state changes (#577)
Fixes #576

Can someone who's more familiar with Masonry please confirm that I'm
doing this the right way? I assume that one is supposed to call
request_accessibility update along with request_paint whenever the
change to the widget state could affect accessibility.
2024-09-05 12:47:53 +00:00
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