SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Preferences: the theme strip shows arrows where more themes are (#6161) (#6167)
DuBearte67adf5abb522
diff --git a/assets/locales/en.json b/assets/locales/en.jsonindex 0f05b74255..67d226a9a7 100644--- a/assets/locales/en.json+++ b/assets/locales/en.json@@ -305,6 +305,7 @@"Mitre": "Mitre","Model Parameters": "Model Parameters","Modeled": "Modeled",+ "More themes": "More themes","More toolbar panels": "More toolbar panels","Motion": "Motion","Mouse gestures": "Mouse gestures",@@ -376,6 +377,7 @@"Preview": "Preview","Preview Row": "Preview Row","Preview leaves the current design unchanged.": "Preview leaves the current design unchanged.",+ "Previous themes": "Previous themes","Profile / Edges": "Profile / Edges","Profiles or curves": "Profiles or curves","Profiles/Curves": "Profiles/Curves",diff --git a/assets/locales/ja.json b/assets/locales/ja.jsonindex 6cf8895f37..18c30ddc5e 100644--- a/assets/locales/ja.json+++ b/assets/locales/ja.json@@ -305,6 +305,7 @@"Mitre": "留め継ぎ","Model Parameters": "モデルパラメータ","Modeled": "モデル化済み",+ "More themes": "その他のテーマ","More toolbar panels": "その他のツールバーパネル","Motion": "モーション","Mouse gestures": "マウス ジェスチャ",@@ -376,6 +377,7 @@"Preview": "プレビュー","Preview Row": "行をプレビュー","Preview leaves the current design unchanged.": "プレビューは現在のデザインを変更しません。",+ "Previous themes": "前のテーマ","Profile / Edges": "プロファイル / エッジ","Profiles or curves": "プロファイルまたは曲線","Profiles/Curves": "プロファイル/曲線",diff --git a/assets/locales/zh.json b/assets/locales/zh.jsonindex 70f8bba8e0..008ec26429 100644--- a/assets/locales/zh.json+++ b/assets/locales/zh.json@@ -305,6 +305,7 @@"Mitre": "斜接","Model Parameters": "模型参数","Modeled": "已建模",+ "More themes": "更多主题","More toolbar panels": "更多工具栏面板","Motion": "运动","Mouse gestures": "鼠标手势",@@ -376,6 +377,7 @@"Preview": "预览","Preview Row": "预览行","Preview leaves the current design unchanged.": "预览不会更改当前设计。",+ "Previous themes": "上一组主题","Profile / Edges": "轮廓 / 边","Profiles or curves": "轮廓或曲线","Profiles/Curves": "轮廓/曲线",diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex 06aaa1ef03..9141595966 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -3312,6 +3312,24 @@ mod tests {/// next frame draws with their colours (dark following the base), an export gives the theme/// back complete, imported themes are saved with the preferences, Remove falls back to the/// base and Cancel takes an import back.+ /// #6161: the theme strip shows a chevron at each end with more themes past it; a click+ /// scrolls that way.+ #[test]+ fn the_theme_strip_shows_where_more_themes_are() {+ use serde_json::json;+ let mut h = crate::scenario::Harness::new();+ h.call("ui.prefs", json!({"open": "Interface"}));+ h.frames(4);+ let shown = |name: &str| crate::scenario::handle_at(name).is_some();+ assert!(shown("theme_rail:next"), "more themes than fit: a chevron on the right");+ assert!(!shown("theme_rail:previous"), "nothing before the first");+ let first = crate::scenario::handle_at("prefs:theme:light").unwrap();+ h.step(&json!({"click": {"handle": "theme_rail:next"}})).unwrap();+ h.frames(4);+ assert!(shown("theme_rail:previous"), "scrolled: a chevron on the left too");+ assert!(crate::scenario::handle_at("prefs:theme:light").is_none_or(|p| p.x < first.x), "the strip moved");+ }+#[test]fn system_theme_tile_export_uses_os_brightness_without_selecting_it() {let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rsindex 3237f5c27b..e8952b60d6 100644--- a/crates/ui-egui/src/ui_kit/preferences.rs+++ b/crates/ui-egui/src/ui_kit/preferences.rs@@ -100,6 +100,7 @@ pub(crate) fn settings_pair<R>(ui: &mut Ui, controls: impl FnOnce(&mut Ui) -> R,/// A horizontally scrollable, draggable tile rail with its import action pinned outside it./// The hidden scrollbar never reserves vertical space; a vertical wheel also moves the rail.+/// An end with more tiles past it shows a chevron that scrolls a page that way (#6161).pub(crate) fn theme_rail(ui: &mut Ui, tiles: impl FnOnce(&mut Ui), import: impl FnOnce(&mut Ui)) {let t = Tokens::get();let action_width = t.form_label_width + t.space_24 + t.space_6;@@ -108,7 +109,7 @@ pub(crate) fn theme_rail(ui: &mut Ui, tiles: impl FnOnce(&mut Ui), import: implui.spacing_mut().item_spacing.x = t.space_8;ui.allocate_ui_with_layout(vec2(rail_width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {ui.style_mut().always_scroll_the_only_direction = true;- egui::ScrollArea::horizontal()+ let out = egui::ScrollArea::horizontal().id_salt("settings_theme_rail").max_width(rail_width).auto_shrink([false, true])@@ -120,11 +121,45 @@ pub(crate) fn theme_rail(ui: &mut Ui, tiles: impl FnOnce(&mut Ui), import: impltiles(ui);});});+ rail_arrows(ui, out.id, out.state, out.inner_rect, out.content_size);});ui.allocate_ui_with_layout(vec2(action_width, 0.0), egui::Layout::top_down(egui::Align::Min), import);});}+/// The theme rail's chevrons: one at each end with tiles past it, over the tiles there.+fn rail_arrows(ui: &mut Ui, id: egui::Id, mut state: egui::scroll_area::State, view: Rect, content: egui::Vec2) {+ let t = Tokens::get();+ let room = (content.x - view.width()).max(0.0);+ // Halfway down the tiles (the area itself may report less height than they take).+ let middle = view.top() + content.y.max(view.height()) / 2.0;+ let size = t.control_height;+ for (more, next) in [(state.offset.x > 0.5, false), (state.offset.x < room - 0.5, true)] {+ if !more {+ continue;+ }+ let x = if next { view.right() - size / 2.0 } else { view.left() + size / 2.0 };+ let r = Rect::from_center_size(pos2(x, middle), vec2(size, size));+ let label = crate::i18n::tr_label(if next { "More themes" } else { "Previous themes" });+ let response = ui.interact(r, id.with(("rail_arrow", next)), Sense::click());+ ui.painter().rect_filled(r, t.control_radius, if response.hovered() { t.hover } else { t.control_fill });+ ui.painter().rect_stroke(r, t.control_radius, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ let icon = r.shrink(t.form_icon_inset);+ if next {+ crate::icons::paint_ink(ui.painter(), icon, "chevron_right", t.form_ink);+ } else {+ crate::icons::paint_ink_mirrored(ui.painter(), icon, "chevron_right", t.form_ink);+ }+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));+ scenario::publish_target(if next { "theme_rail:next" } else { "theme_rail:previous" }, r);+ if response.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(label).clicked() {+ let page = (view.width() * 0.8).max(size);+ state.offset.x = (state.offset.x + if next { page } else { -page }).clamp(0.0, room);+ state.store(ui.ctx(), id);+ }+ }+}+/// Dashed import tile matches the swatch tiles, while remaining permanently visible.pub(crate) fn theme_import_tile(ui: &mut Ui, label: &str, note: &str) -> Response {let t = Tokens::get();