Commit Graph

455 Commits

Author SHA1 Message Date
Philipp Mildenberger a52c3c7b3c
xilem_web: Add support for opacity in `svg::Fill` and dashes, opacity in `svg::Stroke` (#493)
Uses `ViewState` for a little bit of optimization (of allocations
mostly).
2024-08-09 09:28:52 +00:00
Philipp Mildenberger 2f23ee117a
xilem_web: Change `events::OnResize` to be a `ResizeObserver` (#494)
Since
[`on_resize`](https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event)
on an `Element` is not really useful as it won't be called, we can reuse
this event listener with a
[`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver)
on itself, to be actually useful.
2024-08-09 08:40:24 +00:00
Markus Kohlhase 5b6ebc324f
xilem_web: Add an `AfterBuild`, `AfterRebuild` and `BeforeTeardown` view, which reflects `Ref` in React (#481)
Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-08-08 22:44:49 +00:00
Markus Kohlhase 2eda5a2a50
xilem_web: Add async_repeat (#485)
Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-08-08 17:51:04 +00:00
Muhammad Ragib Hasin 43ffdbf824
Fix non-standard textbox behavior in Windows (#489) 2024-08-06 16:52:54 +00:00
Philipp Mildenberger 10387e90ab
xilem: Fix calc example (missing `flex` property) (#491)
Fixes #490
2024-08-06 12:32:21 +00:00
Philipp Mildenberger 99d61603d2
xilem_web: Add `interval` `View`, which somewhat reflects `setInterval` (#486)
Simple but convenient `View`, e.g. for some kind of ticker. (Maybe needs
an additional example)
2024-08-05 13:36:18 +00:00
Philipp Mildenberger bb13f1a760
xilem_web: Allow `DomFragment` instead of `DomView` as `app_logic` (#482)
Should fix #461. This allows a `ViewSequence` (called `DomFragment`) of
`DomView`s as root component.

The `counter` example is updated to show this new behavior.
2024-08-05 13:03:19 +00:00
Daniel McNab e27b3ce0c2
Run tests in CI, and fix fonts for snapshot testing (#233)
See also linebender/vello#439

This should open the door to doing much more comprehensive testing at
higher level in the nearish future (including e.g. in `xilem_masonry`)
2024-08-05 13:01:47 +00:00
Philipp Mildenberger 19454e3dc8
Improve `calc` and xilem_web's `mathml_svg` example (#487)
Reduces a little bit of the boilerplate in `calc`
2024-08-05 12:54:22 +00:00
Philipp Mildenberger 24427bbb44
Use `ViewMarker` trait instead of the generic `Marker` to allow `impl ViewSequence` as return type (#472)
This allows returning `impl ViewSequence` as this was previously not
possibly as the `Marker` generic parameter couldn't be named (easily) in
`ViewSequence<..., Marker>`.

This also provides specialized `ViewSequence`s for xilem
(`WidgetViewSequence` and `FlexSequence`) as well as for xilem_web
(`DomFragment`). Additional doc-tests/documentation and a small example
(in `counter`) for xilem_web is provided as well.

This has the drawback to not being able to reeimplement `ViewSequence`
for types that already implement `View`, which was previously possible
(as seen by the now removed `NoElementView` `ViewSequence`
implementation).
And additionally by introducing more boilerplate by having to implement
`ViewMarker` for every type that implements `View`.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-05 10:53:19 +00:00
Philipp Mildenberger 544a4a1ca9
xilem_web: Fix `DomChildrenSplice::with_scratch` (#484)
I'm surprised that this was not noticed yet,
`DomChildrenSplice::with_scratch` previously only appended new elements
to the end of the children of an element in the DOM tree, whereas it
should've inserted it at the current index of the `ElementSplice`. This
should fix this, using a `DocumentFragment` which is shared on the
`ViewCtx` to avoid unnecessary allocations.
2024-08-05 09:08:34 +00:00
edgy-sphere 0bca54ae52
masonry: `TextEditor` add `Action::TextChanged` for backspace & delete (#483)
`masonry::text::edit::TextEditor` should emit an
`Action::TextChanged(...)` also on `Backspace` and `Delete` if anything
was deleted, so that e.g. `xilem::view::textbox::Textbox` receives this
action. This is already implemented for `Ctrl+Backspace` and
`Ctrl+Delete`.

The code changes are not elegant, but intended to be minimally invasive.

Local `cargo test` failed for the modified and an unmodified code, but
sometimes with different errors&mdash;which I do not quite understand.

I apologize in advance for any mistakes on my part, I've never before
worked on open source repos and did not find any guideline for your
project.
2024-08-05 08:25:36 +00:00
Bruce Mitchener 101fa9bb7d
Fix some `clippy::doc_markdown` lints in masonry. (#479)
This is a start on #449.
2024-08-02 08:04:27 +00:00
Bruce Mitchener b35162b82e
Enable `clippy::doc_markdown` for non-masonry crates. (#480)
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-02 07:42:36 +00:00
Bruce Mitchener dd938d4af4
Fix doc warnings in xilem_core, xilem_web (#478) 2024-08-02 06:50:10 +00:00
Casey Rodarmor 4c991dd3e9
xilem_web: Add HtmlLiElement `value` attribute setter (#471)
From manually testing in Chrome, values between `2**31` and `2**31 - 1`
work, so this takes an `i32`.

It's pretty trivial code, but I think it would be really nice to add
some kind of test, or even just an example which uses it.

What do you think about adding a "misc" example for `xilem_web`, which
exercises a bunch of small features? I was thinking a layout with a
column on the left with a list of items with a larger area on the right.
When an item on the left is clicked, the right side is populated with
whatever that item is.

In this case, the item name would be `ol-li-value`, which when clicked
would show something like this on the right:

```rust
ol((
  li("foo"),
  li("bar"),
  li("baz").value(10),
  li("qux"),
));
```

Ideally, this would be compiled as part of CI, to make sure that no
compilation errors are introduced. Any time a small feature is added, a
new item in the "misc" example could be added which uses it.

It would also be nice for development, to have a place where new, small
features like this can be exercised during development. An actual test
would be great, but from quick googling, I couldn't find an obvious way
to test WASM code which runs in the browser. There's
`wasm_bindgen_test`, but that only runs tests in WASM outside of a
browser environment.
2024-08-01 21:05:09 +00:00
Daniel McNab 3405f6ee69
Support running `calc` on Android (#474)
This works without any other code modifications.

![Xilem Calc on
Android.](https://github.com/user-attachments/assets/b6648c04-bc9e-464c-9a19-0f03e958ade9)
2024-08-01 13:48:58 +00:00
Philipp Mildenberger 210afb4048
xilem_core: Refactor Memoization (add `Frozen` view, fix force-rebuild in `Arc`, and cleanup `Memoize`) (#451)
This adds a `force` which is basically a specialized `Memoize` without
any bound data.
This also cleans up `Memoize` a little bit (mostly code-aesthetic stuff,
but also adds `State` and `Action` params to the view, so that it
doesn't offer weird surprises when composing it with views like
`Adapt`).

The `Arc` view is also fixed, as it didn't support force rebuilding yet,
which is relevant for e.g. async, e.g. the `MemoizedAwait` view would
not work inside an `Arc<impl View>` currently.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-08-01 11:21:56 +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 f5c976c79d
Rename mentions of Zulip Stream to Channel (#470)
See
https://blog.zulip.com/2024/07/25/zulip-9-0-released/#streams-renamed-to-channels
2024-07-31 12:49:54 +00:00
Casey Rodarmor 741c36b13a
xilem_web: Add function to set HtmlIFrameElement src attribute (#466)
Apropos of #462. Let me know if this should have a test or an example!
2024-07-31 08:01:56 +00:00
Philipp Mildenberger b71f533571
xilem_web: Fix #465, by actually replacing the old element in the DOM-tree (#468)
Fixes #465
2024-07-29 12:50:10 +00:00
Philipp Mildenberger 1b1a1d3238
xilem_web: Fix message type of `AnyDomView` and add `.boxed()` combinator (#460)
I guess I missed this when adding #408, the doc-test should ensure that
`Box<AnyDomView>` is now really a `DomView`.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-07-29 09:23:31 +00:00
Philipp Mildenberger a2f136079c
xilem_web: Remove hardcoded `prevent_default`/`stop_propagation` as the user should decide that behavior (#458)
I think we could also create some additional sugar around that, but
since the event is given to the user, they can handle that behavior
anyway.

Fixes #457
2024-07-29 09:15:21 +00:00
Werick da Silva Santana 67afe67816
masonry: add pressure sensitivity to the pen's touch on the screen (#453)
device test
* huion kamvas 13 tablet windows 10 platform
2024-07-29 09:12:01 +00:00
Markus Kohlhase 727d696488
xilem_web: Use separate FetchState in fetch example (#454) 2024-07-28 10:30:26 +00:00
Philipp Mildenberger 981fcc4b5a
xilem_web: Add a `MemoizedAwait` view (#448)
This is the `rerun_on_change` view described in #440, I named it
`MemoizedAwait` as I think that fits its functionality.

It got also additional features `debounce_ms` (default `0`) and
`reset_debounce_on_update` (default `true`) as I think that's quite
useful, in case a lot of updates are happening.

When `reset_debounce_on_update == false`, `debounce` is more a throttle
than an actual debounce.

This also adds a more heavily modified version of the example added in
#427, also showing `OneOf` in xilem_web (which didn't have an example
yet).

This *could* be considered as alternative to #440 (at the very least the
example) but those approaches could also well live next to each other.

---------

Co-authored-by: Markus Kohlhase <markus.kohlhase@slowtec.de>
2024-07-26 16:11:34 +00:00
Daniel McNab d70076262d
Update dependencies and bump to Rust 1.80 (#450)
There is one "semi-false-positive" lint triggered, which I have fixed.
Otherwise, the required
```
cargo upgrade --ignore-rust-version
cargo update
```
2024-07-26 13:02:41 +00:00
Daniel McNab 5e07dcebad
Support `OneOf` in Xilem (#445)
This uses the interface in Xilem Core from #394 and #436

Some thoughts:
1) You only need to specify the number of items in a single match arm.
I.e.
    ```rust
    fn my_view(){
        match x {
            0 => OneOf3(...),
            1=> OneOf9(...),
            _=> OneOf9(...),
        }
    }
    ```
    works. We probably should rename `OneOf9` back again in that case.
2) The example currently isn't that interesting. Any suggestions for a
more suitable state machine would be welcome.
2024-07-24 09:12:04 +00:00
Philipp Mildenberger c53d15472c
xilem_web: Support `Fill` for `SvgPathElement` instead of `SvgmPathElement` (#447)
Fixes #446 

I guess I missed the m before the path
2024-07-24 09:02:26 +00:00
Daniel McNab 51e77f5577
Use the `boxed` combinator (#444)
This removes the need to force type inference.
2024-07-23 10:13:03 +00:00
Andrii Zymohliad 4ddad5129e
Expose control over window background color (#439)
Adds `Xilem::background_color` builder method and the relevant changes
to Masonry. I've also modified `mason` example to demonstrate the usage
of the new API.

[Zulip
discussion](https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/Window.20background.20color)
2024-07-23 09:37:14 +00:00
Daniel McNab f2ee836cab
Tweak `async_repeat` and add some docs (#443)
Addresses post-merge review comments in #423.

Also added some stub-like docs.

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
2024-07-22 13:17:54 +00:00
Olivier FAURE fc6a52265f
Use `cargo-rdme` to sync README and documentation root (#435)
This was remarkably painless.

I especially appreciate @taiki-e providing an install-action which does
90% of the CI work for us.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-07-22 12:44:41 +00:00
Bruce Mitchener d71db1a1bc
ci: Update typos action to 1.23.2 from 1.22.9 (#441) 2024-07-22 11:15:35 +00:00
Bruce Mitchener 05620779b2
xilem: Fix intradoc link. (#442) 2024-07-22 09:32:02 +00:00
Daniel McNab 5f38922d1b
Correctly set `rust-version` in all `Cargo.toml`s (#438)
Discovered in #432; this would otherwise cause errors for users of
nightly (or 1.81 beta, due to be released next week)
2024-07-19 14:42:27 +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 0844e3c431
Change the `OneOf` views to not use macros (#436)
This still needs to be implemented in Xilem.

But I think this is an improvement overall
2024-07-19 14:14:30 +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
Daniel McNab 36ac5a1826
Fix docs on the re-export (#434)
I failed to commit this before merging #423
2024-07-18 09:19:06 +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
Daniel McNab 732cfa8376
Move `text` into `reference` folder (#433)
This was imported in #241

See also [#masonry > text vs
text2](https://xi.zulipchat.com/#narrow/stream/317477-masonry/topic/text.20vs.20text2)

We do want to sort out text properly, see #337, so I'm keeping the
reference code around.
2024-07-18 07:05:11 +00:00
Daniel McNab 7a28babdd6
Allow Masonry to compile in release mode (#431)
Cc @xStrom for the CI change

Cc @PoignardAzur for the Masonry changes
2024-07-17 09:52:37 +00:00
Daniel McNab f913a3882b
Update to Vello 0.2.1 and wgpu 0.20.1 (#430)
Mostly to double check that the new release is suitable, but formalising
the update can't hurt
2024-07-17 07:42:20 +00:00
Bruce Mitchener b83a7ef41f
[masonry] Update to accesskit 0.16 (#426)
There was a breaking change in this release that renamed
`role::StaticText` to `role::Label`.
2024-07-16 08:18:51 +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
Markus Kohlhase 62c06c9f98
xilem_web: Add Elm Architecture example (#425)
I have intentionally left out the `xilem_core::adapt` variant here in
order to have a clear classic Elm example. I would rather show the
`adapt` variant in a separate example.
2024-07-12 11:39:37 +00:00