Skip to content

Commit

Permalink
update visual transform of a widget when render transform changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Jun 8, 2024
1 parent 4cfc476 commit 6301799
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fyrox-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,11 @@ impl UserInterface {
}
}

fn update_visual_transform(&mut self) {
fn update_visual_transform(&mut self, from: Handle<UiNode>) {
scope_profile!();

self.stack.clear();
self.stack.push(self.root_canvas);
self.stack.push(from);
while let Some(node_handle) = self.stack.pop() {
let (widget, parent) = self
.nodes
Expand Down Expand Up @@ -1242,7 +1242,7 @@ impl UserInterface {
);

if self.need_update_global_transform {
self.update_visual_transform();
self.update_visual_transform(self.root_canvas);
self.need_update_global_transform = false;
}

Expand Down Expand Up @@ -1884,6 +1884,11 @@ impl UserInterface {
));
}
}
WidgetMessage::RenderTransform(_) => {
if self.nodes.is_valid_handle(message.destination()) {
self.update_visual_transform(message.destination());
}
}
WidgetMessage::AdjustPositionToFit => {
if self.nodes.is_valid_handle(message.destination()) {
let node = self.node(message.destination());
Expand Down Expand Up @@ -2958,7 +2963,7 @@ impl UserInterface {
pub fn resolve(&mut self) {
self.restore_dynamic_node_data();
self.restore_original_handles_and_inherit_properties(&[], |_, _| {});
self.update_visual_transform();
self.update_visual_transform(self.root_canvas);
self.update_global_visibility(self.root_canvas);
let instances = self.restore_integrity(|model, model_data, handle, dest_graph| {
model_data.copy_node_to(handle, dest_graph, &mut |_, original_handle, node| {
Expand Down

0 comments on commit 6301799

Please sign in to comment.