Status bar: the sketch's state, what is being edited and the design's units (#7243) (#7248)

* claim: #7243

* feat(ui): status bar with the sketch's state, what is being edited and the design's units (#7243)
This commit is contained in:
Lars Jansen authored and GitHub committed 2026-10-28 16:25:32 +00:00
1 parent fe3fb381b1
commit dca332201f
13 files changed
+492 -3

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
{
"en": {
"prefs.status_bar": "Status bar",
"prefs.status_bar_note": "A thin bar along the window's bottom edge shows what is being edited, the open sketch's state in its color and the design's units; a click on the units changes them. The sketch's state then no longer shows in the view's corner.",
"status.editing": "Editing {name}",
"status.under_constrained": "Under constrained ({count} degrees of freedom)",
"status.under_constrained_one": "Under constrained ({count} degree of freedom)",
"status.units_tip": "The design's units. Click to change them"
},
"en-GB": {
"prefs.status_bar_note": "A thin bar along the window's bottom edge shows what is being edited, the open sketch's state in its colour and the design's units; a click on the units changes them. The sketch's state then no longer shows in the view's corner."
},
"de": {
"prefs.status_bar": "Statusleiste",
"prefs.status_bar_note": "Eine schmale Leiste am unteren Fensterrand zeigt, was gerade bearbeitet wird, den Zustand der offenen Skizze in seiner Farbe und die Einheiten der Konstruktion; ein Klick auf die Einheiten ändert sie. Der Zustand der Skizze steht dann nicht mehr in der Ecke der Ansicht.",
"status.editing": "{name} wird bearbeitet",
"status.under_constrained": "Unterbestimmt ({count} Freiheitsgrade)",
"status.under_constrained_one": "Unterbestimmt ({count} Freiheitsgrad)",
"status.units_tip": "Die Einheiten der Konstruktion. Zum Ändern klicken"
},
"ja": {
"prefs.status_bar": "ステータスバー",
"prefs.status_bar_note": "ウィンドウの下端の細いバーに、編集中のもの、開いているスケッチの状態(その色で)、デザインの単位を表示します。単位をクリックすると変更できます。スケッチの状態はビューの隅には表示されなくなります。",
"status.editing": "編集中: {name}",
"status.under_constrained": "拘束不足(自由度 {count})",
"status.under_constrained_one": "拘束不足(自由度 {count})",
"status.units_tip": "デザインの単位。クリックして変更"
},
"ko": {
"prefs.status_bar": "상태 표시줄",
"prefs.status_bar_note": "창 아래쪽 가장자리의 얇은 표시줄에 편집 중인 항목, 열려 있는 스케치의 상태(해당 색상으로), 설계 단위가 표시됩니다. 단위를 클릭하면 변경할 수 있습니다. 스케치 상태는 더 이상 뷰 모서리에 표시되지 않습니다.",
"status.editing": "{name} 편집 중",
"status.under_constrained": "구속 부족 (자유도 {count}개)",
"status.under_constrained_one": "구속 부족 (자유도 {count}개)",
"status.units_tip": "설계 단위입니다. 클릭하여 변경"
},
"nl": {
"prefs.status_bar": "Statusbalk",
"prefs.status_bar_note": "Een smalle balk langs de onderrand van het venster toont wat er wordt bewerkt, de staat van de open schets in zijn kleur en de eenheden van het ontwerp; een klik op de eenheden wijzigt ze. De staat van de schets staat dan niet meer in de hoek van de weergave.",
"status.editing": "{name} wordt bewerkt",
"status.under_constrained": "Onderbeperkt ({count} vrijheidsgraden)",
"status.under_constrained_one": "Onderbeperkt ({count} vrijheidsgraad)",
"status.units_tip": "De eenheden van het ontwerp. Klik om ze te wijzigen"
},
"zh": {
"prefs.status_bar": "状态栏",
"prefs.status_bar_note": "窗口底边的一条细栏显示正在编辑的对象、打开的草图的状态(以其颜色显示)以及设计的单位;单击单位即可更改。草图的状态随后不再显示在视图的角落。",
"status.editing": "正在编辑 {name}",
"status.under_constrained": "欠约束({count} 个自由度)",
"status.under_constrained_one": "欠约束({count} 个自由度)",
"status.units_tip": "设计的单位。单击可更改"
},
"ar": {
"prefs.status_bar": "شريط الحالة",
"prefs.status_bar_note": "شريط رفيع على الحافة السفلية للنافذة يعرض ما يجري تحريره، وحالة الرسم المفتوح بلونها، ووحدات التصميم؛ النقر على الوحدات يغيّرها. عندها لا تظهر حالة الرسم في زاوية العرض.",
"status.editing": "تحرير {name}",
"status.under_constrained": "قيود ناقصة ({count} درجات حرية)",
"status.under_constrained_one": "قيود ناقصة ({count} درجة حرية)",
"status.units_tip": "وحدات التصميم. انقر لتغييرها"
},
"he": {
"prefs.status_bar": "שורת מצב",
"prefs.status_bar_note": "פס דק לאורך הקצה התחתון של החלון מציג מה נערך, את מצב הסקיצה הפתוחה בצבע שלו ואת יחידות התכנון; לחיצה על היחידות משנה אותן. מצב הסקיצה לא מוצג אז עוד בפינת התצוגה.",
"status.editing": "עריכת {name}",
"status.under_constrained": "אילוצים חסרים ({count} דרגות חופש)",
"status.under_constrained_one": "אילוצים חסרים (דרגת חופש {count})",
"status.units_tip": "יחידות התכנון. לחצו כדי לשנות אותן"
},
"vi": {
"prefs.status_bar": "Thanh trạng thái",
"prefs.status_bar_note": "Một thanh mảnh dọc cạnh dưới cửa sổ hiển thị thứ đang được chỉnh sửa, trạng thái của bản phác đang mở theo màu của nó và đơn vị của thiết kế; nhấp vào đơn vị để đổi. Khi đó trạng thái bản phác không còn hiện ở góc khung nhìn.",
"status.editing": "Đang sửa {name}",
"status.under_constrained": "Thiếu ràng buộc ({count} bậc tự do)",
"status.under_constrained_one": "Thiếu ràng buộc ({count} bậc tự do)",
"status.units_tip": "Đơn vị của thiết kế. Nhấp để đổi"
}
}
+3
View File
@@ -265,6 +265,7 @@ pub mod space_mouse_calibration;
pub mod space_mouse_model;
pub mod space_mouse_offer;
pub mod stand_up;
mod status_bar;
#[cfg(test)]
mod sweep_dialog_tests;
pub(crate) mod test_boat;
@@ -2374,6 +2375,8 @@ impl SolveApp {
return;
}
}
// The status bar first: it spans the window's width below History and the side panels.
status_bar::show(self, ui);
let floating = render_workspace::active(self) || ui_kit::Container::new(ui.ctx(), ui_kit::Surface::Panel).floating();
timeline::follow_view_pick(self);
render_ui::focus_shortcut(self, ui);
+4
View File
@@ -870,6 +870,9 @@ preference_settings! {
/// While a dialog or a sketch is open, OK and Cancel in the view's top right corner, with the
/// axis view moved down below them (#6709). Off by default.
view_confirm_corner: bool = false, PAGE_INTERFACE => check_id("prefs.view_confirm_corner");
/// A thin bar along the window's bottom edge: what is being edited, the open sketch's state
/// and the design's units (#7243). Off by default.
status_bar: bool = false, PAGE_INTERFACE => check_id("prefs.status_bar");
/// Put the feature history to the left of the browser instead of below the viewport.
timeline_left: bool = false, PAGE_INTERFACE;
/// Measured outer width; the contents react to this width without a names mode.
@@ -4372,6 +4375,7 @@ mod tests {
("color_vision", json!("protan"), PAGE_INTERFACE),
("viewport_theme", json!("light"), PAGE_INTERFACE),
("view_confirm_corner", json!(true), PAGE_INTERFACE),
("status_bar", json!(true), PAGE_INTERFACE),
("nav", json!("blender"), PAGE_NAVIGATION),
("look_at_anim", json!(false), PAGE_NAVIGATION),
("selection_shift_add_only", json!(true), PAGE_SKETCH),
+5
View File
@@ -183,6 +183,11 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
app.preferences.browser_bodies_folders = *mode;
}
});
// What is being edited, the sketch's state and the units, along the bottom (#7243).
ui_kit::row(ui, "", |ui| {
let check = setting::status_bar(app, ui).on_hover_text(app.tr("prefs.status_bar_note"));
crate::scenario::publish_target("prefs:status_bar", check.rect);
});
ui_kit::text(ui, app.tr("prefs.layout_note"), ui_kit::Text::Hint("layout"));
ui_kit::text(ui, app.tr("prefs.history_sketches_note"), ui_kit::Text::Hint("history_sketches"));
ui_kit::LayoutPreview {
+3
View File
@@ -112,6 +112,8 @@ pub(crate) struct State {
pub left_space: Option<Rect>,
/// The left column an open dialog holds this frame (`dialog_column`).
pub dialog_column: Option<Rect>,
/// The status bar along the window's bottom edge, while it is shown (#7243).
pub status_bar: Option<Rect>,
}
/// Register the actual card, so fitting and pointer shielding use the same rectangle.
@@ -160,6 +162,7 @@ pub(crate) fn covered_rects(app: &SolveApp) -> Vec<Rect> {
rects.extend(app.viewport.palette_rect.filter(|_| app.session.active_sketch.is_some()));
rects.extend(app.viewport.dialog_rect.filter(|_| app.dialog.is_some() || app.tree.redefine.is_some()));
rects.extend(crate::view_confirm::rect(app));
rects.extend(app.shell.status_bar.filter(|_| crate::status_bar::shown(app)));
rects.retain(|r| r.is_finite() && r.is_positive());
rects
}
+143
View File
@@ -965,3 +965,146 @@ fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() {
assert_eq!(restored.preferences.dialog_place, DialogPlace::Edge);
assert_eq!(restored.preferences.default_units, "in");
}
/// Every text the last frame painted.
fn painted_texts(h: &Harness) -> Vec<String> {
fn walk(shape: &egui::Shape, out: &mut Vec<String>) {
match shape {
egui::Shape::Text(t) => out.push(t.galley.text().to_string()),
egui::Shape::Vec(shapes) => shapes.iter().for_each(|s| walk(s, out)),
_ => {}
}
}
let mut out = Vec::new();
h.shapes.iter().for_each(|s| walk(&s.shape, &mut out));
out
}
#[test]
fn status_bar_spans_the_window_below_history_in_both_layouts_and_is_covered() {
for mode in [LayoutMode::Docked, LayoutMode::Floating] {
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1400,"height":900}));
h.call("ui.set", json!({"layout":mode}));
h.app.run("solid.box", json!({"length":40,"width":30,"height":20})).unwrap();
h.settle();
assert!(rect_of("status:bar").is_none() && h.app.shell.status_bar.is_none(), "off by default");
let viewport_without = h.app.viewport.rect.unwrap();
let covered_without = covered_rects(&h.app);
h.call("ui.prefs", json!({"status_bar": true}));
h.settle();
let bar = rect_of("status:bar").unwrap();
assert_eq!(h.app.shell.status_bar, Some(bar));
assert_eq!((bar.left(), bar.right(), bar.bottom()), (0.0, 1400.0, 900.0), "{mode:?}: full width at the window's bottom: {bar:?}");
assert_eq!(bar.height(), crate::status_bar::HEIGHT);
let viewport = h.app.viewport.rect.unwrap();
assert!(viewport.bottom() <= bar.top() + 0.5, "{mode:?}: the view ends above the bar: {viewport:?} {bar:?}");
assert_eq!(viewport.bottom(), viewport_without.bottom() - bar.height(), "{mode:?}: the view gives up only the bar's height");
let history = h.app.shell.history.unwrap();
assert!(history.bottom() <= bar.top() + 0.5, "{mode:?}: History sits above the bar: {history:?} {bar:?}");
let rects = covered_rects(&h.app);
assert!(rects.contains(&bar), "{mode:?}: the bar is covered: {rects:?}");
assert_eq!(rects.len(), covered_without.len() + 1, "{mode:?}: {rects:?} {covered_without:?}");
assert!(covered(&h.app, bar.center()));
h.call("ui.prefs", json!({"status_bar": false}));
h.settle();
assert!(rect_of("status:bar").is_none() && h.app.shell.status_bar.is_none());
assert_eq!(h.app.viewport.rect.unwrap(), viewport_without);
}
}
#[test]
fn status_bar_names_what_is_edited_and_the_sketch_state_and_replaces_the_views_corner_text() {
use crate::status_bar::SketchState;
let mut h = Harness::new();
let corner = |h: &Harness| painted_texts(h).into_iter().filter(|t| t.starts_with("Sketch1 — ")).collect::<Vec<_>>();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.settle();
assert_eq!(corner(&h), ["Sketch1 — fully constrained"], "without the bar the state stays in the view's corner");
h.call("ui.prefs", json!({"status_bar": true}));
h.settle();
let contents = crate::status_bar::contents(&h.app);
assert_eq!(contents.editing.as_deref(), Some("Editing Sketch1"));
assert_eq!(contents.sketch, Some(SketchState::Empty), "a blank sketch is not called fully constrained");
let rectangle = h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[40,30]})).unwrap();
h.settle();
let contents = crate::status_bar::contents(&h.app);
let Some(SketchState::Under(dof)) = contents.sketch else { panic!("{contents:?}") };
assert!(dof > 0);
let texts = painted_texts(&h);
assert!(corner(&h).is_empty(), "with the bar on, the view's corner shows no state: {texts:?}");
assert!(texts.contains(&format!("Under constrained ({dof} degrees of freedom)")), "{texts:?}");
assert!(texts.iter().any(|t| t == "Editing Sketch1") && texts.iter().any(|t| t == "mm"), "{texts:?}");
assert!(crate::scenario::handle_at("status:editing").unwrap().x < crate::scenario::handle_at("status:sketch").unwrap().x);
assert!(crate::scenario::handle_at("status:sketch").unwrap().x < crate::scenario::handle_at("status:units").unwrap().x);
// Fully constrained: the rectangle fixed in place.
h.app.run("sketch.constraint.fix", json!({"entities": rectangle["curves"]})).unwrap();
h.settle();
assert_eq!(crate::status_bar::contents(&h.app).sketch, Some(SketchState::Full));
h.app.run("sketch.finish", json!({})).unwrap();
h.app.run("solid.extrude", json!({"distance":10})).unwrap();
h.settle();
let idle = crate::status_bar::contents(&h.app);
assert_eq!((idle.editing, idle.sketch, idle.units.as_str()), (None, None, "mm"), "idle: only the units");
assert!(crate::scenario::handle_at("status:editing").is_none() && crate::scenario::handle_at("status:sketch").is_none());
// A feature's dialog, editing it.
let extrude = h.app.session.doc.features.iter().find(|f| f.name == "Extrude1").map(|f| f.id).unwrap();
h.app.edit_feature(extrude);
h.settle();
assert!(h.app.dialog.as_ref().is_some_and(|d| d.editing.is_some()));
assert_eq!(crate::status_bar::contents(&h.app).editing.as_deref(), Some("Editing Extrude1"));
// In another language the text is translated, and so is a default feature name.
let _ja = crate::i18n::scope("ja");
assert_eq!(crate::status_bar::contents(&h.app).editing, Some(format!("編集中: {}", crate::i18n::tr_name("Extrude1"))));
assert_eq!(crate::i18n::tr_name("Sketch1"), "スケッチ1");
}
#[test]
fn status_bar_units_open_the_units_menu_above_the_bar_and_change_units_in_one_undo_step() {
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1400,"height":900}));
h.call("ui.prefs", json!({"status_bar": true}));
h.app.run("solid.box", json!({"length":40,"width":30,"height":20})).unwrap();
h.settle();
let undo = h.app.session.undo.len();
let button = rect_of("status:units").unwrap();
assert!(rect_of("status:bar").unwrap().contains_rect(button));
h.step(&json!({"click":{"handle":"status:units"}})).unwrap();
h.settle();
assert_eq!(h.app.menu.target, crate::context_menu::Target::Units);
let at = h.app.viewport.context_menu.unwrap();
assert_eq!(at, button.right_top());
let menu = crate::context_menu::describe(&h.app);
let labels: Vec<_> = menu["items"].as_array().unwrap().iter().map(|i| i["label"].as_str().unwrap().to_string()).collect();
assert_eq!(labels, crate::prefs::UNITS);
// The list opens above the bar, inside the window.
let list = h.ctx.memory(|m| m.area_rect(egui::Id::new("sc_context_menu"))).unwrap();
assert!(list.bottom() <= button.top() + 0.5 && list.top() >= 0.0, "{list:?} {button:?}");
assert_eq!(h.app.session.undo.len(), undo, "opening the menu changes nothing");
h.call("ui.menuPick", json!({"item":"in"}));
h.settle();
assert_eq!(h.app.session.doc.units, "in");
assert_eq!(h.app.session.undo.len(), undo + 1);
assert!(h.app.viewport.context_menu.is_none());
assert_eq!(crate::status_bar::contents(&h.app).units, "in");
h.app.run("edit.undo", json!({})).unwrap();
h.settle();
assert_eq!(h.app.session.doc.units, "mm");
// A second click on the button closes the menu it opened.
h.step(&json!({"click":{"handle":"status:units"}})).unwrap();
h.settle();
assert!(h.app.viewport.context_menu.is_some());
h.step(&json!({"click":{"handle":"status:units"}})).unwrap();
h.settle();
assert!(h.app.viewport.context_menu.is_none());
}
#[test]
fn status_bar_stays_out_of_the_embed() {
let mut h = Harness::new();
h.app.embedded = true;
h.app.preferences.status_bar = true;
h.settle();
assert!(!crate::status_bar::shown(&h.app));
assert!(rect_of("status:bar").is_none() && h.app.shell.status_bar.is_none());
}
+216
View File
@@ -0,0 +1,216 @@
//! The status bar (Preferences › Interface › Status bar, #7243; off by default): a thin bar
//! along the window's bottom edge, below the History strip, with what is being edited, the open
//! sketch's state in that state's colour, and the design's units. A click on the units opens
//! the Units menu, whose rows run Change Design Units (`document.units`, one undo step). While
//! the bar is on, the sketch's state is not also painted in the view's top-left corner.
//!
//! The bar is window chrome like the application bar: full width and flat in either workspace
//! layout. It is allocated before the viewport, so the view and everything anchored to its
//! bottom (History, the navigation bar, toasts) sit above it, and it is one of the shell's
//! covered rects.
use egui::{Color32, FontId, Rect, Sense, pos2, vec2};
use crate::SolveApp;
use crate::theme::Tokens;
use crate::ui_kit::{Container, Edge, Surface};
/// The bar's height (logical pixels).
pub(crate) const HEIGHT: f32 = 24.0;
/// The bar is drawn: the preference is on, outside the compact browser embed (which has no
/// application chrome).
pub(crate) fn shown(app: &SolveApp) -> bool {
app.preferences.status_bar && !app.embedded
}
/// The open sketch's state as its solve reports it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum SketchState {
/// Nothing drawn in it yet.
Empty,
/// Degrees of freedom remain.
Under(usize),
Full,
/// The constraints conflict (the solve failed).
Conflict,
}
impl SketchState {
pub(crate) fn of(ss: &solidcraft_engine::doc::SolvedSketch) -> SketchState {
if !ss.report.ok() {
SketchState::Conflict
} else if !crate::sketch_palette::has_geometry(&ss.sketch) {
SketchState::Empty
} else if ss.report.dof == 0 {
SketchState::Full
} else {
SketchState::Under(ss.report.dof)
}
}
pub(crate) fn text(self) -> String {
match self {
SketchState::Conflict => crate::i18n::tr("ui.constraints_conflict").to_string(),
SketchState::Empty => crate::i18n::tr("ui.no_geometry_yet").to_string(),
SketchState::Full => crate::i18n::tr("ui.fully_constrained").to_string(),
SketchState::Under(dof) => crate::i18n::format(
if dof == 1 { "status.under_constrained_one" } else { "status.under_constrained" },
&[("count", &dof.to_string())],
),
}
}
/// The colour the sketch's curves take in this state, in the window's theme: the bar is
/// window chrome, not part of the view.
pub(crate) fn colour(self, t: &Tokens) -> Color32 {
match self {
SketchState::Conflict => t.error,
SketchState::Empty => t.text_dim,
SketchState::Full => t.sketch_fixed,
SketchState::Under(_) => t.sketch,
}
}
}
/// What the bar shows now.
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct Contents {
/// "Editing Sketch1": the feature whose dialog edits it, else the sketch whose plane is being
/// redefined, else the open sketch; nothing while idle or while a new feature is set up.
pub editing: Option<String>,
/// The open sketch's state.
pub sketch: Option<SketchState>,
/// The design's units (`mm`, `cm`, `m`, `in`, `ft`).
pub units: String,
}
pub(crate) fn contents(app: &SolveApp) -> Contents {
let st = app.session.world_state();
let sketch = app.session.active_sketch.and_then(|id| st.sketch(id));
let edited = app
.dialog
.as_ref()
.and_then(|d| d.editing)
.map(|(id, _)| id)
.or(app.tree.redefine)
.or(app.session.active_sketch)
.and_then(|id| app.session.doc.feature(id).map(|f| f.name.clone()).or_else(|| st.sketch(id).map(|ss| ss.name.clone())));
Contents {
editing: edited.map(|name| crate::i18n::format("status.editing", &[("name", &crate::i18n::tr_name(&name))])),
sketch: sketch.map(SketchState::of),
units: app.session.doc.units.clone(),
}
}
/// Draw the bar along the window's bottom edge. Call it before the panels and the viewport take
/// the rest of the window: the bar then spans the whole width and sits below History.
pub(crate) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
app.shell.status_bar = None;
if !shown(app) {
return;
}
let t = Tokens::get();
let contents = contents(app);
let host = Container::new(ui.ctx(), Surface::ApplicationBar);
let response = host
.edge("sc_status_bar", Edge::Bottom)
.exact_size(HEIGHT)
.show_separator_line(false)
.frame(host.edge_frame(t.toolbar))
.show(ui, |ui| paint(app, ui, &contents))
.response;
app.shell.status_bar = Some(response.rect);
crate::scenario::publish_target("status:bar", response.rect);
}
/// The items, right-aligned from the window's right edge: units, the sketch's state, what is
/// being edited. The left end stays free (for next-step hints, #2325). An item that would not
/// fit is left out, the leftmost first.
fn paint(app: &mut SolveApp, ui: &mut egui::Ui, contents: &Contents) {
let t = Tokens::get();
let r = ui.max_rect();
let painter = ui.painter().clone();
painter.hline(r.x_range(), r.top() + 0.5, t.primary_border(t.border));
let font = FontId::proportional(t.font_body);
let left = r.left() + t.space_8;
let mut right = r.right() - t.space_6;
// The units: a flat button with the kit's dropdown chevron.
let units = painter.layout_no_wrap(contents.units.clone(), font.clone(), t.text);
let chevron = t.space_10;
let width = t.space_6 + units.size().x + t.space_4 + chevron + t.space_6;
let button = Rect::from_min_max(pos2(right - width, r.top() + t.space_3), pos2(right, r.bottom() - t.space_3));
let response = ui.interact(button, egui::Id::new("sc_status_units"), Sense::click());
let open = app.viewport.context_menu.is_some() && app.menu.target == crate::context_menu::Target::Units;
if response.hovered() || open {
painter.rect_filled(button, t.control_radius, t.hover);
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
}
let units_at = pos2(button.left() + t.space_6, button.center().y - units.size().y / 2.0);
painter.galley(units_at, units, t.text);
let chevron_rect = Rect::from_center_size(pos2(button.right() - t.space_6 - chevron / 2.0, button.center().y), vec2(chevron, chevron));
crate::ui_kit::dropdown_indicator(&painter, chevron_rect, t.text_dim);
let label = crate::i18n::format("browser.units", &[("units", &contents.units)]);
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, &label));
crate::scenario::publish_target("status:units", button);
if response.on_hover_text(crate::i18n::tr("status.units_tip")).clicked() {
// The menu opens above the bar, its right edge on the button's.
crate::context_menu::toggle_for(app, button, button.right_top(), crate::context_menu::Target::Units);
}
right = button.left() - t.space_6;
// The sketch's state, after a dot in its colour; then what is being edited.
let mut items: Vec<(&str, String, Color32, Option<Color32>)> = Vec::new();
if let Some(state) = contents.sketch {
let colour = state.colour(&t);
items.push(("status:sketch", state.text(), colour, Some(colour)));
}
if let Some(editing) = &contents.editing {
items.push(("status:editing", editing.clone(), t.text_dim, None));
}
for (handle, text, colour, dot) in items {
let galley = painter.layout_no_wrap(text.clone(), font.clone(), colour);
let dot_width = if dot.is_some() { t.space_8 + t.space_6 } else { 0.0 };
let width = dot_width + galley.size().x;
// A rule between this item and the one to its right.
let rule = right - t.space_6;
if rule - t.space_6 - width < left {
break;
}
t.secondary_vline(&painter, rule, (r.top() + t.space_6)..=(r.bottom() - t.space_6), t.border);
let item = Rect::from_min_max(pos2(rule - t.space_6 - width, r.top()), pos2(rule - t.space_6, r.bottom()));
if let Some(dot) = dot {
painter.circle_filled(pos2(item.left() + t.space_4, item.center().y), t.space_3 + 0.5, dot);
}
painter.galley(pos2(item.left() + dot_width, item.center().y - galley.size().y / 2.0), galley, colour);
ui.interact(item, egui::Id::new(handle), Sense::hover()).widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &text));
crate::scenario::publish_target(handle, item);
right = item.left();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sketch_states_take_their_texts_and_the_window_themes_sketch_colours() {
let t = Tokens::light();
assert_eq!(SketchState::Full.text(), "Fully constrained");
assert_eq!(SketchState::Conflict.text(), "Constraints conflict");
assert_eq!(SketchState::Empty.text(), "No geometry yet");
assert_eq!(SketchState::Under(1).text(), "Under constrained (1 degree of freedom)");
assert_eq!(SketchState::Under(4).text(), "Under constrained (4 degrees of freedom)");
assert_eq!(SketchState::Under(4).colour(&t), t.sketch);
assert_eq!(SketchState::Full.colour(&t), t.sketch_fixed);
assert_eq!(SketchState::Conflict.colour(&t), t.error);
// Each state's text reads on the bar in both themes.
for t in [Tokens::light(), Tokens::dark()] {
for state in [SketchState::Under(2), SketchState::Full, SketchState::Conflict, SketchState::Empty] {
let ratio = crate::theme::contrast_ratio(state.colour(&t), t.toolbar);
assert!(ratio >= 3.0, "{state:?} on the bar: contrast {ratio:.2}");
}
}
}
}
+2 -1
View File
@@ -16,7 +16,8 @@ pub enum Surface {
Palette,
/// Workspace switcher and ribbon cards.
Chrome,
/// Native application/title bar; its presentation is independent of workspace layout.
/// Native application/title bar and the optional status bar along the window's bottom edge;
/// their presentation is independent of workspace layout.
ApplicationBar,
/// Movable system windows and modal dialogs; never become workspace docks.
Window,
+2 -2
View File
@@ -5398,8 +5398,8 @@ fn overlays(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
}
}
loose_end_markers(sk, &ss.ends, &ss.plane, painter, proj, &v);
// Sketch status.
if let Some(r) = app.viewport.layout.as_ref().map(|l| l.content) {
// Sketch status, unless the status bar shows it (#7243).
if let Some(r) = app.viewport.layout.as_ref().map(|l| l.content).filter(|_| !crate::status_bar::shown(app)) {
let status = if !ss.report.ok() {
crate::i18n::tr("sketch.status_conflict").to_string()
} else if ss.report.dof == 0 {
@@ -0,0 +1,29 @@
[
{"note": "Interface › Status bar (#7243): a thin bar along the window's bottom edge, off by default."},
{"expect": {"hidden_handles": ["status:bar", "status:units", "status:sketch", "status:editing"]}},
{"call": "ui.prefs", "params": {"status_bar": true}},
{"frames": 2},
{"note": "Idle: only the design's units."},
{"expect": {"shown_handles": ["status:bar", "status:units"], "hidden_handles": ["status:sketch", "status:editing"]}},
{"start": "sketch.create"},
{"click": {"plane": "XY"}},
{"start": "sketch.rectangle.two_point"},
{"click": {"sketch": [0, 0]}},
{"click": {"sketch": [40, 30]}},
{"key": "Escape"},
{"note": "In a sketch: what is being edited, the sketch's state, then the units, left to right."},
{"expect": {"sketching": true, "handle_order": ["status:editing", "status:sketch", "status:units"]}},
{"note": "A click on the units opens the Units menu; a row runs Change Design Units, one undo step."},
{"click": {"handle": "status:units"}},
{"frames": 2},
{"call": "ui.menuPick", "params": {"item": "in"}},
{"expect": {"query": {"command": "document.inspect", "path": ["units"], "value": "in"}, "sketching": true, "errors": 0}},
{"call": "engine.execute", "params": {"command": "edit.undo", "params": {}}},
{"expect": {"query": {"command": "document.inspect", "path": ["units"], "value": "mm"}}},
{"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},
{"expect": {"sketching": false, "shown_handles": ["status:units"], "hidden_handles": ["status:sketch", "status:editing"]}},
{"note": "Turned off again, the bar goes."},
{"call": "ui.prefs", "params": {"status_bar": false}},
{"frames": 2},
{"expect": {"hidden_handles": ["status:bar", "status:units", "status:sketch", "status:editing"]}}
]
+6
View File
@@ -115,6 +115,12 @@
selects it, and while the marker sits between a sketch and its feature, or the two are in
different folders, the sketch keeps a row of its own. The timeline along the bottom always lists
features in creation order.
- **Status bar** (off by default: Preferences › Interface › **Status bar**). A thin bar along
the window's bottom edge, below the timeline. From the right: the design's units (click them
to change the design's units, one undo step), the open sketch's state in its colour (under
constrained with its degrees of freedom, fully constrained, constraints conflict) and what is
being edited (Editing Sketch1, or Editing Extrude1 while that feature's dialog is open). While
it is on, the sketch's state no longer shows in the view's top-left corner.
- **Command search (S).** Click the ribbon search field or press S to open the search popup
below it. Results group commands by their ribbon path and show matching features and user
parameters from this design. With an empty query, recent commands appear first, followed by
+1
View File
@@ -355,6 +355,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned))
- `sketch_tab_always` (default false: the SKETCH tab stays in the ribbon right after MODEL while no sketch is open; a tool in its CREATE or REFERENCE section then opens Create Sketch, on the selected plane or planar face or else on the plane picked next, and starts in the new sketch, #7904)
- `smooth_wheel_zoom` (default true)
- `status_bar` (default false: a thin bar along the window's bottom edge, below History, handle `status:bar`: what is being edited (`status:editing`), the open sketch's state in its colour (`status:sketch`) and the design's units (`status:units`, a click opens the Units menu, whose rows run `document.units`); the sketch's state then leaves the view's top-left corner, #7243)
- `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field)
- `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them)
- `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes))
+1
View File
@@ -39,6 +39,7 @@ windows use the shared composition, including its header and fixed outer frame.
| Feature forms, Parameters, material review, Redefine Sketch Plane | `dialogs`, `params_dialog`, `material_card_review`, `sketch_attachment_ui` → `Panel` | Adaptive feature surface; bounded anchors and pinned actions retained |
| Sketch options | `sketch_palette` → `Panel` | Adaptive palette surface, preserving transparency |
| Application bar, workspace and ribbon | `toolbar`, `shell` | Chrome hosts; adaptive card geometry comes from the shared policy |
| Status bar | `status_bar` | Application-bar surface along the window's bottom edge; flat and full width in both layouts, allocated before History and the viewport and counted as covered by the shell |
| Render settings | `render_workspace` | Panel host; existing right dock retained |
| Preferences, managers, About, update/install/recovery/crash/issue prompts | `Window`, `Confirm` | System windows and modal sheets retain modality; these are not workspace sidebars |
| BOM, Messages, mouse gestures, 3D mouse calibration | respective modules → `Window::show_body` | Shared header, tokenised frame and bounded body; native egui title bars/resize highlights and legacy report/width helpers removed |