M0.9–M0.10: egui frontend (AE-style panels, viewer, timeline, effect controls, dialogs), desktop app with control channel, host wiring; cargo fmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e2ba01a11f
commit
3a59a8470d
@@ -0,0 +1,36 @@
|
||||
//! Automation registry: every interactive element registers a stable id and its screen rect each
|
||||
//! frame, so agents can click/drag by id (`ui.click {id:"timeline.track.V1.lock"}`) and
|
||||
//! `ui.inspect` can report the full on-screen widget tree.
|
||||
|
||||
use egui::Rect;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct Element {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
pub rect: [f32; 4],
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Registry {
|
||||
pub elements: Vec<Element>,
|
||||
/// Last frame's elements (for lookups from control handlers between frames).
|
||||
pub previous: Vec<Element>,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
pub fn add(&mut self, id: &str, rect: Rect, label: &str) {
|
||||
self.elements.push(Element { id: id.to_string(), label: label.to_string(), rect: [rect.min.x, rect.min.y, rect.width(), rect.height()] });
|
||||
}
|
||||
pub fn begin_frame(&mut self) {
|
||||
self.previous = std::mem::take(&mut self.elements);
|
||||
}
|
||||
pub fn find(&self, id: &str) -> Option<&Element> {
|
||||
self.previous.iter().chain(self.elements.iter()).find(|e| e.id == id)
|
||||
}
|
||||
/// Elements whose id starts with a prefix.
|
||||
pub fn query(&self, prefix: &str) -> Vec<&Element> {
|
||||
self.previous.iter().filter(|e| e.id.starts_with(prefix)).collect()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user