Commit Graph

213 Commits

Author SHA1 Message Date
Daniel McNab ee3126139f
Resolve mismatch between label width and alignment (#727)
If the alignment was set previously, and the `CrossAxisAlignment` was
not `Start`, the width Parley believed we were in wouldn't match the
width used for Masonry layout. This would lead to weird behaviour.

See the diff for the test images in
0a68159869
for more context
2024-11-06 11:31:46 +00:00
Kaur Kuut 419f8f115e
Match CI doc testing with docs.rs. (#726)
* Treat doc warnings as errors. Historically we've not done so due to
various `rustdoc` bugs giving false positives but I got it to pass
without failure right now, so perhaps better times have arrived.
* Target only `x86_64-unknown-linux-gnu` on docs.rs as we don't have any
platform specific docs.
* Properly enable example scraping for `xilem`, `xilem_core`, and
`masonry`. Fully disable it for `xilem_web` which does not have examples
as Cargo defines them.
* Pass `--all-features` at docs.rs to match our CI and reduce the
maintenance burden of manually syncing the features list.
* Enable the `doc_auto_cfg` feature for docs.rs which will show a little
tip next to feature gated functionality informing of the crate feature
flag.
* Replaced `[!TIP]` with `💡 Tip` that was inside `<div
class="rustdoc-hidden" />`. The GitHub specific tip causes a `rustdoc`
error and [didn't even render
properly](ac2ca38785/masonry/src/doc/01_creating_app.md).
* Updated `01_creating_app.md` just enough to get `rustdoc` to pass, but
that file needs a bunch of more work, as it is outdated.
2024-11-05 11:25:36 +00:00
Bruce Mitchener 1b804fbcd2
masonry: Export `UnitPoint` (#720)
This is needed for `Align::horizontal`, `Align::vertical`, etc.
2024-10-29 16:43:33 +00:00
Bruce Mitchener 231e304249
masonry example: Fix reference to `on_status_changed` (#719)
This is now just `update`.
2024-10-29 16:40:35 +00:00
Bruce Mitchener 0edce4f20f
masonry: Export `WindowSizePolicy` (#718)
This is a pub enum within `render_root` and is required for creating a
`RenderRootOptions` which is already exported. This is needed for people
embedding masonry in a non-Xilem way.
2024-10-29 13:56:40 +00:00
Olivier FAURE 30cb1e0b13
Tweak get_cursor code (#713)
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-10-23 14:37:45 +00:00
Olivier FAURE e03dfdd82b
Create skeleton of documentation (#632)
This is a very messy, very basic skeleton of what Masonry documentation
will eventually look like.

Main points are:

- Dedicated documentation modules.
- Re-using most of the language from the RFCs.

Next steps are:

- Flesh out the Widget documentation.
- Rewrite all those docs in a less placeholder-y way.
- Add chapter about the widget arena.
- Spread out that pass documentation to the respective pass files.
- Rewrite ARCHITECTURE.md.
- Add screenshots.

Fixes #376 and #389.

---------

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
2024-10-22 13:49:43 +00:00
Olivier FAURE 30dba40300
Remove `WidgetState::Cursor` (#710) 2024-10-22 13:41:13 +00:00
Olivier FAURE f322894e50
Replace WidgetMut methods with free functions. (#705)
See discussion here https://github.com/linebender/xilem/pull/663 and [on
zulip](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Improving.20docs.20for.20WidgetMut).

Basically, previous code was using `WidgetMut<MyWidget>` as a receiver.
This can be done when WidgetMut is a local type, but external users
wouldn't be able to do it. The result would be that users importing
Masonry as a dependency but copy-pasting code from one of our widgets
would get compile errors.

This PR switches to a syntax that external crates will be able to use
when declaring widgets. It's a more verbose, less readable syntax, but
it's unambiguous and doesn't require clever tricks.

We can consider switching back to WidgetMut-as-a-receiver when
`#![feature(arbitrary_self_types)]` or some equivalent gets stabilized.
See
https://github.com/rust-lang/rust/issues/44874#issuecomment-2122179688
for current progress.
2024-10-22 13:36:48 +00:00
Olivier FAURE 9c397da91f
Document and clean up WidgetState (#707) 2024-10-22 09:24:39 +00:00
Olivier FAURE 8342c7ec12
Streamline giving ids to TreeArena methods (#709) 2024-10-21 14:24:18 +00:00
Daniel McNab e3c38e1d76
Give actionable suggestions for implementing `on_anim_frame` (#702)
Users could easily run into difficulties where animation does not work
as expected, with no obvious hints for how to debug this. Documenting
the correct usage of `on_anim_frame` should help them.
2024-10-21 13:16:49 +00:00
Daniel McNab 03245d0080
Refactor tracing handling for events (#688)
Inspired by #687, I thought some more tidying up of the log file was in
order.

The main differences are:
1) Higher-scale spans exist for key operations
2) Something is always logged for each event, but less for high-density
eventskey
3) Less is logged for high-density events
4) Key repeats are no longer treated as high density
5) We no longer do extra work if the hover and focus paths haven't
changed (which also means less logging)

This PR *does not* depend on #687
2024-10-21 13:11:24 +00:00
Olivier FAURE 6f111233d7
Add comment in accessibility pass (#704) 2024-10-21 12:23:18 +00:00
Olivier FAURE ed5c141701
Reorganize top-level Masonry modules (#703) 2024-10-21 12:18:30 +00:00
Olivier FAURE 7fef215fb0
Update test-related documentation (#698) 2024-10-21 10:05:32 +00:00
Daniel McNab 38415d65ca
Don't use full tracing spans in full-tree passes by default (#687)
This can be toggled using the `MASONRY_TRACE_PASSES` environment
variable.

This is as-discussed in [#xilem > Scrolling is insanely
laggy](https://xi.zulipchat.com/#narrow/channel/354396-xilem/topic/Scrolling.20is.20insanely.20laggy).
There are a few overlapping issues, but this *significantly* improves
performance in debug mode.

The main pass which was problematic was the compose pass, however this
also had a significant impact on the time taken by the
accessibility/paint passes.

This only applies to the passes which traverse the entire tree, so not
the targeted passes. I also chose to exclude update_disabled and
update_stashed, as those will not necessarily happen to all widgets.

This also significantly reduces the size of the created log files - see
[#masonry > Heavy amounts of logs with large
app](https://xi.zulipchat.com/#narrow/channel/317477-masonry/topic/Heavy.20amounts.20of.20logs.20with.20large.20app).
In most cases, if you're using the log file, you will be in development,
which means that you can hopefully recreate the issue with the logging
for the passes you need enabled.
2024-10-21 09:51:34 +00:00
Olivier FAURE 4d20e0dd19
Merge StatusChange with Update (#697) 2024-10-20 17:15:18 +00:00
Olivier FAURE f403337219
Implement fixpoint loop in run_rewrite_passes (#696)
This implements the last feature from the Pass Specification RFC 🎉
2024-10-20 17:12:18 +00:00
Olivier FAURE 40d1987161
Make passes that affect accesskit nodes request an accessibility pass (#692) 2024-10-20 16:38:14 +00:00
Olivier FAURE d5f28ba2de
Refactor away some redundant methods in RenderRoot (#694) 2024-10-20 16:01:56 +00:00
Philipp Mildenberger 4817f24e86
Clippy pass, cosmetic fixes, and `rust-version.workspace=true` for web examples (#689)
Phew, fixing (future) clippy-lints is grunt-work (I enabled
`unnameable_types` for this), this is by far not complete, mostly
xilem-side, but at least a small step towards enabling more of our lint
set.

There's a few "drive-by fixes" like hiding `View::ViewState` types in
Xilem (I don't think we generally want to expose these), or exposing
event types in xilem_web.

I would suggest disabling the `allow_attributes_without_reason` lint for
now, so that we can update the rust version. I feel like adding comments
next to these is just unnecessary extra-work. I think adding more
reasons should probably be a separate pass, after a rust version update,
so that `#[allow(..., reason="")]` is supported.
2024-10-20 15:57:22 +00:00
Olivier FAURE 9ccc0f9e59
Remove bitrotted comment (#695)
See discussion in #666
2024-10-20 15:11:44 +00:00
Olivier FAURE 7f0ccb8c1f
Tweak comment on anim method (#693) 2024-10-20 15:05:06 +00:00
Olivier FAURE 3d8c7950e4
Reorder imports across project (#690)
Split off from #637.
2024-10-20 14:54:13 +00:00
Olivier FAURE ef5d9afec3
Rename `RenderRoot::state` to `global_state` (#691) 2024-10-20 14:46:46 +00:00
Daniel McNab 2832766eff
Remove the dead `links` field from TextLayout (#686)
cc for awareness @mwcampbell.

That field was dead code left behind when we removed previous links
support. On that struct is probably not the right field for links to
live, since `Label` also uses `TextLayout`, but can't meaningfully
support links as part of a different interactive widget.
2024-10-18 12:41:31 +00:00
Daniel McNab 86604b7a74
Remove potential interactivity from `Label` (#683)
The whole reason the Label widget exists is as a non-interactive text
holder for higher-level widgets. Therefore, it isn't meaningful for it
to have interactivity.
2024-10-18 09:53:54 +00:00
Olivier FAURE d01652ddc7
Create on_anim method (#678)
This marks animation as something that's somewhere between an event
(it's triggered externally, it can't be requested synchronously as part
of rewrite passes) and an update (it takes the same context type, and
isn't tied to a user interaction).
2024-10-17 12:42:46 +00:00
Olivier FAURE dc9a2e2a97
Rename lifecycle to update (#677) 2024-10-17 12:09:14 +00:00
Olivier FAURE cdda9b542d
Only send ImeMoved signal for focused text input (#684) 2024-10-17 12:06:28 +00:00
Olivier FAURE f4848ce937
Add missing_trait_methods lints to test helper widgets (#679) 2024-10-17 12:01:39 +00:00
Olivier FAURE 3ba0df6064
Reorder update passes (#674)
Reorder update passes so their code is in the same order as they're run.
Split out anim pass to a separate file (since it's not run with the
other passes).
This is strictly cut-and-paste, no code has been changed.
2024-10-16 16:44:30 +00:00
Olivier FAURE 17f5f24ff3
Remove debug_validate method (#676)
I'm pretty sure this method never caught a single bug.

I think the idea of a "safety net" that checks invariants are upheld by
passes (without trusting pass code) has merit, but it should be based on
a survey of previous bugs in pass code.
2024-10-16 15:21:14 +00:00
Olivier FAURE 1258a258cd
Rename pass functions from root_xxx to run_xxx_pass (#675)
This means all the pass functions now have the same naming convention,
which makes the code more grep-able.
2024-10-16 13:53:39 +00:00
Matt Campbell c73beee706
Accessibility for text (#615)
This adds the necessary AccessKit properties and child nodes to expose
detailed information about text widgets. It also supports the
`SetTextSelection` action.

---------

Co-authored-by: Olivier FAURE <couteaubleu@gmail.com>
2024-10-16 13:03:17 +00:00
Olivier FAURE f4a8b47587
Refactor safety rails for layout pass (#644)
Merge call_widget_method_with_checks, run_layout_inner and
run_layout_on.
Remove needs_visit flag.
Add checks for invalid values in place_child, set_child_translation and
run_layout.

---------

Co-authored-by: jaredoconnell <jared.oc321@gmail.com>
2024-10-15 16:25:46 +00:00
Olivier FAURE 9a6178b3d4
Add request_render context method (#660)
Remove some redundant request_paint calls

Fixes #585.
2024-10-15 16:18:47 +00:00
Olivier FAURE 1aab06ad52
Stop storing text in TextLayout (#666)
Remove type parameter from TextLayout.
Tweak error message in text widgets.

This makes the TextLayout code slightly simpler (though with more
invariants) in anticipation of splitting it into its own crate.
2024-10-15 16:09:53 +00:00
Olivier FAURE 6f8e3824fc
Handle signals in TestHarness (#650) 2024-10-15 16:08:08 +00:00
Bruce Mitchener cc32727e9d
docs: Fix some missing backticks. (#672) 2024-10-15 09:26:27 +00:00
Marco Melorio 634afd7010
Expose font weight parameter in label widget (#669) 2024-10-14 17:01:53 +00:00
Marco Melorio d74a7deea1
Update to Kurbo 0.11.1 (#671)
This allows to remove a TODO comment.
2024-10-14 16:27:40 +00:00
Olivier FAURE 4ad4506bc0
Remove register methods (#636)
Replace with `Widget::accepts_xxx()` methods
Tweak accessibility code
Remove `BuildFocusChain` event

Remove `WidgetState::is_portal`, `register_as_portal()`, and overall
remove the idea of a first-class "portal" concept.
2024-10-13 01:22:20 +00:00
Olivier FAURE a26bf11119
Add target field to EventCtx (#657)
Remove target field from AccessEvent
2024-10-13 01:21:52 +00:00
Olivier FAURE 76c808b454
Refactor rewrite passes (#639)
Create run_rewrite_passes function.
Remove redundant uses of synthetic WidgetState.
Small bugfixes.
Move RenderRoot::root_layout code into the layout pass. Rename
update_new_widgets pass to update_widget_tree.
2024-10-12 14:37:49 +00:00
Olivier FAURE 9899a700c7
Add needs_rewrite_passes and content_changed methods (#658)
These methods will be used with #639 to implement a fixpoint loop for
rewrite passes.

This also lets us remove `mark_changed`, since we can use
`content_changed` for the same purpose.
2024-10-12 13:33:55 +00:00
Olivier FAURE 72c1bd983d
Refactor Blur case of on_access_event pass (#643)
Match how tab focus works in on_text_event pass.
2024-10-11 13:45:22 +00:00
Olivier FAURE da92ba6cf0
Add TestHarness::animate_ms method (#661) 2024-10-09 14:01:28 +00:00
Olivier FAURE 6589ac343d
Remove masonry/src/text/reference (#665)
I'm pretty sure no-one has consulted these files in months. They're dead
code, and there's always source control if someone really needs them.
2024-10-09 13:23:27 +00:00