* claim: #9875 * Preferences: split pages and preserve aliases and profiles * Preferences: preserve moved-page regressions and complete translations * Preferences: retain newly added settings in profiles * Preferences: target Tools in tool-cursor persistence tests
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
{
|
||||
"ar": {
|
||||
"prefs.structure.appearance": "المظهر",
|
||||
"prefs.structure.appearance_note": "الألوان والنصوص وإمكانية الوصول.",
|
||||
"prefs.structure.in_profile": "ضمن ملف التعريف",
|
||||
"prefs.structure.layout": "التخطيط",
|
||||
"prefs.structure.layout_note": "مواضع أجزاء النافذة.",
|
||||
"prefs.structure.look": "المظهر",
|
||||
"prefs.structure.measure_pointer": "القياس والمؤشر",
|
||||
"prefs.structure.mouse3d": "فأرة ثلاثية الأبعاد",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse وSpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "الفأرة ولوحة اللمس. للفأرة ثلاثية الأبعاد صفحة خاصة بها.",
|
||||
"prefs.structure.profile": "ملف التعريف",
|
||||
"prefs.structure.profile_edited": "تغيّر منذ الحفظ",
|
||||
"prefs.structure.profile_hover": "محفوظ في ملفات تعريف الإعدادات",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "رسم",
|
||||
"prefs.structure.tools": "الأدوات",
|
||||
"prefs.structure.tools_note": "كيفية عمل أدوات النمذجة.",
|
||||
"prefs.structure.work": "العمل"
|
||||
},
|
||||
"de": {
|
||||
"prefs.structure.appearance": "Erscheinungsbild",
|
||||
"prefs.structure.appearance_note": "Farben, Text und Barrierefreiheit.",
|
||||
"prefs.structure.in_profile": "Im Profil",
|
||||
"prefs.structure.layout": "Layout",
|
||||
"prefs.structure.layout_note": "Anordnung der Fensterbereiche.",
|
||||
"prefs.structure.look": "Ansicht",
|
||||
"prefs.structure.measure_pointer": "Messen und Zeiger",
|
||||
"prefs.structure.mouse3d": "3D-Maus",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse und SpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "Maus und Trackpad. Die 3D-Maus hat eine eigene Seite.",
|
||||
"prefs.structure.profile": "Profil",
|
||||
"prefs.structure.profile_edited": "Seit dem Speichern geändert",
|
||||
"prefs.structure.profile_hover": "Wird in Einstellungsprofilen gespeichert",
|
||||
"prefs.structure.scale_percent": "{percent} %",
|
||||
"prefs.structure.sketch": "Skizze",
|
||||
"prefs.structure.tools": "Werkzeuge",
|
||||
"prefs.structure.tools_note": "Verhalten der Modellierungswerkzeuge.",
|
||||
"prefs.structure.work": "Arbeit"
|
||||
},
|
||||
"en": {
|
||||
"prefs.structure.appearance": "Appearance",
|
||||
"prefs.structure.appearance_note": "Colors, text and accessibility.",
|
||||
"prefs.structure.in_profile": "In profile",
|
||||
"prefs.structure.layout": "Layout",
|
||||
"prefs.structure.layout_note": "Where the parts of the window sit.",
|
||||
"prefs.structure.look": "Look",
|
||||
"prefs.structure.measure_pointer": "Measure and pointer",
|
||||
"prefs.structure.mouse3d": "3D mouse",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse and SpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "Mouse and trackpad. The 3D mouse has its own page.",
|
||||
"prefs.structure.profile": "Profile",
|
||||
"prefs.structure.profile_edited": "Changed since saved",
|
||||
"prefs.structure.profile_hover": "Saved in settings profiles",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "Sketch",
|
||||
"prefs.structure.tools": "Tools",
|
||||
"prefs.structure.tools_note": "How modeling tools behave.",
|
||||
"prefs.structure.work": "Work"
|
||||
},
|
||||
"en-GB": {
|
||||
"prefs.structure.appearance_note": "Colours, text and accessibility.",
|
||||
"prefs.structure.tools_note": "How modelling tools behave."
|
||||
},
|
||||
"fi": {
|
||||
"prefs.structure.scale_percent": "{percent} %"
|
||||
},
|
||||
"fr": {
|
||||
"prefs.structure.scale_percent": "{percent} %"
|
||||
},
|
||||
"he": {
|
||||
"prefs.structure.appearance": "מראה",
|
||||
"prefs.structure.appearance_note": "צבעים, טקסט ונגישות.",
|
||||
"prefs.structure.in_profile": "כלול בפרופיל",
|
||||
"prefs.structure.layout": "פריסה",
|
||||
"prefs.structure.layout_note": "מיקום חלקי החלון.",
|
||||
"prefs.structure.look": "מראה",
|
||||
"prefs.structure.measure_pointer": "מדידה ומצביע",
|
||||
"prefs.structure.mouse3d": "עכבר תלת־ממדי",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse ו־SpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "עכבר ומשטח מגע. לעכבר התלת־ממדי יש עמוד משלו.",
|
||||
"prefs.structure.profile": "פרופיל",
|
||||
"prefs.structure.profile_edited": "השתנה מאז השמירה",
|
||||
"prefs.structure.profile_hover": "נשמר בפרופילי הגדרות",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "סקיצה",
|
||||
"prefs.structure.tools": "כלים",
|
||||
"prefs.structure.tools_note": "אופן הפעולה של כלי המידול.",
|
||||
"prefs.structure.work": "עבודה"
|
||||
},
|
||||
"ja": {
|
||||
"prefs.structure.appearance": "外観",
|
||||
"prefs.structure.appearance_note": "色、文字、アクセシビリティ。",
|
||||
"prefs.structure.in_profile": "プロファイルに保存",
|
||||
"prefs.structure.layout": "レイアウト",
|
||||
"prefs.structure.layout_note": "ウィンドウ内の配置。",
|
||||
"prefs.structure.look": "表示",
|
||||
"prefs.structure.measure_pointer": "計測とポインター",
|
||||
"prefs.structure.mouse3d": "3Dマウス",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse と SpaceNavigator。",
|
||||
"prefs.structure.navigation_note": "マウスとトラックパッド。3Dマウスは専用ページにあります。",
|
||||
"prefs.structure.profile": "プロファイル",
|
||||
"prefs.structure.profile_edited": "保存後に変更あり",
|
||||
"prefs.structure.profile_hover": "設定プロファイルに保存されます",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "スケッチ",
|
||||
"prefs.structure.tools": "ツール",
|
||||
"prefs.structure.tools_note": "モデリングツールの動作。",
|
||||
"prefs.structure.work": "作業"
|
||||
},
|
||||
"ko": {
|
||||
"prefs.structure.appearance": "모양",
|
||||
"prefs.structure.appearance_note": "색상, 텍스트 및 접근성.",
|
||||
"prefs.structure.in_profile": "프로필에 포함",
|
||||
"prefs.structure.layout": "레이아웃",
|
||||
"prefs.structure.layout_note": "창 구성 요소의 위치.",
|
||||
"prefs.structure.look": "보기",
|
||||
"prefs.structure.measure_pointer": "측정 및 포인터",
|
||||
"prefs.structure.mouse3d": "3D 마우스",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse 및 SpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "마우스와 트랙패드. 3D 마우스는 별도 페이지에 있습니다.",
|
||||
"prefs.structure.profile": "프로필",
|
||||
"prefs.structure.profile_edited": "저장 후 변경됨",
|
||||
"prefs.structure.profile_hover": "설정 프로필에 저장됨",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "스케치",
|
||||
"prefs.structure.tools": "도구",
|
||||
"prefs.structure.tools_note": "모델링 도구의 동작.",
|
||||
"prefs.structure.work": "작업"
|
||||
},
|
||||
"tr": {
|
||||
"prefs.structure.scale_percent": "%{percent}"
|
||||
},
|
||||
"vi": {
|
||||
"prefs.structure.appearance": "Giao diện",
|
||||
"prefs.structure.appearance_note": "Màu sắc, văn bản và khả năng tiếp cận.",
|
||||
"prefs.structure.in_profile": "Trong hồ sơ",
|
||||
"prefs.structure.layout": "Bố cục",
|
||||
"prefs.structure.layout_note": "Vị trí các phần của cửa sổ.",
|
||||
"prefs.structure.look": "Hiển thị",
|
||||
"prefs.structure.measure_pointer": "Đo lường và con trỏ",
|
||||
"prefs.structure.mouse3d": "Chuột 3D",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse và SpaceNavigator.",
|
||||
"prefs.structure.navigation_note": "Chuột và bàn di chuột. Chuột 3D có trang riêng.",
|
||||
"prefs.structure.profile": "Hồ sơ",
|
||||
"prefs.structure.profile_edited": "Đã thay đổi kể từ lần lưu",
|
||||
"prefs.structure.profile_hover": "Được lưu trong hồ sơ cài đặt",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "Phác thảo",
|
||||
"prefs.structure.tools": "Công cụ",
|
||||
"prefs.structure.tools_note": "Cách các công cụ dựng mô hình hoạt động.",
|
||||
"prefs.structure.work": "Công việc"
|
||||
},
|
||||
"zh": {
|
||||
"prefs.structure.appearance": "外观",
|
||||
"prefs.structure.appearance_note": "颜色、文字和无障碍。",
|
||||
"prefs.structure.in_profile": "包含在配置中",
|
||||
"prefs.structure.layout": "布局",
|
||||
"prefs.structure.layout_note": "窗口各部分的位置。",
|
||||
"prefs.structure.look": "外观",
|
||||
"prefs.structure.measure_pointer": "测量和指针",
|
||||
"prefs.structure.mouse3d": "3D 鼠标",
|
||||
"prefs.structure.mouse3d_note": "SpaceMouse 和 SpaceNavigator。",
|
||||
"prefs.structure.navigation_note": "鼠标和触控板。3D 鼠标有单独的页面。",
|
||||
"prefs.structure.profile": "配置",
|
||||
"prefs.structure.profile_edited": "保存后已更改",
|
||||
"prefs.structure.profile_hover": "保存在设置配置中",
|
||||
"prefs.structure.scale_percent": "{percent}%",
|
||||
"prefs.structure.sketch": "草图",
|
||||
"prefs.structure.tools": "工具",
|
||||
"prefs.structure.tools_note": "建模工具的行为。",
|
||||
"prefs.structure.work": "工作"
|
||||
}
|
||||
}
|
||||
@@ -1070,7 +1070,7 @@ fn switcher(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
add = true;
|
||||
}
|
||||
if ui_kit::list_picker(ui, "settings", tr("ui.ai_settings"), false).clicked() {
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_AI);
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_ASSISTANT);
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1808,7 +1808,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
if agents::entries(app).is_empty() && app.agent_chat.detecting.is_none() {
|
||||
ui_kit::assistant_empty(ui, tr("ui.agent_chat_setup_title"), tr("ui.agent_chat_setup_body"), |ui| {
|
||||
if ui_kit::primary_button(ui, tr("ui.agent_chat_open_settings")).clicked() {
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_AI);
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_ASSISTANT);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -321,7 +321,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
if !cfg!(target_arch = "wasm32") && app.preferences.ai_features {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let browsing = !crate::prefs_search::querying(ui) || app.prefs_window.section == crate::prefs::PAGE_AI;
|
||||
let browsing = !crate::prefs_search::querying(ui) || app.prefs_window.section == crate::prefs::PAGE_ASSISTANT;
|
||||
if browsing && app.agent_chat.detection.is_none() && app.agent_chat.detecting.is_none() {
|
||||
refresh(app, &ui.ctx().clone());
|
||||
}
|
||||
|
||||
@@ -328,11 +328,11 @@ fn tapped_thread_depth_field_keeps_focus_and_typing_separate_from_acceptance() {
|
||||
assert_eq!(h.app.session.doc.to_json(), original, "Cancel preserves the accepted design");
|
||||
}
|
||||
|
||||
/// The upstream Preferences split must retain both Hole controls on Design.
|
||||
/// The Preferences split must retain both Hole controls on Tools.
|
||||
#[test]
|
||||
fn hole_design_preferences_keep_both_controls_and_cancel_after_page_split() {
|
||||
let mut h = Harness::new();
|
||||
h.call("ui.prefs", json!({"language":"en", "open":"Design"}));
|
||||
h.call("ui.prefs", json!({"language":"en", "open":"Tools"}));
|
||||
let page = rect_of("prefs:page_body").unwrap();
|
||||
for label in ["Snap to face and edge centers", "Move holes by clicking or dragging"] {
|
||||
let mut point = None;
|
||||
@@ -353,7 +353,7 @@ fn hole_design_preferences_keep_both_controls_and_cancel_after_page_split() {
|
||||
h.call("ui.scroll", json!({"x":page.center().x,"y":page.center().y,"delta":-100}));
|
||||
h.frames(12);
|
||||
}
|
||||
let p = point.unwrap_or_else(|| panic!("Hole preference missing from Design: {label}"));
|
||||
let p = point.unwrap_or_else(|| panic!("Hole preference missing from Tools: {label}"));
|
||||
h.call("ui.click", json!({"x":p.x,"y":p.y}));
|
||||
}
|
||||
assert!(h.app.preferences.hole_snaps && h.app.preferences.hole_moves);
|
||||
|
||||
@@ -224,7 +224,7 @@ fn measurement_axis_distances_can_be_disabled_saved_and_restored_in_preferences(
|
||||
assert!(serde_json::from_value::<crate::prefs::Prefs>(json!({})).unwrap().measure_axis_distances, "existing settings get the default-on option");
|
||||
let mut h = vertex_measurement([0., 0., 0.], [-3., 4., -12.]);
|
||||
let measurement = result(&h).clone();
|
||||
h.call("ui.prefs", json!({"open":"Graphics"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
// The kit's 24 pt rows scroll inside the bounded Preferences page.
|
||||
let page = crate::scenario::rect_of("prefs:page_body").unwrap();
|
||||
for _ in 0..8 {
|
||||
@@ -248,11 +248,11 @@ fn measurement_axis_distances_can_be_disabled_saved_and_restored_in_preferences(
|
||||
let mut restored = crate::SolveApp::new(Default::default(), Default::default());
|
||||
restored.load_prefs(&h.app.prefs());
|
||||
assert!(!restored.preferences.measure_axis_distances, "disabled preference survives restart");
|
||||
h.call("ui.prefs", json!({"open":"Graphics","measure_axis_distances":true}));
|
||||
h.call("ui.prefs", json!({"open":"Tools","measure_axis_distances":true}));
|
||||
assert!(crate::scenario::handle_at("measure:label:x").is_some());
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert!(!h.app.preferences.measure_axis_distances, "Cancel restores the saved choice");
|
||||
h.call("ui.prefs", json!({"open":"Graphics"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert!(h.app.preferences.measure_axis_distances);
|
||||
h.call("ui.prefs", json!({"button":"apply"}));
|
||||
|
||||
@@ -471,7 +471,7 @@ fn navigation_context_menus_customise_hide_reset_and_remove() {
|
||||
match action {
|
||||
"customise" => {
|
||||
assert!(h.app.prefs_window.open);
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_INTERFACE);
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_LAYOUT);
|
||||
assert!(crate::scenario::rect_of("prefs:navbar:preview").is_some());
|
||||
}
|
||||
"hide" => assert!(!h.app.ui.show_navigation_bar),
|
||||
|
||||
+546
-277
File diff suppressed because it is too large
Load Diff
@@ -82,70 +82,39 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
},
|
||||
);
|
||||
setting::extrude_auto_to_object(app, ui);
|
||||
// Extrude's view (#9176): isometric when it opens, and back afterwards only with that.
|
||||
setting::extrude_view_isometric(app, ui);
|
||||
let isometric = app.preferences.extrude_view_isometric;
|
||||
ui.add_enabled_ui(isometric, |ui| setting::extrude_view_return(app, ui));
|
||||
let auto = setting::auto_operation(app, ui);
|
||||
crate::scenario::publish_handle("prefs:auto_operation", auto.rect.center());
|
||||
ui_kit::text(ui, app.tr("prefs.auto_operation_note"), ui_kit::Text::Hint("auto_operation"));
|
||||
setting::hide_origin(app, ui);
|
||||
ui_kit::text(ui, app.tr("ui.hide_origin_note"), ui_kit::Text::Hint("hide_origin"));
|
||||
});
|
||||
ui_kit::settings_section(ui, "joint_move", app.tr("joint_move.settings"), |ui| {
|
||||
setting::assembly_move_handles(app, ui);
|
||||
ui_kit::text(ui, app.tr("joint_move.legacy_hint"), ui_kit::Text::Hint("joint_move_legacy"));
|
||||
ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| {
|
||||
ui_kit::row(ui, app.tr("joint_move.coarse"), |ui| {
|
||||
ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_coarse, 0.001..=180.0, 0.1);
|
||||
});
|
||||
ui_kit::row(ui, app.tr("joint_move.fine"), |ui| {
|
||||
ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_fine, 0.001..=180.0, 0.01);
|
||||
});
|
||||
});
|
||||
ui_kit::text(ui, app.tr("joint_move.precision"), ui_kit::Text::Hint("joint_move"));
|
||||
});
|
||||
// The Hole command's own settings, under its name.
|
||||
ui_kit::settings_section(ui, "create_hole", crate::i18n::tr_label("Create Hole"), |ui| {
|
||||
setting::hole_snaps(app, ui);
|
||||
ui_kit::text(
|
||||
ui,
|
||||
crate::i18n::tr_label("A Single hole snaps to the middle of its face and to the centres of its round edges"),
|
||||
ui_kit::Text::Hint("hole_snaps"),
|
||||
);
|
||||
setting::hole_moves(app, ui);
|
||||
ui_kit::text(
|
||||
ui,
|
||||
crate::i18n::tr_label(
|
||||
"A placed Single hole has a handle to drag it, and picking its face again moves the hole there instead of taking it out",
|
||||
),
|
||||
ui_kit::Text::Hint("hole_moves"),
|
||||
);
|
||||
});
|
||||
ui_kit::settings_section(ui, "placement", app.tr("prefs.placement"), |ui| {
|
||||
setting::placement_handles(app, ui);
|
||||
});
|
||||
origin_plane_names(app, ui);
|
||||
ui_kit::settings_section(ui, "linked_designs", app.tr("prefs.linked_designs"), |ui| {
|
||||
setting::update_changed_links(app, ui);
|
||||
setting::double_click_components(app, ui);
|
||||
setting::insert_lists_open_designs(app, ui);
|
||||
});
|
||||
// Where the files a design names may be: never a network location the user hasn't allowed.
|
||||
ui_kit::settings_section(ui, "network_locations", app.tr("prefs.network_locations_section"), |ui| {
|
||||
setting::network_locations(app, ui);
|
||||
ui_kit::text(ui, app.tr("prefs.network_locations_note"), ui_kit::Text::Hint("network_locations"));
|
||||
let mut remove = None;
|
||||
for (i, host) in app.preferences.network_hosts.iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui_kit::text(ui, &format!("\\\\{host}"), ui_kit::Text::Hint("network_host"));
|
||||
if ui_kit::button(ui, app.tr("prefs.network_host_remove"), ui_kit::Button::Small).clicked() {
|
||||
remove = Some(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Origin plane names: each choice shows the three names it gives (`XY / XZ / YZ`), with a note
|
||||
/// that only the names shown change.
|
||||
fn origin_plane_names(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "origin_plane_names", app.tr("prefs.origin_plane_names"), |ui| {
|
||||
let choices: Vec<String> =
|
||||
OriginPlaneNames::ALL.iter().map(|names| OriginPlaneNames::PLANES.map(|plane| names.label(plane)).join(" / ")).collect();
|
||||
let options: Vec<&str> = choices.iter().map(String::as_str).collect();
|
||||
let mut selected = OriginPlaneNames::ALL.iter().position(|names| *names == app.preferences.origin_plane_names).unwrap_or(0);
|
||||
if ui_kit::settings_segments(ui, app.tr("prefs.origin_plane_names"), &mut selected, &options)
|
||||
&& let Some(names) = OriginPlaneNames::ALL.get(selected)
|
||||
{
|
||||
app.preferences.origin_plane_names = *names;
|
||||
}
|
||||
if let Some(i) = remove.filter(|i| *i < app.preferences.network_hosts.len()) {
|
||||
app.preferences.network_hosts.remove(i);
|
||||
// Handles that don't depend on the language, by the choice's saved value.
|
||||
for (choice, key) in choices.iter().zip(["xyz", "top_front_right"]) {
|
||||
if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{choice}", app.tr("prefs.origin_plane_names"))) {
|
||||
crate::scenario::publish_handle(&format!("prefs:origin_plane_names:{key}"), at);
|
||||
}
|
||||
}
|
||||
let top = OriginPlaneNames::TopFrontRight;
|
||||
let note =
|
||||
crate::i18n::format("prefs.origin_plane_names_note", &[("top", top.label("XY")), ("front", top.label("XZ")), ("right", top.label("YZ"))]);
|
||||
ui_kit::text(ui, ¬e, ui_kit::Text::Hint("origin_plane_names"));
|
||||
setting::hide_origin(app, ui);
|
||||
ui_kit::text(ui, app.tr("ui.hide_origin_note"), ui_kit::Text::Hint("hide_origin"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ use super::*;
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
let labels = t.space_24 * 6.0 + t.space_6;
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.general"), app.tr("prefs.general_note"));
|
||||
ui_kit::settings_heading_with_tag(ui, app.tr("prefs.general"), app.tr("prefs.general_note"), Some(crate::settings_profiles::tag));
|
||||
crate::settings_profiles::section(app, ui, labels);
|
||||
ui_kit::settings_section(ui, "language", app.tr("ui.language"), |ui| {
|
||||
ui_kit::settings_form(ui, labels, |ui| {
|
||||
ui_kit::row(ui, app.tr("prefs.interface_language"), |ui| {
|
||||
@@ -39,7 +40,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
});
|
||||
});
|
||||
crate::settings_profiles::section(app, ui, labels);
|
||||
ui_kit::settings_section(ui, "saving", app.tr("prefs.saving"), |ui| {
|
||||
ui_kit::settings_block_hint(ui, app.tr("ui.autosave_every"), crate::i18n::tr_label("0 turns it off"), labels, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
@@ -70,6 +70,23 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
});
|
||||
ui_kit::settings_section(ui, "file_size", app.tr("prefs.max_file_size"), |ui| file_size_rows(app, ui, labels));
|
||||
// Where the files a design names may be: never a network location the user hasn't allowed.
|
||||
ui_kit::settings_section(ui, "network_locations", app.tr("prefs.network_locations_section"), |ui| {
|
||||
setting::network_locations(app, ui);
|
||||
ui_kit::text(ui, app.tr("prefs.network_locations_note"), ui_kit::Text::Hint("network_locations"));
|
||||
let mut remove = None;
|
||||
for (i, host) in app.preferences.network_hosts.iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui_kit::text(ui, &format!("\\\\{host}"), ui_kit::Text::Hint("network_host"));
|
||||
if ui_kit::button(ui, app.tr("prefs.network_host_remove"), ui_kit::Button::Small).clicked() {
|
||||
remove = Some(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(i) = remove.filter(|i| *i < app.preferences.network_hosts.len()) {
|
||||
app.preferences.network_hosts.remove(i);
|
||||
}
|
||||
});
|
||||
ui_kit::settings_section(ui, "slicer", app.tr("ui.slicer"), |ui| {
|
||||
ui_kit::settings_block(ui, app.tr("ui.slicer"), labels, |ui| {
|
||||
let (single, tip) = (app.tr("ui.slicer_single_instance").to_string(), app.tr("ui.slicer_single_instance_tip").to_string());
|
||||
|
||||
@@ -189,12 +189,29 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
right.add_enabled_ui(app.ui.show_grid, |ui| {
|
||||
setting::grid_follows_view(app, ui);
|
||||
});
|
||||
let response = setting::measure_axis_distances(app, right);
|
||||
crate::scenario::publish_rect("prefs:measure_axis_distances", response.rect);
|
||||
response.on_hover_text(app.tr("settings.measure_axis_distances_help"));
|
||||
}
|
||||
});
|
||||
ui_kit::settings_form(ui, t.space_24 * 6.0 + t.space_6, |ui| {
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::quick_measure(app, ui).on_hover_text(app.tr("prefs.quick_measure_note"));
|
||||
crate::scenario::publish_target("prefs:quick_measure", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_analysis_status(app, ui).on_hover_text(app.tr("prefs.viewport_analysis_status_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_analysis_status", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_section_status(app, ui).on_hover_text(app.tr("prefs.viewport_section_status_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_section_status", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_status_details(app, ui).on_hover_text(app.tr("prefs.viewport_status_details_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_status_details", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_status_summary(app, ui).on_hover_text(app.tr("prefs.viewport_status_summary_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_status_summary", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, app.tr_label("Visual style"), |ui| {
|
||||
let mut selected = usize::from(app.ui.visual_style.min(3));
|
||||
ui_kit::dropdown(ui, "pref_style", &mut selected, &["Shaded with edges", "Shaded", "Wireframe", "Shaded with hidden edges"]);
|
||||
|
||||
@@ -1,34 +1,13 @@
|
||||
//! Interface settings composition, using shared controls and previews.
|
||||
//! Appearance and Layout settings composition, using shared controls and previews.
|
||||
use super::*;
|
||||
|
||||
/// Origin plane names: each choice shows the three names it gives (`XY / XZ / YZ`), with a note
|
||||
/// that only the names shown change.
|
||||
fn origin_plane_names(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "origin_plane_names", app.tr("prefs.origin_plane_names"), |ui| {
|
||||
let choices: Vec<String> =
|
||||
OriginPlaneNames::ALL.iter().map(|names| OriginPlaneNames::PLANES.map(|plane| names.label(plane)).join(" / ")).collect();
|
||||
let options: Vec<&str> = choices.iter().map(String::as_str).collect();
|
||||
let mut selected = OriginPlaneNames::ALL.iter().position(|names| *names == app.preferences.origin_plane_names).unwrap_or(0);
|
||||
if ui_kit::settings_segments(ui, app.tr("prefs.origin_plane_names"), &mut selected, &options)
|
||||
&& let Some(names) = OriginPlaneNames::ALL.get(selected)
|
||||
{
|
||||
app.preferences.origin_plane_names = *names;
|
||||
}
|
||||
// Handles that don't depend on the language, by the choice's saved value.
|
||||
for (choice, key) in choices.iter().zip(["xyz", "top_front_right"]) {
|
||||
if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{choice}", app.tr("prefs.origin_plane_names"))) {
|
||||
crate::scenario::publish_handle(&format!("prefs:origin_plane_names:{key}"), at);
|
||||
}
|
||||
}
|
||||
let top = OriginPlaneNames::TopFrontRight;
|
||||
let note =
|
||||
crate::i18n::format("prefs.origin_plane_names_note", &[("top", top.label("XY")), ("front", top.label("XZ")), ("right", top.label("YZ"))]);
|
||||
ui_kit::text(ui, ¬e, ui_kit::Text::Hint("origin_plane_names"));
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.interface"), app.tr("prefs.interface_note"));
|
||||
pub(super) fn appearance(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_heading_with_tag(
|
||||
ui,
|
||||
app.tr("prefs.structure.appearance"),
|
||||
app.tr("prefs.structure.appearance_note"),
|
||||
Some(crate::settings_profiles::tag),
|
||||
);
|
||||
ui_kit::settings_section(ui, "theme", app.tr("ui.theme"), |ui| {
|
||||
theme_row(app, ui);
|
||||
theme_options_row(app, ui);
|
||||
@@ -73,6 +52,97 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
}
|
||||
});
|
||||
});
|
||||
ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| {
|
||||
ui_kit::settings_pair(
|
||||
ui,
|
||||
|ui| {
|
||||
let response = ui_kit::slider(
|
||||
ui,
|
||||
&mut app.preferences.ui_scale,
|
||||
0.5..=2.5,
|
||||
ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
);
|
||||
crate::scenario::publish_target("prefs:scale", response.rect);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let locale = crate::i18n::Locale::for_language(&app.preferences.language);
|
||||
for value in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] {
|
||||
let percent = format!("{:.0}", value * 100.0);
|
||||
if ui_kit::button(
|
||||
ui,
|
||||
locale.format("prefs.structure.scale_percent", &[("percent", &percent)]),
|
||||
if (app.preferences.ui_scale - value).abs() < 0.001 { ui_kit::Button::SmallSelected } else { ui_kit::Button::Small },
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
app.preferences.ui_scale = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
ui_kit::text(ui, app.tr("prefs.scale_note"), ui_kit::Text::Hint("scale"));
|
||||
app.preferences.ui_scale
|
||||
},
|
||||
ui_kit::scale_specimen,
|
||||
);
|
||||
ui_kit::divider(ui, "scale_font");
|
||||
if !cfg!(target_arch = "wasm32") {
|
||||
ui_kit::settings_font_row(ui, crate::i18n::tr("prefs.font"), |ui, part| {
|
||||
if part == 0 {
|
||||
ui_font_row(app, ui);
|
||||
return;
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("prefs.choose_font"), ui_kit::Button::Normal).clicked() {
|
||||
app.pick_open_for(&["ttf", "otf", "ttc"], |app, path| {
|
||||
if let Some(path) = path {
|
||||
if crate::fonts::ui_font(&path).is_some() {
|
||||
app.preferences.ui_font = path;
|
||||
} else {
|
||||
app.set_status(crate::i18n::tr("prefs.font_unreadable"), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Ghost).clicked() {
|
||||
app.preferences.ui_font.clear();
|
||||
}
|
||||
});
|
||||
ui_kit::font_specimen(ui, app.tr("prefs.font_sample"));
|
||||
ui_kit::text(ui, app.tr("prefs.font_fallback"), ui_kit::Text::Hint("font_fallback"));
|
||||
}
|
||||
});
|
||||
ui_kit::settings_section(ui, "colour_vision", app.tr("ui.colour_vision"), |ui| {
|
||||
let mode = app.preferences.color_vision;
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let modes = crate::theme::ColorVision::ALL;
|
||||
let labels: Vec<_> = modes.iter().map(|m| crate::i18n::tr(m.label_id())).collect();
|
||||
let mut selected = modes.iter().position(|m| *m == mode).unwrap_or(0);
|
||||
if ui_kit::settings_segments(ui, app.tr("ui.colour_vision_mode"), &mut selected, &labels)
|
||||
&& let Some(mode) = modes.get(selected)
|
||||
{
|
||||
app.preferences.color_vision = *mode;
|
||||
}
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", app.tr("ui.colour_vision_mode"))) {
|
||||
crate::scenario::publish_target("prefs:color_vision", rect);
|
||||
}
|
||||
ui_kit::status_palette_sample(ui, app.preferences.color_vision);
|
||||
});
|
||||
// What the modes recolour, in the mode being chosen (#7152): the status chips above keep
|
||||
// their colours in every mode.
|
||||
ui_kit::colour_vision_sample(ui, &crate::theme::Tokens::get_in(app.preferences.color_vision));
|
||||
if app.preferences.color_vision != mode {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
ui_kit::text(ui, app.tr("ui.colour_vision_note"), ui_kit::Text::Hint("colour_vision"));
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn layout(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
ui_kit::settings_heading_with_tag(
|
||||
ui,
|
||||
app.tr("prefs.structure.layout"),
|
||||
app.tr("prefs.structure.layout_note"),
|
||||
Some(crate::settings_profiles::tag),
|
||||
);
|
||||
ui_kit::settings_section(ui, "layout", app.tr("prefs.layout"), |ui| {
|
||||
ui_kit::settings_pair(
|
||||
ui,
|
||||
@@ -99,22 +169,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
let check = setting::persistent_ribbon_pressed(app, ui).on_hover_text(app.tr("prefs.persistent_ribbon_pressed_help"));
|
||||
crate::scenario::publish_target("prefs:persistent_ribbon_pressed", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_analysis_status(app, ui).on_hover_text(app.tr("prefs.viewport_analysis_status_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_analysis_status", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_section_status(app, ui).on_hover_text(app.tr("prefs.viewport_section_status_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_section_status", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_status_details(app, ui).on_hover_text(app.tr("prefs.viewport_status_details_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_status_details", check.rect);
|
||||
});
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::viewport_status_summary(app, ui).on_hover_text(app.tr("prefs.viewport_status_summary_help"));
|
||||
crate::scenario::publish_target("prefs:viewport_status_summary", check.rect);
|
||||
});
|
||||
// The SKETCH tab outside a sketch too (#7904).
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::sketch_tab_always(app, ui).on_hover_text(app.tr("prefs.sketch_tab_always_note"));
|
||||
@@ -297,11 +351,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
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);
|
||||
});
|
||||
// The selection's measurement in the view's corner (#7000).
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let check = setting::quick_measure(app, ui).on_hover_text(app.tr("prefs.quick_measure_note"));
|
||||
crate::scenario::publish_target("prefs:quick_measure", 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 {
|
||||
@@ -321,7 +370,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::layout_preview,
|
||||
);
|
||||
});
|
||||
origin_plane_names(app, ui);
|
||||
super::navbar::show(app, ui);
|
||||
// The same choice as the toolbar's own menu (the plus after the tabs, or right-click a tab).
|
||||
ui_kit::settings_section(ui, "toolbar_tabs", app.tr("prefs.toolbar_tabs"), |ui| {
|
||||
@@ -334,83 +382,4 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
}
|
||||
}
|
||||
});
|
||||
ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| {
|
||||
ui_kit::settings_pair(
|
||||
ui,
|
||||
|ui| {
|
||||
let response = ui_kit::slider(
|
||||
ui,
|
||||
&mut app.preferences.ui_scale,
|
||||
0.5..=2.5,
|
||||
ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
);
|
||||
crate::scenario::publish_target("prefs:scale", response.rect);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for value in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] {
|
||||
if ui_kit::button(
|
||||
ui,
|
||||
format!("{:.0}%", value * 100.0),
|
||||
if (app.preferences.ui_scale - value).abs() < 0.001 { ui_kit::Button::SmallSelected } else { ui_kit::Button::Small },
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
app.preferences.ui_scale = value;
|
||||
}
|
||||
}
|
||||
});
|
||||
ui_kit::text(ui, app.tr("prefs.scale_note"), ui_kit::Text::Hint("scale"));
|
||||
app.preferences.ui_scale
|
||||
},
|
||||
ui_kit::scale_specimen,
|
||||
);
|
||||
ui_kit::divider(ui, "scale_font");
|
||||
if !cfg!(target_arch = "wasm32") {
|
||||
ui_kit::settings_font_row(ui, crate::i18n::tr("prefs.font"), |ui, part| {
|
||||
if part == 0 {
|
||||
ui_font_row(app, ui);
|
||||
return;
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("prefs.choose_font"), ui_kit::Button::Normal).clicked() {
|
||||
app.pick_open_for(&["ttf", "otf", "ttc"], |app, path| {
|
||||
if let Some(path) = path {
|
||||
if crate::fonts::ui_font(&path).is_some() {
|
||||
app.preferences.ui_font = path;
|
||||
} else {
|
||||
app.set_status(crate::i18n::tr("prefs.font_unreadable"), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Ghost).clicked() {
|
||||
app.preferences.ui_font.clear();
|
||||
}
|
||||
});
|
||||
ui_kit::font_specimen(ui, app.tr("prefs.font_sample"));
|
||||
ui_kit::text(ui, app.tr("prefs.font_fallback"), ui_kit::Text::Hint("font_fallback"));
|
||||
}
|
||||
});
|
||||
ui_kit::settings_section(ui, "colour_vision", app.tr("ui.colour_vision"), |ui| {
|
||||
let mode = app.preferences.color_vision;
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let modes = crate::theme::ColorVision::ALL;
|
||||
let labels: Vec<_> = modes.iter().map(|m| crate::i18n::tr(m.label_id())).collect();
|
||||
let mut selected = modes.iter().position(|m| *m == mode).unwrap_or(0);
|
||||
if ui_kit::settings_segments(ui, app.tr("ui.colour_vision_mode"), &mut selected, &labels)
|
||||
&& let Some(mode) = modes.get(selected)
|
||||
{
|
||||
app.preferences.color_vision = *mode;
|
||||
}
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", app.tr("ui.colour_vision_mode"))) {
|
||||
crate::scenario::publish_target("prefs:color_vision", rect);
|
||||
}
|
||||
ui_kit::status_palette_sample(ui, app.preferences.color_vision);
|
||||
});
|
||||
// What the modes recolour, in the mode being chosen (#7152): the status chips above keep
|
||||
// their colours in every mode.
|
||||
ui_kit::colour_vision_sample(ui, &crate::theme::Tokens::get_in(app.preferences.color_vision));
|
||||
if app.preferences.color_vision != mode {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
ui_kit::text(ui, app.tr("ui.colour_vision_note"), ui_kit::Text::Hint("colour_vision"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
use super::*;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.navigation"), app.tr("prefs.navigation_note"));
|
||||
ui_kit::settings_heading_with_tag(ui, app.tr("prefs.navigation"), app.tr("prefs.structure.navigation_note"), Some(crate::settings_profiles::tag));
|
||||
ui_kit::settings_section(ui, "mouse", app.tr("prefs.mouse_heading"), |ui| {
|
||||
let mut gestures: Vec<_> = nav_preset(&app.preferences.nav)
|
||||
.bindings
|
||||
@@ -137,7 +137,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
.on_hover_text(if touchpad { crate::i18n::tr("nav.touchpad.scroll") } else { crate::i18n::tr("ui.trackpad_pan_tip") });
|
||||
});
|
||||
setting::radial_context_menu(app, ui);
|
||||
setting::direct_interaction(app, ui);
|
||||
});
|
||||
});
|
||||
ui_kit::row(ui, app.tr("prefs.trackpad_zoom_modifier"), |ui| {
|
||||
@@ -159,8 +158,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
})
|
||||
.on_hover_text(crate::i18n::tr("prefs.trackpad_zoom_modifier.help"));
|
||||
});
|
||||
let cursor = ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor);
|
||||
crate::scenario::publish_target("view:tool_cursor", cursor.rect);
|
||||
ui_kit::divider(ui, "navigation_view_controls");
|
||||
ui_kit::settings_form(ui, 150.0, |ui| {
|
||||
setting::wheel_zoom_speed(app, ui);
|
||||
@@ -221,31 +218,4 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
// The existing ring editor is part of the real product and remains available.
|
||||
crate::mouse_gesture::nav_rows(app, ui, t);
|
||||
});
|
||||
// The 3D mouse is a section like the ones above: the driver, calibration, axes, picture and buttons
|
||||
// (`prefs::space_mouse_section`).
|
||||
space_mouse_section(app, ui);
|
||||
}
|
||||
|
||||
/// A device's own app on this computer driving the view (the navigation bridge): on or off, its
|
||||
/// port, and whether an app is connected. Part of the 3D mouse section (`space_mouse_rows`).
|
||||
pub(super) fn nav_bridge(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let (label, tip, port) = (app.tr("ui.nav_bridge").to_owned(), app.tr("ui.nav_bridge_tip").to_owned(), app.tr("ui.nav_bridge_port").to_owned());
|
||||
let status = match (&app.space_mouse.bridge, app.preferences.nav_bridge_enabled) {
|
||||
(_, false) => None,
|
||||
(Some(name), true) => Some((format!("{} · {name}", app.tr("ui.nav_bridge_connected")), false)),
|
||||
(None, true) => Some((app.tr("ui.nav_bridge_waiting").to_owned(), true)),
|
||||
};
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui_kit::checkbox(ui, &label, &mut app.preferences.nav_bridge_enabled).on_hover_text(&tip);
|
||||
if let Some((status, waiting)) = &status {
|
||||
ui_kit::settings_badge(ui, status, *waiting);
|
||||
}
|
||||
});
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
ui_kit::row(ui, &port, |ui| {
|
||||
ui.add_enabled_ui(app.preferences.nav_bridge_enabled, |ui| {
|
||||
ui_kit::number_field(ui, &mut app.preferences.nav_bridge_port, 1..=u16::MAX, 1.0, "");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,12 @@ use super::*;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.sketch_selection_heading"), app.tr("prefs.sketch_selection_note"));
|
||||
ui_kit::settings_heading_with_tag(
|
||||
ui,
|
||||
app.tr("prefs.structure.sketch"),
|
||||
app.tr("prefs.sketch_selection_note"),
|
||||
Some(crate::settings_profiles::tag),
|
||||
);
|
||||
ui_kit::settings_section(ui, "sketch", app.tr("prefs.sketching"), |ui| {
|
||||
ui_kit::checkbox(ui, app.tr("prefs.sketch_tracking_guides"), &mut app.preferences.sketch_tracking_guides)
|
||||
.on_hover_text(app.tr("prefs.sketch_tracking_guides_note"));
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//! Existing modelling-tool controls, regrouped without changing their semantics.
|
||||
use super::*;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.structure.tools"), app.tr("prefs.structure.tools_note"));
|
||||
// The Hole command's own settings, under its name.
|
||||
ui_kit::settings_section(ui, "create_hole", crate::i18n::tr_label("Create Hole"), |ui| {
|
||||
setting::hole_snaps(app, ui);
|
||||
ui_kit::text(
|
||||
ui,
|
||||
crate::i18n::tr_label("A Single hole snaps to the middle of its face and to the centres of its round edges"),
|
||||
ui_kit::Text::Hint("hole_snaps"),
|
||||
);
|
||||
setting::hole_moves(app, ui);
|
||||
ui_kit::text(
|
||||
ui,
|
||||
crate::i18n::tr_label(
|
||||
"A placed Single hole has a handle to drag it, and picking its face again moves the hole there instead of taking it out",
|
||||
),
|
||||
ui_kit::Text::Hint("hole_moves"),
|
||||
);
|
||||
});
|
||||
ui_kit::settings_section(ui, "extrude", app.tr_label("Extrude"), |ui| {
|
||||
setting::extrude_auto_to_object(app, ui);
|
||||
// Extrude's view (#9176): isometric when it opens, and back afterwards only with that.
|
||||
setting::extrude_view_isometric(app, ui);
|
||||
let isometric = app.preferences.extrude_view_isometric;
|
||||
ui.add_enabled_ui(isometric, |ui| setting::extrude_view_return(app, ui));
|
||||
let auto = setting::auto_operation(app, ui);
|
||||
crate::scenario::publish_handle("prefs:auto_operation", auto.rect.center());
|
||||
ui_kit::text(ui, app.tr("prefs.auto_operation_note"), ui_kit::Text::Hint("auto_operation"));
|
||||
});
|
||||
ui_kit::settings_section(ui, "placement", app.tr("prefs.placement"), |ui| {
|
||||
setting::placement_handles(app, ui);
|
||||
});
|
||||
ui_kit::settings_section(ui, "joint_move", app.tr("joint_move.settings"), |ui| {
|
||||
setting::assembly_move_handles(app, ui);
|
||||
ui_kit::text(ui, app.tr("joint_move.legacy_hint"), ui_kit::Text::Hint("joint_move_legacy"));
|
||||
ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| {
|
||||
ui_kit::row(ui, app.tr("joint_move.coarse"), |ui| {
|
||||
ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_coarse, 0.001..=180.0, 0.1);
|
||||
});
|
||||
ui_kit::row(ui, app.tr("joint_move.fine"), |ui| {
|
||||
ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_fine, 0.001..=180.0, 0.01);
|
||||
});
|
||||
});
|
||||
ui_kit::text(ui, app.tr("joint_move.precision"), ui_kit::Text::Hint("joint_move"));
|
||||
});
|
||||
ui_kit::settings_section(ui, "measure_pointer", app.tr("prefs.structure.measure_pointer"), |ui| {
|
||||
let response = setting::measure_axis_distances(app, ui);
|
||||
crate::scenario::publish_rect("prefs:measure_axis_distances", response.rect);
|
||||
response.on_hover_text(app.tr("settings.measure_axis_distances_help"));
|
||||
let cursor = ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor);
|
||||
crate::scenario::publish_target("view:tool_cursor", cursor.rect);
|
||||
setting::direct_interaction(app, ui);
|
||||
});
|
||||
}
|
||||
@@ -783,6 +783,13 @@ mod tests {
|
||||
h.step(&serde_json::json!({"key": "ArrowUp"})).expect("previous match");
|
||||
h.frames(1);
|
||||
assert_eq!(crate::scenario::handle_at("prefs:search:current"), first, "Up moves back");
|
||||
let (_, _, hits) = nav(&h.ctx);
|
||||
let cursor = hits
|
||||
.iter()
|
||||
.position(|hit| hit.page == crate::prefs::PAGE_NAVIGATION && hit.label == "Reverse zoom direction")
|
||||
.expect("the Navigation setting remains keyboard reachable");
|
||||
set_cursor(&h.ctx, cursor);
|
||||
h.frames(2);
|
||||
h.step(&serde_json::json!({"key": "Enter"})).expect("open");
|
||||
h.frames(2);
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_NAVIGATION, "Enter opens the match's page");
|
||||
@@ -905,7 +912,7 @@ mod tests {
|
||||
fn preferences_search_finds_settings_in_rows_without_a_label() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_INTERFACE);
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_LAYOUT);
|
||||
h.frames(2);
|
||||
// Drawn, not merely present: a hidden row's controls still exist, far off screen.
|
||||
let drawn = |h: &crate::scenario::Harness, label: &str| {
|
||||
@@ -939,4 +946,29 @@ mod tests {
|
||||
h.frames(4);
|
||||
assert!(!drawn(&h, "Status bar"), "a miss shows nothing");
|
||||
}
|
||||
#[test]
|
||||
fn moved_preferences_search_paths_and_enter_follow_window_groups() {
|
||||
for (query, path, page) in [
|
||||
("Direct interaction", "Work > Tools", crate::prefs::PAGE_TOOLS),
|
||||
("Navigate with the 3D mouse", "Input > 3D mouse", crate::prefs::PAGE_MOUSE3D),
|
||||
("Origin plane names", "Work > Design", crate::prefs::PAGE_DESIGN),
|
||||
("Status bar", "Look > Layout", crate::prefs::PAGE_LAYOUT),
|
||||
] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL);
|
||||
h.app.prefs_window.filter = query.into();
|
||||
h.frames(4);
|
||||
assert!(h.widget(path).is_some(), "{query} shows {path}");
|
||||
let (_, _, hits) = nav(&h.ctx);
|
||||
let index = hits.iter().position(|hit| hit.page == page && hit.label == query).expect("moved control is keyboard reachable");
|
||||
set_cursor(&h.ctx, index);
|
||||
h.frames(2);
|
||||
h.step(&serde_json::json!({"key":"Enter"})).unwrap();
|
||||
h.frames(2);
|
||||
assert_eq!(h.app.prefs_window.section, page);
|
||||
assert!(h.app.prefs_window.filter.is_empty());
|
||||
assert!(h.widget(query).is_some());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Settings profiles (#6237): the input and interface settings kept together under a name, such
|
||||
//! as "Laptop" and "Large monitor", and switched at once. A profile holds the preferences of the
|
||||
//! Interface, Navigation and Sketch pages and the language, the keyboard shortcuts, the toolbar
|
||||
//! and the S box favourites, and the imported theme it uses. Machine-specific settings stay out:
|
||||
//! the 3D mouse, graphics, recent files and the AI pages.
|
||||
//! as "Laptop" and "Large monitor", and switched at once. A profile holds the original Interface,
|
||||
//! Navigation and Sketch preference keys and the language, keyboard shortcuts, toolbar,
|
||||
//! S box favourites, and imported theme it uses. Page moves preserve that stored key set;
|
||||
//! device-specific 3D mouse keys, graphics, recent files and Assistant settings stay out.
|
||||
//!
|
||||
//! A profile is kept, exported and imported as one `solidcraft-profile/1` document. Every
|
||||
//! document is checked by [`sanitize`] first: unknown keys are dropped, sizes are capped, and a
|
||||
@@ -34,24 +34,108 @@ const MAX_THEMES: usize = 4;
|
||||
/// Most characters in a command id or a key name.
|
||||
const MAX_ID: usize = 200;
|
||||
|
||||
/// The Preferences pages whose settings a profile holds.
|
||||
const PAGES: [usize; 3] = [prefs::PAGE_INTERFACE, prefs::PAGE_NAVIGATION, prefs::PAGE_SKETCH];
|
||||
/// Settings a profile holds from other pages.
|
||||
const ALSO: [&str; 1] = ["language"];
|
||||
|
||||
/// Settings of those pages that belong to the computer, not the person: the 3D mouse (its
|
||||
/// calibration, driver and axes) and the cursor flag older releases saved.
|
||||
fn machine_specific(key: &str) -> bool {
|
||||
key.starts_with("space_mouse_") || key == "orbit_cursor"
|
||||
}
|
||||
/// The 93 stored keys from the pre-split Interface, Navigation and Sketch pages, plus
|
||||
/// language, excluding space_mouse_* and orbit_cursor. Page moves and title tags must never
|
||||
/// change profile contents (including the bridge, origin names and direct interaction).
|
||||
const PROFILE_KEYS: &[&str] = &[
|
||||
"browser_bodies_folders",
|
||||
"browser_collapsed",
|
||||
"browser_eye_left",
|
||||
"browser_float",
|
||||
"browser_share",
|
||||
"browser_show",
|
||||
"browser_width",
|
||||
"center_arc_follows_cursor",
|
||||
"color_vision",
|
||||
"dialog_buttons",
|
||||
"dialog_place",
|
||||
"direct_interaction",
|
||||
"free_orbit",
|
||||
"free_orbit_upright",
|
||||
"hidden_toolbar_tabs",
|
||||
"hide_constraint_glyphs_zoomed_out",
|
||||
"history_in_browser",
|
||||
"history_play_button",
|
||||
"history_sketches",
|
||||
"keep_work_on_tab_switch",
|
||||
"language",
|
||||
"layout",
|
||||
"line_drag_draws_one",
|
||||
"line_hover_tangent_arc",
|
||||
"logo_accent",
|
||||
"look_at_anim",
|
||||
"look_at_speed",
|
||||
"manipulator_free_alt",
|
||||
"middle_double_click",
|
||||
"mouse_gestures",
|
||||
"nav",
|
||||
"nav_bridge_enabled",
|
||||
"nav_bridge_port",
|
||||
"navigation_bar",
|
||||
"navigator_style",
|
||||
"orbit_around",
|
||||
"orbit_reverse",
|
||||
"origin_plane_names",
|
||||
"pan_reverse_x",
|
||||
"pan_reverse_y",
|
||||
"persistent_ribbon_pressed",
|
||||
"prefer_free_sketch_points",
|
||||
"project_options_dialog",
|
||||
"quick_measure",
|
||||
"radial_context_menu",
|
||||
"ribbon_icon_grid",
|
||||
"ribbon_labels",
|
||||
"ribbon_menus_skip_pinned",
|
||||
"ribbon_reveal",
|
||||
"right_drag_orbits",
|
||||
"select_other_hidden",
|
||||
"selection_shift_add_only",
|
||||
"shortcut_cycles_modes",
|
||||
"sketch_align_points",
|
||||
"sketch_auto_dimensions",
|
||||
"sketch_auto_locate",
|
||||
"sketch_conflict_colour",
|
||||
"sketch_construction_lines",
|
||||
"sketch_exit_view",
|
||||
"sketch_open_look_at",
|
||||
"sketch_recent_snap",
|
||||
"sketch_state_icons",
|
||||
"sketch_tab_always",
|
||||
"sketch_tracking_guides",
|
||||
"sketch_tracking_points",
|
||||
"smooth_wheel_zoom",
|
||||
"status_bar",
|
||||
"suppress_sketch_snap",
|
||||
"theme",
|
||||
"theme_follow",
|
||||
"theme_options",
|
||||
"timeline_collapsed",
|
||||
"timeline_left",
|
||||
"timeline_left_browser_collapsed",
|
||||
"timeline_left_width",
|
||||
"timeline_origin_bodies",
|
||||
"timeline_under_browser",
|
||||
"toast_place",
|
||||
"trackpad_pan",
|
||||
"trackpad_zoom_modifier",
|
||||
"ui_font",
|
||||
"ui_scale",
|
||||
"view_confirm_corner",
|
||||
"viewport_analysis_status",
|
||||
"viewport_background",
|
||||
"viewport_section_status",
|
||||
"viewport_status_details",
|
||||
"viewport_status_summary",
|
||||
"viewport_theme",
|
||||
"wheel_zoom_speed",
|
||||
"zoom_reverse",
|
||||
"zoom_stop_at_model",
|
||||
"zoom_to_cursor",
|
||||
];
|
||||
|
||||
/// The preferences a profile holds, by their stored key.
|
||||
pub fn keys() -> impl Iterator<Item = &'static str> {
|
||||
prefs::FIELD_PAGES
|
||||
.iter()
|
||||
.filter(|(key, page)| ALSO.contains(key) || page.is_some_and(|page| PAGES.contains(&page)))
|
||||
.map(|(key, _)| *key)
|
||||
.filter(|key| !machine_specific(key))
|
||||
prefs::FIELD_PAGES.iter().map(|(key, _)| *key).filter(|key| PROFILE_KEYS.contains(key))
|
||||
}
|
||||
|
||||
/// The kept profiles, which one was applied or saved last, and the Preferences section's state.
|
||||
@@ -520,3 +604,59 @@ pub(crate) fn section(app: &mut SolveApp, ui: &mut egui::Ui, labels: f32) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// The pinned profile switcher on every Preferences page. Actions use the same commands as
|
||||
/// General > Profiles; saving a new name remains in that existing section.
|
||||
pub(crate) fn sidebar(ui: &mut egui::Ui, app: &mut SolveApp) {
|
||||
ui_kit::divider(ui, "profile_sidebar");
|
||||
ui_kit::text(ui, app.tr("prefs.structure.profile"), ui_kit::Text::Heading("profile_sidebar"));
|
||||
let active = app.settings_profiles.active.clone();
|
||||
let edited = active.as_ref().is_some_and(|name| app.settings_profiles.get(name).is_ok_and(|doc| *doc != capture(app, name)));
|
||||
let current = active.clone().unwrap_or_else(|| app.tr_label("None").to_string());
|
||||
let names = app.settings_profiles.names();
|
||||
let mut apply = None;
|
||||
let mut save = false;
|
||||
ui.horizontal(|ui| {
|
||||
let t = crate::theme::Tokens::get();
|
||||
let width = ui.available_width() - if edited { t.space_16 + ui.spacing().item_spacing.x } else { 0.0 };
|
||||
let response = ui_kit::settings_control_width(ui, width, |ui| {
|
||||
ui_kit::dropdown_menu(ui, "profile_sidebar", ¤t, |ui| {
|
||||
for name in &names {
|
||||
if ui_kit::list_picker(ui, name, name, active.as_ref() == Some(name)).clicked() {
|
||||
apply = Some(name.clone());
|
||||
}
|
||||
}
|
||||
if let Some(name) = &active
|
||||
&& ui_kit::button(ui, app.tr("prefs.profile_save"), ui_kit::Button::Normal).clicked()
|
||||
{
|
||||
save = true;
|
||||
apply = None;
|
||||
app.settings_profiles.draft = name.clone();
|
||||
ui.close();
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("prefs.profiles"), ui_kit::Button::Normal).clicked() {
|
||||
prefs::open_profiles(app);
|
||||
ui.close();
|
||||
}
|
||||
})
|
||||
});
|
||||
crate::scenario::publish_target("prefs:profile", response.rect);
|
||||
if edited {
|
||||
let dot = ui_kit::status_line(ui, "●", ui_kit::StatusTone::Warning).on_hover_text(app.tr("prefs.structure.profile_edited"));
|
||||
crate::scenario::publish_target("prefs:profile:edited", dot.rect);
|
||||
}
|
||||
});
|
||||
if let Some(name) = apply {
|
||||
app.settings_profiles.draft = name.clone();
|
||||
act(app, "settings.profile.apply", json!({"name":name}), "prefs.profile_applied");
|
||||
} else if save && let Some(name) = active {
|
||||
act(app, "settings.profile.save", json!({"name":name}), "prefs.profile_saved");
|
||||
}
|
||||
}
|
||||
|
||||
/// Page-title tag. Membership is descriptive; the stable key list above governs storage.
|
||||
pub(crate) fn tag(ui: &mut egui::Ui) {
|
||||
let response =
|
||||
ui_kit::workspace_chip(ui, crate::i18n::tr("prefs.structure.in_profile")).on_hover_text(crate::i18n::tr("prefs.structure.profile_hover"));
|
||||
crate::scenario::publish_target("prefs:in_profile", response.rect);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,12 @@ fn a_profile_holds_input_and_interface_settings_but_not_the_machine() {
|
||||
"space_mouse_calibrations",
|
||||
"space_mouse_driver",
|
||||
"space_mouse_speed",
|
||||
"dark_parts_shading",
|
||||
"msaa",
|
||||
"window_system",
|
||||
"default_units",
|
||||
"extrude_view_isometric",
|
||||
"extrude_view_return",
|
||||
"update",
|
||||
"agents",
|
||||
"custom_themes",
|
||||
@@ -344,3 +347,181 @@ fn choosing_a_profile_in_preferences_applies_it() {
|
||||
assert_eq!(h.app.settings_profiles.active.as_deref(), Some("Large monitor"));
|
||||
assert!(h.app.preferences.zoom_reverse);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_keys_preserve_the_literal_pre_split_baseline() {
|
||||
let expected = [
|
||||
"browser_bodies_folders",
|
||||
"browser_collapsed",
|
||||
"browser_eye_left",
|
||||
"browser_float",
|
||||
"browser_share",
|
||||
"browser_show",
|
||||
"browser_width",
|
||||
"center_arc_follows_cursor",
|
||||
"color_vision",
|
||||
"dialog_buttons",
|
||||
"dialog_place",
|
||||
"direct_interaction",
|
||||
"free_orbit",
|
||||
"free_orbit_upright",
|
||||
"hidden_toolbar_tabs",
|
||||
"hide_constraint_glyphs_zoomed_out",
|
||||
"history_in_browser",
|
||||
"history_play_button",
|
||||
"history_sketches",
|
||||
"keep_work_on_tab_switch",
|
||||
"language",
|
||||
"layout",
|
||||
"line_drag_draws_one",
|
||||
"line_hover_tangent_arc",
|
||||
"logo_accent",
|
||||
"look_at_anim",
|
||||
"look_at_speed",
|
||||
"manipulator_free_alt",
|
||||
"middle_double_click",
|
||||
"mouse_gestures",
|
||||
"nav",
|
||||
"nav_bridge_enabled",
|
||||
"nav_bridge_port",
|
||||
"navigation_bar",
|
||||
"navigator_style",
|
||||
"orbit_around",
|
||||
"orbit_reverse",
|
||||
"origin_plane_names",
|
||||
"pan_reverse_x",
|
||||
"pan_reverse_y",
|
||||
"persistent_ribbon_pressed",
|
||||
"prefer_free_sketch_points",
|
||||
"project_options_dialog",
|
||||
"quick_measure",
|
||||
"radial_context_menu",
|
||||
"ribbon_icon_grid",
|
||||
"ribbon_labels",
|
||||
"ribbon_menus_skip_pinned",
|
||||
"ribbon_reveal",
|
||||
"right_drag_orbits",
|
||||
"select_other_hidden",
|
||||
"selection_shift_add_only",
|
||||
"shortcut_cycles_modes",
|
||||
"sketch_align_points",
|
||||
"sketch_auto_dimensions",
|
||||
"sketch_auto_locate",
|
||||
"sketch_conflict_colour",
|
||||
"sketch_construction_lines",
|
||||
"sketch_exit_view",
|
||||
"sketch_open_look_at",
|
||||
"sketch_recent_snap",
|
||||
"sketch_state_icons",
|
||||
"sketch_tab_always",
|
||||
"sketch_tracking_guides",
|
||||
"sketch_tracking_points",
|
||||
"smooth_wheel_zoom",
|
||||
"status_bar",
|
||||
"suppress_sketch_snap",
|
||||
"theme",
|
||||
"theme_follow",
|
||||
"theme_options",
|
||||
"timeline_collapsed",
|
||||
"timeline_left",
|
||||
"timeline_left_browser_collapsed",
|
||||
"timeline_left_width",
|
||||
"timeline_origin_bodies",
|
||||
"timeline_under_browser",
|
||||
"toast_place",
|
||||
"trackpad_pan",
|
||||
"trackpad_zoom_modifier",
|
||||
"ui_font",
|
||||
"ui_scale",
|
||||
"view_confirm_corner",
|
||||
"viewport_analysis_status",
|
||||
"viewport_background",
|
||||
"viewport_section_status",
|
||||
"viewport_status_details",
|
||||
"viewport_status_summary",
|
||||
"viewport_theme",
|
||||
"wheel_zoom_speed",
|
||||
"zoom_reverse",
|
||||
"zoom_stop_at_model",
|
||||
"zoom_to_cursor",
|
||||
];
|
||||
let mut actual: Vec<_> = keys().collect();
|
||||
actual.sort_unstable();
|
||||
assert_eq!(expected.len(), 93);
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn moved_profile_settings_survive_saved_roundtrip_and_apply() {
|
||||
let mut h = Harness::new();
|
||||
let defaults = crate::prefs::Prefs::default();
|
||||
assert!(!defaults.keep_work_on_tab_switch && !defaults.line_hover_tangent_arc);
|
||||
for (key, page) in [("keep_work_on_tab_switch", crate::prefs::PAGE_LAYOUT), ("line_hover_tangent_arc", crate::prefs::PAGE_SKETCH)] {
|
||||
let homes: Vec<_> = crate::prefs::FIELD_PAGES.iter().filter_map(|(field, page)| (*field == key).then_some(*page)).collect();
|
||||
assert_eq!(homes, [Some(page)], "{key} keeps its new page home");
|
||||
}
|
||||
h.app.preferences.nav_bridge_enabled = true;
|
||||
h.app.preferences.nav_bridge_port = 9876;
|
||||
h.app.preferences.origin_plane_names = crate::prefs::OriginPlaneNames::TopFrontRight;
|
||||
h.app.preferences.direct_interaction = true;
|
||||
h.app.preferences.quick_measure = true;
|
||||
h.app.preferences.viewport_analysis_status = false;
|
||||
h.app.preferences.keep_work_on_tab_switch = true;
|
||||
h.app.preferences.line_hover_tangent_arc = true;
|
||||
run(&mut h, "settings.profile.save", json!({"name":"Moved"}));
|
||||
let saved = h.app.settings_profiles.prefs();
|
||||
let doc = h.app.settings_profiles.list[0].clone();
|
||||
assert_eq!(doc["preferences"]["keep_work_on_tab_switch"], true);
|
||||
assert_eq!(doc["preferences"]["line_hover_tangent_arc"], true);
|
||||
assert!(doc["preferences"].get("dark_parts_shading").is_none());
|
||||
assert_eq!(sanitize(&doc).unwrap(), doc);
|
||||
h.app.settings_profiles.load(&serde_json::from_str::<Value>(&serde_json::to_string(&saved).unwrap()).unwrap());
|
||||
assert_eq!(h.app.settings_profiles.list[0], doc);
|
||||
h.app.preferences.nav_bridge_enabled = false;
|
||||
h.app.preferences.nav_bridge_port = 8765;
|
||||
h.app.preferences.origin_plane_names = crate::prefs::OriginPlaneNames::Xyz;
|
||||
h.app.preferences.direct_interaction = false;
|
||||
h.app.preferences.quick_measure = false;
|
||||
h.app.preferences.viewport_analysis_status = true;
|
||||
h.app.preferences.keep_work_on_tab_switch = false;
|
||||
h.app.preferences.line_hover_tangent_arc = false;
|
||||
let out = run(&mut h, "settings.profile.apply", json!({"name":"Moved"}));
|
||||
assert_eq!(out["skipped"], json!([]));
|
||||
assert!(h.app.preferences.keep_work_on_tab_switch && h.app.preferences.line_hover_tangent_arc);
|
||||
assert_eq!(capture(&h.app, "Moved"), doc);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_sidebar_switches_saves_and_marks_edits_with_existing_commands() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
run(&mut h, "settings.profile.save", json!({"name":"Laptop"}));
|
||||
h.app.preferences.zoom_reverse = true;
|
||||
run(&mut h, "settings.profile.save", json!({"name":"Desk"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("prefs:profile:edited").is_none());
|
||||
h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap();
|
||||
h.frames(2);
|
||||
h.step(&json!({"click":{"handle":"dialog:list:Laptop"}})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(h.app.settings_profiles.active.as_deref(), Some("Laptop"));
|
||||
assert!(!h.app.preferences.zoom_reverse);
|
||||
h.app.preferences.direct_interaction = true;
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("prefs:profile:edited").is_some());
|
||||
h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap();
|
||||
h.frames(2);
|
||||
h.step(&json!({"widget":"Save"})).unwrap();
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::rect_of("prefs:profile:edited").is_none());
|
||||
assert!(h.app.prefs_window.open, "saving a profile keeps Preferences open");
|
||||
let saved = run(&mut h, "settings.profile.export", json!({"name":"Laptop"}));
|
||||
assert_eq!(saved["profile"]["preferences"]["direct_interaction"], true);
|
||||
h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap();
|
||||
h.frames(2);
|
||||
let profiles_label = h.app.tr("prefs.profiles").to_string();
|
||||
h.step(&json!({"widget":profiles_label})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_GENERAL);
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ fn compact_layout_is_saved_and_survives_cancel_apply_defaults_and_bad_input() {
|
||||
let design = h.app.session.doc.to_json();
|
||||
let undo = h.app.session.undo.len();
|
||||
let camera = h.app.cam;
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout"}));
|
||||
crate::prefs::reveal_preference(&mut h, "dialog:Workspace:Compact");
|
||||
h.step(&json!({"click":{"handle":"dialog:Workspace:Compact"}})).unwrap();
|
||||
h.call("ui.prefs", json!({"button":"ok"}));
|
||||
@@ -609,15 +609,15 @@ fn compact_layout_is_saved_and_survives_cancel_apply_defaults_and_bad_input() {
|
||||
restored.load_prefs(&h.app.prefs());
|
||||
assert_eq!(restored.ui.layout, LayoutMode::Docked);
|
||||
assert_eq!(restored.preferences.layout, LayoutMode::Docked);
|
||||
h.call("ui.prefs", json!({"open":"Interface","layout":"floating"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout","layout":"floating"}));
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.ui.layout, LayoutMode::Docked);
|
||||
h.call("ui.prefs", json!({"open":"Interface","layout":"floating"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout","layout":"floating"}));
|
||||
h.call("ui.prefs", json!({"button":"apply"}));
|
||||
h.call("ui.prefs", json!({"layout":"compact"}));
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.ui.layout, LayoutMode::Floating);
|
||||
h.call("ui.prefs", json!({"open":"Interface","layout":"compact"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout","layout":"compact"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert_eq!(h.app.ui.layout, LayoutMode::Floating);
|
||||
assert_eq!(h.app.preferences.layout, LayoutMode::Floating);
|
||||
@@ -929,7 +929,7 @@ fn the_view_corner_answers_a_dialog_in_the_left_column() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Dialogs is an Interface preference: set from the page or the control channel, saved,
|
||||
/// Dialogs is a Layout preference: set from the page or the control channel, saved,
|
||||
/// refused when unknown, and Cancel and Restore Defaults put it back. A dialog already open
|
||||
/// moves with it.
|
||||
#[test]
|
||||
@@ -941,7 +941,7 @@ fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() {
|
||||
h.settle();
|
||||
let right = h.app.viewport.dialog_rect.unwrap();
|
||||
assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge);
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout"}));
|
||||
crate::prefs::reveal_preference(&mut h, "dialog:Dialogs:In the left column");
|
||||
h.step(&json!({"click":{"handle":"dialog:Dialogs:In the left column"}})).unwrap();
|
||||
assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn);
|
||||
@@ -952,10 +952,10 @@ fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() {
|
||||
let mut restored = crate::SolveApp::new(Default::default(), Default::default());
|
||||
restored.load_prefs(&h.app.prefs());
|
||||
assert_eq!(restored.preferences.dialog_place, DialogPlace::LeftColumn);
|
||||
h.call("ui.prefs", json!({"open":"Interface","dialog_place":"edge"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout","dialog_place":"edge"}));
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn);
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge);
|
||||
h.call("ui.prefs", json!({"button":"ok"}));
|
||||
|
||||
@@ -307,7 +307,7 @@ pub fn buttons_hook(app: &mut SolveApp, ctx: &egui::Context, seen: Buttons, raw:
|
||||
fn run_button_job(app: &mut SolveApp, job: &ButtonJob, modifiers: egui::Modifiers, raw: &mut egui::RawInput) {
|
||||
match job {
|
||||
// Navigation, where the 3D mouse's section is.
|
||||
ButtonJob::Settings => crate::prefs::open_at(app, crate::prefs::PAGE_NAVIGATION),
|
||||
ButtonJob::Settings => crate::prefs::open_at(app, crate::prefs::PAGE_MOUSE3D),
|
||||
ButtonJob::View(view) => app.animate_view(view),
|
||||
ButtonJob::Key(ButtonKey::Esc) => {
|
||||
for pressed in [true, false] {
|
||||
|
||||
@@ -222,7 +222,7 @@ pub fn act(app: &mut SolveApp, ctx: &egui::Context, offer: &Offer, action: Actio
|
||||
app.preferences.space_mouse_offered.insert(offer.device.clone());
|
||||
if action == Action::Calibrate {
|
||||
// The calibration window lives with Preferences, at Navigation.
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_NAVIGATION);
|
||||
crate::prefs::open_at(app, crate::prefs::PAGE_MOUSE3D);
|
||||
crate::space_mouse_calibration::start(app);
|
||||
}
|
||||
}
|
||||
@@ -391,7 +391,7 @@ mod preferences_tests {
|
||||
h.app.space_mouse.device = Some("hid 046d:c62b".into());
|
||||
h.frames(3);
|
||||
if open_first {
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION);
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
}
|
||||
for _ in 0..frames_before {
|
||||
h.frame();
|
||||
@@ -879,7 +879,7 @@ mod preferences_tests {
|
||||
h.app.preferences.space_mouse_calibrations.insert("hid 046d:c62b".into(), calibration);
|
||||
h.app.space_mouse.device = Some("hid 046d:c62b".into());
|
||||
if prefs_open {
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION);
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
}
|
||||
run(&mut h, 2.0);
|
||||
assert_eq!(crate::space_mouse::calibration(&h.app), Some(calibration));
|
||||
@@ -918,7 +918,7 @@ mod preferences_tests {
|
||||
let mut h = spacenavd_harness();
|
||||
run(&mut h, 2.0);
|
||||
assert!(card_up(&h));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION);
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
run(&mut h, 3.0);
|
||||
assert!(!card_up(&h), "no card over Preferences");
|
||||
h.app.prefs_window.open = false;
|
||||
|
||||
@@ -95,10 +95,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_preference_restores_tool_badge_on_cancel_and_defaults() {
|
||||
fn tools_preference_restores_tool_badge_on_cancel_and_defaults() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap();
|
||||
@@ -106,7 +106,7 @@ mod tests {
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert!(!h.app.ui.tool_cursor);
|
||||
h.app.ui.tool_cursor = true;
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert!(!h.app.ui.tool_cursor);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
@@ -114,10 +114,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_preference_keeps_applied_tool_badge_after_restart() {
|
||||
fn tools_preference_keeps_applied_tool_badge_after_restart() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap();
|
||||
@@ -129,7 +129,7 @@ mod tests {
|
||||
assert!(restarted.ui.tool_cursor, "an explicitly enabled tool badge survives a restart");
|
||||
|
||||
// Turning it off must replace a previously saved true value too.
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap();
|
||||
@@ -140,11 +140,11 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_preference_does_not_save_unapplied_tool_badge_changes() {
|
||||
fn tools_preference_does_not_save_unapplied_tool_badge_changes() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
let saved = |h: &Harness| serde_json::from_str::<serde_json::Value>(&h.app.prefs()).unwrap()["tool_cursor"].clone();
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap();
|
||||
@@ -179,21 +179,21 @@ mod tests {
|
||||
fn badge_shows_the_running_tool_beside_the_pointer() {
|
||||
let mut h = Harness::new();
|
||||
h.settle();
|
||||
// Off by default: a running tool shows no badge until Navigation preferences turn it on.
|
||||
// Off by default: a running tool shows no badge until Tools preferences turn it on.
|
||||
assert!(!h.app.ui.tool_cursor, "the badge is on by default");
|
||||
h.step(&json!({"start": "sketch.create"})).unwrap();
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "off by default, yet a badge is drawn at {badge:?}");
|
||||
h.step(&json!({"key": "Escape"})).unwrap();
|
||||
h.settle();
|
||||
// The board's Display menu omits this preference; Navigation keeps its checkbox.
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
// The board's Display menu omits this preference; Tools keeps its checkbox.
|
||||
h.call("ui.prefs", json!({"open":"Tools"}));
|
||||
h.frames(4);
|
||||
crate::prefs::reveal_preference(&mut h, "view:tool_cursor");
|
||||
h.step(&json!({"click": {"handle": "view:tool_cursor"}})).unwrap();
|
||||
h.call("ui.prefs", json!({"button":"ok"}));
|
||||
h.frames(2);
|
||||
assert!(h.app.ui.tool_cursor, "the Navigation preferences checkbox did not turn the badge on");
|
||||
assert!(h.app.ui.tool_cursor, "the Tools preferences checkbox did not turn the badge on");
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "no tool runs, yet a badge is drawn at {badge:?}");
|
||||
|
||||
@@ -214,7 +214,7 @@ mod tests {
|
||||
// The coordinate readout starts READOUT below and right of the pointer: no overlap.
|
||||
assert!(badge.bottom() < at.y + READOUT.y, "the badge {badge:?} covers the readout under {at:?}");
|
||||
|
||||
// Turned off in Navigation preferences.
|
||||
// Turned off in Tools preferences.
|
||||
h.app.ui.tool_cursor = false;
|
||||
let (_, badge) = hover_middle(&mut h);
|
||||
assert!(badge.is_none(), "turned off, yet a badge is drawn at {badge:?}");
|
||||
|
||||
@@ -1106,7 +1106,7 @@ impl<'a> Window<'a> {
|
||||
state: &mut S,
|
||||
left: impl FnOnce(&mut Ui),
|
||||
) -> (bool, super::Action) {
|
||||
self.show_pages_inner(ctx, selected, pages, state, None, None, left)
|
||||
self.show_pages_inner(ctx, selected, pages, state, None, None, None, left)
|
||||
}
|
||||
|
||||
/// Page navigation with a strip above the page body (Preferences search).
|
||||
@@ -1119,9 +1119,10 @@ impl<'a> Window<'a> {
|
||||
state: &mut S,
|
||||
header: fn(&mut Ui, &mut S),
|
||||
on_select: fn(&mut S),
|
||||
sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>,
|
||||
left: impl FnOnce(&mut Ui),
|
||||
) -> (bool, super::Action) {
|
||||
self.show_pages_inner(ctx, selected, pages, state, Some(header), Some(on_select), left)
|
||||
self.show_pages_inner(ctx, selected, pages, state, Some(header), Some(on_select), sidebar_footer, left)
|
||||
}
|
||||
|
||||
fn show_pages_inner<S>(
|
||||
@@ -1132,13 +1133,14 @@ impl<'a> Window<'a> {
|
||||
state: &mut S,
|
||||
header: Option<fn(&mut Ui, &mut S)>,
|
||||
on_select: Option<fn(&mut S)>,
|
||||
sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>,
|
||||
left: impl FnOnce(&mut Ui),
|
||||
) -> (bool, super::Action) {
|
||||
self.body_padding = false;
|
||||
self.page_chrome = true;
|
||||
let rows = self.page_rows;
|
||||
let padding = self.page_padding;
|
||||
self.show_with_left(ctx, true, |ui| page_list_sized(ui, selected, pages, state, rows, padding, header, on_select), left)
|
||||
self.show_with_left(ctx, true, |ui| page_list_sized(ui, selected, pages, state, rows, padding, header, on_select, sidebar_footer), left)
|
||||
}
|
||||
|
||||
/// The same bounded card frame, either movable or an input-blocking modal.
|
||||
@@ -1206,7 +1208,7 @@ pub(crate) struct WindowPage<S> {
|
||||
|
||||
#[cfg(test)]
|
||||
pub(super) fn page_list<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPage<S>], state: &mut S) {
|
||||
page_list_sized(ui, selected, pages, state, 16.0, egui::Margin::same(Tokens::get().space_16 as i8), None, None);
|
||||
page_list_sized(ui, selected, pages, state, 16.0, egui::Margin::same(Tokens::get().space_16 as i8), None, None, None);
|
||||
}
|
||||
|
||||
fn page_list_sized<S>(
|
||||
@@ -1218,6 +1220,7 @@ fn page_list_sized<S>(
|
||||
padding: egui::Margin,
|
||||
header: Option<fn(&mut Ui, &mut S)>,
|
||||
on_select: Option<fn(&mut S)>,
|
||||
sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>,
|
||||
) {
|
||||
let t = Tokens::get();
|
||||
// The search strip, the gap under it, and the following item spacing sit above the page.
|
||||
@@ -1237,10 +1240,19 @@ fn page_list_sized<S>(
|
||||
t.secondary_vline(ui.painter(), nav.right(), nav.y_range(), t.dialog_rule);
|
||||
scenario::publish_rect("dialog:pages", nav);
|
||||
*selected = (*selected).min(pages.len().saturating_sub(1));
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(nav.shrink2(vec2(t.space_8, t.space_6))), |ui| {
|
||||
let nav_inner = nav.shrink2(vec2(t.space_8, t.space_6));
|
||||
let footer_height = sidebar_footer.map_or(0.0, |(height, _)| dimension(height).min(nav_inner.height()));
|
||||
let list = egui::Rect::from_min_max(nav_inner.min, egui::pos2(nav_inner.right(), nav_inner.bottom() - footer_height));
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(list), |ui| {
|
||||
ui.set_clip_rect(ui.clip_rect().intersect(nav));
|
||||
ui.spacing_mut().item_spacing.y = t.space_2;
|
||||
egui::ScrollArea::vertical().id_salt("window_pages").show(ui, |ui| {
|
||||
let selection_id = ui.id().with("page_selection");
|
||||
let changed = ui.data_mut(|data| {
|
||||
let previous = data.get_temp::<usize>(selection_id);
|
||||
data.insert_temp(selection_id, *selected);
|
||||
previous != Some(*selected)
|
||||
});
|
||||
egui::ScrollArea::vertical().id_salt("window_pages").max_height(list.height()).show(ui, |ui| {
|
||||
for (index, page) in pages.iter().enumerate() {
|
||||
if let Some(group) = page.group {
|
||||
ui.add_space(t.space_8);
|
||||
@@ -1258,6 +1270,9 @@ fn page_list_sized<S>(
|
||||
}
|
||||
}
|
||||
let on = *selected == index;
|
||||
if on && changed && sidebar_footer.is_some() && !list.contains_rect(rect) {
|
||||
response.scroll_to_me(Some(egui::Align::Center));
|
||||
}
|
||||
if on || response.hovered() || response.has_focus() {
|
||||
ui.painter().rect_filled(rect, t.control_radius, if on { t.selected_bg } else { t.hover });
|
||||
}
|
||||
@@ -1283,6 +1298,14 @@ fn page_list_sized<S>(
|
||||
}
|
||||
});
|
||||
});
|
||||
if let Some((_, footer)) = sidebar_footer {
|
||||
let rect = egui::Rect::from_min_max(egui::pos2(nav_inner.left(), list.bottom()), nav_inner.max);
|
||||
ui.scope_builder(egui::UiBuilder::new().id_salt("pages_footer").max_rect(rect), |ui| {
|
||||
ui.set_clip_rect(ui.clip_rect().intersect(rect));
|
||||
footer(ui, state);
|
||||
});
|
||||
scenario::publish_rect("dialog:pages_footer", rect);
|
||||
}
|
||||
let content = egui::Rect::from_min_max(egui::pos2(nav.right(), body.top()), body.max);
|
||||
let padding = egui::epaint::MarginF32 {
|
||||
left: padding.leftf().min(content.width() / 2.0),
|
||||
|
||||
@@ -856,6 +856,19 @@ fn preferences_preserves_every_page_and_footer_in_both_themes() {
|
||||
}
|
||||
assert!(scenario::rect_of("prefs:page_body").is_some());
|
||||
assert!(h.widget(h.app.tr("ui.restore_defaults")).is_some());
|
||||
let footer = scenario::rect_of("dialog:pages_footer").expect("pinned profile footer");
|
||||
assert!(nav.contains_rect(footer));
|
||||
assert!(footer.contains_rect(scenario::rect_of("prefs:profile").expect("real switcher")));
|
||||
let tagged = [
|
||||
crate::prefs::PAGE_GENERAL,
|
||||
crate::prefs::PAGE_APPEARANCE,
|
||||
crate::prefs::PAGE_LAYOUT,
|
||||
crate::prefs::PAGE_SKETCH,
|
||||
crate::prefs::PAGE_NAVIGATION,
|
||||
crate::prefs::PAGE_SHORTCUTS,
|
||||
]
|
||||
.contains(&index);
|
||||
assert_eq!(scenario::rect_of("prefs:in_profile").is_some(), tagged, "{page}");
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
@@ -1281,3 +1294,30 @@ fn a_left_panel_in_an_inside_out_view_keeps_an_anchor() {
|
||||
let anchor = panel.bounded_anchor(&ctx);
|
||||
assert!(anchor.x.is_finite() && anchor.y.is_finite(), "{anchor:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_sidebar_footer_stays_visible_when_the_page_list_scrolls() {
|
||||
for theme in ["light", "dark"] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.preferences.theme = theme.into();
|
||||
h.call("ui.resize", serde_json::json!({"width":1200,"height":620}));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL);
|
||||
h.frames(6);
|
||||
let footer = scenario::rect_of("dialog:pages_footer").unwrap();
|
||||
let nav = scenario::rect_of("dialog:pages").unwrap();
|
||||
h.frame_with(vec![
|
||||
egui::Event::PointerMoved(egui::pos2(nav.center().x, nav.top() + 30.0)),
|
||||
egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: egui::vec2(0.0, -1000.0),
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
phase: egui::TouchPhase::Move,
|
||||
},
|
||||
]);
|
||||
h.frames(60);
|
||||
assert_eq!(scenario::rect_of("dialog:pages_footer"), Some(footer));
|
||||
assert!(footer.contains_rect(scenario::rect_of("prefs:profile").unwrap()));
|
||||
assert!(nav.contains_rect(scenario::rect_of("prefs:page:Plugins").unwrap()), "last page is reachable in {theme}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,6 +355,10 @@ pub(crate) fn settings_scroll<R>(ui: &mut Ui, id: impl egui::AsIdSalt, add: impl
|
||||
}
|
||||
|
||||
pub(crate) fn settings_heading(ui: &mut Ui, title: &str, description: &str) {
|
||||
settings_heading_with_tag(ui, title, description, None);
|
||||
}
|
||||
|
||||
pub(crate) fn settings_heading_with_tag(ui: &mut Ui, title: &str, description: &str, tag: Option<fn(&mut Ui)>) {
|
||||
if crate::prefs_search::querying(ui) {
|
||||
return;
|
||||
}
|
||||
@@ -364,6 +368,12 @@ pub(crate) fn settings_heading(ui: &mut Ui, title: &str, description: &str) {
|
||||
let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_16 + t.space_3), Sense::hover());
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
|
||||
paint_text(ui, rect, title, crate::fonts::semibold(t.font_intro), t.form_ink, false);
|
||||
if let Some(tag) = tag {
|
||||
let width = ui.painter().layout_no_wrap(title.to_owned(), crate::fonts::semibold(t.font_intro), t.form_ink).size().x;
|
||||
let start = (rect.left() + width + t.space_8).min(rect.right());
|
||||
let tag_rect = Rect::from_min_max(egui::pos2(start, rect.top()), rect.max);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(tag_rect), tag);
|
||||
}
|
||||
super::text(ui, description, super::Text::Hint("settings_heading"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1050,8 +1050,8 @@ mod tests {
|
||||
assert!(crate::scenario::handle_at("tab:MODEL").is_none());
|
||||
assert_eq!(h.app.ui.tab, "SURFACE", "the first tab still shown is selected");
|
||||
|
||||
// Settings › Interface lists the standard tabs too.
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
// Settings › Layout lists the standard tabs too.
|
||||
h.call("ui.prefs", json!({"open":"Layout"}));
|
||||
crate::prefs::reveal_preference(&mut h, "prefs:toolbar_tab:MODEL");
|
||||
h.step(&json!({"click":{"handle":"prefs:toolbar_tab:MODEL"}})).unwrap();
|
||||
assert!(h.app.preferences.hidden_toolbar_tabs.is_empty());
|
||||
@@ -1177,7 +1177,7 @@ mod tests {
|
||||
assert_eq!(visible_tabs(&h.app), ["SKETCH"]);
|
||||
assert_eq!(h.app.ui.tab, "SKETCH");
|
||||
|
||||
h.call("ui.prefs", json!({"open":"Interface"}));
|
||||
h.call("ui.prefs", json!({"open":"Layout"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
h.call("ui.prefs", json!({"button":"ok"}));
|
||||
assert!(h.app.preferences.hidden_toolbar_tabs.is_empty());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{"call": "ui.home", "params": {"open": true}},
|
||||
{"expect": {"home": true}},
|
||||
{"call": "ui.prefs", "params": {"open": "AI"}},
|
||||
{"expect": {"home": true, "prefs": {"dialog": "AI"}}},
|
||||
{"expect": {"home": true, "prefs": {"dialog": "Assistant"}}},
|
||||
{"until": {"not_shown": "Looking for agents…"}},
|
||||
{"expect": {"shown": "Add agent…"}},
|
||||
{"click": {"handle": "prefs:ai_add"}},
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
{"note": "Colour vision lives on Interface: choices apply immediately; Cancel restores them, OK keeps them, and Interface defaults reset them. Page scrolling preserves the fixed window width."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"expect": {"prefs": {"dialog": "General", "color_vision": "off"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}},
|
||||
{"call": "ui.inspect", "params": {}},
|
||||
{"expect": {"shown": "Color vision", "prefs": {"dialog": "Interface"}, "same_width": "prefs:window"}},
|
||||
{"expect": {"shown": "Color vision", "prefs": {"dialog": "Appearance"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Deutan"},
|
||||
{"expect": {"prefs": {"color_vision": "deutan"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Cancel"},
|
||||
{"expect": {"prefs": {"dialog": null, "color_vision": "off"}}},
|
||||
{"key": "Comma", "cmd": true},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}},
|
||||
{"call": "ui.inspect", "params": {}},
|
||||
{"widget": "Tritan"},
|
||||
{"widget": "OK"},
|
||||
{"expect": {"prefs": {"dialog": null, "color_vision": "tritan"}}},
|
||||
{"key": "Comma", "cmd": true},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}},
|
||||
{"call": "ui.inspect", "params": {}},
|
||||
{"expect": {"shown": "Tritan", "same_width": "prefs:window"}},
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
{"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch1"}}},
|
||||
{"call": "engine.execute", "params": {"command": "sketch.rectangle.two_point", "params": {"p0": [0, 0], "p1": [40, 30]}}},
|
||||
{"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},
|
||||
{"call": "ui.prefs", "params": {"open": "Interface"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Layout"}},
|
||||
{"widget": "Top", "near": "Dialog buttons"},
|
||||
{"widget": "OK"},
|
||||
{"expect": {"prefs": {"dialog": null, "dialog_buttons": "top"}}},
|
||||
|
||||
@@ -2,12 +2,19 @@
|
||||
{"note": "With Preferences open and nothing being edited, typing focuses Search preferences and the letters are the query. Enter opens that setting on its own page."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"expect": {"shown": "Restore Defaults", "prefs": {"dialog": "General"}}},
|
||||
{"text": "zo"},
|
||||
{"text": "Reverse zoom direction"},
|
||||
{"frames": 3},
|
||||
{"expect": {"shown": "Reverse zoom direction", "not_shown": "Units of new designs"}},
|
||||
{"key": "Enter"},
|
||||
{"frames": 2},
|
||||
{"expect": {"shown": "Reverse zoom direction", "prefs": {"dialog": "Navigation"}}},
|
||||
{"expect": {"shown": "Reverse zoom direction", "shown_handles": ["prefs:revealed"], "prefs": {"dialog": "Navigation"}}},
|
||||
{"call": "ui.prefs", "params": {"open": "General"}},
|
||||
{"text": "Direct interaction"},
|
||||
{"frames": 3},
|
||||
{"expect": {"shown": "Work > Tools"}},
|
||||
{"key": "Enter"},
|
||||
{"frames": 2},
|
||||
{"expect": {"shown": "Direct interaction", "prefs": {"dialog": "Tools"}}},
|
||||
{"key": "Escape"},
|
||||
{"expect": {"not_shown": "Restore Defaults", "prefs": {"dialog": null}}}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{"note": "#2255: theme tiles offer the built-in themes; choosing one applies it immediately, and Cancel restores the previous theme."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"expect": {"prefs": {"dialog": "General", "theme": "dark", "dark": true}}},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"click": {"handle": "prefs:theme:light"}},
|
||||
{"expect": {"prefs": {"theme": "light", "dark": false}, "shown_handles": ["prefs:theme"]}},
|
||||
{"click": {"handle": "prefs:theme:gruvbox-dark"}},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{"note": "#4146: under the theme tiles, Viewport draws the 3D view in the Light or Dark theme's colours whatever the window uses; it applies at once, and Cancel puts it back."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"expect": {"prefs": {"theme": "dark", "dark": true, "viewport_theme": "theme", "viewport_dark": true}}},
|
||||
{"widget": "Light", "near": "Viewport"},
|
||||
{"expect": {"prefs": {"theme": "dark", "dark": true, "viewport_theme": "light", "viewport_dark": false}}},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{"note": "#36: one Preferences dialog, from the gear at the top right (and Ctrl+,). Changes apply at once; Cancel puts them back, OK keeps them."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"expect": {"shown": "Restore Defaults", "prefs": {"dialog": "General", "theme": "dark", "dark": true}}},
|
||||
{"widget": "Interface"},
|
||||
{"widget": "Appearance"},
|
||||
{"click": {"handle": "prefs:theme"}},
|
||||
{"click": {"handle": "prefs:theme:light"}},
|
||||
{"expect": {"prefs": {"theme": "light", "dark": false}}},
|
||||
@@ -12,7 +12,7 @@
|
||||
{"key": "Comma", "cmd": true},
|
||||
{"expect": {"prefs": {"dialog": "General"}}},
|
||||
{"widget": "Shortcuts"},
|
||||
{"expect": {"shown": "Reset All", "prefs": {"dialog": "Keyboard Shortcuts"}}},
|
||||
{"expect": {"shown": "Reset All", "prefs": {"dialog": "Shortcuts"}}},
|
||||
{"widget": "Navigation"},
|
||||
{"widget": "Fusion"},
|
||||
{"widget": "Tinkercad"},
|
||||
|
||||
@@ -2,27 +2,62 @@
|
||||
{"note": "#290: Preferences keeps one size on every page; descriptions wrap inside it, and the kit footer keeps Cancel / Apply / OK flush right inside its action inset."},
|
||||
{"click": {"handle": "titlebar:preferences"}},
|
||||
{"expect": {"prefs": {"dialog": "General"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}, "spans": {"inner": "prefs:footer", "outer": "prefs:window", "axis": "x", "tol": 12}}},
|
||||
{"widget": "Interface"},
|
||||
{"expect": {"prefs": {"dialog": "Interface"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Appearance"},
|
||||
{"expect": {"prefs": {"dialog": "Appearance"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Layout"},
|
||||
{"expect": {"prefs": {"dialog": "Layout"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Tools"},
|
||||
{"expect": {"prefs": {"dialog": "Tools"}, "same_width": "prefs:window"}},
|
||||
{"widget": "3D mouse"},
|
||||
{"expect": {"prefs": {"dialog": "3D mouse"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Navigation"},
|
||||
{"expect": {"prefs": {"dialog": "Navigation"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Fusion"},
|
||||
{"widget": "SolidWorks"},
|
||||
{"expect": {"prefs": {"nav": "solidworks"}, "same_width": "prefs:window"}},
|
||||
{"widget": "Shortcuts"},
|
||||
{"expect": {"prefs": {"dialog": "Keyboard Shortcuts"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"expect": {"prefs": {"dialog": "Shortcuts"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Design"},
|
||||
{"expect": {"prefs": {"dialog": "Design"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Graphics"},
|
||||
{"expect": {"prefs": {"dialog": "Graphics"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Sketch & selection"},
|
||||
{"widget": "Sketch"},
|
||||
{"expect": {"prefs": {"dialog": "Sketch"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Assistant"},
|
||||
{"expect": {"prefs": {"dialog": "AI"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"expect": {"prefs": {"dialog": "Assistant"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "Plugins"},
|
||||
{"expect": {"prefs": {"dialog": "Plugins"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"widget": "General"},
|
||||
{"expect": {"prefs": {"dialog": "General"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},
|
||||
{"note": "Repeat the twelve-page structure in the light theme, retaining real legacy handles."},
|
||||
{"call": "ui.prefs", "params": {"theme": "light", "open": "General"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Appearance"}},
|
||||
{"expect": {"prefs": {"dialog": "Appearance"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Layout"}},
|
||||
{"expect": {"prefs": {"dialog": "Layout"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Graphics"}},
|
||||
{"expect": {"prefs": {"dialog": "Graphics"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Design"}},
|
||||
{"expect": {"prefs": {"dialog": "Design"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Sketch"}},
|
||||
{"expect": {"prefs": {"dialog": "Sketch"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Tools"}},
|
||||
{"expect": {"prefs": {"dialog": "Tools"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Navigation"}},
|
||||
{"expect": {"prefs": {"dialog": "Navigation"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "3D mouse"}},
|
||||
{"expect": {"prefs": {"dialog": "3D mouse"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Shortcuts"}},
|
||||
{"expect": {"prefs": {"dialog": "Shortcuts"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Assistant"}},
|
||||
{"expect": {"prefs": {"dialog": "Assistant"}, "same_width": "prefs:window"}},
|
||||
{"call": "ui.prefs", "params": {"open": "Plugins"}},
|
||||
{"expect": {"prefs": {"dialog": "Plugins"}, "same_width": "prefs:window"}},
|
||||
{"click": {"handle": "prefs:page:Interface"}},
|
||||
{"expect": {"prefs": {"dialog": "Appearance"}}},
|
||||
{"call": "ui.prefs", "params": {"open": "Shortcuts"}},
|
||||
{"click": {"handle": "prefs:page:Keyboard Shortcuts"}},
|
||||
{"expect": {"prefs": {"dialog": "Shortcuts"}}},
|
||||
{"widget": "Cancel"},
|
||||
{"expect": {"prefs": {"dialog": null}}}
|
||||
]
|
||||
|
||||
@@ -540,7 +540,7 @@ and output schema types live in `solidcraft_engine::schema::ui_prefs` (`PrefsPar
|
||||
|
||||
Other `ui.prefs` parameters:
|
||||
|
||||
- `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there
|
||||
- `open` opens Preferences at General; Look: Appearance, Layout, Graphics; Work: Design, Sketch, Tools; Input: Navigation, 3D mouse, Shortcuts; or Extend: Assistant, Plugins. Names are case-insensitive. Legacy aliases remain accepted: Interface → Appearance, Interface/navigation bar → Layout, Keyboard Shortcuts → Shortcuts, AI → Assistant, and Selection, Sketch & selection or Sketch and selection → Sketch. Replies use the canonical page name. The corresponding legacy `prefs:page:<name>` scenario handles also remain aliases of the canonical page rows.
|
||||
- `button`: `ok`, `cancel`, `apply`, `defaults`
|
||||
- `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer, dialog or note, closes and `offer_stand_up` stays on)
|
||||
- the dialog's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never`
|
||||
|
||||
Reference in New Issue
Block a user