Preferences: the theme strip shows arrows where more themes are (#6161) (#6167)

* claim: #6161

* Preferences: the theme strip shows arrows where more themes are (#6161)

The strip scrolls sideways with a hidden scrollbar, so nothing showed that
more themes were past its end. An end with themes past it now shows a
chevron button over the tiles there; a click scrolls most of a page.

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:
DuBearte
2026-10-25 01:24:54 +00:00
committed by GitHub
parent adbd2adf89
commit 67adf5abb5
5 changed files with 60 additions and 1 deletions
+2
View File
@@ -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",
+2
View File
@@ -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": "プロファイル/曲線",
+2
View File
@@ -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": "轮廓/曲线",
+18
View File
@@ -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());
+36 -1
View File
@@ -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: impl
ui.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: impl
tiles(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();