Skip to content

Commit

Permalink
Expose transform_has_changed and use that instead
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Jan 17, 2025
1 parent c34e5bf commit 93ce171
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 9 additions & 0 deletions masonry/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ impl MutateCtx<'_> {
widget_children: self.widget_children.reborrow_mut(),
}
}

/// Whether the (local) transform of this widget has been modified since
/// the last time this widget's transformation was resolved.
///
/// This is exposed for Xilem, and is more likely to change or be removed
/// in major releases of Masonry.
pub fn transform_has_changed(&self) -> bool {
self.widget_state.transform_changed
}
}

// --- MARK: WIDGET_REF ---
Expand Down
6 changes: 2 additions & 4 deletions xilem/src/view/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,14 @@ where
ctx: &mut ViewCtx,
mut element: xilem_core::Mut<'_, Self::Element>,
) {
let initial_transform = element.ctx.transform();
self.child.rebuild(
&prev.child,
&mut view_state.child,
ctx,
element.reborrow_mut(),
);
let transform_changed = element.ctx.transform() != initial_transform;
// We detect a child view changing the transform by comparing the
// resulting transform before and after the child view runs.
let transform_changed = element.ctx.transform_has_changed();
// If the child view changed the transform, we know we're out of date.
if transform_changed {
// If it has changed the transform, then we know that it will only be due to effects
// "below us" (that is, it will have restarted from scratch).
Expand Down

0 comments on commit 93ce171

Please sign in to comment.