Format:
```rust
label("everything").text_size(42.)
```
and the same with `prose`.
I've also added `font_size` aliases for these, because people will
expect it to have these names.
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>
Since #314, we request the IME to be positioned every paint cycle. This
triggers a new event from the IME, which is a preedit clear. This IME
event also breaks text selection, which is why we handle it here.
This is still not the fully correct behaviour, but it does at least make
text selection in textboxes work again. We really need to improve our
testing story here.
Also give more detail in the short form of IME events; these events all
have quite different properties.
This adds yet another generic parameter `Message` to the `View`,
`ViewSequence` and `AnyView` trait, such that implementors have more
freedom about what the message is. This is necessary for xilem_web, as a
`Send` bound is not possible to use with wasm_bindgen IIRC. (At least I
had to remove it in the `DynMessage` to get it to compile...).
It was fortunately straight-forward to just add the `Message` param with
the default `DynMessage`. Basically search replace... (I hope I haven't
missed anything, but I went through it twice...)
This ports the `OneOfN` views from `xilem_web` to `xilem_core`.
~~The new marking mechanism for the `ViewSequence` makes it possible to
use the same type as well for an implementation of `ViewSequence`, which
is provided here as well.~~
Because of ambiguity, and needing to specify the explicit type when
`OneOf(impl View)` would be used, where an `impl ViewSequence` is
expected, we have decided to not provide a `ViewSequence` impl, so that
it's not ambiguous, and not necessary to specify the concrete type. We
could instead add separate types for a `ViewSequence` instead like
`OneSeqOf2`.
Since macros make this unfortunately not super readable, for reviewers
of the code [this pre-macro
version](4f786c4282/xilem_core/src/views/one_of.rs)
may be better to look at, the only difference to this, is that this has
slightly enhanced doc comments, and obviously more than just `OneOf2`.
Ports `Adapt` to new xilem_core.
It also adds `MapState` which was previously called `AdaptState` and a
new view `MapAction` which is basically about how elm works.
`MapAction` and `Adapt` is shown in action in the added `elm` example,
while `MapState` can be seen in action in the added `components`
example.
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.
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).
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>
This brings the `PointerButton` enum from glazier and has all code
outside of the winit event loop integration using it.
For now, it has a `todo!()` for the `MouseButton::Other` as it isn't
clear what that is for.
Note that this adds a link to a section added in
https://github.com/linebender/parley/pull/69
I removed Taffy from the diagram for simplicity, and because Taffy's
current integration is in flux.
Overall I think the Xilem README is in desperate need of a rewrite, and
this PR should be considered a stopgap. Further PRs should better
integrate the ecosystem descriptions into the README, move some sections
around, etc.
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!
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.
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.
This allows for running `masonry` with an externally managed event loop
for integrating with an application that is already running an event
loop.
* Expose `PointerState` to allow creating `PointerEvent`
* Expose `WindowEvent` to allow managing window size and scale factor.
* Make `DriverCtx` usable from outside the crate. While this struct was
already `pub`, the sole member of it was not.
In the call to updating the hot state from the widget pod, the
`mouse_pos` is already of the right type, so it doesn't need to try to
reconstruct itself as the right type.
This is different from another call site (in `contexts.rs`) where the
`mouse_pos` is an `Option<Point>` and so it does need reconstructing.
The current nightly issues warnings for unknown cfgs, so we need to
suppress some of these for now.
Even though these are only needed for `masonry`, we put them in the
workspace configuration due to limitations in how the lints table is
configured and overridden in current versions of Cargo.
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`.
This ports the `Memoize` view from old xilem, slightly enhances it, by
checking whether the given view callback is a non-capturing closure and
not a function pointer (by asserting `std::mem::size_of::<F>() == 0`)
It also ports the `Arc<impl View>` and `Arc<dyn AnyMasonryView>` from
#164 including the example there to show how these two forms of
memoization can be used.
Currently, the only legit typo being found is `seeked` but I'm not sure
what to do about that.
Would be nice to check for new typos in CI anyways, right?
---------
Co-authored-by: Kaur Kuut <strom@nevermore.ee>
These standardized options can make code a little nicer. Right now they
don't change anything, though they include an implicit commitment to
adopt the # `imports_granularity = "Module"` and `group_imports =
"StdExternalCrate"` settings.
While these settings are unstable, we can apply them with rustfmt
nightly without actually committing to using nightly in CI. We should
progressively move parts of the codebase towards that format in future
PRs.
---------
Co-authored-by: Kaur Kuut <strom@nevermore.ee>