improv: PreOperation for tracking children in selections

This commit is contained in:
Ashley Wulber 2026-09-04 14:31:46 -04:00 • committed by Ashley Wulber
parent 880f2c7565
commit 2e12eba5cd
5 changed files with 49 additions and 1 deletions

View file

@ -78,6 +78,9 @@ pub trait Operation<T = ()>: Send {
/// Track the active window id being processed if relevant to the operation
fn set_window_id(&mut self, _id: window::Id) {}
/// Used to mark the beginning of operations for a widget and its children
fn pre_operation(&mut self, _id: Option<&Id>) {}
}
impl<T, O> Operation<O> for Box<T>
@ -147,6 +150,10 @@ where
fn set_window_id(&mut self, id: window::Id) {
self.as_mut().set_window_id(id);
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.as_mut().pre_operation(id);
}
}
/// The result of an [`Operation`].
@ -251,6 +258,10 @@ where
Outcome::None
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.operation.pre_operation(id);
}
fn set_window_id(&mut self, id: window::Id) {
self.operation.set_window_id(id);
}
@ -352,6 +363,10 @@ where
) {
self.operation.custom(id, bounds, state);
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.operation.pre_operation(id);
}
}
self.operation.traverse(&mut |operation| {
@ -425,6 +440,10 @@ where
fn set_window_id(&mut self, id: window::Id) {
self.operation.set_window_id(id);
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.operation.pre_operation(id);
}
}
Map {
@ -534,6 +553,10 @@ where
fn set_window_id(&mut self, id: window::Id) {
self.operation.set_window_id(id);
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.operation.pre_operation(id);
}
}
Chain {
@ -586,6 +609,10 @@ pub fn scoped<T: 'static>(
}
}
fn pre_operation(&mut self, id: Option<&Id>) {
self.operation.pre_operation(id);
}
fn set_window_id(&mut self, id: window::Id) {
self.operation.set_window_id(id);
}