Commit Graph

10 Commits

Author SHA1 Message Date
Olivier FAURE 9ffc650983
Remove `Box<dyn Widget>` from a few places (#837)
Having `Box<dyn Widget>` implement the `Widget` trait is a crutch that
makes a bunch of things more complicated.

It leads to double-boxing in cases when the `dyn Widget` is itself a
`Box<dyn Widget>` (especially since the arena's current implementation
boxes all widgets by default), makes it harder to reason about
downcasting, and ends up producing a lot of code to handle the edge
cases.

On the xilem side, `Box<dyn Widget>` is slightly redundant with
`DynWidget`.

This PR still leaves a lot of boxing. On the long term, we'd like for
the arena to pack arbitrary widgets efficiently using some kind of
archetype scheme, but in the meantime, boxing will have to do.

Changes in this PR:
- New `FromDynWidget` trait that maybe-downcasts widgets to a
maybe-sized `Widget` type.
- Most places that accept `Widget` now accept `Widget + ?Sized`.
- Remove `impl Widget for Box<dyn Widget>`.
- Replace all instances of `WidgetPod<Box<dyn Widget>>` with
`WidgetPod<dyn Widget>`.
- Replace all instances of `xilem::Pod<Box<dyn Widget>>` with
`xilem::Pod<dyn Widget>`.
- Rename WidgetPod to WidgetBox in xilem_core example to avoid
ambiguity.
2025-01-20 12:52:08 +00:00
Philipp Mildenberger 9bb33dd1c6
Support transforms for each widget (#753)
Adds basic support for transforms (`kurbo::Affine`) of widgets in
Masonry and Xilem, similarly as CSS transforms.
A new example `transforms` shows this in a playful way.
The pointer-intersection logic needed a core change to handle now
possibly overlapping widgets.

Checkout
[this](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Add.20.60Affine.60.20transform.20to.20.60Widget.60.20trait.3F)
zulip thread for more info/discussion.
2025-01-14 09:59:31 +00:00
Philipp Mildenberger e0fee7425c
Eliminate needless lifetimes (#723)
Result from `__CARGO_FIX_YOLO=1 cargo clippy --fix`.
As newest nightly clippy bleats about all of this.
2024-11-29 14:00:11 +00:00
Olivier FAURE dc9a2e2a97
Rename lifecycle to update (#677) 2024-10-17 12:09:14 +00:00
Olivier FAURE 337f7c774e
Make WidgetState private (#655)
This enforces a pattern in the codebase where that WidgetState can only
be accessed through pass contexts, which prevents invalidation bugs.
2024-10-09 09:53:59 +00:00
Bruce Mitchener c380d8a2b6
masonry: Fix a couple of broken doc links. (#520) 2024-08-16 11:20:15 +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 4fdcb26eb9
Add a `FlexElement` to support explicit spacers and flex parameters for `Flex` in xilem (#428)
Takes ideas from #235 (in particular the masonry side).

This implements support for explicit spacers in the `Flex` view and flex
parameters for views (see examples `flex` and `mason` for more details).
It also adds a way (`AnyFlexChild`) to dynamically switch between
spacers and widgets (with optional flex parameters).
`masonry::widget::Flex::layout` is also updated to be in sync with
current druid.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-07-19 08:00:41 +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
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