diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs index 45e14b11..93107c07 100644 --- a/crates/ui-egui/src/browser.rs +++ b/crates/ui-egui/src/browser.rs @@ -281,6 +281,7 @@ fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp { }; ui.painter().add(egui::Shape::convex_polygon(pts, t.text_dim, Stroke::NONE)); out.fold = ui.interact(ar.expand(3.0), id.with("fold"), Sense::click()).clicked(); + crate::scenario::publish_handle(&format!("fold:{}", row.label), ar.center()); } x += 14.0; // Eye. @@ -322,6 +323,7 @@ fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp { badge(ui.painter(), br, b, t.text_dim); bx += 15.0; } + crate::scenario::publish_handle(&format!("row:{}", row.label), r.center()); out.resp = Some(resp.clone()); out.clicked = resp.clicked(); out.double = resp.double_clicked(); diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 8613bfff..d5233296 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -264,6 +264,12 @@ pub fn handle(app: &mut SolveApp, ctx: &egui::Context, req: &ControlRequest) -> }; } let Some(rect) = app.viewport.rect else { return err("no viewport") }; + if let Some(c) = p.get("cube") { + // A point on the view cube, in cube units (faces at ±1). + let n = |i: usize| c.get(i).and_then(Value::as_f64).unwrap_or(0.0); + let q = crate::viewport::cube_point(app, rect, solvecraft_engine::geom::Vec3::new(n(0), n(1), n(2))); + return ok(json!([q.x, q.y])); + } let proj = crate::viewport::projection(app, rect); let num = |v: &Value, i: usize| v.get(i).and_then(Value::as_f64).unwrap_or(0.0); let world = if let Some(w) = p.get("world") { diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs index 0b3c6851..f1128b1c 100644 --- a/crates/ui-egui/src/scenario.rs +++ b/crates/ui-egui/src/scenario.rs @@ -16,7 +16,10 @@ //! folder (Save pickers save there) //! - `{"shot": "name"}`: a screenshot when run in a window; headless, a render of the model //! into `$SOLVECRAFT_SCENARIO_SHOTS` when that is set; `{"debug": 1}` -//! prints the UI state +//! prints the UI state (`"widgets"`: also every widget's text; `"handles"`: every published +//! handle, browser rows as `row: