DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
UI: match measured InDesign 2026 chrome (Medium Dark palette, native macOS menu bar, 43 pt app bar, dock layout, rulers, status bar, tools metrics, hairline guides, handles/ports)
Brandon Thomasa7b9a31fc589
diff --git a/Cargo.lock b/Cargo.lockindex c87dd85c8..048b65dd6 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -757,6 +757,7 @@ dependencies = ["eframe","egui","log",+ "muda","rfd","serde_json",]@@ -1734,6 +1735,16 @@ dependencies = ["wasm-bindgen",]+[[package]]+name = "keyboard-types"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0fbe853b403ae61a04233030ae8a79d94975281ed9770a1f9e246732b534b28d"+dependencies = [+ "bitflags 2.13.2",+ "serde",+]+[[package]]name = "khronos-egl"version = "6.0.0"@@ -1891,6 +1902,25 @@ dependencies = ["pxfm",]+[[package]]+name = "muda"+version = "0.21.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6744ab645ebe79f9c428455c7cb9dfa4275fa3b50a25408e08f927da8dc618c"+dependencies = [+ "crossbeam-channel",+ "dpi",+ "keyboard-types",+ "objc2 0.6.4",+ "objc2-app-kit 0.3.2",+ "objc2-core-foundation",+ "objc2-foundation 0.3.2",+ "once_cell",+ "png",+ "thiserror 2.0.21",+ "windows-sys 0.61.2",+]+[[package]]name = "naga"version = "30.0.1"diff --git a/apps/designcraft/Cargo.toml b/apps/designcraft/Cargo.tomlindex 12f455e70..d5c41d74a 100644--- a/apps/designcraft/Cargo.toml+++ b/apps/designcraft/Cargo.toml@@ -19,3 +19,6 @@ log = { workspace = true }[target.'cfg(not(target_arch = "wasm32"))'.dependencies]rfd = { workspace = true }++[target.'cfg(target_os = "macos")'.dependencies]+muda = { version = "0.21", default-features = false }diff --git a/apps/designcraft/src/main.rs b/apps/designcraft/src/main.rsindex e1c2508f5..e09b425be 100644--- a/apps/designcraft/src/main.rs+++ b/apps/designcraft/src/main.rs@@ -7,14 +7,25 @@//! See `designcraft_ui_egui::control` for the methods.mod control_server;+#[cfg(target_os = "macos")]+mod native_menu;use designcraft_engine::Session;use designcraft_ui_egui::{DesignApp, Services};-struct App(DesignApp);+struct App(DesignApp, #[cfg(target_os = "macos")] Option<native_menu::NativeMenu>);impl eframe::App for App {fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {+ #[cfg(target_os = "macos")]+ {+ if self.1.is_none() && std::env::var_os("DESIGNCRAFT_NO_NATIVE_MENU").is_none() {+ self.1 = Some(native_menu::NativeMenu::install(&mut self.0));+ }+ if let Some(m) = &mut self.1 {+ m.poll(&mut self.0);+ }+ }self.0.logic(ctx);}fn raw_input_hook(&mut self, _ctx: &egui::Context, raw: &mut egui::RawInput) {@@ -129,7 +140,11 @@ fn main() -> eframe::Result {eprintln!("designcraft: {f}: {e}");}}- Ok(Box::new(App(app)))+ Ok(Box::new(App(+ app,+ #[cfg(target_os = "macos")]+ None,+ )))}),)}diff --git a/apps/designcraft/src/native_menu.rs b/apps/designcraft/src/native_menu.rsnew file mode 100644index 000000000..ceb96c3ab--- /dev/null+++ b/apps/designcraft/src/native_menu.rs@@ -0,0 +1,125 @@+//! macOS: DesignCraft's menu tree as the native system menu bar (like InDesign on the Mac).+//! Items dispatch through the same command path as the in-window menus; enablement and check+//! marks are refreshed a few times per second.++use std::collections::HashMap;+use std::str::FromStr;++use designcraft_ui_egui::DesignApp;+use designcraft_ui_egui::menus::{self, Item};+use muda::accelerator::Accelerator;+use muda::{AboutMetadata, CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};+use serde_json::Value;++enum Handle {+ Plain(MenuItem),+ Check(CheckMenuItem),+}++pub struct NativeMenu {+ _menu: Menu,+ items: HashMap<String, (String, Value, Handle)>,+ last_refresh: f64,+}++/// Accelerator for "Cmd+Shift+]" (modifier-less shortcuts stay in the app so typing works).+fn accel(sc: &str) -> Option<Accelerator> {+ if !(sc.contains("Cmd") || sc.contains("Ctrl") || sc.contains("Alt")) {+ return None;+ }+ Accelerator::from_str(&sc.replace("Cmd", "CMD").replace("Alt", "ALT").replace("Shift", "SHIFT").replace("Ctrl", "CTRL")).ok()+}++impl NativeMenu {+ pub fn install(app: &mut DesignApp) -> Self {+ let menu = Menu::new();+ let mut items = HashMap::new();+ let mut counter = 0usize;+ // Application menu.+ let app_menu = Submenu::new("DesignCraft", true);+ let _ = app_menu.append_items(&[+ &PredefinedMenuItem::about(+ None,+ Some(AboutMetadata { name: Some("DesignCraft".into()), version: Some(env!("CARGO_PKG_VERSION").into()), ..Default::default() }),+ ),+ &PredefinedMenuItem::separator(),+ &PredefinedMenuItem::services(None),+ &PredefinedMenuItem::separator(),+ &PredefinedMenuItem::hide(None),+ &PredefinedMenuItem::hide_others(None),+ &PredefinedMenuItem::show_all(None),+ &PredefinedMenuItem::separator(),+ &PredefinedMenuItem::quit(None),+ ]);+ let _ = menu.append(&app_menu);+ for (title, entries) in menus::menu_tree() {+ let sub = Submenu::new(title, true);+ build(app, &sub, &entries, &mut items, &mut counter);+ let _ = menu.append(&sub);+ }+ menu.init_for_nsapp();+ app.native_menu = true;+ app.native_shortcuts = items+ .values()+ .filter_map(|(id, p, _)| {+ let sc = menus::ui_label(id).and_then(|(_, sc)| sc).or_else(|| designcraft_engine::find_command(id).and_then(|c| c.shortcut))?;+ (p.is_null() && accel(sc).is_some()).then(|| id.clone())+ })+ .collect();+ Self { _menu: menu, items, last_refresh: 0.0 }+ }++ pub fn poll(&mut self, app: &mut DesignApp) {+ while let Ok(ev) = MenuEvent::receiver().try_recv() {+ if let Some((cmd, params, _)) = self.items.get(ev.id.as_ref()) {+ let p = if params.is_null() { serde_json::json!({}) } else { params.clone() };+ let _ = app.run(cmd, p);+ }+ }+ let now = designcraft_ui_egui::now_ms();+ if now - self.last_refresh < 250.0 {+ return;+ }+ self.last_refresh = now;+ for (cmd, params, h) in self.items.values() {+ let en = menus::menu_enabled(app, cmd);+ match h {+ Handle::Plain(i) => i.set_enabled(en),+ Handle::Check(c) => {+ c.set_enabled(en);+ c.set_checked(menus::checked(app, cmd, params).unwrap_or(false));+ }+ }+ }+ }+}++fn build(app: &DesignApp, parent: &Submenu, entries: &[Item], items: &mut HashMap<String, (String, Value, Handle)>, counter: &mut usize) {+ for e in entries {+ match e {+ Item::Sep => {+ let _ = parent.append(&PredefinedMenuItem::separator());+ }+ Item::Sub(label, children) => {+ let sub = Submenu::new(label, true);+ build(app, &sub, children, items, counter);+ let _ = parent.append(&sub);+ }+ Item::Cmd { label, id, params, shortcut } => {+ *counter += 1;+ let mid = format!("dc{counter}");+ let sc = if params.is_null() { shortcut.and_then(accel) } else { None };+ let handle = if menus::checked(app, id, params).is_some() {+ let c = CheckMenuItem::with_id(mid.clone(), label, true, false, sc);+ let _ = parent.append(&c);+ Handle::Check(c)+ } else {+ let i = MenuItem::with_id(mid.clone(), label, true, sc);+ let _ = parent.append(&i);+ Handle::Plain(i)+ };+ items.insert(mid, (id.clone(), params.clone(), handle));+ }+ }+ }+}diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rsindex 1bc22820f..337e5cb08 100644--- a/crates/doc/src/lib.rs+++ b/crates/doc/src/lib.rs@@ -142,10 +142,10 @@ impl Default for DocSettings {baseline_grid: BaselineGrid::default(),grid: DocumentGrid::default(),pasteboard: (72.0, 72.0),- margin_color: [255, 0, 255],- column_color: [148, 112, 255],- bleed_color: [255, 0, 0],- slug_color: [60, 120, 255],+ margin_color: [255, 56, 255],+ column_color: [166, 40, 255],+ bleed_color: [255, 72, 103],+ slug_color: [100, 188, 221],keyboard_increment: 1.0,}}@@ -176,7 +176,7 @@ fn yes() -> bool {/// InDesign's layer colour sequence (names are the conventional colour names).pub const LAYER_COLORS: &[(&str, [u8; 3])] = &[- ("Light Blue", [79, 153, 255]),+ ("Light Blue", [43, 155, 255]),("Red", [255, 0, 0]),("Green", [79, 255, 79]),("Blue", [0, 0, 255]),diff --git a/crates/tools/src/catalog.rs b/crates/tools/src/catalog.rsindex 6b153f064..be36947cf 100644--- a/crates/tools/src/catalog.rs+++ b/crates/tools/src/catalog.rs@@ -54,6 +54,7 @@ pub const TOOL_GROUPS: &[&[ToolInfo]] = &[t("ellipse", "Ellipse Tool", Some("L"), "tool-ellipse"),t("polygon", "Polygon Tool", None, "tool-polygon"),],+ &[],&[t("scissors", "Scissors Tool", Some("C"), "tool-scissors")],&[t("freeTransform", "Free Transform Tool", Some("E"), "tool-free-transform"),@@ -65,6 +66,7 @@ pub const TOOL_GROUPS: &[&[ToolInfo]] = &[t("gradientSwatch", "Gradient Swatch Tool", Some("G"), "tool-gradient"),t("gradientFeather", "Gradient Feather Tool", Some("Shift+G"), "tool-gradient-feather"),],+ &[],&[t("note", "Note Tool", None, "tool-note")],&[t("colorTheme", "Color Theme Tool", Some("Shift+I"), "tool-color-theme"),diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 1939ea4e2..f4e9307c1 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -11,7 +11,7 @@ use serde_json::{Value, json};use crate::{DesignApp, ScreenMode, View, theme::Tokens};-pub const RULER: f32 = 17.0;+pub const RULER: f32 = 15.0;/// Canvas ↔ screen transform.#[derive(Clone, Copy, Debug)]@@ -170,10 +170,10 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {let preview = matches!(app.ui.screen_mode, ScreenMode::Preview | ScreenMode::Presentation);let bg = if app.ui.screen_mode == ScreenMode::Presentation { Color32::BLACK } else { t.pasteboard };painter.rect_filled(rect, 0.0, bg);- // Page shadows.+ // Page shadow: a hard 1.5 pt black offset on the right and bottom (InDesign 2026).for slot in &layout.slots {let r = xf.rect(slot.bounds);- painter.rect_filled(r.translate(vec2(3.0, 3.0)), 0.0, Color32::from_black_alpha(110));+ painter.rect_filled(r.translate(vec2(1.5, 1.5)), 0.0, Color32::BLACK);}// Rendered content.render_texture(app, ui.ctx(), rect, &xf, &layout, preview);@@ -193,6 +193,10 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {painter.image(tex.id(), rect, uv, Color32::WHITE);}}+ let hair = 1.0 / ui.ctx().pixels_per_point();+ for slot in &layout.slots {+ painter.rect_stroke(xf.rect(slot.bounds), 0.0, Stroke::new(hair, Color32::from_rgb(0x4a, 0x4a, 0x4a)), StrokeKind::Outside);+ }if !preview {draw_guides(app, &painter, &xf, &doc, &layout, &t);draw_frames(app, &painter, &xf, &doc, &layout);@@ -279,7 +283,7 @@ fn draw_guides(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documentlet r = if last.side == PageSide::Right || last.side == PageSide::Single { b[3] } else { b[2] };let sb = sp.bounds() + off;let br = DRect::new(sb.x0 - l, sb.y0 - b[0], sb.x1 + r, sb.y1 + b[1]);- painter.rect_stroke(xf.rect(br), 0.0, Stroke::new(1.0, c32(s.bleed_color)), StrokeKind::Middle);+ painter.rect_stroke(xf.rect(br), 0.0, Stroke::new(hair(painter), c32(s.bleed_color)), StrokeKind::Middle);}for p in &sp.pages {let pr = p.bounds() + off;@@ -293,18 +297,18 @@ fn draw_guides(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documentwhile y < p.height {let a = xf.to_screen(Point::new(pr.x0, pr.y0 + y));let bb = xf.to_screen(Point::new(pr.x1, pr.y0 + y));- painter.line_segment([a, bb], Stroke::new(1.0, c32(g.color).gamma_multiply(0.8)));+ painter.line_segment([a, bb], Stroke::new(hair(painter), c32(g.color).gamma_multiply(0.8)));y += g.increment.max(1.0);}}// Margins (magenta) and columns (violet).let m = p.margin_rect() + off;- painter.rect_stroke(xf.rect(m), 0.0, Stroke::new(1.0, c32(s.margin_color)), StrokeKind::Middle);+ painter.rect_stroke(xf.rect(m), 0.0, Stroke::new(hair(painter), c32(s.margin_color)), StrokeKind::Middle);let cols = p.column_rects();if cols.len() > 1 {for (i, c) in cols.iter().enumerate() {let c = *c + off;- let col = Stroke::new(1.0, c32(s.column_color));+ let col = Stroke::new(hair(painter), c32(s.column_color));if i > 0 {painter.line_segment([xf.to_screen(Point::new(c.x0, c.y0)), xf.to_screen(Point::new(c.x0, c.y1))], col);}@@ -318,7 +322,7 @@ fn draw_guides(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documentdesigncraft_doc::Orientation::Horizontal => (Point::new(pr.x0, g.position + off.y), Point::new(pr.x1, g.position + off.y)),designcraft_doc::Orientation::Vertical => (Point::new(g.position + off.x, pr.y0), Point::new(g.position + off.x, pr.y1)),};- painter.line_segment([xf.to_screen(a), xf.to_screen(bb)], Stroke::new(1.0, Color32::from_rgb(74, 227, 255)));+ painter.line_segment([xf.to_screen(a), xf.to_screen(bb)], Stroke::new(hair(painter), Color32::from_rgb(74, 227, 255)));}}}@@ -383,7 +387,7 @@ fn draw_frames(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documentlet col = doc.layer(it.layer).map(|l| c32(l.color)).unwrap_or(Color32::LIGHT_BLUE);for poly in path_screen(it, xf, a * Affine::translate((dx, 0.0))) {for w in poly.windows(2) {- dashed(painter, w[0], w[1], Stroke::new(1.0, col.gamma_multiply(0.8)), 2.0, 2.0);+ dashed(painter, w[0], w[1], Stroke::new(hair(painter), col.gamma_multiply(0.8)), 2.0, 2.0);}}}@@ -410,7 +414,7 @@ fn draw_item_edges(painter: &egui::Painter, xf: &Xf, doc: &Document, it: &Item,let show = it.stroke.is_none() || matches!(it.content, Content::Text(_) | Content::Graphic(_));if show {for poly in path_screen(it, xf, a) {- painter.add(egui::Shape::line(poly, Stroke::new(1.0, col.gamma_multiply(0.75))));+ painter.add(egui::Shape::line(poly, Stroke::new(hair(painter), col.gamma_multiply(0.75))));}}// Empty graphic frame: the X.@@ -418,8 +422,8 @@ fn draw_item_edges(painter: &egui::Painter, xf: &Xf, doc: &Document, it: &Item,let r = it.inner_bounds();let m = a * it.xf;let p = |x: f64, y: f64| xf.to_screen(m * Point::new(x, y));- painter.line_segment([p(r.x0, r.y0), p(r.x1, r.y1)], Stroke::new(1.0, col.gamma_multiply(0.75)));- painter.line_segment([p(r.x1, r.y0), p(r.x0, r.y1)], Stroke::new(1.0, col.gamma_multiply(0.75)));+ painter.line_segment([p(r.x0, r.y0), p(r.x1, r.y1)], Stroke::new(hair(painter), col.gamma_multiply(0.75)));+ painter.line_segment([p(r.x1, r.y0), p(r.x0, r.y1)], Stroke::new(hair(painter), col.gamma_multiply(0.75)));}}@@ -442,6 +446,10 @@ fn draw_selection(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documfor poly in path_screen(it, xf, a) {painter.add(egui::Shape::line(poly, Stroke::new(1.0, color)));}+ if sel.items.len() == 1 && sel.text.is_none() {+ // InDesign draws a 1 pt bounding box around the selection.+ painter.rect_stroke(xf.rect(a.transform_rect_bbox(it.bounds())), 0.0, Stroke::new(1.0, color), StrokeKind::Middle);+ }let b = xf.rect(a.transform_rect_bbox(it.bounds()));union = Some(union.map_or(b, |u| u.union(b)));// Text frame ports.@@ -485,11 +493,20 @@ fn draw_selection(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Documif sel.items.len() > 1 {painter.rect_stroke(u, 0.0, Stroke::new(1.0, color), StrokeKind::Middle);}- let hs = 6.0;+ let hs = 6.5;+ // Centre point and the live-corner widget.+ painter.rect_filled(Rect::from_center_size(u.center(), vec2(3.5, 3.5)), 0.0, color);+ if sel.items.len() == 1+ && doc.item(sel.items[0]).is_some_and(|i| matches!(i.shape, designcraft_doc::Shape::Rectangle) && i.children().is_empty())+ {+ let lc = Rect::from_center_size(pos2(u.max.x, u.min.y + 11.5), vec2(6.0, 6.0));+ painter.rect_filled(lc, 0.0, Color32::from_rgb(0xff, 0xe5, 0x00));+ painter.rect_stroke(lc, 0.0, Stroke::new(1.0, color), StrokeKind::Inside);+ }for h in designcraft_tools::select::handles(DRect::new(u.min.x as f64, u.min.y as f64, u.max.x as f64, u.max.y as f64)) {let r = Rect::from_center_size(pos2(h.x as f32, h.y as f32), vec2(hs, hs));painter.rect_filled(r, 0.0, Color32::WHITE);- painter.rect_stroke(r, 0.0, Stroke::new(1.0, color), StrokeKind::Inside);+ painter.rect_stroke(r, 0.0, Stroke::new(hair(painter), color), StrokeKind::Inside);}// Content grabber on graphic frames.if sel.items.len() == 1 && doc.item(sel.items[0]).is_some_and(|i| matches!(i.content, Content::Graphic(_))) {@@ -537,16 +554,18 @@ fn draw_ports(let is_last = pos + 1 == story.frames.len();let cs = app.session.cache.get(doc, sid, None);let overset = is_last && cs.is_overset();- let s = 8.0;+ let s = 8.5;let _ = layout;let r = it.inner_bounds();let m = a * it.xf;- let inp = xf.to_screen(m * Point::new(r.x0 + 12.0, r.y0));- let outp = xf.to_screen(m * Point::new(r.x1 - 12.0, r.y1));+ // In port on the left edge below the top-left corner; out port on the right edge above the+ // bottom-right corner (screen-space offsets).+ let inp = xf.to_screen(m * Point::new(r.x0, r.y0)) + vec2(0.0, 14.5);+ let outp = xf.to_screen(m * Point::new(r.x1, r.y1)) - vec2(0.0, 12.0);for (c, has_link, is_out) in [(inp, pos > 0, false), (outp, !is_last, true)] {let pr = Rect::from_center_size(c, vec2(s, s));painter.rect_filled(pr, 0.0, Color32::WHITE);- painter.rect_stroke(pr, 0.0, Stroke::new(1.0, color), StrokeKind::Inside);+ painter.rect_stroke(pr, 0.0, Stroke::new(hair(painter), color), StrokeKind::Inside);if is_out && overset {let red = Color32::from_rgb(230, 20, 20);painter.line_segment([c - vec2(2.5, 0.0), c + vec2(2.5, 0.0)], Stroke::new(1.5, red));@@ -662,8 +681,8 @@ fn draw_rulers(app: &DesignApp, ui: &egui::Ui, full: Rect, rect: Rect, xf: &Xf,painter.rect_filled(top, 0.0, t.ruler);painter.rect_filled(left, 0.0, t.ruler);painter.rect_filled(Rect::from_min_max(full.min, rect.min), 0.0, t.ruler);- painter.line_segment([pos2(rect.min.x, rect.min.y - 0.5), pos2(full.max.x, rect.min.y - 0.5)], Stroke::new(1.0, t.divider));- painter.line_segment([pos2(rect.min.x - 0.5, rect.min.y), pos2(rect.min.x - 0.5, full.max.y)], Stroke::new(1.0, t.divider));+ painter.line_segment([pos2(rect.min.x, rect.min.y - 0.25), pos2(full.max.x, rect.min.y - 0.25)], Stroke::new(0.5, t.ruler_tick));+ painter.line_segment([pos2(rect.min.x - 0.25, rect.min.y), pos2(rect.min.x - 0.25, full.max.y)], Stroke::new(0.5, t.ruler_tick));// Zero-point crosshair box.let zc = Rect::from_min_max(full.min, rect.min).center();painter.line_segment([zc - vec2(4.0, 0.0), zc + vec2(4.0, 0.0)], Stroke::new(1.0, t.ruler_tick));@@ -695,7 +714,7 @@ fn draw_rulers(app: &DesignApp, ui: &egui::Ui, full: Rect, rect: Rect, xf: &Xf,painter.line_segment([pos2(sx, top.max.y - len), pos2(sx, top.max.y)], tick);if s == 0 {let v = unit.from_pt(x);- painter.text(pos2(sx + 2.0, top.min.y + 1.0), egui::Align2::LEFT_TOP, fmt_tick(v), font.clone(), t.ruler_tick);+ painter.text(pos2(sx + 2.0, top.min.y + 1.0), egui::Align2::LEFT_TOP, fmt_tick(v), font.clone(), t.ruler_text);}}k += 1;@@ -721,7 +740,7 @@ fn draw_rulers(app: &DesignApp, ui: &egui::Ui, full: Rect, rect: Rect, xf: &Xf,// Stacked digits like InDesign's vertical ruler.let label = fmt_tick(unit.from_pt(y));for (j, ch) in label.chars().enumerate() {- painter.text(pos2(left.min.x + 3.0, sy + 2.0 + j as f32 * 8.5), egui::Align2::LEFT_TOP, ch, font.clone(), t.ruler_tick);+ painter.text(pos2(left.min.x + 3.0, sy + 2.0 + j as f32 * 8.5), egui::Align2::LEFT_TOP, ch, font.clone(), t.ruler_text);}}}@@ -914,3 +933,8 @@ pub fn selected_text(app: &DesignApp) -> Option<String> {}Some(s.replace(designcraft_doc::story::FORCED_LINE_BREAK, "\n"))}++/// One device pixel, the width InDesign uses for guides and frame edges.+fn hair(painter: &egui::Painter) -> f32 {+ 1.0 / painter.ctx().pixels_per_point()+}diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rsindex bd1728e53..a74f2d069 100644--- a/crates/ui-egui/src/chrome.rs+++ b/crates/ui-egui/src/chrome.rs@@ -8,68 +8,69 @@ use serde_json::json;use crate::panels::{self, SelInfo};use crate::theme::{Tokens, semibold};use crate::widgets::{caption, measure, number};-use crate::{DesignApp, ScreenMode, icons};+use crate::{DesignApp, icons};pub fn app_bar(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());let left = if app.integrated_titlebar { 78 } else { 8 };- egui::Panel::top("app_bar")- .exact_size(36.0)- .frame(egui::Frame::NONE.fill(t.app_bar).inner_margin(egui::Margin { left, right: 10, top: 0, bottom: 0 }))+ // 36 pt bar + 7 pt lower band (InDesign 2026), then a 1 pt border.+ let resp = egui::Panel::top("app_bar")+ .exact_size(43.0)+ .frame(egui::Frame::NONE.fill(t.app_bar).inner_margin(egui::Margin { left, right: 10, top: 0, bottom: 7 })).show(ui, |ui| {+ let full = ui.max_rect();ui.horizontal_centered(|ui| {- // Brand mark: our own "Dc" tile.- let (r, _) = ui.allocate_exact_size(vec2(24.0, 24.0), Sense::hover());- ui.painter().rect_filled(r, 5.0, Color32::from_rgb(214, 44, 104));- ui.painter().text(r.center(), egui::Align2::CENTER_CENTER, "Dc", semibold(12.5), Color32::WHITE);- ui.add_space(4.0);if icons::button(ui, "home", 24.0, app.session.active().is_none(), "Home").clicked() {app.session_home();}- ui.add_space(4.0);- ui.style_mut().visuals.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;- ui.style_mut().visuals.widgets.inactive.bg_stroke = Stroke::NONE;- ui.style_mut().visuals.widgets.hovered.bg_stroke = Stroke::NONE;- ui.style_mut().spacing.button_padding = vec2(7.0, 3.0);- crate::menus::menu_bar(app, ui);+ ui.add_space(6.0);+ if !app.native_menu {+ ui.style_mut().visuals.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;+ ui.style_mut().visuals.widgets.inactive.bg_stroke = Stroke::NONE;+ ui.style_mut().visuals.widgets.hovered.bg_stroke = Stroke::NONE;+ ui.style_mut().spacing.button_padding = vec2(7.0, 3.0);+ crate::menus::menu_bar(app, ui);+ }ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {ui.add_space(4.0);- icons::button(ui, "search", 22.0, false, "Search");- ui.menu_button(egui::RichText::new("Essentials ▾").color(t.text), |ui| {- for w in ["Essentials", "Advanced", "Book", "Digital Publishing", "Printing and Proofing", "Typography"] {+ // Search field.+ let (r, _) = ui.allocate_exact_size(vec2(125.0, 18.0), Sense::click());+ ui.painter().rect(r, 1.0, t.input, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);+ icons::paint(ui.painter(), egui::Rect::from_min_size(r.min + vec2(3.0, 2.0), vec2(14.0, 14.0)), "search", t.icon);+ ui.painter().text(r.min + vec2(20.0, 9.0), egui::Align2::LEFT_CENTER, "Search", egui::FontId::proportional(11.0), t.text_dim);+ ui.add_space(8.0);+ ui.menu_button(egui::RichText::new("Essentials ▾").font(semibold(11.5)).color(t.text), |ui| {+ for w in+ ["Essentials", "Advanced", "Book", "Digital Publishing", "Interactive for PDF", "Printing and Proofing", "Typography"]+ {if ui.button(w).clicked() {+ let _ = app.run("window.workspace", json!({"name": w}));ui.close();}}});- if ui- .add(egui::Button::new(egui::RichText::new("Share").color(Color32::WHITE)).fill(t.accent_strong).corner_radius(12.0))- .clicked()- {- app.status("Sharing is not part of DesignCraft — export a PDF or package instead.");- }- ui.add_space(8.0);- // Screen mode.- let mode = app.ui.screen_mode;- for (m, icon, tip) in [(ScreenMode::Preview, "screen-preview", "Preview (W)"), (ScreenMode::Normal, "screen-normal", "Normal")] {- if icons::button(ui, icon, 22.0, mode == m, tip).clicked() {- app.ui.screen_mode = m;- }- }ui.add_space(6.0);- // Zoom dropdown.- let z = app.view().map(|v| v.zoom).unwrap_or(1.0);- ui.menu_button(egui::RichText::new(format!("{:.0}% ▾", z * 100.0)).color(t.text), |ui| {- for p in [0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 4.0] {- if ui.button(format!("{:.0}%", p * 100.0)).clicked() {- let _ = app.run("view.zoom", json!({"zoom": p}));- ui.close();- }- }- });+ if icons::button(ui, "share", 22.0, false, "Share").clicked() {+ app.status("Export a PDF, IDML or package to share — no cloud account needed.");+ }});});+ // Centred title.+ let title = match app.session.active() {+ Some(d) => format!("DesignCraft — {}", d.title()),+ None => "DesignCraft".to_string(),+ };+ ui.painter().text(+ egui::pos2(full.center().x, full.min.y + 18.0),+ egui::Align2::CENTER_CENTER,+ title,+ egui::FontId::proportional(11.5),+ t.text,+ );});+ let r = resp.response.rect;+ ui.painter().rect_filled(egui::Rect::from_min_max(egui::pos2(r.min.x, r.max.y - 7.0), r.max), 0.0, t.pasteboard);+ ui.painter().line_segment([egui::pos2(r.min.x, r.max.y), egui::pos2(r.max.x, r.max.y)], Stroke::new(1.0, t.border));}impl DesignApp {@@ -88,7 +89,7 @@ fn vsep(ui: &mut egui::Ui) {pub fn control_bar(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());egui::Panel::top("control_bar")- .exact_size(64.0)+ .exact_size(59.0).frame(egui::Frame::NONE.fill(t.panel).inner_margin(egui::Margin { left: 8, right: 8, top: 5, bottom: 3 }).stroke(Stroke::new(1.0, t.divider)),)@@ -350,8 +351,9 @@ fn control_text(app: &mut DesignApp, ui: &mut egui::Ui) {pub fn doc_tabs(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());- let (bar, _) = ui.allocate_exact_size(vec2(ui.available_width(), 26.0), Sense::hover());- ui.painter().rect_filled(bar, 0.0, t.panel_darker);+ let (bar, _) = ui.allocate_exact_size(vec2(ui.available_width(), 28.0), Sense::hover());+ ui.painter().rect_filled(bar, 0.0, t.tab_strip);+ ui.painter().line_segment([bar.left_bottom(), bar.right_bottom()], Stroke::new(1.0, t.border));let mut x = bar.min.x;let active = app.session.active_index();let zoom = app.view().map(|v| v.zoom).unwrap_or(1.0);@@ -360,20 +362,13 @@ pub fn doc_tabs(app: &mut DesignApp, ui: &mut egui::Ui) {let titles: Vec<(String, bool)> = app.session.documents().iter().map(|d| (d.title(), d.is_dirty())).collect();for (i, (title, dirty)) in titles.iter().enumerate() {let is_active = Some(i) == active;- let label = if is_active {- format!("{}{} @ {:.0}%", if *dirty { "*" } else { "" }, title, zoom * 100.0)- } else {- format!("{}{}", if *dirty { "*" } else { "" }, title)- };- let galley = ui.painter().layout_no_wrap(label, egui::FontId::proportional(12.0), if is_active { t.text_strong } else { t.text_dim });- let w = galley.size().x + 44.0;- let r = egui::Rect::from_min_size(egui::pos2(x, bar.min.y), vec2(w, 26.0));+ let label = format!("{}{} @ {:.0}%", if *dirty { "*" } else { "" }, title, zoom * 100.0);+ let galley = ui.painter().layout_no_wrap(label, semibold(11.5), if is_active { t.text_strong } else { t.text_dim });+ let w = (galley.size().x + 44.0).max(if is_active { 210.0 } else { 150.0 });+ let r = egui::Rect::from_min_size(egui::pos2(x, bar.min.y), vec2(w, 28.0));let resp = ui.interact(r, ui.id().with(("doctab", i)), Sense::click());- ui.painter().rect_filled(r, 0.0, if is_active { t.pasteboard } else { t.tab_inactive });- if is_active {- ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(2.0, t.accent));- }- let cr = egui::Rect::from_center_size(egui::pos2(r.min.x + 13.0, r.center().y), vec2(14.0, 14.0));+ ui.painter().rect_filled(r, 0.0, if is_active { t.panel } else { t.tab_strip });+ let cr = egui::Rect::from_center_size(egui::pos2(r.min.x + 18.0, r.center().y), vec2(14.0, 14.0));let cresp = ui.interact(cr, ui.id().with(("docclose", i)), Sense::click());ui.painter().text(cr.center(),@@ -382,8 +377,8 @@ pub fn doc_tabs(app: &mut DesignApp, ui: &mut egui::Ui) {egui::FontId::proportional(14.0),if cresp.hovered() { t.text_strong } else { t.text_dim },);- ui.painter().galley(egui::pos2(r.min.x + 26.0, r.center().y - galley.size().y / 2.0), galley, Color32::WHITE);- ui.painter().line_segment([r.right_top(), r.right_bottom()], Stroke::new(1.0, t.divider));+ ui.painter().galley(egui::pos2(r.min.x + 32.0, r.center().y - galley.size().y / 2.0), galley, Color32::WHITE);+ ui.painter().line_segment([r.right_top(), r.right_bottom()], Stroke::new(1.0, t.border));if cresp.clicked() {close = Some(i);} else if resp.clicked() {@@ -400,28 +395,41 @@ pub fn doc_tabs(app: &mut DesignApp, ui: &mut egui::Ui) {pub fn status_bar(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());- egui::Panel::bottom("status_bar")- .exact_size(24.0)- .frame(egui::Frame::NONE.fill(t.panel_darker).inner_margin(egui::Margin::symmetric(8, 0)))+ let resp = egui::Panel::bottom("status_bar")+ .exact_size(17.0)+ .frame(egui::Frame::NONE.fill(t.panel).inner_margin(egui::Margin::symmetric(8, 0))).show(ui, |ui| {+ ui.spacing_mut().item_spacing.x = 4.0;ui.horizontal_centered(|ui| {+ let small = egui::FontId::proportional(10.5);if app.session.active().is_none() {- ui.label(egui::RichText::new(&app.ui.status).size(11.5).color(t.text_dim));+ ui.label(egui::RichText::new(&app.ui.status).font(small).color(t.text_dim));return;}let z = app.view().map(|v| v.zoom).unwrap_or(1.0);- ui.label(egui::RichText::new(format!("{:.0}%", z * 100.0)).size(11.5));+ ui.menu_button(egui::RichText::new(format!("{:.2}% ▾", z * 100.0)).font(small.clone()), |ui| {+ for p in [0.05, 0.125, 0.25, 0.5, 0.75, 1.0, 2.0, 4.0, 8.0, 16.0] {+ if ui.button(format!("{}%", p * 100.0)).clicked() {+ let _ = app.run("view.zoom", json!({"zoom": p}));+ ui.close();+ }+ }+ });ui.add_space(8.0);let n = app.session.active().map(|d| d.doc.page_count()).unwrap_or(1);let cur = crate::canvas::current_page(app).unwrap_or(0);- if icons::button(ui, "first", 16.0, false, "First Spread").clicked() {+ if icons::button(ui, "first", 14.0, false, "First Spread").clicked() {crate::canvas::go_to_page(app, 0);}- if icons::button(ui, "prev", 16.0, false, "Previous Spread").clicked() {+ if icons::button(ui, "prev", 14.0, false, "Previous Spread").clicked() {crate::canvas::go_to_page(app, cur.saturating_sub(1));}let name = app.session.active().map(|d| d.doc.page_name(cur)).unwrap_or_default();- ui.menu_button(egui::RichText::new(format!(" {name} ▾ ")).size(11.5), |ui| {+ let (fr, fresp) = ui.allocate_exact_size(vec2(80.0, 14.0), Sense::click());+ ui.painter().rect(fr, 0.0, t.input, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);+ ui.painter().text(fr.left_center() + vec2(5.0, 0.0), egui::Align2::LEFT_CENTER, &name, small.clone(), t.text);+ ui.painter().text(fr.right_center() - vec2(5.0, 0.0), egui::Align2::RIGHT_CENTER, "▾", small.clone(), t.text);+ egui::Popup::menu(&fresp).show(|ui| {let names: Vec<String> = app.session.active().map(|d| (0..n).map(|i| d.doc.page_name(i)).collect()).unwrap_or_default();egui::ScrollArea::vertical().max_height(300.0).show(ui, |ui| {for (i, nm) in names.iter().enumerate() {@@ -432,40 +440,37 @@ pub fn status_bar(app: &mut DesignApp, ui: &mut egui::Ui) {}});});- if icons::button(ui, "next", 16.0, false, "Next Spread").clicked() {+ if icons::button(ui, "next", 14.0, false, "Next Spread").clicked() {crate::canvas::go_to_page(app, (cur + 1).min(n - 1));}- if icons::button(ui, "last", 16.0, false, "Last Spread").clicked() {+ if icons::button(ui, "last", 14.0, false, "Last Spread").clicked() {crate::canvas::go_to_page(app, n - 1);}- ui.add_space(14.0);- // Preflight indicator: overset text is an error.+ ui.add_space(12.0);+ ui.label(egui::RichText::new("[Basic] (working) ▾").font(small.clone()));+ ui.add_space(8.0);+ // Preflight: overset text is an error.let errors = panels::preflight_errors(app);- let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), Sense::hover());+ let (r, _) = ui.allocate_exact_size(vec2(9.0, 9.0), Sense::hover());ui.painter().circle_filled(r.center(),- 4.5,- if errors == 0 { Color32::from_rgb(60, 190, 90) } else { Color32::from_rgb(230, 50, 50) },+ 4.0,+ if errors == 0 { Color32::from_rgb(60, 200, 90) } else { Color32::from_rgb(235, 50, 50) },);ui.label(egui::RichText::new(if errors == 0 {- "No errors".to_string()+ "No errors ▾".to_string()} else {- format!("{errors} error{}", if errors == 1 { "" } else { "s" })+ format!("{errors} error{} ▾", if errors == 1 { "" } else { "s" })})- .size(11.5),+ .font(small.clone()),);- ui.add_space(14.0);- ui.label(egui::RichText::new(&app.ui.status).size(11.5).color(t.text_dim));- ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {- ui.label(- egui::RichText::new(format!("{:.1} ms render · {:.0} fps", app.perf.render_ms, app.perf.fps))- .size(10.5)- .color(t.text_disabled),- );- });+ ui.add_space(12.0);+ ui.label(egui::RichText::new(&app.ui.status).font(small).color(t.text_dim));});});+ let r = resp.response.rect;+ ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(1.0, t.border));}pub fn start_screen(app: &mut DesignApp, ui: &mut egui::Ui) {diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex c672f1784..f69af9ecc 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -1,7 +1,7 @@//! The right dock: an expanded panel group (Properties · Pages · Layers) and a collapsed icon//! column whose panels open as flyouts beside the dock.-use egui::{Sense, Stroke, vec2};+use egui::{Color32, Sense, Stroke, vec2};use crate::theme::{Tokens, semibold};use crate::{DesignApp, icons, panels};@@ -28,60 +28,69 @@ pub const ICON_PANELS: &[(&str, &str, &str)] = &[pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());- // Collapsed icon column (rightmost).- egui::Panel::right("icon_column")- .exact_size(40.0)- .resizable(false)- .frame(egui::Frame::NONE.fill(t.panel_darker).stroke(Stroke::new(1.0, t.divider)))- .show(ui, |ui| {- ui.add_space(6.0);- ui.vertical_centered(|ui| {- for (id, label, icon) in ICON_PANELS {- let open = app.ui.open_panel.as_deref() == Some(*id);- if icons::button(ui, icon, 30.0, open, label).clicked() {- app.ui.open_panel = if open { None } else { Some(id.to_string()) };+ // Expanded panel stack (outermost, 253 pt) — declared first so it sits at the far right.+ if app.ui.dock_expanded {+ egui::Panel::right("dock").default_size(253.0).size_range(220.0..=420.0).resizable(true).frame(egui::Frame::NONE.fill(t.panel)).show(+ ui,+ |ui| {+ dock_header(ui, &t, "»");+ // Tab strip (27 pt).+ let (strip, _) = ui.allocate_exact_size(vec2(ui.available_width(), 27.0), Sense::hover());+ ui.painter().rect_filled(strip, 0.0, t.tab_strip);+ let mut x = strip.min.x;+ for (id, label, _) in DOCK_TABS {+ let active = app.ui.dock_tab == *id;+ let g = ui.painter().layout_no_wrap(+ label.to_string(),+ semibold(11.5),+ if active { Color32::from_rgb(0xf3, 0xf3, 0xf3) } else { t.text_dim },+ );+ let w = g.size().x + 26.0;+ let r = egui::Rect::from_min_size(egui::pos2(x, strip.min.y), vec2(w, 27.0));+ if active {+ ui.painter().rect_filled(r, 0.0, t.panel);}- ui.add_space(1.0);+ ui.painter().galley(egui::pos2(r.min.x + 13.0, r.center().y - g.size().y / 2.0), g, Color32::WHITE);+ ui.painter().line_segment([r.right_top(), r.right_bottom()], Stroke::new(1.0, t.border));+ if ui.interact(r, ui.id().with(("docktab", *id)), Sense::click()).clicked() {+ app.ui.dock_tab = id.to_string();+ }+ x += w;}- });- });- if !app.ui.dock_expanded {- return;+ let menu_r = egui::Rect::from_min_size(egui::pos2(strip.max.x - 24.0, strip.min.y + 4.0), vec2(18.0, 18.0));+ icons::paint(ui.painter(), menu_r, "menu", t.icon);+ egui::Frame::NONE.inner_margin(egui::Margin { left: 10, right: 10, top: 4, bottom: 6 }).show(ui, |ui| {+ egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| match app.ui.dock_tab.as_str() {+ "pages" => panels::pages::show(app, ui),+ "layers" => panels::layers::show(app, ui),+ _ => panels::properties::show(app, ui),+ });+ });+ },+ );}- egui::Panel::right("dock")- .default_size(280.0)- .size_range(240.0..=420.0)- .resizable(true)- .frame(egui::Frame::NONE.fill(t.panel).stroke(Stroke::new(1.0, t.divider)))- .show(ui, |ui| {- // Tab strip.- let (strip, _) = ui.allocate_exact_size(vec2(ui.available_width(), 28.0), Sense::hover());- ui.painter().rect_filled(strip, 0.0, t.panel_darker);- let mut x = strip.min.x;- for (id, label, _) in DOCK_TABS {- let active = app.ui.dock_tab == *id;- let g = ui.painter().layout_no_wrap(label.to_string(), semibold(12.0), if active { t.text_strong } else { t.text_dim });- let w = g.size().x + 22.0;- let r = egui::Rect::from_min_size(egui::pos2(x, strip.min.y), vec2(w, 28.0));- if active {- ui.painter().rect_filled(r, 0.0, t.panel);- }- ui.painter().galley(egui::pos2(r.min.x + 11.0, r.center().y - g.size().y / 2.0), g, egui::Color32::WHITE);- if ui.interact(r, ui.id().with(("docktab", *id)), Sense::click()).clicked() {- app.ui.dock_tab = id.to_string();+ // Collapsed icon strip (37 pt) to the left of the panel stack.+ egui::Panel::right("icon_column").exact_size(37.0).resizable(false).frame(egui::Frame::NONE.fill(t.panel)).show(ui, |ui| {+ dock_header(ui, &t, "«");+ ui.add_space(4.0);+ ui.vertical_centered(|ui| {+ for (id, label, icon) in ICON_PANELS {+ let open = app.ui.open_panel.as_deref() == Some(*id);+ if icons::button(ui, icon, 28.0, open, label).clicked() {+ app.ui.open_panel = if open { None } else { Some(id.to_string()) };}- x += w;+ ui.add_space(1.0);}- let menu_r = egui::Rect::from_min_size(egui::pos2(strip.max.x - 26.0, strip.min.y + 4.0), vec2(20.0, 20.0));- icons::paint(ui.painter(), menu_r, "menu", t.icon);- egui::Frame::NONE.inner_margin(egui::Margin { left: 10, right: 10, top: 6, bottom: 6 }).show(ui, |ui| {- egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| match app.ui.dock_tab.as_str() {- "pages" => panels::pages::show(app, ui),- "layers" => panels::layers::show(app, ui),- _ => panels::properties::show(app, ui),- });- });});+ });+}++/// 11 pt dock header strip with a collapse chevron.+fn dock_header(ui: &mut egui::Ui, t: &Tokens, chevron: &str) {+ let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), 11.0), Sense::hover());+ ui.painter().rect_filled(r, 0.0, t.tab_strip);+ ui.painter().text(egui::pos2(r.max.x - 8.0, r.center().y), egui::Align2::RIGHT_CENTER, chevron, egui::FontId::proportional(9.0), t.text_dim);+ ui.painter().line_segment([r.left_bottom(), r.right_bottom()], Stroke::new(1.0, t.border));}/// A panel opened from the icon column, shown as a floating flyout next to the dock.@@ -91,7 +100,7 @@ pub fn flyout(app: &mut DesignApp, ctx: &egui::Context) {let label = ICON_PANELS.iter().find(|p| p.0 == id).map(|p| p.1).unwrap_or("Panel");let screen = ctx.content_rect();let dock_w = if app.ui.dock_expanded { ctx.memory(|m| m.area_rect(egui::Id::new("dock")).map(|r| r.width())).unwrap_or(280.0) } else { 0.0 };- let pos = egui::pos2(screen.max.x - 40.0 - dock_w - 262.0, 130.0);+ let pos = egui::pos2(screen.max.x - 37.0 - dock_w - 262.0, 120.0);let mut open = true;egui::Area::new(egui::Id::new("panel_flyout")).order(egui::Order::Foreground).fixed_pos(pos).show(ctx, |ui| {egui::Frame::popup(ui.style()).fill(t.panel).inner_margin(egui::Margin::same(0)).show(ui, |ui| {diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rsindex 4e8470be3..9f9519fd1 100644--- a/crates/ui-egui/src/icons.rs+++ b/crates/ui-egui/src/icons.rs@@ -78,8 +78,8 @@ fn arrow(pen: &Pen, hollow: bool) {pub fn paint(p: &Painter, r: Rect, name: &str, c: Color32) {let mut pen = Pen { p, r, c, w: 1.3 };match name {- "tool-selection" => arrow(&pen, false),- "tool-direct" => arrow(&pen, true),+ "tool-selection" => arrow(&pen, true),+ "tool-direct" => arrow(&pen, false),"tool-page" => {pen.closed(&[(5.0, 3.0), (12.0, 3.0), (15.0, 6.0), (15.0, 17.0), (5.0, 17.0)]);pen.line(&[(12.0, 3.0), (12.0, 6.0), (15.0, 6.0)]);diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex f98bf94a6..0800524b0 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -75,6 +75,7 @@ pub struct UiState {pub open_panel: Option<String>,pub dock_expanded: bool,pub units: Unit,+ pub workspace: String,#[serde(skip)]pub status: String,#[serde(skip)]@@ -88,7 +89,7 @@ pub struct UiState {impl Default for UiState {fn default() -> Self {UiState {- brightness: theme::Brightness::Dark,+ brightness: theme::Brightness::MediumDark,screen_mode: ScreenMode::Normal,frame_edges: true,rulers: true,@@ -97,12 +98,13 @@ impl Default for UiState {document_grid: false,text_threads: false,hidden_characters: false,- control_bar: true,+ control_bar: false,tools_double_column: false,dock_tab: "properties".into(),open_panel: None,dock_expanded: true,units: Unit::Picas,+ workspace: "Essentials".into(),status: String::new(),dialog: None,palette: None,@@ -159,6 +161,10 @@ pub struct DesignApp {pub restyle: bool,fonts_ready: bool,pub integrated_titlebar: bool,+ /// The host installed a native menu bar (macOS): don't draw menus in the window.+ pub native_menu: bool,+ /// Shortcuts the native menu handles (skip them in the egui shortcut handler).+ pub native_shortcuts: std::collections::HashSet<String>,last_time: f64,}@@ -184,6 +190,8 @@ impl DesignApp {restyle: false,fonts_ready: false,integrated_titlebar: false,+ native_menu: false,+ native_shortcuts: Default::default(),last_time: 0.0,}}diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex e48b769f9..a049119c4 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -39,6 +39,12 @@ pub const UI_COMMANDS: &[(&str, &str, Option<&str>, &str)] = &[),("window.controlBar", "Control", Some("Cmd+Alt+6"), "{}"),("window.toolsDoubleColumn", "Tools: Double Column", None, "{}"),+ (+ "window.workspace",+ "Workspace",+ None,+ "{name: Essentials|Advanced|Book|Digital Publishing|Interactive for PDF|Printing and Proofing|Typography}",+ ),("window.brightness", "Interface Color Theme", None, "{brightness: dark|mediumDark|mediumLight|light}"),];@@ -294,6 +300,19 @@ pub fn run_ui(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value,}"window.controlBar" => flag(&mut app.ui.control_bar),"window.toolsDoubleColumn" => flag(&mut app.ui.tools_double_column),+ "window.workspace" => {+ let name = p.get("name").and_then(Value::as_str).unwrap_or("Essentials");+ // Workspaces choose which bars and panels are visible.+ app.ui.control_bar = matches!(name, "Advanced" | "Typography" | "Printing and Proofing" | "Book");+ app.ui.dock_tab = if name == "Typography" { "properties".into() } else { app.ui.dock_tab.clone() };+ app.ui.open_panel = match name {+ "Typography" => Some("paragraphStyles".into()),+ "Printing and Proofing" => Some("swatches".into()),+ _ => None,+ };+ app.ui.workspace = name.to_string();+ Ok(Value::Null)+ }"window.brightness" => {let b = p.get("brightness").and_then(Value::as_str).and_then(crate::theme::Brightness::parse).unwrap_or(crate::theme::Brightness::Dark);app.ui.brightness = b;@@ -354,89 +373,132 @@ fn shortcut_text(sc: &str) -> String {.collect()}-/// The menu bar contents (inside the app bar).-pub fn menu_bar(app: &mut DesignApp, ui: &mut egui::Ui) {- for (menu, entries) in MENUS {- ui.menu_button(*menu, |ui| {- ui.set_min_width(240.0);- menu_entries(app, ui, entries);- });- }+/// A menu entry, shared by the in-window menu bar and the native macOS menu.+#[derive(Clone, Debug)]+pub enum Item {+ Sep,+ Sub(String, Vec<Item>),+ Cmd { label: String, id: String, params: Value, shortcut: Option<&'static str> },+}++fn cmd_item(id: &str, params: Value) -> Item {+ let (label, shortcut) = match ui_label(id) {+ Some((l, sc)) => (l.to_string(), sc),+ None => match designcraft_engine::find_command(id) {+ Some(c) => (c.label.to_string(), c.shortcut),+ None => (id.to_string(), None),+ },+ };+ Item::Cmd { label, id: id.to_string(), params, shortcut }}-fn menu_entries(app: &mut DesignApp, ui: &mut egui::Ui, entries: &[&str]) {+fn parse_entries(entries: &[&str]) -> Vec<Item> {+ let mut out = Vec::new();let mut i = 0;while i < entries.len() {let e = entries[i];i += 1;if e == "-" {- ui.separator();- continue;- }- if let Some(name) = e.strip_prefix('>') {+ out.push(Item::Sep);+ } else if let Some(name) = e.strip_prefix('>') {let start = i;while i < entries.len() && entries[i] != "<" {i += 1;}- let sub = &entries[start..i];+ let sub = parse_entries(&entries[start..i]);i += 1;- ui.menu_button(name, |ui| menu_entries(app, ui, sub));- continue;+ out.push(Item::Sub(name.to_string(), sub));+ } else if e == "ui:window.panel" {+ let items = crate::dock::DOCK_TABS+ .iter()+ .chain(crate::dock::ICON_PANELS)+ .map(|(id, label, _)| Item::Cmd { label: label.to_string(), id: "window.panel".into(), params: json!({"panel": id}), shortcut: None })+ .collect();+ out.push(Item::Sub("Panels".into(), items));+ } else if e == "ui:window.brightness" {+ let items = crate::theme::Brightness::ALL+ .iter()+ .map(|b| Item::Cmd {+ label: b.label().to_string(),+ id: "window.brightness".into(),+ params: json!({"brightness": b.id()}),+ shortcut: None,+ })+ .collect();+ out.push(Item::Sub("Interface Color Theme".into(), items));+ } else {+ let (_, id) = e.split_once(':').unwrap_or(("cmd", e));+ out.push(cmd_item(id, Value::Null));}- if e == "ui:window.panel" {- ui.menu_button("Panels", |ui| {- for (id, label, _) in crate::dock::DOCK_TABS.iter().chain(crate::dock::ICON_PANELS) {- if ui.button(*label).clicked() {- let _ = app.run("window.panel", json!({"panel": id}));- ui.close();- }+ }+ out+}++/// The whole menu tree (InDesign order).+pub fn menu_tree() -> Vec<(&'static str, Vec<Item>)> {+ MENUS.iter().map(|(m, e)| (*m, parse_entries(e))).collect()+}++/// Check state of a toggle command (None = not a toggle).+pub fn checked(app: &DesignApp, id: &str, params: &Value) -> Option<bool> {+ Some(match id {+ "view.rulers" => app.ui.rulers,+ "view.frameEdges" => app.ui.frame_edges,+ "view.guides" => app.ui.guides,+ "view.baselineGrid" => app.ui.baseline_grid,+ "view.textThreads" => app.ui.text_threads,+ "view.hiddenCharacters" => app.ui.hidden_characters,+ "window.controlBar" => app.ui.control_bar,+ "window.toolsDoubleColumn" => app.ui.tools_double_column,+ "view.togglePreview" => app.ui.screen_mode == crate::ScreenMode::Preview,+ "window.brightness" => params.get("brightness").and_then(Value::as_str) == Some(app.ui.brightness.id()),+ _ => return None,+ })+}++/// Enablement for menu display (UI commands need a document unless they're app/window-level).+pub fn menu_enabled(app: &DesignApp, id: &str) -> bool {+ if ui_label(id).is_some() {+ return app.session.active().is_some() || id.starts_with("app.") || id.starts_with("window.");+ }+ enabled(app, id)+}++/// The menu bar contents (inside the app bar; macOS uses the native menu instead).+pub fn menu_bar(app: &mut DesignApp, ui: &mut egui::Ui) {+ for (menu, entries) in menu_tree() {+ ui.menu_button(menu, |ui| {+ ui.set_min_width(240.0);+ menu_items(app, ui, &entries);+ });+ }+}++fn menu_items(app: &mut DesignApp, ui: &mut egui::Ui, items: &[Item]) {+ for it in items {+ match it {+ Item::Sep => {+ ui.separator();+ }+ Item::Sub(name, children) => {+ ui.menu_button(name, |ui| menu_items(app, ui, children));+ }+ Item::Cmd { label, id, params, shortcut } => {+ let text = match checked(app, id, params) {+ Some(true) => format!("✓ {label}"),+ Some(false) => format!(" {label}"),+ None => label.clone(),+ };+ let mut b = egui::Button::new(text);+ if let Some(sc) = shortcut {+ b = b.shortcut_text(shortcut_text(sc));}- });- continue;- }- if e == "ui:window.brightness" {- ui.menu_button("Interface Color Theme", |ui| {- for b in crate::theme::Brightness::ALL {- if ui.radio(app.ui.brightness == b, b.label()).clicked() {- let _ = app.run("window.brightness", json!({"brightness": b.id()}));- ui.close();- }+ if ui.add_enabled(menu_enabled(app, id), b).clicked() {+ let p = if params.is_null() { json!({}) } else { params.clone() };+ let _ = app.run(id, p);+ ui.close();}- });- continue;- }- let (kind, id) = e.split_once(':').unwrap_or(("cmd", e));- let (label, sc, en) = if kind == "ui" {- let (l, sc) = ui_label(id).unwrap_or((id, None));- (l.to_string(), sc, app.session.active().is_some() || id.starts_with("app.") || id.starts_with("window."))- } else {- match designcraft_engine::find_command(id) {- Some(c) => (c.label.to_string(), c.shortcut, enabled(app, id)),- None => (id.to_string(), None, false),}- };- let checked = match id {- "view.rulers" => Some(app.ui.rulers),- "view.frameEdges" => Some(app.ui.frame_edges),- "view.guides" => Some(app.ui.guides),- "view.baselineGrid" => Some(app.ui.baseline_grid),- "view.textThreads" => Some(app.ui.text_threads),- "view.hiddenCharacters" => Some(app.ui.hidden_characters),- "window.controlBar" => Some(app.ui.control_bar),- _ => None,- };- let text = match checked {- Some(true) => format!("✓ {label}"),- Some(false) => format!(" {label}"),- None => label,- };- let mut b = egui::Button::new(text);- if let Some(sc) = sc {- b = b.shortcut_text(shortcut_text(sc));- }- if ui.add_enabled(en, b).clicked() {- let _ = app.run(id, json!({}));- ui.close();}}}@@ -505,6 +567,9 @@ pub fn shortcuts(app: &mut DesignApp, ctx: &egui::Context) {}}if let Some(id) = fired {+ if app.native_shortcuts.contains(id) {+ continue; // The native menu handles it.+ }let _ = app.run(id, json!({}));continue;}diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex a819b2738..6737fa5b0 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -7,8 +7,8 @@ use serde::{Deserialize, Serialize};#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]pub enum Brightness {- #[default]Dark,+ #[default]MediumDark,MediumLight,Light,@@ -63,6 +63,17 @@ pub struct Tokens {pub tab_inactive: Color32,pub button: Color32,pub radius: u8,+ /// 1 pt chrome edges.+ pub border: Color32,+ /// Outline of fields and buttons.+ pub field_border: Color32,+ /// Active tool / toggle well.+ pub well: Color32,+ pub well_rim: Color32,+ pub ruler_text: Color32,+ pub section_divider: Color32,+ /// Panel tab strips, doc-tab bar, dock headers.+ pub tab_strip: Color32,}fn hex(s: u32) -> Color32 {@@ -94,26 +105,45 @@ impl Tokens {ruler_tick: hex(0x9a9a9a),tab_inactive: hex(0x262626),button: hex(0x404040),- radius: 3,+ radius: 1,+ border: hex(0x1e1e1e),+ field_border: hex(0x5a5a5a),+ well: hex(0x1b1b1b),+ well_rim: hex(0x3a3a3a),+ ruler_text: hex(0xd8d8d8),+ section_divider: hex(0x282828),+ tab_strip: hex(0x282828),};match b {Brightness::Dark => dark,+ // Measured from InDesign 2026 (plan/indesign/11-observed-ui.md §1).Brightness::MediumDark => Tokens {- app_bar: hex(0x404040),+ app_bar: hex(0x535353),panel: hex(0x535353),- panel_darker: hex(0x454545),- input: hex(0x3d3d3d),- input_border: hex(0x6a6a6a),- divider: hex(0x3a3a3a),- text: hex(0xe6e6e6),- text_dim: hex(0xbcbcbc),- hover: hex(0x626262),- tool_active: hex(0x353535),+ panel_darker: hex(0x424242),+ input: hex(0x454545),+ input_border: hex(0x747474),+ divider: hex(0x4b4b4b),+ text: hex(0xffffff),+ text_strong: hex(0xffffff),+ text_dim: hex(0xb0b0b0),+ text_disabled: hex(0x8a8a8a),+ icon: hex(0xc2c2c2),+ hover: hex(0x606060),+ tool_active: hex(0x303030),row_selected: hex(0x4a6a92),- pasteboard: hex(0x4a4a4a),- ruler: hex(0x4c4c4c),- tab_inactive: hex(0x454545),- button: hex(0x606060),+ pasteboard: hex(0x5e5e5e),+ ruler: hex(0x1f1f1f),+ ruler_tick: hex(0x858585),+ tab_inactive: hex(0x424242),+ button: hex(0x535353),+ border: hex(0x383838),+ field_border: hex(0x747474),+ well: hex(0x303030),+ well_rim: hex(0x565656),+ ruler_text: hex(0xffffff),+ section_divider: hex(0x4b4b4b),+ tab_strip: hex(0x424242),..dark},Brightness::MediumLight => Tokens {@@ -136,7 +166,14 @@ impl Tokens {ruler: hex(0xc0c0c0),ruler_tick: hex(0x3a3a3a),tab_inactive: hex(0xa6a6a6),- button: hex(0xcbcbcb),+ button: hex(0xb8b8b8),+ border: hex(0x8c8c8c),+ field_border: hex(0x7a7a7a),+ well: hex(0x9a9a9a),+ well_rim: hex(0x8a8a8a),+ ruler_text: hex(0x1e1e1e),+ section_divider: hex(0x9c9c9c),+ tab_strip: hex(0xa6a6a6),..dark},Brightness::Light => Tokens {@@ -159,7 +196,14 @@ impl Tokens {ruler: hex(0xf2f2f2),ruler_tick: hex(0x4a4a4a),tab_inactive: hex(0xdcdcdc),- button: hex(0xe6e6e6),+ button: hex(0xf0f0f0),+ border: hex(0xc4c4c4),+ field_border: hex(0xa8a8a8),+ well: hex(0xcfcfcf),+ well_rim: hex(0xbdbdbd),+ ruler_text: hex(0x1e1e1e),+ section_divider: hex(0xd0d0d0),+ tab_strip: hex(0xe2e2e2),..dark},}@@ -187,9 +231,9 @@ pub fn semibold(size: f32) -> FontId {pub fn apply(ctx: &egui::Context, t: &Tokens) {ctx.data_mut(|d| d.insert_temp(egui::Id::NULL, *t));let text_styles: std::collections::BTreeMap<TextStyle, FontId> = [- (TextStyle::Small, FontId::proportional(10.5)),- (TextStyle::Body, FontId::proportional(12.5)),- (TextStyle::Button, FontId::proportional(12.5)),+ (TextStyle::Small, FontId::proportional(10.0)),+ (TextStyle::Body, FontId::proportional(11.5)),+ (TextStyle::Button, FontId::proportional(11.5)),(TextStyle::Heading, FontId::new(15.0, FontFamily::Name("semibold".into()))),(TextStyle::Monospace, FontId::monospace(11.5)),]@@ -220,16 +264,19 @@ pub fn apply(ctx: &egui::Context, t: &Tokens) {w.fg_stroke = Stroke::new(1.0, t.text);}v.widgets.noninteractive.bg_stroke = Stroke::new(1.0, t.divider);- v.widgets.inactive.bg_stroke = Stroke::new(1.0, t.input_border);- v.widgets.hovered.bg_stroke = Stroke::new(1.0, t.input_border);+ v.widgets.inactive.bg_stroke = Stroke::new(1.0, t.field_border);+ v.widgets.hovered.bg_stroke = Stroke::new(1.0, t.field_border);+ v.widgets.active.bg_stroke = Stroke::new(1.0, t.field_border);+ // InDesign buttons are outline-only.v.widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;+ v.widgets.inactive.bg_fill = t.input;v.popup_shadow = egui::epaint::Shadow { offset: [0, 4], blur: 12, spread: 0, color: Color32::from_black_alpha(90) };ctx.set_visuals(v);ctx.global_style_mut(|s| {s.text_styles = text_styles.clone();s.spacing.item_spacing = egui::vec2(6.0, 4.0);s.spacing.button_padding = egui::vec2(6.0, 2.0);- s.spacing.interact_size = egui::vec2(20.0, 20.0);+ s.spacing.interact_size = egui::vec2(20.0, 21.0);s.spacing.menu_margin = egui::Margin::same(4);s.animation_time = 0.06;});diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rsindex 3d08bdd84..6554fd3ac 100644--- a/crates/ui-egui/src/toolbar.rs+++ b/crates/ui-egui/src/toolbar.rs@@ -8,12 +8,12 @@ use serde_json::json;use crate::theme::Tokens;use crate::{DesignApp, icons};-const BTN: f32 = 26.0;+const BTN: f32 = 24.0;pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());let cols = if app.ui.tools_double_column { 2 } else { 1 };- let width = 10.0 + BTN * cols as f32 + 4.0 * (cols as f32 - 1.0) + 10.0;+ let width = 8.0 + BTN * cols as f32 + 4.0 * (cols as f32 - 1.0) + 8.0;egui::Panel::left("tools").exact_size(width).resizable(false).frame(egui::Frame::NONE.fill(t.panel).stroke(Stroke::new(1.0, t.divider))).show(ui,|ui| {@@ -53,7 +53,7 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {}Some(_) => {ui.horizontal(|ui| {- ui.add_space(10.0);+ ui.add_space(8.0);ui.spacing_mut().item_spacing.x = 4.0;for _ in 0..cols {let Some(Some(gi)) = row_items.get(i).copied() else { break };@@ -64,7 +64,7 @@ pub fn show(app: &mut DesignApp, ui: &mut egui::Ui) {Some(s) => format!("{} ({s})", shown.label),None => shown.label.to_string(),};- let resp = icons::button(ui, shown.icon, BTN, active, &tip);+ let resp = tool_button(ui, shown.icon, active, &tip);if g.len() > 1 {// Flyout triangle.let r = resp.rect;@@ -210,3 +210,17 @@ fn fill_stroke_proxy(app: &mut DesignApp, ui: &mut egui::Ui, width: f32) {}});}++/// A Tools-panel button: 24 pt pitch; the active tool sits in a 28×20 pt `#303030` well with a rim.+fn tool_button(ui: &mut egui::Ui, icon: &str, active: bool, tip: &str) -> egui::Response {+ let t = Tokens::get(ui.ctx());+ let (r, resp) = ui.allocate_exact_size(egui::vec2(BTN, BTN), Sense::click());+ if active {+ let well = egui::Rect::from_center_size(r.center(), egui::vec2(28.0, 20.0));+ ui.painter().rect(well, 2.0, t.well, Stroke::new(1.0, t.well_rim), StrokeKind::Outside);+ } else if resp.hovered() {+ ui.painter().rect_filled(egui::Rect::from_center_size(r.center(), egui::vec2(28.0, 20.0)), 2.0, t.hover);+ }+ icons::paint(ui.painter(), egui::Rect::from_center_size(r.center(), egui::vec2(17.0, 17.0)), icon, if active { t.text_strong } else { t.icon });+ resp.on_hover_text(tip)+}diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rsindex ae6949505..152137b20 100644--- a/crates/ui-egui/src/widgets.rs+++ b/crates/ui-egui/src/widgets.rs@@ -15,7 +15,7 @@ pub fn measure(ui: &mut Ui, id: &str, value: Option<f64>, unit: Unit, width: f32let mut buf: String =ui.data(|d| d.get_temp::<String>(key)).unwrap_or_else(|| value.map(|v| format_measure_prec(v, unit, 3)).unwrap_or_default());let r = ui.add_sized(- [width, 19.0],+ [width, 21.0],egui::TextEdit::singleline(&mut buf).font(egui::FontId::proportional(12.0)).background_color(t.input).margin(egui::Margin::symmetric(4, 1)),);let mut out = None;@@ -46,7 +46,7 @@ pub fn number(ui: &mut Ui, id: &str, value: Option<f64>, suffix: &str, width: f3};let mut buf: String = ui.data(|d| d.get_temp::<String>(key)).unwrap_or_else(|| value.map(show).unwrap_or_default());let r = ui.add_sized(- [width, 19.0],+ [width, 21.0],egui::TextEdit::singleline(&mut buf).font(egui::FontId::proportional(12.0)).background_color(t.input).margin(egui::Margin::symmetric(4, 1)),);let mut out = None;@@ -73,33 +73,22 @@ pub fn caption(ui: &mut Ui, s: &str) {ui.label(egui::RichText::new(s).size(11.5).color(t.text_dim));}-/// Panel section header with a disclosure triangle. Returns open state.-pub fn section(ui: &mut Ui, title: &str, default_open: bool) -> bool {+/// Panel section header (InDesign 2026: regular-weight white title, no disclosure chevron; a+/// 1.5 pt rule separates sections). Returns whether to show the section body (always true).+pub fn section(ui: &mut Ui, title: &str, _default_open: bool) -> bool {let t = Tokens::get(ui.ctx());- let id = ui.id().with(("section", title));- let mut open = ui.data(|d| d.get_temp::<bool>(id)).unwrap_or(default_open);- ui.add_space(4.0);- let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 20.0), Sense::click());- if resp.clicked() {- open = !open;- ui.data_mut(|d| d.insert_temp(id, open));- }- let p = ui.painter();- crate::icons::paint(- p,- egui::Rect::from_min_size(r.min + vec2(0.0, 3.0), vec2(14.0, 14.0)),- if open { "chevron-down" } else { "chevron-right" },- t.text_dim,- );- p.text(r.min + vec2(17.0, 10.0), egui::Align2::LEFT_CENTER, title, crate::theme::semibold(12.0), t.text_strong);- open+ ui.add_space(6.0);+ let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), 18.0), Sense::hover());+ ui.painter().text(r.left_center(), egui::Align2::LEFT_CENTER, title, egui::FontId::proportional(11.5), t.text_strong);+ true}pub fn divider(ui: &mut Ui) {let t = Tokens::get(ui.ctx());let r = ui.available_rect_before_wrap();- ui.painter().line_segment([egui::pos2(r.min.x, r.min.y + 2.0), egui::pos2(r.max.x, r.min.y + 2.0)], Stroke::new(1.0, t.divider));- ui.add_space(5.0);+ ui.painter()+ .line_segment([egui::pos2(r.min.x - 10.0, r.min.y + 4.0), egui::pos2(r.max.x + 10.0, r.min.y + 4.0)], Stroke::new(1.5, t.section_divider));+ ui.add_space(8.0);}/// A swatch chip (colour square, [None] slash, gradient ramp).