Add scoped overlay hosts

This commit is contained in:
iris committed 2026-09-10 18:49:03 -04:00
1 parent a33fbca966
commit 44a5da378b
14 files changed
+882 -27

No files matched your search

+30
View File
@@ -14,6 +14,10 @@ impl ControllerId {
pub fn host(self) -> WidgetId {
self.host
}
pub fn is<C: 'static>(self) -> bool {
self.kind == TypeId::of::<C>()
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -44,6 +48,10 @@ pub trait Controller<Rsc>: ControllerValue {
fn command(&mut self, _command: Command, _rsc: &mut Rsc) -> CommandResult {
CommandResult::Unused
}
fn blocks_prior_input(&self) -> bool {
false
}
}
pub struct ControllerManager<Rsc> {
@@ -206,6 +214,16 @@ impl<Rsc: 'static> ControllerManager<Rsc> {
self.command_target
}
pub fn command_target_blocks_input(&self) -> bool {
let Some(id) = self.command_target else {
return false;
};
self.by_widget
.get(&id.host)
.and_then(|controllers| controllers.get(&id.kind))
.is_some_and(|controller| controller.blocks_prior_input())
}
pub(crate) fn command_target_revision(&self) -> u64 {
self.command_target_revision
}
@@ -214,6 +232,18 @@ impl<Rsc: 'static> ControllerManager<Rsc> {
self.command_boundary
}
pub(crate) fn is_below(&self, mut widget: WidgetId, ancestor: WidgetId) -> bool {
loop {
let Some(parent) = self.parents.get(&widget).copied().flatten() else {
return false;
};
if parent == ancestor {
return true;
}
widget = parent;
}
}
pub(crate) fn set_command_boundary(&mut self, boundary: Option<WidgetId>) {
self.command_boundary = boundary;
}