Commit Graph

22 Commits

Author SHA1 Message Date
Olivier FAURE 2642a9e146
Replace RouteWidgetAdded event with new register_children method (#602)
Make lifecycle method optional.
Remove InternalLifecycle.
2024-09-23 08:25:32 +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
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
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
Bruce Mitchener 7bd572b9a3
Fix typos. (#556) 2024-08-26 13:55:55 +00:00
Olivier FAURE 42a6a320da
Fix visual bug in masonry_calc example (#526) 2024-08-19 15:13:26 +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
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
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
Jared O'Connell 759d746653
Xilem Calculator Example (#467)
This pull request adds a simple calculator that can display binomial
math (ex: 2 + 2 = 4). Math operations with more than two operands are
done by moving the prior binomial results into the left operands.

This pull request also follows the existing convention by masonry's
calculator example to calc_masonry to differentiate them.

Let me know if there are any changes that I should make to improve code
quality.

<img width="404" alt="image"
src="https://github.com/user-attachments/assets/3498913b-dd4d-451c-8fa2-fcd2f7fd26af">

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-07-31 15:07:55 +00:00
Daniel McNab 2dc1c08b80
Add a CSS `gap` inspired Flex property. (#437)
See https://developer.mozilla.org/en-US/docs/Web/CSS/gap

Since #428, we no longer have default spacing between flex elements in
Masonry. This makes the examples quite ugly.

Choices made based on [#xilem > Porting Taffy Integration to New
Xilem](https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/Porting.20Taffy.20Integration.20to.20New.20Xilem).
Of particular note is the choice to not have this be overwritten by
spacers, due to:

> My first thought is that users are going to be very confused when they
add a space between two items and the result is the items are closer
together.

There is no such concept of a spacer in CSS parlance
2024-07-19 14:14:38 +00:00
Daniel McNab f11b64892c
Import our intended set of lints (#432)
See discussion in [#linebender > Standard Lint
set](https://xi.zulipchat.com/#narrow/stream/419691-linebender/topic/Standard.20Lint.20set)

Of note: I have taken steps to ensure that this can be practically
reviewed by *not* applying most of the lints.
The commented out lints make good follow-ups

---------

Co-authored-by: Olivier FAURE <couteaubleu@gmail.com>
2024-07-18 08:58:16 +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
Olivier FAURE be4a5bf5e8
Implement widgets-in-arenas RFC (#396)
See https://github.com/linebender/rfcs/pull/6 and [zulip
thread](https://xi.zulipchat.com/#narrow/stream/317477-masonry/topic/New.20RFC.3A.20.22widgets-in-arena.22).
2024-07-15 11:45:19 +00:00
Daniel McNab 9299b67986
Move to a single global `parley::LayoutContext` (#405)
Based on a suggestion from @dfrg.

This appears to have improved performance with the 30_000 hello's
example from ~$\frac{1}{20}$ms to $\frac{1}{160}$ms
So an approx 8x increase in throughput for that scene.
2024-06-18 19:04:17 +00:00
Daniel McNab d6af6a6ef7
Differentiate pointer buttons in `Button` Widget and View (#397)
In most cases, you want a button which only actuates when the primary
mouse button is pressed, so the easy case is still that. This is a short
term hack, because e.g. the active state is still based on any button
being pressed, not just those we are interested in.

That is, we probably need to represent a set of buttons we are
interested in. However, this change minimally unblocks additional work
with Xilem. In particular, see [#xilem > Minesweeper converted from Iced
to
Xilem](https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/Minesweeper.20converted.20from.20Iced.20to.20Xilem).
2024-06-14 16:40:26 +00:00
Olivier FAURE a2045f1356
Document masonry (#329)
This was initially a supposed to be a small documentation pass, which
grew into a few changes:

- Adding back a to-do-list example.
- Fixing the bugs revealed by that example (infinite bounding boxes,
wrong accessibility handling in Portal, etc).
- Making sure all widgets return the correct spans instead of the
less-useful default one.
- Adding a trace to the layout pass for easier debugging.

Overall I'm pretty happy with this!
2024-06-03 14:21:41 +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
Daniel McNab 866d416cef
Make execution on Android work properly (#309)
```
cargo apk run --example mason_android -p xilem
```


![image](https://github.com/linebender/xilem/assets/36049421/40cec14e-ce27-4bb8-ba46-8e6bd902852d)

There will some followup needed here, of course. But some of that will
want to come after xilem#235, when the way to do multiple windows has
become clearer
2024-05-23 08:13:30 +00:00
Olivier FAURE ef5d36e8fc
Move crates to the repository root (#302)
Follows the convention proposed in this discussion:

https://xi.zulipchat.com/#narrow/stream/419691-linebender/topic/Standardizing.20multi-package.20repos
2024-05-11 21:59:03 +00:00