Ribbon: a tool pinned into the Finish Sketch group shows pressed (#12049) (#12050)

* Ribbon: a tool pinned into the Finish Sketch group shows pressed

The Finish Sketch and Finish Editing groups never drew the pressed state for any of their buttons, so a drawing tool dragged into them (the group at the ribbon's right edge takes drops) looked like a one-shot action while it ran. Only Finish, Cancel and Finish Edit are now left out of the pressed state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Ribbon: test that Finish, Cancel and Finish Edit stay plain under a press

None of the three runs as a tool or leaves a dialog behind, so a press is the one way they could light up. The tests now press each one and fail if any of them is dropped from the exclusion. Finish Edit is pressed and released in the edit-in-place test, so the release is also the click that finishes the edit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Ribbon: Finish with AutoConstrain stays plain under a press like Finish

Finish with AutoConstrain belongs to the Finish Sketch group and ends the sketch like Finish, but it was not in the list of buttons left out of the pressed state, so once pinned as a button it lit while the pointer was held on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel
2026-11-04 21:32:12 +00:00
committed by GitHub
parent 61ada52984
commit 5efdd52854
2 changed files with 58 additions and 2 deletions
+11 -1
View File
@@ -390,7 +390,17 @@ fn finish_editing_is_a_model_tab_button_only_while_a_part_is_edited_in_place() {
settle(&mut h.app);
h.frames(3);
assert!(crate::scenario::rect_of("panel:MODEL:FINISH EDITING").is_some(), "the part's MODEL tab ends with Finish Edit");
h.app.start("component.finish_edit");
// Under a press Finish Edit stays plain, as Finish Sketch does; the release finishes.
let button = crate::scenario::rect_of("button:component.finish_edit").unwrap();
h.frame_with(crate::test_support::pointer(button.center(), true));
let soft = crate::theme::Tokens::get().accent_soft;
let lit = h.shapes.iter().any(|s| match &s.shape {
egui::Shape::Rect(r) => r.rect == button && r.fill == soft,
egui::Shape::Vec(v) => v.iter().any(|s| matches!(s, egui::Shape::Rect(r) if r.rect == button && r.fill == soft)),
_ => false,
});
assert!(!lit, "a press does not show Finish Edit pressed");
h.frame_with(crate::test_support::pointer(button.center(), false));
settle(&mut h.app);
h.frames(3);
assert!(h.app.edit_in_place.active.is_none());
+47 -1
View File
@@ -1833,7 +1833,11 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
let background_slot = painter.add(egui::Shape::Noop);
let accent = crate::theme::TabAccent::for_tab(&t, &tab);
let family_open = family.is_some_and(|f| egui::Popup::is_id_open(ui.ctx(), ui.id().with(("family", f.label)).with("popup")));
let neutral = if !finish
// The buttons that leave the sketch or the edit (Finish, Finish with AutoConstrain,
// Cancel, Finish Edit) never show pressed; a tool pinned into their group does.
let exit =
finish && matches!(selected.id, "sketch.finish" | "sketch.finish_auto_constrain" | "sketch.cancel" | "component.finish_edit");
let neutral = if !exit
&& (resp.is_pointer_button_down_on()
|| (ribbon_shows_pressed(app, selected.id) && !(persistent && app.preferences.persistent_ribbon_pressed))
|| family_open
@@ -5166,6 +5170,48 @@ mod dropdown_toggle_tests {
assert_eq!(h.app.tool.as_ref().map(|t| t.cmd), Some("sketch.line"));
}
/// A tool pinned into the Finish Sketch group, the one at the ribbon's right edge, shows
/// pressed while it runs like any other tool button; only Finish and Cancel never do, not
/// even under a press.
#[test]
fn a_tool_pinned_into_the_finish_group_shows_pressed_while_it_runs() {
fn flat(shape: &egui::Shape, out: &mut Vec<egui::Shape>) {
match shape {
egui::Shape::Vec(v) => v.iter().for_each(|s| flat(s, out)),
s => out.push(s.clone()),
}
}
let mut h = Harness::new();
h.app.home.open = false;
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
crate::toolbar_custom::reorder(&mut h.app, "SKETCH", "sketch.ellipse", "FINISH SKETCH", None);
h.settle();
h.step(&json!({"click": {"handle": "button:sketch.ellipse"}})).unwrap();
assert_eq!(h.app.tool.as_ref().map(|t| t.cmd), Some("sketch.ellipse"), "the click starts the tool");
h.frames(3);
let soft = crate::theme::TabAccent::for_tab(&crate::theme::Tokens::get(), "SKETCH").soft;
let pressed = |h: &Harness, id: &str| {
let r = rect_of(&format!("button:{id}")).unwrap();
let mut all = Vec::new();
h.shapes.iter().for_each(|s| flat(&s.shape, &mut all));
all.iter().any(|s| matches!(s, egui::Shape::Rect(s) if s.rect == r && s.fill == soft))
};
assert!(pressed(&h, "sketch.ellipse"), "the running tool's button is pressed");
// A press lights any other button while the pointer is down; Finish, Cancel and Finish
// with AutoConstrain (a button only once pinned) stay plain. None runs as a tool or
// leaves a dialog, so a press is how they would light.
for exit in ["sketch.finish", "sketch.cancel", "sketch.finish_auto_constrain"] {
let mut h = Harness::new();
h.app.home.open = false;
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
crate::toolbar_custom::pin(&mut h.app, "SKETCH", exit).unwrap();
h.settle();
let at = crate::scenario::handle_at(&format!("button:{exit}")).unwrap();
h.frame_with(crate::test_support::pointer(at, true));
assert!(!pressed(&h, exit), "a press on {exit} does not show it pressed");
}
}
/// A drop-down row's help tooltip names the key the command runs from now, not its default.
#[test]
fn a_drop_down_row_tooltip_names_a_rebound_key() {