Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Command search: show a command's place in the ribbon, also inside section menus (#7287) (#7322)

tr1pp4b43712cdb0e5
diff --git a/assets/locales/pending/command-search-reveal.json b/assets/locales/pending/command-search-reveal.json
new file mode 100644
index 0000000000..5f41f2b0a6
--- /dev/null
+++ b/assets/locales/pending/command-search-reveal.json
@@ -0,0 +1,30 @@
+{
+ "en": {
+ "prefs.ribbon_reveal": "Show search results in the ribbon",
+ "prefs.ribbon_reveal_note": "Hovering a result in Search commands shows where the command sits in the ribbon: its tab, its button or its row in a panel's drop-down. A command started from the search blinks there, and a running command from a drop-down marks its panel."
+ },
+ "de": {
+ "prefs.ribbon_reveal": "Suchergebnisse im Menüband zeigen",
+ "prefs.ribbon_reveal_note": "Steht der Zeiger über einem Ergebnis in Befehle suchen, zeigt das Menüband, wo der Befehl liegt: seine Registerkarte, seine Schaltfläche oder seine Zeile im Aufklappmenü eines Panels. Ein aus der Suche gestarteter Befehl blinkt dort, und ein laufender Befehl aus einem Aufklappmenü markiert sein Panel."
+ },
+ "ar": {
+ "prefs.ribbon_reveal": "إظهار نتائج البحث في الشريط",
+ "prefs.ribbon_reveal_note": "يؤدي تمرير المؤشر فوق نتيجة في البحث عن الأوامر إلى إظهار مكان الأمر في الشريط: علامة التبويب أو الزر أو صفه في القائمة المنسدلة للوحة. يومض الأمر الذي بدأ من البحث هناك، ويضع الأمر الجاري من قائمة منسدلة علامة على لوحته."
+ },
+ "he": {
+ "prefs.ribbon_reveal": "הצגת תוצאות חיפוש בסרט",
+ "prefs.ribbon_reveal_note": "מעבר עם הסמן מעל תוצאה בחיפוש פקודות מראה היכן הפקודה נמצאת בסרט: הלשונית, הכפתור או השורה שלה בתפריט הנפתח של לוח. פקודה שהופעלה מהחיפוש מהבהבת שם, ופקודה פעילה מתפריט נפתח מסמנת את הלוח שלה."
+ },
+ "ja": {
+ "prefs.ribbon_reveal": "検索結果をリボンに表示",
+ "prefs.ribbon_reveal_note": "コマンド検索で結果にポインターを合わせると、そのコマンドがリボンのどこにあるか(タブ、ボタン、またはパネルのドロップダウン内の行)を表示します。検索から開始したコマンドはそこで点滅し、ドロップダウンから実行中のコマンドはそのパネルに印が付きます。"
+ },
+ "vi": {
+ "prefs.ribbon_reveal": "Hiện kết quả tìm kiếm trên ribbon",
+ "prefs.ribbon_reveal_note": "Khi rê chuột lên một kết quả trong Tìm lệnh, ribbon cho biết lệnh nằm ở đâu: tab, nút hoặc dòng của nó trong menu thả xuống của một bảng. Lệnh bắt đầu từ tìm kiếm sẽ nhấp nháy ở đó, và lệnh đang chạy từ menu thả xuống sẽ đánh dấu bảng của nó."
+ },
+ "zh": {
+ "prefs.ribbon_reveal": "在功能区中显示搜索结果",
+ "prefs.ribbon_reveal_note": "将指针悬停在“搜索命令”的结果上时,会显示该命令在功能区中的位置:其选项卡、按钮或面板下拉菜单中的行。从搜索启动的命令会在那里闪烁,从下拉菜单运行的命令会标记其面板。"
+ }
+}
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index d0f6d7e07a..25665accfb 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -1063,6 +1063,11 @@ preference_settings! {
/// Keep the SKETCH tab in the ribbon, right after MODEL, while no sketch is open; its drawing
/// tools then start a sketch first (#7904).
sketch_tab_always: bool = false, PAGE_INTERFACE => check_id("prefs.sketch_tab_always");
+ /// Hovering a result in Search commands shows the command's place in the ribbon: its tab,
+ /// its button or its row in a section's drop-down (#7287). A command started from the search
+ /// blinks there, and a running command that sits in a drop-down marks its section label. Off
+ /// by default: the ribbon stays as it was.
+ ribbon_reveal: bool = false, PAGE_INTERFACE => check_id("prefs.ribbon_reveal");
/// Where a dialog's OK and Cancel sit: under its inputs (the default) or in its title row (#6708).
dialog_buttons: crate::ui_kit::DialogButtons = Default::default(), PAGE_INTERFACE;
/// Where notices and offers stack: the view's bottom-right corner (the default) or the bottom
@@ -4918,6 +4923,7 @@ mod tests {
("layout", json!("compact"), PAGE_INTERFACE),
("ribbon_labels", json!(false), PAGE_INTERFACE),
("sketch_tab_always", json!(true), PAGE_INTERFACE),
+ ("ribbon_reveal", json!(true), PAGE_INTERFACE),
("dialog_buttons", json!("top"), PAGE_INTERFACE),
("toast_place", json!("centre"), PAGE_INTERFACE),
("timeline_left", json!(true), PAGE_INTERFACE),
diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rs
index 5396f3735c..6a98c12f39 100644
--- a/crates/ui-egui/src/prefs/interface.rs
+++ b/crates/ui-egui/src/prefs/interface.rs
@@ -99,6 +99,11 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
let check = setting::sketch_tab_always(app, ui).on_hover_text(app.tr("prefs.sketch_tab_always_note"));
crate::scenario::publish_target("prefs:sketch_tab_always", check.rect);
});
+ // Search results point out their place in the ribbon (#7287).
+ ui_kit::row(ui, "", |ui| {
+ let check = setting::ribbon_reveal(app, ui).on_hover_text(app.tr("prefs.ribbon_reveal_note"));
+ crate::scenario::publish_target("prefs:ribbon_reveal", check.rect);
+ });
// Where every feature dialog puts its OK and Cancel (#6708).
ui_kit::row(ui, app.tr("prefs.dialog_buttons"), |ui| {
let placements = [crate::ui_kit::DialogButtons::Bottom, crate::ui_kit::DialogButtons::Top];
diff --git a/crates/ui-egui/src/shortcut_box.rs b/crates/ui-egui/src/shortcut_box.rs
index 98e932f841..91afb68c50 100644
--- a/crates/ui-egui/src/shortcut_box.rs
+++ b/crates/ui-egui/src/shortcut_box.rs
@@ -32,6 +32,68 @@ pub struct ShortcutBox {
design: Option<(u64, Vec<DesignRow>)>,
/// Retained paint content while closing; the public query still clears immediately.
closing_text: String,
+ /// The pointer moved while the box was open: only then does a hovered result reveal its
+ /// place, not when the results appear under a resting pointer.
+ moved: bool,
+ /// The command whose place the ribbon shows (#7287).
+ pub reveal: Option<Reveal>,
+}
+
+/// A command the ribbon points out: its button pulses, or its section's drop-down opens on its
+/// row with its tooltip, or (once started) its section label pulses.
+#[derive(Clone, Debug)]
+pub struct Reveal {
+ pub id: &'static str,
+ /// When it started (egui input time, seconds).
+ pub since: f64,
+ /// Shown while a search result is hovered; then the drop-down and tooltip stay open, and
+ /// the ribbon goes back to `back` when the pointer leaves the results.
+ pub preview: bool,
+ /// The tab to return to after a preview.
+ pub back: String,
+}
+
+/// How long a reveal pulses, in seconds: two blinks.
+pub const REVEAL_PULSE: f64 = 1.2;
+
+impl Reveal {
+ /// The pulse's strength at `now`: 0 to 1 and back twice over `REVEAL_PULSE`, then 1 for a
+ /// preview (it stays marked while hovered) and 0 for a started command. Without animations
+ /// a preview is marked steadily and a start isn't pulsed.
+ pub fn strength(&self, now: f64, animate: bool) -> f32 {
+ let t = now - self.since;
+ if !animate || !(0.0..REVEAL_PULSE).contains(&t) {
+ return if self.preview { 1.0 } else { 0.0 };
+ }
+ (0.5 - 0.5 * (t / REVEAL_PULSE * 4.0 * std::f64::consts::PI).cos()) as f32
+ }
+}
+
+/// Shows the hovered result's place in the ribbon (#7287): its tab, then its button or its
+/// section drop-down row. `None` ends a preview and goes back to the tab the user was on.
+fn preview(app: &mut SolveApp, now: f64, id: Option<&'static str>) {
+ let Some(id) = id else {
+ end_preview(app);
+ return;
+ };
+ if app.sbox.reveal.as_ref().is_some_and(|r| r.preview && r.id == id) {
+ return;
+ }
+ let back = match app.sbox.reveal.take() {
+ Some(r) if r.preview => r.back,
+ _ => app.ui.tab.clone(),
+ };
+ app.ui.tab = back.clone();
+ if let Some(tab) = crate::workspace::command_tab(app, id) {
+ app.ui.tab = tab.into();
+ }
+ app.sbox.reveal = Some(Reveal { id, since: now, preview: true, back });
+}
+
+fn end_preview(app: &mut SolveApp) {
+ if let Some(r) = app.sbox.reveal.take_if(|r| r.preview) {
+ app.ui.tab = r.back;
+ }
}
impl ShortcutBox {
@@ -278,6 +340,7 @@ pub fn open(app: &mut SolveApp, at: Option<Pos2>) {
app.sbox.text.clear();
app.sbox.focus = true;
app.sbox.design = None;
+ app.sbox.moved = false;
}
/// A line typed as `command.id {"param": value}`: the command runs at once with those parameters
@@ -296,6 +359,7 @@ fn run_typed(app: &mut SolveApp, line: &str) {
}
fn close(app: &mut SolveApp) {
+ end_preview(app);
app.ui.palette_open = false;
app.sbox.at = None;
app.sbox.text.clear();
@@ -356,6 +420,12 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
});
let mut picked = None;
let mut menu = None;
+ // The command result under the pointer, when it has a place on the ribbon to show.
+ let mut hovered = None;
+ let now = ctx.input(|i| i.time);
+ if open && ctx.input(|i| i.pointer.delta() != egui::Vec2::ZERO) {
+ app.sbox.moved = true;
+ }
let mut rows = Vec::new();
let mut design = Vec::new();
let mut mode = None;
@@ -492,12 +562,16 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
item.shortcut = &shortcut;
let path = place.map_or_else(|| id.to_string(), |(tab, panel)| format!("{tab} › {panel}"));
let response = item.search_row(ui, &query, &path, None);
+ crate::scenario::publish_target(&format!("search:command:{id}"), response.rect);
if item.highlighted && (up || down) {
ui.scroll_to_rect(response.rect, None);
}
if response.clicked() {
picked = Some(index);
}
+ if response.hovered() && place.is_some() {
+ hovered = Some(*id);
+ }
if response.secondary_clicked() {
menu = Some((response.rect.left_bottom(), (*id).to_owned()));
}
@@ -557,6 +631,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
if !open {
return;
}
+ preview(app, now, hovered.filter(|_| app.preferences.ribbon_reveal && app.sbox.moved && menu.is_none()));
+ if app.sbox.reveal.is_some() {
+ ctx.request_repaint();
+ }
app.sbox.text = query;
app.sbox.closing_text = app.sbox.text.clone();
if let Some((at, id)) = menu {
@@ -595,6 +673,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
app.sbox.used(id);
close(app);
app.start(id);
+ // The ribbon shows where it was started from: its button or section label pulses.
+ if app.preferences.ribbon_reveal {
+ app.sbox.reveal = Some(Reveal { id, since: now, preview: false, back: String::new() });
+ }
} else if let Some(row) = design.get(index.saturating_sub(rows.len())).filter(|_| index >= rows.len()) {
let target = row.target.clone();
close(app);
@@ -660,6 +742,126 @@ mod tests {
assert!(ctx.memory(|m| m.has_focus(field)), "reopening the box focuses the field again");
}
+ #[test]
+ fn a_reveal_pulses_twice_then_stays_for_a_preview_and_ends_for_a_start() {
+ let preview = Reveal { id: "surface.stitch", since: 10.0, preview: true, back: "MODEL".into() };
+ let start = Reveal { preview: false, ..preview.clone() };
+ for r in [&preview, &start] {
+ assert_eq!(r.strength(10.0, true), 0.0);
+ assert!((r.strength(10.0 + REVEAL_PULSE / 4.0, true) - 1.0).abs() < 1e-6, "the first blink");
+ assert!(r.strength(10.0 + REVEAL_PULSE / 2.0, true) < 1e-6, "dark between the blinks");
+ }
+ assert_eq!(preview.strength(12.0, true), 1.0, "a hovered result stays marked");
+ assert_eq!(start.strength(12.0, true), 0.0, "a started command's pulse ends");
+ // Without animations: marked steadily while hovered, no pulse after a start.
+ assert_eq!(preview.strength(10.2, false), 1.0);
+ assert_eq!(start.strength(10.2, false), 0.0);
+ }
+
+ /// Hovering a result shows where its command lives (#7287): the ribbon switches to its tab
+ /// and marks its button with its tooltip, or opens the section drop-down that holds it on
+ /// its row; leaving the results goes back to the tab the user was on. Starting a command
+ /// that lives only in a drop-down marks that section's label while it runs.
+ #[test]
+ fn hovering_a_result_reveals_its_place_in_the_ribbon() {
+ use crate::scenario::rect_of;
+ let mut h = crate::scenario::Harness::new();
+ h.app.home.open = false;
+ h.app.preferences.ribbon_reveal = true;
+ h.frames(3);
+ assert_eq!(h.app.ui.tab, "MODEL");
+ let away = rect_of("toolbar").unwrap().center_bottom() + vec2(0.0, 300.0);
+ h.call("ui.move", json!({"x": away.x, "y": away.y}));
+ h.call("ui.palette", json!({}));
+ h.frames(10);
+ let hover = |h: &mut crate::scenario::Harness, id: &str| {
+ let row = rect_of(&format!("search:command:{id}")).unwrap_or_else(|| panic!("no result row for {id}"));
+ h.call("ui.move", json!({"x": row.center().x, "y": row.center().y + 1.0}));
+ h.call("ui.move", json!({"x": row.center().x, "y": row.center().y}));
+ h.frames(3);
+ };
+
+ // Results appearing under a resting pointer reveal nothing: the box opens again with
+ // the pointer already where the row will be.
+ h.app.sbox.text = "stitch".into();
+ h.frames(2);
+ let row = rect_of("search:command:surface.stitch").unwrap();
+ h.call("ui.key", json!({"key": "Escape"}));
+ h.frames(10);
+ h.call("ui.move", json!({"x": row.center().x, "y": row.center().y}));
+ h.frames(2);
+ h.call("ui.palette", json!({}));
+ h.app.sbox.text = "stitch".into();
+ h.frames(10);
+ assert!(h.app.sbox.reveal.is_none() && h.app.ui.tab == "MODEL", "{:?}", h.app.sbox.reveal);
+
+ // A visible button: its tab, the button marked, its tooltip open.
+ hover(&mut h, "surface.stitch");
+ assert_eq!(h.app.ui.tab, "SURFACE");
+ assert_eq!(rect_of("ribbon:reveal"), rect_of("button:surface.stitch"));
+ assert!(rect_of("ribbon:reveal_tooltip").is_some());
+ h.call("ui.move", json!({"x": away.x, "y": away.y}));
+ h.frames(2);
+ assert_eq!(h.app.ui.tab, "MODEL", "leaving the results goes back");
+ assert!(rect_of("ribbon:reveal").is_none());
+
+ // Only in its section's drop-down: the drop-down opens on its row.
+ h.app.sbox.text = "circular".into();
+ h.frames(2);
+ hover(&mut h, "solid.pattern.circular");
+ assert_eq!(h.app.ui.tab, "MODEL");
+ assert!(rect_of("button:solid.pattern.circular").is_none(), "the command has no button on the default ribbon");
+ let row = rect_of("ribbon:reveal").expect("the revealed row");
+ assert!(rect_of("toolbar_dropdown").unwrap().contains_rect(row), "{row:?}");
+ assert!(rect_of("ribbon:reveal_tooltip").is_some_and(|tip| tip.left() >= row.right()), "the row's tooltip beside it");
+ assert_eq!(h.ctx.data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))), None, "the preview doesn't open it for good");
+
+ // Starting it from the box: the section label pulses, then stays marked while it runs.
+ h.call("ui.key", json!({"key": "Enter"}));
+ h.frames(2);
+ assert!(!h.app.ui.palette_open);
+ assert!(rect_of("toolbar_dropdown").is_none(), "the preview's drop-down closes");
+ let label = rect_of("ribbon:section:MODEL:ARRANGE").unwrap();
+ assert_eq!(rect_of("ribbon:reveal"), Some(label));
+ assert_eq!(rect_of("ribbon:running_section:MODEL:ARRANGE"), Some(label));
+ h.frames((REVEAL_PULSE * 60.0) as usize + 2);
+ assert!(rect_of("ribbon:reveal").is_none(), "the pulse ends");
+ assert_eq!(rect_of("ribbon:running_section:MODEL:ARRANGE"), Some(label), "marked while it runs");
+ }
+
+ /// Without the preference (the default) the ribbon stays as it was: hovering a result
+ /// neither switches the tab nor opens a drop-down, and a command started from a drop-down
+ /// doesn't mark its section label.
+ #[test]
+ fn without_the_preference_hovering_a_result_leaves_the_ribbon_alone() {
+ use crate::scenario::rect_of;
+ let mut h = crate::scenario::Harness::new();
+ h.app.home.open = false;
+ h.frames(3);
+ assert!(!h.app.preferences.ribbon_reveal, "off by default");
+ let away = rect_of("toolbar").unwrap().center_bottom() + vec2(0.0, 300.0);
+ h.call("ui.move", json!({"x": away.x, "y": away.y}));
+ h.call("ui.palette", json!({}));
+ h.frames(10);
+ for (query, id) in [("stitch", "surface.stitch"), ("circular", "solid.pattern.circular")] {
+ h.app.sbox.text = query.into();
+ h.frames(2);
+ let row = rect_of(&format!("search:command:{id}")).unwrap_or_else(|| panic!("no result row for {id}"));
+ h.call("ui.move", json!({"x": row.center().x, "y": row.center().y + 1.0}));
+ h.call("ui.move", json!({"x": row.center().x, "y": row.center().y}));
+ h.frames(3);
+ assert_eq!(h.app.ui.tab, "MODEL", "{id}");
+ assert!(h.app.sbox.reveal.is_none(), "{id}");
+ assert!(rect_of("ribbon:reveal").is_none() && rect_of("toolbar_dropdown").is_none(), "{id}");
+ }
+ h.call("ui.key", json!({"key": "Enter"}));
+ h.frames(2);
+ assert!(!h.app.ui.palette_open);
+ assert!(h.app.sbox.reveal.is_none());
+ assert!(rect_of("ribbon:reveal").is_none());
+ assert!(rect_of("ribbon:running_section:MODEL:ARRANGE").is_none());
+ }
+
#[test]
fn search_finds_by_name_id_and_panel_and_puts_recent_first() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs
index 1e0a98df01..239ab666f8 100644
--- a/crates/ui-egui/src/toolbar.rs
+++ b/crates/ui-egui/src/toolbar.rs
@@ -1339,6 +1339,14 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
(None, Some(_)) => app.last_command.as_ref().map(|(id, _)| id.clone()),
_ => None,
};
+ // The command the search points out (#7287): a preview while a result is hovered, or the
+ // short pulse after starting one.
+ let now = ui.input(|i| i.time);
+ let reveal = app.sbox.reveal.clone().filter(|r| r.preview || now - r.since < crate::shortcut_box::REVEAL_PULSE);
+ let pulse = reveal.as_ref().map_or(0.0, |r| r.strength(now, ui.ctx().global_style().animation_time > 0.0));
+ if reveal.is_some() {
+ ui.ctx().request_repaint();
+ }
let mut px = ribbon_left;
let top = r.top() + TAB_ROW_HEIGHT;
let mut drop: Option<(&'static str, &'static str, Option<&'static str>)> = None;
@@ -1529,6 +1537,16 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
} else if resp.hovered() && info.enabled {
painter.rect_filled(whole, t.radius_sm, t.hover);
}
+ let revealed = reveal.as_ref().filter(|r| r.id == c.id || r.id == selected.id || family.is_some_and(|f| f.commands.contains(&r.id)));
+ if revealed.is_some() {
+ paint_reveal(&painter, whole, &accent, pulse, true);
+ crate::scenario::publish_rect("ribbon:reveal", whole);
+ }
+ if let Some(r) = revealed.filter(|r| r.preview)
+ && let Some(command) = solidcraft_engine::find_command(r.id)
+ {
+ reveal_tooltip(app, ui, whole, command, egui::RectAlign::BOTTOM_START);
+ }
let icon = if selected.id == "sketch.finish" { "finish" } else { info.icon };
let side = if finish { 30.0 } else { 26.0 };
let icon_rect =
@@ -1610,6 +1628,13 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
),
egui::StrokeKind::Inside,
);
+ if let Some(r) = reveal.as_ref().filter(|r| r.id == c.id) {
+ paint_reveal(&painter, cell, &accent, pulse, true);
+ crate::scenario::publish_rect("ribbon:reveal", cell);
+ if r.preview {
+ reveal_tooltip(app, ui, cell, c, egui::RectAlign::BOTTOM_START);
+ }
+ }
icons::paint_icon(
&painter,
Rect::from_center_size(cell.center(), vec2(15.0, 15.0)),
@@ -1647,13 +1672,32 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
let lresp = ui.interact(lr, ui.id().with(("panel", panel)), Sense::click());
crate::scenario::publish_handle(&format!("panel:{tab}:{panel}"), lr.center());
crate::scenario::publish_target(&format!("ribbon:section:{tab}:{panel}"), lr);
+ // Commands this panel has only in its drop-down (not drawn as a button or cell).
+ let drawn_ids: Vec<&str> = large
+ .iter()
+ .take(drawn)
+ .flat_map(|c| crate::sketch_families::family(c.id).filter(|_| sketch_create).map_or_else(|| vec![c.id], |f| f.commands.to_vec()))
+ .chain(gallery.iter().filter(|_| !collapsed && drawn > large.len()).map(|c| c.id))
+ .collect();
+ let hidden = |id: &str| cmds.iter().any(|c| c.id == id) && !drawn_ids.contains(&id);
+ let hidden_running = app.preferences.ribbon_reveal && running.as_deref().is_some_and(hidden);
+ let hidden_reveal = reveal.as_ref().filter(|r| hidden(r.id));
let panel_open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))) == Some(popup_id);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
let hot = lresp.hovered() && enabled_panel;
- if panel_open || hot {
+ if hidden_running && !panel_open {
+ // Its command is running from the drop-down: the label shows it like a pressed button.
+ painter.rect(lr, t.radius_sm, accent.soft, Stroke::new(1.0, accent.color), egui::StrokeKind::Inside);
+ crate::scenario::publish_rect(&format!("ribbon:running_section:{tab}:{panel}"), lr);
+ } else if panel_open || hot {
painter.rect_filled(lr, t.radius_sm, if panel_open { accent.soft } else { t.hover });
}
+ if hidden_reveal.is_some_and(|r| !r.preview) {
+ paint_reveal(&painter, lr, &accent, pulse, true);
+ crate::scenario::publish_rect("ribbon:reveal", lr);
+ }
let label = if finish { app.tr("ui.ribbon_exit").to_string() } else { ribbon_label(app, panel) };
+ let panel_open = panel_open || hidden_running;
let font = if panel_open || hot {
crate::fonts::semibold(crate::theme::Tokens::get().font_caption)
} else {
@@ -1696,11 +1740,15 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
}
}
let open = ui.ctx().data(|d| d.get_temp::<egui::Id>(egui::Id::new("sc_panel_open"))) == Some(popup_id);
- if open {
+ // A hovered search result in this drop-down opens it on its row, under the search sheet.
+ let previewed = hidden_reveal.is_some_and(|r| r.preview && !open);
+ if open || previewed {
let cmds = if collapsed || trimmed { menu_commands(&cmds, &shown) } else { cmds.clone() };
- let area = Container::new(ui.ctx(), Surface::Popup).area(popup_id).fixed_pos(lr.left_bottom()).order(egui::Order::Foreground).show(
- ui.ctx(),
- |ui| {
+ let area = Container::new(ui.ctx(), Surface::Popup)
+ .area(popup_id)
+ .fixed_pos(lr.left_bottom())
+ .order(if open { egui::Order::Foreground } else { egui::Order::Middle })
+ .show(ui.ctx(), |ui| {
crate::ui_kit::Menu::show_frame(ui, crate::ui_kit::Menu::frame(), |ui| {
ui.spacing_mut().item_spacing.y = 0.0;
ui.set_min_width(200.0);
@@ -1752,7 +1800,8 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
section_heading(ui, heading, row_w);
}
let pinned = crate::toolbar_custom::pinned_on(app, &tab, c.id).is_some();
- match dropdown_row(app, ui, c, row_w, pinned) {
+ let revealed = reveal.as_ref().is_some_and(|r| r.id == c.id);
+ match dropdown_row(app, ui, c, row_w, pinned, revealed.then_some(pulse)) {
RowAction::None => {}
RowAction::Menu(at) => menu = Some((at, c.id)),
RowAction::TogglePin => toggle = Some(c.id),
@@ -1765,13 +1814,15 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
});
section_footer(ui);
});
- },
- );
+ });
popup_rect = Some(area.response.rect);
crate::scenario::publish_rect("toolbar_dropdown", area.response.rect);
// A drag out of the drop-down ends with a release elsewhere: not a click elsewhere.
let dragging = egui::DragAndDrop::has_payload_of_type::<ToolbarDrag>(ui.ctx());
- if (area.response.clicked_elsewhere() && !lresp.clicked() && !opened && !dragging) || ui.input(|i| i.key_pressed(egui::Key::Escape)) {
+ if open
+ && ((area.response.clicked_elsewhere() && !lresp.clicked() && !opened && !dragging)
+ || ui.input(|i| i.key_pressed(egui::Key::Escape)))
+ {
ui.ctx().data_mut(|d| d.remove::<egui::Id>(egui::Id::new("sc_panel_open")));
}
}
@@ -1952,6 +2003,47 @@ fn ribbon_tooltip(app: &SolveApp, response: egui::Response, command: &solidcraft
})
}
+/// The pulse around a command the search points out (#7287); `strength` 0 draws nothing.
+/// `fill` tints the inside too, for a button painted before its icon and label.
+fn paint_reveal(painter: &egui::Painter, rect: Rect, accent: &crate::theme::TabAccent, strength: f32, fill: bool) {
+ if strength <= 0.0 {
+ return;
+ }
+ let t = Tokens::get();
+ painter.rect(
+ rect,
+ t.radius_sm,
+ if fill { accent.soft.gamma_multiply(strength) } else { Color32::TRANSPARENT },
+ Stroke::new(2.0, accent.color.gamma_multiply(strength)),
+ egui::StrokeKind::Inside,
+ );
+}
+
+/// A revealed command's tooltip, open without the pointer on it (#7287).
+fn reveal_tooltip(app: &SolveApp, ui: &egui::Ui, rect: Rect, command: &solidcraft_engine::CommandSpec, align: egui::RectAlign) {
+ let mut tip = egui::Tooltip::always_open(ui.ctx().clone(), ui.layer_id(), egui::Id::new(("ribbon_reveal", command.id)), rect);
+ tip.popup = tip.popup.align(align);
+ // The same text as a drop-down row's own tooltip: name and shortcut, its help, and why it is
+ // disabled when it is.
+ let info = crate::render_workspace::interactive_command_info(app, command);
+ let label = app.tr_label(info.label);
+ let shortcut = crate::keymap::display_for(app, command.id).map(|k| format!(" ({k})")).unwrap_or_default();
+ let help = crate::command_help::help(command.id);
+ if let Some(shown) = tip.show(|ui| {
+ ui.set_max_width(300.0);
+ ui.label(egui::RichText::new(format!("{label}{shortcut}")).strong());
+ if let Some(help) = help {
+ ui.add_space(2.0);
+ ui.label(egui::RichText::new(help).weak());
+ }
+ if let Some(reason) = info.disabled_reason.as_deref() {
+ ui.label(egui::RichText::new(reason).weak());
+ }
+ }) {
+ crate::scenario::publish_rect("ribbon:reveal_tooltip", shown.response.rect);
+ }
+}
+
fn section_heading(ui: &mut egui::Ui, label: &str, width: f32) {
let t = Tokens::get();
let (rect, _) = ui.allocate_exact_size(vec2(width, 24.0), Sense::hover());
@@ -1998,7 +2090,15 @@ fn dropdown_width(app: &SolveApp, ui: &egui::Ui, cmds: &[&'static solidcraft_eng
/// One command row of a panel drop-down: icon, label and shortcut, with the hover background
/// under the pointer or keyboard focus (like every menu).
-fn dropdown_row(app: &SolveApp, ui: &mut egui::Ui, c: &'static solidcraft_engine::CommandSpec, width: f32, pinned: bool) -> RowAction {
+/// `revealed` is the pulse strength when the command search points this row out (#7287).
+fn dropdown_row(
+ app: &SolveApp,
+ ui: &mut egui::Ui,
+ c: &'static solidcraft_engine::CommandSpec,
+ width: f32,
+ pinned: bool,
+ revealed: Option<f32>,
+) -> RowAction {
let t = Tokens::get();
let info = crate::render_workspace::interactive_command_info(app, c);
let (rect, _) = ui.allocate_exact_size(vec2(width, ROW_H), Sense::hover());
@@ -2027,10 +2127,18 @@ fn dropdown_row(app: &SolveApp, ui: &mut egui::Ui, c: &'static solidcraft_engine
if c.id == "view.shots_strip" {
row.checked = Some(app.preferences.render_shots_strip);
}
- row.highlighted = hot;
+ row.highlighted = hot || revealed.is_some();
let shortcut = crate::keymap::display_for(app, c.id).unwrap_or_default();
row.shortcut = &shortcut;
row.paint(ui, rect, &resp, 26.0);
+ if let Some(strength) = revealed {
+ paint_reveal(ui.painter(), rect, &crate::theme::TabAccent::for_tab(&t, &app.ui.tab), strength, false);
+ crate::scenario::publish_rect("ribbon:reveal", rect);
+ if !ui.clip_rect().contains_rect(rect) {
+ ui.scroll_to_rect(rect, None);
+ }
+ reveal_tooltip(app, ui, rect, c, egui::RectAlign::RIGHT_START);
+ }
if hot {
crate::scenario::publish_handle(&format!("dropdown_hot:{}", c.id), rect.center());
}
@@ -2139,7 +2247,9 @@ fn sketch_menu_rows(
) {
for c in cmds {
let pinned = crate::toolbar_custom::pinned_on(app, "SKETCH", c.id).is_some();
- match dropdown_row(app, ui, c, width, pinned) {
+ // A hovered search result in a sketch creation menu is marked steadily (#7287).
+ let revealed = app.sbox.reveal.as_ref().is_some_and(|r| r.preview && r.id == c.id);
+ match dropdown_row(app, ui, c, width, pinned, revealed.then_some(1.0)) {
RowAction::None => {}
RowAction::Menu(at) => *menu = Some((at, c.id)),
RowAction::TogglePin => *toggle = Some(c.id),
diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rs
index 654800bef0..139fca2d3d 100644
--- a/crates/ui-egui/src/workspace.rs
+++ b/crates/ui-egui/src/workspace.rs
@@ -725,19 +725,23 @@ pub fn sync_context(app: &mut crate::SolveApp) {
pub fn select_command_tab(app: &mut crate::SolveApp, id: &str) {
sync_context(app);
- let Some(c) = solidcraft_engine::find_command(id) else { return };
+ if let Some(tab) = command_tab(app, id) {
+ app.ui.tab = tab.into();
+ }
+}
+
+/// The tab to switch to so the ribbon shows command `id`, or `None` to stay: the current tab
+/// already lists it, or its home tab can't be shown.
+pub fn command_tab(app: &crate::SolveApp, id: &str) -> Option<&'static str> {
+ let c = solidcraft_engine::find_command(id)?;
// Keep the tab a toolbar click came from when it already lists this shared command.
if crate::toolbar_custom::panel_lists(&app.ui.tab).iter().any(|(_, cmds, _)| cmds.iter().any(|c| c.id == id)) {
- return;
- }
- if let Some((tab, _)) = destination(c) {
- if render_tab(tab) && !crate::render_workspace::active(app) {
- return;
- } // The Render workspace owns its entry/exit lifecycle.
- if visible_tabs(app).contains(&tab) {
- app.ui.tab = tab.into();
- }
+ return None;
}
+ let (tab, _) = destination(c)?;
+ // The Render workspace owns its entry/exit lifecycle.
+ let render_closed = render_tab(tab) && !crate::render_workspace::active(app);
+ (!render_closed && visible_tabs(app).contains(&tab)).then_some(tab)
}
/// Defaults from the previous ribbon, used only to carry removals into the new layout.
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index d2146e14eb..524163b1a2 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -414,6 +414,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `pan_reverse_y` (default false: vertical scrolling pans the other way)
- `perspective_fov` (Perspective view's vertical field of view in radians, 0.2618…1.5708 (15°…90°), default 0.6; when it changes, the camera's distance scales so the view keeps its size)
- `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it)
+- `ribbon_reveal` (default false: hovering a result in Search commands switches the ribbon to the command's tab and marks its button, or opens the panel drop-down that holds it on its row, handle `ribbon:reveal`; leaving the results goes back to the tab before; a command started from the search blinks there, and a running command from a drop-down marks its panel label, `ribbon:running_section:<TAB>:<SECTION>`, #7287)
- `right_drag_orbits` (default true; false: a right drag the mouse preset would orbit leaves the camera alone, #6492)
- `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle)
- `sketch_auto_dimensions` (default false: each shape drawn in a sketch gets all its dimensions at the sizes drawn, as `sketch.draw.dimensioned` with `as_drawn`; typed values win)