masonry: allow swapping tree-wide default properties at runtime#1821
Open
mark-ik wants to merge 1 commit into
Open
masonry: allow swapping tree-wide default properties at runtime#1821mark-ik wants to merge 1 commit into
mark-ik wants to merge 1 commit into
Conversation
mark-ik
commented
May 30, 2026
Contributor
Nice. |
PoignardAzur
approved these changes
May 30, 2026
PoignardAzur
requested changes
May 30, 2026
3022aa0 to
e6987c5
Compare
Author
|
Ok, comment block truncated, and |
`DefaultProperties` is fixed at construction, so a host that wants to re-theme a running app (e.g. a light/dark toggle re-coloring widgets that rely on default `ContentColor` / `Background`) cannot do so today without rebuilding. Add `RenderRoot::set_default_properties`, which swaps the arena's default set and re-runs the update-properties pass over the whole tree: it marks every widget and invalidates each property cache, so the pass re-fires `Widget::property_changed` for every cached property. Each widget's handler (with the built-in `core_property_changed`) then requests whatever paint or layout that property needs. A defaults swap does not change a defaulted property's resolved stack index (only its fallback value), so the cache invalidation is what forces the per-entry re-fire. Also adds a `TestHarness::set_default_properties` passthrough and a test that seeds a cached `ContentColor` read, swaps defaults, and asserts `property_changed` re-fires for the cached type. The test fails against the bare-repaint version, so it guards the propagation invariant. Signed-off-by: Markik <54276851+mark-ik@users.noreply.github.com>
e6987c5 to
d457d22
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Touches
masonry_core(the method),masonry_testing(a one-lineTestHarness::set_default_propertiespassthrough for the test), andmasonry(the test).Background
DefaultPropertiesis fixed at construction, so a host that wants to re-theme a running app (e.g. a light/dark theme toggle re-coloring widgets that rely on defaultContentColor/Background) cannot do so today without restarting.Fix
This PR adds
RenderRoot::set_default_properties, which swaps the arena's default properties. It iterates over the tree flagging every widget and invalidating each property cache so the update-props pass re-firesWidget::property_changed. Each widget's handler (with the built-incore_property_changed) then requests whatever paint or layout that property needs.A defaults swap does not change a defaulted property's resolved stack index (only its fallback value); the cache invalidation is what triggers the per-entry re-fire of
property_changed.Testing
Also adds a
TestHarness::set_default_propertiespassthrough and a test (set_default_properties_refires_property_changedin masonry/src/tests/update.rs) that (1) seeds a cachedContentColorread, (2) swaps defaults, and (3) assertsproperty_changedre-fires for the cached type. The test fails against the fluke fix I made earlier (in issue #1819).Disclosure: AI-assisted; my responsibility.
Relevant issues:
#1819: closes
#1765: related, leaves
background_color(), system light/dark detection, and the per-widget override API to that issue.#1786: related, leaves per-widget-type styling for later.