* Preferences: preserve Navigation and 3D mouse alongside other panels * Tests: check preference search visibility after scrolling settles * Tests: identify preference search results through indexed row handles
No files matched your search
@@ -152,6 +152,12 @@ pub(crate) fn curved_arrow(painter: &egui::Painter, at: Pos2, clockwise: bool, h
|
||||
/// The pointer target around a compass end: larger than the drawn disc, so it is easy to hit.
|
||||
pub(crate) const AXIS_RADIUS: f32 = 15.0;
|
||||
pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, at: Pos2, depth: f64, hovered: bool, t: Tokens) {
|
||||
axis_tip_scaled(painter, c, name, d, at, depth, hovered, t, 1.0);
|
||||
}
|
||||
|
||||
/// The same compass artwork at a uniform scale, including its lettering and strokes.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn axis_tip_scaled(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, at: Pos2, depth: f64, hovered: bool, t: Tokens, scale: f32) {
|
||||
let col = if d.x != 0.0 {
|
||||
t.axis_x
|
||||
} else if d.y != 0.0 {
|
||||
@@ -164,11 +170,11 @@ pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, a
|
||||
// Positive shafts are the full axis colour; negative ones are a dimmed tint (and any end
|
||||
// pointing away from the viewer dims further).
|
||||
let ink = if !positive || depth < -0.01 { col.gamma_multiply(0.55) } else { col };
|
||||
let radius = if positive { 11.0 } else { 4.8 };
|
||||
let radius = if positive { 11.0 } else { 4.8 } * scale;
|
||||
let direction = (at - c).normalized();
|
||||
let width = 3.6;
|
||||
let width = 3.6 * scale;
|
||||
// A negative shaft stops at the outer edge of its ring; a positive one runs under its disc.
|
||||
let end = if positive { at - direction * radius } else { at - direction * (radius + 1.2) };
|
||||
let end = if positive { at - direction * radius } else { at - direction * (radius + 1.2 * scale) };
|
||||
painter.line_segment([c, end], Stroke::new(width, ink));
|
||||
// The round cap sits at the origin; the other end is covered by the disc or ring.
|
||||
painter.circle_filled(c, width / 2.0, ink);
|
||||
@@ -180,18 +186,18 @@ pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, a
|
||||
// kind turns fully white.
|
||||
if hovered {
|
||||
// Same outer size as the resting tip: a ring's outline is half its stroke outside.
|
||||
painter.circle_filled(at, if positive { radius } else { radius + 1.2 }, t.on_accent);
|
||||
painter.circle_filled(at, if positive { radius } else { radius + 1.2 * scale }, t.on_accent);
|
||||
// On the light theme a white disc vanishes into the compass, so it carries an outline in
|
||||
// the axis colour, drawn inside the disc so it does not grow.
|
||||
if light && positive {
|
||||
painter.circle_stroke(at, radius - 1.0, Stroke::new(2.0, col));
|
||||
painter.circle_stroke(at, radius - scale, Stroke::new(2.0 * scale, col));
|
||||
}
|
||||
}
|
||||
if positive {
|
||||
// On a hovered (white) disc the letter takes the axis colour.
|
||||
let letter = if hovered { col } else { t.on_accent };
|
||||
let label = name.to_uppercase();
|
||||
let galley = painter.layout_no_wrap(label, crate::fonts::bold(crate::theme::Tokens::get().font_compass), letter);
|
||||
let galley = painter.layout_no_wrap(label, crate::fonts::bold(crate::theme::Tokens::get().font_compass * scale), letter);
|
||||
let origin = at - galley.size() / 2.0;
|
||||
let ppp = painter.ctx().pixels_per_point().max(0.5);
|
||||
let origin = pos2((origin.x * ppp).round() / ppp, (origin.y * ppp).round() / ppp);
|
||||
@@ -202,7 +208,7 @@ pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, a
|
||||
at,
|
||||
radius,
|
||||
Stroke::new(
|
||||
2.4,
|
||||
2.4 * scale,
|
||||
if !hovered {
|
||||
ink
|
||||
} else if light {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"ar": {
|
||||
"prefs.navigation.axes_signed": "المحاور",
|
||||
"prefs.navigation.cube_compact": "المكعب",
|
||||
"prefs.navigation.device": "الجهاز",
|
||||
"prefs.navigation.free": "حر",
|
||||
"prefs.navigation.orbit_style": "نمط الدوران",
|
||||
"prefs.navigation.radial_help": "اضغط مطولاً أو انقر سريعاً بالزر الأيمن لعرض حلقة من الأدوات.",
|
||||
"prefs.navigation.turntable": "طاولة دوارة"
|
||||
},
|
||||
"de": {
|
||||
"prefs.navigation.axes_signed": "Achsen",
|
||||
"prefs.navigation.cube_compact": "Würfel",
|
||||
"prefs.navigation.device": "Gerät",
|
||||
"prefs.navigation.free": "Frei",
|
||||
"prefs.navigation.orbit_style": "Drehstil",
|
||||
"prefs.navigation.radial_help": "Die rechte Taste halten oder kurz bewegen, um einen Werkzeugring zu öffnen.",
|
||||
"prefs.navigation.turntable": "Drehteller"
|
||||
},
|
||||
"en": {
|
||||
"prefs.navigation.axes_signed": "Axes",
|
||||
"prefs.navigation.cube_compact": "Cube",
|
||||
"prefs.navigation.device": "Device",
|
||||
"prefs.navigation.free": "Free",
|
||||
"prefs.navigation.orbit_style": "Orbit style",
|
||||
"prefs.navigation.radial_help": "Hold or flick the right button for a ring of tools.",
|
||||
"prefs.navigation.turntable": "Turntable"
|
||||
},
|
||||
"he": {
|
||||
"prefs.navigation.axes_signed": "צירים",
|
||||
"prefs.navigation.cube_compact": "קובייה",
|
||||
"prefs.navigation.device": "התקן",
|
||||
"prefs.navigation.free": "חופשי",
|
||||
"prefs.navigation.orbit_style": "סגנון סיבוב",
|
||||
"prefs.navigation.radial_help": "יש להחזיק או להניע במהירות את הלחצן הימני להצגת טבעת כלים.",
|
||||
"prefs.navigation.turntable": "שולחן מסתובב"
|
||||
},
|
||||
"ja": {
|
||||
"prefs.navigation.axes_signed": "軸",
|
||||
"prefs.navigation.cube_compact": "キューブ",
|
||||
"prefs.navigation.device": "デバイス",
|
||||
"prefs.navigation.free": "自由",
|
||||
"prefs.navigation.orbit_style": "回転方式",
|
||||
"prefs.navigation.radial_help": "右ボタンを長押しするかフリックすると、ツールのリングを表示します。",
|
||||
"prefs.navigation.turntable": "ターンテーブル"
|
||||
},
|
||||
"ko": {
|
||||
"prefs.navigation.axes_signed": "축",
|
||||
"prefs.navigation.cube_compact": "큐브",
|
||||
"prefs.navigation.device": "장치",
|
||||
"prefs.navigation.free": "자유",
|
||||
"prefs.navigation.orbit_style": "회전 방식",
|
||||
"prefs.navigation.radial_help": "오른쪽 버튼을 길게 누르거나 튕겨 도구 링을 표시합니다.",
|
||||
"prefs.navigation.turntable": "턴테이블",
|
||||
"ui.3d_mouse_sketch_orbit": "스케치 편집 중 뷰 회전",
|
||||
"ui.nav_bridge_tip": "장치의 내비게이션 브리지에 연결합니다. 요청하기 전에는 꺼져 있습니다. 3D 입력 장치 자체 프로그램(예: 직접 만든 3D 마우스 드라이버)이 뷰를 움직이며 마우스 포인터는 그대로 사용할 수 있습니다. 연결은 이 컴퓨터의 이 포트만 사용합니다."
|
||||
},
|
||||
"vi": {
|
||||
"prefs.navigation.axes_signed": "Trục",
|
||||
"prefs.navigation.cube_compact": "Khối lập phương",
|
||||
"prefs.navigation.device": "Thiết bị",
|
||||
"prefs.navigation.free": "Tự do",
|
||||
"prefs.navigation.orbit_style": "Kiểu xoay",
|
||||
"prefs.navigation.radial_help": "Giữ hoặc hất nút phải để mở vòng công cụ.",
|
||||
"prefs.navigation.turntable": "Bàn xoay"
|
||||
},
|
||||
"zh": {
|
||||
"prefs.navigation.axes_signed": "坐标轴",
|
||||
"prefs.navigation.cube_compact": "立方体",
|
||||
"prefs.navigation.device": "设备",
|
||||
"prefs.navigation.free": "自由",
|
||||
"prefs.navigation.orbit_style": "旋转方式",
|
||||
"prefs.navigation.radial_help": "按住或轻甩右键以显示工具环。",
|
||||
"prefs.navigation.turntable": "转台"
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ mod design;
|
||||
mod general;
|
||||
mod graphics;
|
||||
mod interface;
|
||||
mod mouse3d;
|
||||
mod navbar;
|
||||
mod navigation;
|
||||
mod sketch;
|
||||
@@ -1020,7 +1021,7 @@ preference_settings! {
|
||||
nav: String = "fusion".into(), PAGE_NAVIGATION;
|
||||
/// Opt in to rotation through both poles with roll, without the Shift axis-snap spring.
|
||||
/// Independent of mouse bindings; false also preserves existing saved presets' behavior.
|
||||
free_orbit: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit.label");
|
||||
free_orbit: bool = false, PAGE_NAVIGATION;
|
||||
/// With free orbit, mouse drags turn sideways about the world's up axis (a turntable without
|
||||
/// the pole limit) instead of the screen's.
|
||||
free_orbit_upright: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit_upright.label");
|
||||
@@ -1350,14 +1351,14 @@ preference_settings! {
|
||||
/// Hold this modifier alone to zoom with vertical wheel or two-finger scroll.
|
||||
trackpad_zoom_modifier: TrackpadZoomModifier = TrackpadZoomModifier::default(), PAGE_NAVIGATION;
|
||||
/// Horizontal trackpad and thumb-wheel scrolling pans the view the other way (#2007).
|
||||
pan_reverse_x: bool = false, PAGE_NAVIGATION => check("Reverse horizontal pan direction", "Horizontal two-finger scrolling and the thumb wheel pan the other way");
|
||||
pan_reverse_x: bool = false, PAGE_NAVIGATION => check("ui.reverse_horizontal_pan_direction", "Horizontal two-finger scrolling and the thumb wheel pan the other way");
|
||||
/// Vertical trackpad scrolling pans the view the other way (#5240).
|
||||
pan_reverse_y: bool = false, PAGE_NAVIGATION => check("Reverse vertical pan direction", "Vertical two-finger scrolling pans the other way");
|
||||
pan_reverse_y: bool = false, PAGE_NAVIGATION => check("ui.reverse_vertical_pan_direction", "Vertical two-finger scrolling pans the other way");
|
||||
/// Shift with two-finger trackpad scrolling orbits the view the other way, both ways at once,
|
||||
/// as natural scrolling turns it (#8410).
|
||||
orbit_reverse: bool = false, PAGE_NAVIGATION => check("Reverse trackpad orbit direction", "Shift with two-finger scrolling orbits the other way");
|
||||
orbit_reverse: bool = false, PAGE_NAVIGATION => check("ui.reverse_trackpad_orbit_direction", "Shift with two-finger scrolling orbits the other way");
|
||||
/// View changes (axis view, Look At, Home) animate; `look_at_speed` scales how fast.
|
||||
look_at_anim: bool = true, PAGE_NAVIGATION => check("Animate view changes", "Axis view, Look At, Home and Fit");
|
||||
look_at_anim: bool = true, PAGE_NAVIGATION => check("Animate view changes", "ui.look_at_anim_desc");
|
||||
look_at_speed: f32 = 1.0, PAGE_NAVIGATION, accept(0.25..=4.0) => enabled_slider(look_at_anim, "Animation speed", 0.5..=3.0, 0.25, |v| format!("{v:.2}×"));
|
||||
/// Default modelling orientation: `z` (Z up) or `y` (Y up) (#3).
|
||||
up_axis: String = "z".into(), PAGE_DESIGN;
|
||||
@@ -2856,7 +2857,6 @@ fn draw_page(app: &mut SolveApp, ui: &mut egui::Ui, index: usize, t: &Tokens) {
|
||||
PAGE_LAYOUT => interface::layout(app, ui),
|
||||
PAGE_TOOLS => tools::show(app, ui),
|
||||
PAGE_MOUSE3D => {
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.structure.mouse3d"), app.tr("prefs.structure.mouse3d_note"));
|
||||
space_mouse_section(app, ui);
|
||||
}
|
||||
PAGE_DESIGN => design::show(app, ui),
|
||||
@@ -2877,13 +2877,13 @@ fn page_index(name: &str) -> Option<usize> {
|
||||
/// The 3D mouse page's settings, drawn with the same settings kit as the sections above
|
||||
/// it: whether it moves the view and shows in it, where the picture goes, its speed, the driver and
|
||||
/// calibration, each axis, the picture with its dead zone, and what its buttons do. A section like the
|
||||
/// others, so it folds with its header and stays as the user last left it.
|
||||
/// others, with independent, searchable sections.
|
||||
fn space_mouse_section(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "space_mouse", crate::i18n::tr("ui.3d_mouse_section"), |ui| space_mouse_rows(app, ui));
|
||||
mouse3d::show(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`).
|
||||
/// port, and whether an app is connected. Part of the 3D mouse Advanced section.
|
||||
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) {
|
||||
@@ -2891,342 +2891,26 @@ fn nav_bridge(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
(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.with_layout(egui::Layout::left_to_right(egui::Align::Min).with_main_wrap(true), |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_state_badge(ui, status, if *waiting { ui_kit::SettingsBadgeTone::Warning } else { ui_kit::SettingsBadgeTone::Success });
|
||||
}
|
||||
});
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
ui_kit::settings_form(ui, ui_kit::ContentWidth::label(ui, &port), |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, "");
|
||||
ui_kit::settings_control_width(ui, Tokens::get().space_24 * 3.0 + Tokens::get().space_8, |ui| {
|
||||
ui_kit::number_field(ui, &mut app.preferences.nav_bridge_port, 1..=u16::MAX, 1.0, "");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// The label column the Navigation page's forms share (`prefs/navigation.rs`).
|
||||
/// Legacy label alignment for the 3D mouse's supplemental controls.
|
||||
const FORM_LABEL_WIDTH: f32 = 150.0;
|
||||
|
||||
fn space_mouse_rows(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
// The two checkboxes sit in the two-column grid Wheel and trackpad uses (`navigation.rs`).
|
||||
let width = (ui.available_width() - (t.space_16 + t.space_4)) * 0.5;
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_16 + t.space_4;
|
||||
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
setting::space_mouse_enabled(app, ui);
|
||||
let device = app.space_mouse.device.as_ref();
|
||||
let saved = device.is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));
|
||||
if let Some(device) = device {
|
||||
let state = app.tr(if saved { "ui.3d_mouse_calibrated" } else { "ui.3d_mouse_not_calibrated" });
|
||||
ui_kit::settings_badge(ui, &format!("{state} · {device}"), !saved);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
setting::space_mouse_in_view(app, ui).on_hover_text(crate::i18n::tr("ui.3d_mouse_show_in_view_tip"));
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
|
||||
setting::space_mouse_sketch_orbit(app, ui).on_hover_text(crate::i18n::tr("ui.3d_mouse_sketch_orbit_tip"));
|
||||
});
|
||||
});
|
||||
});
|
||||
// Where the picture goes, a choice that waits on the checkbox above.
|
||||
let names: Vec<(SpaceMouseGhost, String)> = [
|
||||
(SpaceMouseGhost::LeftViewport, "ui.3d_mouse_ghost_left_viewport"),
|
||||
(SpaceMouseGhost::RightViewport, "ui.3d_mouse_ghost_right_viewport"),
|
||||
(SpaceMouseGhost::LeftWindow, "ui.3d_mouse_ghost_left_window"),
|
||||
]
|
||||
.map(|(position, key)| (position, app.tr(key).to_owned()))
|
||||
.into();
|
||||
let orbits = [app.tr("ui.3d_mouse_orbit_traced").to_owned(), app.tr("ui.3d_mouse_orbit_classic").to_owned()];
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
// Traced or classic orbit: a choice between two named ways rather than a checkbox.
|
||||
ui_kit::row(ui, crate::i18n::tr("ui.3d_mouse_orbit"), |ui| {
|
||||
let mut selected = usize::from(!app.preferences.space_mouse_model_pivot);
|
||||
let response = ui.scope(|ui| ui_kit::segmented(ui, &mut selected, &orbits.each_ref().map(String::as_str), ui_kit::Segments::default()));
|
||||
if response.inner {
|
||||
app.preferences.space_mouse_model_pivot = selected == 0;
|
||||
}
|
||||
let rect = response.response.rect;
|
||||
crate::scenario::publish_handle("prefs:3d_mouse_orbit_traced", egui::pos2(rect.left() + rect.width() * 0.25, rect.center().y));
|
||||
crate::scenario::publish_handle("prefs:3d_mouse_orbit_classic", egui::pos2(rect.left() + rect.width() * 0.75, rect.center().y));
|
||||
response.response.on_hover_text(crate::i18n::tr("ui.3d_mouse_orbit_tip"));
|
||||
});
|
||||
ui_kit::row(ui, crate::i18n::tr("ui.3d_mouse_ghost_position"), |ui| {
|
||||
let (in_view, position) = (app.preferences.space_mouse_in_view, &mut app.preferences.space_mouse_ghost_position);
|
||||
ui.add_enabled_ui(in_view, |ui| {
|
||||
ui_kit::settings_control_width(ui, AXIS_DRIVEN_WIDTH, |ui| {
|
||||
let current = names.iter().find(|(choice, _)| choice == position).map_or("", |(_, name)| name.as_str());
|
||||
ui_kit::dropdown_menu(ui, "sc_space_mouse_ghost", current, |ui| {
|
||||
for (choice, name) in &names {
|
||||
if ui_kit::list_picker(ui, name, name, choice == position).clicked() {
|
||||
*position = *choice;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
ui_kit::row(ui, app.tr("prefs.overall_speed"), |ui| {
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
|
||||
ui_kit::slider(
|
||||
ui,
|
||||
&mut app.preferences.space_mouse_speed,
|
||||
0.25..=5.0,
|
||||
ui_kit::Slider { step: Some(0.05), format: |value| format!("{value:.2}×"), ..Default::default() },
|
||||
);
|
||||
});
|
||||
});
|
||||
ui_kit::row(ui, app.tr("ui.3d_mouse_calibration"), |ui| {
|
||||
let device = app.space_mouse.device.clone();
|
||||
let saved = device.as_ref().is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled && device.is_some(), |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_calibrate"), ui_kit::Button::Normal)
|
||||
.on_hover_text(app.tr("ui.3d_mouse_calibrate_tip"))
|
||||
.on_disabled_hover_text(app.tr(if app.space_mouse.device.is_none() {
|
||||
"ui.3d_mouse_calibrate_wait"
|
||||
} else {
|
||||
"ui.3d_mouse_calibrate_tip"
|
||||
}))
|
||||
.clicked()
|
||||
{
|
||||
crate::space_mouse_calibration::start(app);
|
||||
}
|
||||
if saved
|
||||
&& ui_kit::button(ui, app.tr("ui.3d_mouse_forget"), ui_kit::Button::Normal).clicked()
|
||||
&& let Some(device) = &device
|
||||
{
|
||||
app.preferences.space_mouse_calibrations.remove(device);
|
||||
}
|
||||
});
|
||||
let not_allowed = found_but_not_allowed(app.space_mouse.drivers);
|
||||
// With a device, the badge beside the toggle above says this.
|
||||
if device.is_some() {
|
||||
return;
|
||||
}
|
||||
let status = if not_allowed {
|
||||
app.tr("ui.3d_mouse_denied_short")
|
||||
} else if waiting_for_a_record(app.space_mouse.drivers) {
|
||||
app.tr("ui.3d_mouse_calibrate_wait")
|
||||
} else {
|
||||
app.tr("ui.3d_mouse_none")
|
||||
};
|
||||
let status_line = ui_kit::text(ui, status, ui_kit::Text::Report("calibration_status", false));
|
||||
// Nothing confirmed yet (none found, or waiting for the first record): a hint to try, as a
|
||||
// tooltip here and, while a reader is waiting for the first record, as a line below.
|
||||
if device.is_none() && !not_allowed {
|
||||
status_line.on_hover_text(app.tr("ui.3d_mouse_wiggle"));
|
||||
}
|
||||
});
|
||||
if app.space_mouse.device.is_none() {
|
||||
if found_but_not_allowed(app.space_mouse.drivers) {
|
||||
// Wiggling will not help: the device is there and SolidCraft may not read it.
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_denied"), "space_mouse_denied");
|
||||
} else {
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_wiggle"), "space_mouse_wiggle");
|
||||
}
|
||||
}
|
||||
});
|
||||
// A device whose own app drives the view instead (the navigation bridge).
|
||||
ui_kit::divider(ui, "nav_bridge");
|
||||
nav_bridge(app, ui);
|
||||
// The rarely needed settings sit behind one disclosure, closed until the reader opens it.
|
||||
ui_kit::section(ui, "space_mouse_advanced", crate::i18n::tr_label("Advanced"), false, |ui| {
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
// Only where the reader has seen the choice: Linux, with spacenavd and the device both there.
|
||||
if let Some(present) = app.space_mouse.drivers.filter(|present| present.spacenavd || (present.direct && !present.denied)) {
|
||||
let [label, auto, direct, only_spacenavd, only_direct] =
|
||||
["driver", "driver_auto", "driver_direct", "driver_only_spacenavd", "driver_only_direct"]
|
||||
.map(|key| app.tr(&format!("ui.3d_mouse_{key}")).to_owned());
|
||||
let driver = &mut app.preferences.space_mouse_driver;
|
||||
ui_kit::row(ui, &label, |ui| match (present.spacenavd, present.direct) {
|
||||
(true, true) => {
|
||||
let name = |driver| match driver {
|
||||
SpaceMouseDriver::Automatic => auto.as_str(),
|
||||
SpaceMouseDriver::Spacenavd => "spacenavd",
|
||||
SpaceMouseDriver::Direct => direct.as_str(),
|
||||
};
|
||||
ui_kit::settings_control_width(ui, AXIS_DRIVEN_WIDTH, |ui| {
|
||||
ui_kit::dropdown_menu(ui, "sc_space_mouse_driver", name(*driver), |ui| {
|
||||
for choice in SpaceMouseDriver::ALL {
|
||||
if ui_kit::list_picker(ui, name(choice), name(choice), *driver == choice).clicked() {
|
||||
*driver = choice;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
(true, false) => {
|
||||
ui_kit::text(ui, &only_spacenavd, ui_kit::Text::Hint("space_mouse_driver"));
|
||||
}
|
||||
(false, _) => {
|
||||
ui_kit::text(ui, &only_direct, ui_kit::Text::Hint("space_mouse_driver"));
|
||||
}
|
||||
});
|
||||
}
|
||||
// The setting says what was asked for; this says what is read when that is not it: Direct or
|
||||
// Automatic with the daemon read because the device itself could not be opened.
|
||||
if let Some(present) = app.space_mouse.drivers
|
||||
&& present.spacenavd
|
||||
&& present.direct
|
||||
&& app.preferences.space_mouse_driver != SpaceMouseDriver::Spacenavd
|
||||
&& app.space_mouse.device.as_deref() == Some("spacenavd")
|
||||
{
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_driver_fallback"), "space_mouse_driver_fallback");
|
||||
}
|
||||
let enabled = app.preferences.space_mouse_enabled;
|
||||
let (label, tip) = (app.tr("ui.3d_mouse_dead_zone").to_owned(), app.tr("ui.3d_mouse_dead_zone_tip").to_owned());
|
||||
let device = app.space_mouse.device.clone();
|
||||
if let Some(calibration) = device.and_then(|device| app.preferences.space_mouse_calibrations.get_mut(&device)) {
|
||||
ui_kit::row(ui, &label, |ui| {
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
ui_kit::slider(
|
||||
ui,
|
||||
&mut calibration.dead_zone_share,
|
||||
0.0..=solidcraft_space_mouse::MAX_DEAD_ZONE_SHARE,
|
||||
ui_kit::Slider { step: Some(0.01), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
)
|
||||
.on_hover_text(tip);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
ui_kit::divider(ui, "space_mouse_axes");
|
||||
// Rows say what they do to the view, through the mapping navigation uses; the choices
|
||||
// are the device's calibrated motions. Neither names a kind of device.
|
||||
let mapping = app.space_mouse.mapping;
|
||||
let rows: Vec<(String, bool)> = (0..6)
|
||||
.map(|row| {
|
||||
let label = crate::space_mouse::row_label(mapping, row);
|
||||
let text = crate::i18n::Locale::for_language(&app.preferences.language).format(label, &[("n", &(row + 1).to_string())]);
|
||||
(text, label == "ui.3d_mouse_view_off")
|
||||
})
|
||||
.collect();
|
||||
let driven_by = app.tr("ui.3d_mouse_driven_by").to_owned();
|
||||
let off_tip = app.tr("ui.3d_mouse_view_off_tip").to_owned();
|
||||
let motions: Vec<String> = crate::space_mouse::MOTIONS.iter().map(|motion| app.tr(motion).to_owned()).collect();
|
||||
// The axes are a table of their own: each row is a live meter of the motion that drives that
|
||||
// view axis, then its Invert, Speed and the motion choice.
|
||||
let enabled = app.preferences.space_mouse_enabled;
|
||||
let raw: [i16; 6] = app.space_mouse.raw.into();
|
||||
// Frames come on input, so a reading that moved since the last one gets a frame to show it.
|
||||
let seen = ui.id().with("space_mouse_meter_raw");
|
||||
let before = ui.data_mut(|data| data.get_temp::<[i16; 6]>(seen));
|
||||
ui.data_mut(|data| data.insert_temp(seen, raw));
|
||||
if before.is_some_and(|before| before != raw) {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
let calibration = app.space_mouse.device.as_ref().and_then(|device| app.preferences.space_mouse_calibrations.get(device));
|
||||
let meters: [_; 6] = std::array::from_fn(|axis| axis_meter(calibration, raw, app.preferences.space_mouse_axis_source, axis));
|
||||
ui_kit::settings_axis_header(ui);
|
||||
for (axis, (name, off)) in rows.iter().enumerate() {
|
||||
ui.push_id(("space_mouse_axis", axis), |ui| {
|
||||
let (value, zone) = meters[axis];
|
||||
let prefs = &mut app.preferences;
|
||||
let (reverse, speed, source) =
|
||||
(prefs.space_mouse_reverse.get_mut(axis), prefs.space_mouse_axis_speed.get_mut(axis), &mut prefs.space_mouse_axis_source);
|
||||
ui_kit::settings_axis_row(
|
||||
ui,
|
||||
name,
|
||||
value,
|
||||
zone,
|
||||
// Invert and speed do nothing on a row the driver turns off. The motion choice
|
||||
// stays live, so a motion can still be swapped out of it.
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled && !off, |ui| {
|
||||
if let Some(reverse) = reverse {
|
||||
ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);
|
||||
}
|
||||
});
|
||||
},
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled && !off, |ui| {
|
||||
if let Some(speed) = speed {
|
||||
ui_kit::settings_axis_gain(ui, speed);
|
||||
}
|
||||
});
|
||||
},
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
let current = source.get(axis).copied().unwrap_or(axis);
|
||||
let mut chosen = current;
|
||||
ui_kit::dropdown_menu(ui, ("sc_space_mouse_source", axis), motions.get(current).map_or("", String::as_str), |ui| {
|
||||
for (from, name) in motions.iter().enumerate() {
|
||||
if ui_kit::list_picker(ui, name, name, chosen == from).clicked() {
|
||||
chosen = from;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_hover_text(if *off { &off_tip } else { &driven_by });
|
||||
if chosen != current {
|
||||
crate::space_mouse::reassign(source, axis, chosen);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let reassigned = app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES;
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled && reassigned, |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_reset_axes"), ui_kit::Button::Normal).clicked() {
|
||||
app.preferences.space_mouse_axis_source = crate::space_mouse::SAME_AXES;
|
||||
}
|
||||
});
|
||||
});
|
||||
// Restore this section's settings (after asking); the calibration, the button mapping and the
|
||||
// test model are not touched.
|
||||
if app.space_mouse.restore_pending {
|
||||
// A short question on its own, not in a row (a row has one line's height and cut it off), so
|
||||
// that it wraps to its whole height at any width; the buttons are under it.
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_restore_ask"), "space_mouse_restore_ask");
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_restore"), ui_kit::Button::Normal).clicked() {
|
||||
restore_space_mouse_defaults(app);
|
||||
app.space_mouse.restore_pending = false;
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("ui.cancel"), ui_kit::Button::Normal).clicked() {
|
||||
app.space_mouse.restore_pending = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_restore"), ui_kit::Button::Normal).clicked() {
|
||||
app.space_mouse.restore_pending = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// The calibrated device moving as it does, with the test model beside it, then its dead zones.
|
||||
let (device, raw) = (app.space_mouse.device.clone(), app.space_mouse.raw.into());
|
||||
let (boat, motion, free_orbit) = (&mut app.space_mouse.boat, app.space_mouse.motion, app.preferences.free_orbit);
|
||||
if let Some(calibration) = device.as_ref().and_then(|device| app.preferences.space_mouse_calibrations.get_mut(device)) {
|
||||
ui_kit::divider(ui, "space_mouse_picture");
|
||||
// Under each circle's axes, what the view does with them: the rows' own labels.
|
||||
let stories = crate::space_mouse::stories(&app.preferences.language, mapping, app.preferences.space_mouse_axis_source);
|
||||
let help = crate::i18n::tr("ui.3d_mouse_circles_help").to_string();
|
||||
let pads = |ui: &mut egui::Ui| {
|
||||
crate::space_mouse_calibration::dead_zone_pads(ui, calibration, raw, false, &stories);
|
||||
ui_kit::text(ui, &help, ui_kit::Text::Hint("space_mouse_circles_help"));
|
||||
};
|
||||
picture_and_boat(ui, boat, motion, free_orbit, true, |ui| crate::space_mouse_model::live(ui, calibration, raw), pads);
|
||||
} else if device.is_some() {
|
||||
// Not calibrated: the test model alone.
|
||||
ui_kit::divider(ui, "space_mouse_picture");
|
||||
picture_and_boat(ui, boat, motion, free_orbit, false, |_| {}, |_| {});
|
||||
}
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
hint_under_controls(ui, crate::i18n::tr_label("Move and rotate the view together; sketches use pan and zoom only."), "space_mouse");
|
||||
});
|
||||
ui_kit::divider(ui, "space_mouse_buttons");
|
||||
space_mouse_buttons(app, ui);
|
||||
});
|
||||
}
|
||||
|
||||
/// A hint in the control column of the forms above and below it, as the form rows' controls are,
|
||||
/// not at the section's left edge.
|
||||
fn hint_under_controls(ui: &mut egui::Ui, text: &str, key: &str) {
|
||||
@@ -3238,9 +2922,6 @@ fn hint_under_controls(ui: &mut egui::Ui, text: &str, key: &str) {
|
||||
});
|
||||
}
|
||||
|
||||
/// The width of the "driven by" choice.
|
||||
const AXIS_DRIVEN_WIDTH: f32 = 140.0;
|
||||
|
||||
/// Where the motion that drives view axis `axis` sits, as a share of its full travel (calibrated
|
||||
/// when the device has a calibration, else the raw reading over full scale), and the share of that
|
||||
/// travel which reads as no motion on each side, for the live meter in its row.
|
||||
@@ -3316,7 +2997,7 @@ fn picture_and_boat(
|
||||
// The coordinate circles stay under the device's picture, from its left edge; the test model is
|
||||
// beside the picture where there is room, else under the circles.
|
||||
if beside {
|
||||
ui.horizontal(|ui| {
|
||||
ui.horizontal_top(|ui| {
|
||||
picture(ui);
|
||||
boat_and_reset(ui);
|
||||
});
|
||||
@@ -5124,7 +4805,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folding_the_3d_mouse_section_does_not_move_the_controls_of_the_rows_above_it() {
|
||||
fn folding_a_3d_mouse_section_does_not_move_navigation_controls() {
|
||||
for width in [900, 1100, 1318, 1600, 1920] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
@@ -5138,7 +4819,7 @@ mod tests {
|
||||
open_at(&mut h.app, PAGE_MOUSE3D);
|
||||
h.frames(6);
|
||||
assert!(h.widget("Middle double-click").is_none());
|
||||
scroll_to_and_click(&mut h, "dialog:section:3D mouse");
|
||||
scroll_to_and_click(&mut h, "dialog:section:Device");
|
||||
open_at(&mut h.app, PAGE_NAVIGATION);
|
||||
h.frames(6);
|
||||
assert_eq!(controls(), before);
|
||||
@@ -5277,39 +4958,115 @@ mod tests {
|
||||
h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000}));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
h.frames(36);
|
||||
open_advanced(&mut h);
|
||||
h
|
||||
}
|
||||
|
||||
/// Opens the section's "Advanced" disclosure, which starts closed. Once per harness: it toggles.
|
||||
fn open_advanced(h: &mut crate::scenario::Harness) {
|
||||
scroll_to_and_click(h, "dialog:section:Advanced");
|
||||
h.frames(10);
|
||||
}
|
||||
|
||||
/// The driver, dead zone, axis table and buttons are rarely needed, so they start folded away and
|
||||
/// are not drawn until the reader opens "Advanced"; the everyday controls are there either way.
|
||||
/// Axes and buttons have independent search homes and stay available when Advanced folds.
|
||||
#[test]
|
||||
fn the_advanced_3d_mouse_settings_start_folded_away() {
|
||||
fn the_3d_mouse_sections_keep_axes_and_buttons_outside_advanced() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.space_mouse.device = Some("hid 046d:c62b".into());
|
||||
h.app.space_mouse.seen = 1;
|
||||
h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd: true, direct: true, denied: false });
|
||||
h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000}));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
h.call("ui.resize", json!({"width":1600,"height":4000}));
|
||||
open_at(&mut h.app, PAGE_MOUSE3D);
|
||||
h.frames(36);
|
||||
let drawn = |name: &str| crate::scenario::rect_of(&format!("dialog:row:{name}")).is_some();
|
||||
let (driver, axes) = (crate::i18n::tr("ui.3d_mouse_driver"), crate::i18n::tr("ui.3d_mouse_button").replace("{number}", "1"));
|
||||
assert!(drawn("Calibration") && drawn("Overall speed"), "everyday controls are always there");
|
||||
assert!(!drawn(driver) && !drawn(&axes), "closed: no driver row, no buttons");
|
||||
assert!(crate::scenario::rect_of("dialog:section:Advanced").is_some());
|
||||
open_advanced(&mut h);
|
||||
assert!(drawn(driver), "open: the driver row");
|
||||
assert!(crate::scenario::rect_of("dialog:button::Restore defaults").is_some(), "open: the restore button");
|
||||
open_advanced(&mut h);
|
||||
assert!(!drawn(driver), "closed again");
|
||||
let sections = ["space_mouse_device", "space_mouse_orbit", "space_mouse_axes", "space_mouse_buttons", "space_mouse_advanced"];
|
||||
let bodies = sections.map(|key| crate::scenario::rect_of(&format!("prefs:section:{key}:body")).unwrap());
|
||||
assert!(bodies.windows(2).all(|pair| pair[0].bottom() <= pair[1].top()));
|
||||
assert!(crate::scenario::rect_of("dialog:row:Button 1").is_some());
|
||||
assert!(crate::scenario::rect_of("dialog:row:Driver").is_some());
|
||||
scroll_to_and_click(&mut h, "dialog:section:Advanced");
|
||||
assert!(crate::scenario::rect_of("dialog:row:Driver").is_none());
|
||||
assert!(crate::scenario::rect_of("dialog:row:Button 1").is_some());
|
||||
assert!(crate::scenario::rect_of("prefs:space_mouse_reset_axes").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse3d_device_card_uses_content_height_and_paints_status_and_actions_at_its_top() {
|
||||
let previous = crate::theme::is_dark();
|
||||
for dark in [false, true] {
|
||||
crate::theme::set_dark(dark);
|
||||
let t = Tokens::get();
|
||||
for width in [280.0, 646.0] {
|
||||
for (drivers, status_id) in [
|
||||
(None, "ui.3d_mouse_none"),
|
||||
(Some(crate::space_mouse::DriversPresent { spacenavd: true, direct: false, denied: false }), "ui.3d_mouse_calibrate_wait"),
|
||||
(Some(crate::space_mouse::DriversPresent { spacenavd: false, direct: true, denied: true }), "ui.3d_mouse_denied_short"),
|
||||
] {
|
||||
let mut heights = Vec::new();
|
||||
for viewport_height in [900.0, 1800.0] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
|
||||
app.preferences.language = "en".into();
|
||||
app.space_mouse.drivers = drivers;
|
||||
let before = app.preferences.clone();
|
||||
crate::scenario::clear_handles();
|
||||
let output = crate::test_support::frame(
|
||||
&ctx,
|
||||
egui::RawInput {
|
||||
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, viewport_height))),
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
ui_kit::scope(ui, |ui| {
|
||||
ui.set_width(width);
|
||||
super::space_mouse_section(&mut app, ui);
|
||||
});
|
||||
},
|
||||
);
|
||||
let card = crate::scenario::rect_of("prefs:space_mouse_device_card").unwrap();
|
||||
let status = crate::scenario::rect_of("prefs:space_mouse_status").unwrap();
|
||||
let calibrate = crate::scenario::rect_of("prefs:space_mouse_calibrate").unwrap();
|
||||
assert!(card.height() < t.control_height * 4.0 + t.space_24 * 2.0, "{width}/{viewport_height}: compact card {card:?}");
|
||||
assert!(card.contains_rect(status) && card.contains_rect(calibrate));
|
||||
assert!(status.top() - card.top() < t.control_height, "the status belongs at the card's top");
|
||||
assert!(calibrate.top() - status.bottom() <= t.space_24, "actions follow the status without viewport-sized space");
|
||||
for label in [app.tr(status_id), app.tr("ui.3d_mouse_calibrate")] {
|
||||
let mut painted = 0;
|
||||
for clipped in &output.shapes {
|
||||
crate::test_support::each_shape(&clipped.shape, &mut |shape| {
|
||||
if let egui::Shape::Text(text) = shape
|
||||
&& text.galley.text() == label
|
||||
{
|
||||
painted += 1;
|
||||
let rect = text.galley.rect.translate(text.pos.to_vec2());
|
||||
assert!(!text.galley.elided && card.expand(1.0).contains_rect(rect));
|
||||
assert!(clipped.clip_rect.expand(1.0).contains_rect(rect), "{label} must be fully painted");
|
||||
}
|
||||
});
|
||||
}
|
||||
assert_eq!(painted, 1, "one actual {label} is visible");
|
||||
}
|
||||
assert_eq!(app.preferences, before);
|
||||
assert!(app.space_mouse.device.is_none() && app.space_mouse.calibrating.is_none());
|
||||
heights.push(card.height());
|
||||
}
|
||||
assert!((heights[0] - heights[1]).abs() < 0.5, "viewport height must not stretch the device card");
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_axis_assignment_preserves_gains_inversion_and_every_other_setting() {
|
||||
for theme in ["light", "dark"] {
|
||||
let mut h = changed_3d_mouse_settings(Some("hid 046d:c62b"));
|
||||
h.call("ui.prefs", json!({"theme":theme}));
|
||||
let mut expected = h.app.preferences.clone();
|
||||
expected.space_mouse_axis_source = crate::space_mouse::SAME_AXES;
|
||||
scroll_to_and_click(&mut h, "prefs:space_mouse_reset_axes");
|
||||
assert_eq!(h.app.preferences, expected);
|
||||
h.app.preferences.space_mouse_axis_source = [1, 0, 2, 3, 4, 5];
|
||||
h.app.preferences.space_mouse_enabled = false;
|
||||
h.frames(3);
|
||||
let before = h.app.preferences.clone();
|
||||
scroll_to_and_click(&mut h, "prefs:space_mouse_reset_axes");
|
||||
assert_eq!(h.app.preferences, before, "disabled navigation cannot reset assignments");
|
||||
}
|
||||
}
|
||||
/// The question is short, says what stays, and exists in every language.
|
||||
#[test]
|
||||
fn the_restore_question_is_short_and_says_what_stays() {
|
||||
@@ -5467,7 +5224,6 @@ mod tests {
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
h.frames(6);
|
||||
h.frames(30);
|
||||
open_advanced(&mut h);
|
||||
let up = h.widget(¬e).is_some();
|
||||
assert_eq!(up, shown, "{driver:?} reading {device}, device present {direct}");
|
||||
// Whatever it says, no calibration moves between keys.
|
||||
@@ -5504,8 +5260,7 @@ mod tests {
|
||||
h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000}));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
h.frames(6);
|
||||
scroll_to_and_click(&mut h, &format!("dialog:section:{}", crate::i18n::Locale::for_language(catalog.id).text("Advanced")));
|
||||
h.frames(10);
|
||||
// The redesigned Advanced section starts expanded.
|
||||
// The restore question is up, so its whole text can be checked too.
|
||||
h.app.space_mouse.restore_pending = true;
|
||||
// The frame's language is only set while it runs, so the texts come from the catalog itself.
|
||||
@@ -5645,9 +5400,9 @@ mod tests {
|
||||
h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000}));
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D);
|
||||
h.frames(5);
|
||||
assert!(crate::scenario::rect_of("dialog:section:3D mouse").is_some(), "the section is drawn with the kit's header");
|
||||
assert!(crate::scenario::rect_of("dialog:section:3D mouse:count").is_none());
|
||||
assert!(crate::scenario::rect_of("dialog:hint:space_mouse_wiggle").is_some());
|
||||
assert!(crate::scenario::rect_of("dialog:section:Device").is_some(), "the section is drawn with the kit's header");
|
||||
assert!(crate::scenario::rect_of("dialog:section:Device:count").is_none());
|
||||
assert!(h.widget(crate::i18n::tr("ui.3d_mouse_calibrate_wait")).is_some());
|
||||
}
|
||||
|
||||
/// The boat's Reset view puts the boat back and nothing else: calibration, sensitivity, axis
|
||||
@@ -5684,10 +5439,10 @@ mod tests {
|
||||
let mut h = changed_3d_mouse_settings(None);
|
||||
h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd: true, direct: false, denied: false });
|
||||
h.frames(10);
|
||||
assert!(crate::scenario::rect_of("dialog:hint:space_mouse_wiggle").is_some(), "no device yet: the hint is a line");
|
||||
assert!(h.widget(crate::i18n::tr("ui.3d_mouse_calibrate_wait")).is_some(), "the reader waits for a real record");
|
||||
h.app.space_mouse.device = Some("spacenavd".into());
|
||||
h.frames(10);
|
||||
assert!(crate::scenario::rect_of("dialog:hint:space_mouse_wiggle").is_none(), "confirmed: no hint");
|
||||
assert!(crate::scenario::rect_of("prefs:space_mouse_status").is_none(), "confirmed: the real device replaces the waiting status");
|
||||
}
|
||||
|
||||
/// A 3D mouse that is there but may not be read, with no spacenavd to ask instead: Preferences says so
|
||||
@@ -5712,9 +5467,15 @@ mod tests {
|
||||
let mut h = changed_3d_mouse_settings(None);
|
||||
h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd, direct, denied });
|
||||
h.frames(10);
|
||||
let said = crate::scenario::rect_of("dialog:hint:space_mouse_denied").is_some();
|
||||
let said = h.widget(crate::i18n::tr("ui.3d_mouse_denied_short")).is_some();
|
||||
assert_eq!(said, shown, "spacenavd {spacenavd}, found {direct}, denied {denied}");
|
||||
let wiggle = crate::scenario::rect_of("dialog:hint:space_mouse_wiggle").is_some();
|
||||
let wiggle = h
|
||||
.widget(crate::i18n::tr(if super::waiting_for_a_record(h.app.space_mouse.drivers) {
|
||||
"ui.3d_mouse_calibrate_wait"
|
||||
} else {
|
||||
"ui.3d_mouse_none"
|
||||
}))
|
||||
.is_some();
|
||||
assert_eq!(wiggle, !shown, "the hint to wiggle shows only where waiting can help");
|
||||
assert_eq!(super::waiting_for_a_record(h.app.space_mouse.drivers), spacenavd || (direct && !denied));
|
||||
}
|
||||
@@ -8805,8 +8566,6 @@ mod tests {
|
||||
let nav = h.app.preferences.nav.clone();
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
super::reveal_preference(&mut h, "prefs:navigator");
|
||||
let picker = crate::scenario::rect_of("prefs:navigator").unwrap().center();
|
||||
h.call("ui.click", json!({"x":picker.x,"y":picker.y}));
|
||||
let cube = crate::scenario::rect_of("prefs:navigator:Cube").unwrap().center();
|
||||
assert!(crate::scenario::rect_of("prefs:navigator:Signed axes").is_some());
|
||||
h.call("ui.click", json!({"x":cube.x,"y":cube.y}));
|
||||
@@ -9120,13 +8879,109 @@ mod tests {
|
||||
assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Top);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_legend_follows_all_presets_and_runtime_options_without_mutating_them() {
|
||||
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
|
||||
for preset in NAV_PRESETS {
|
||||
choose_nav_preset(&mut app.preferences, preset);
|
||||
let before = app.preferences.clone();
|
||||
let rows = navigation::mapping_rows(&app);
|
||||
assert!(!rows.is_empty());
|
||||
assert!(rows.iter().all(|(keys, action)| !keys.is_empty() && !action.is_empty()));
|
||||
assert_eq!(app.preferences, before);
|
||||
if preset.id == "creo" {
|
||||
assert!(preset.reverse_drag_zoom);
|
||||
assert_eq!(preset.mode(NavButton::Middle, Modifiers::NONE), Some(NavMode::Orbit));
|
||||
assert!(
|
||||
rows.iter().any(|(keys, action)| keys.iter().any(|key| key == "Ctrl/Cmd") && action == crate::i18n::tr("prefs.gesture_zoom"))
|
||||
);
|
||||
}
|
||||
if preset.id == TOUCHPAD_NAV {
|
||||
assert!(
|
||||
rows.iter()
|
||||
.any(|(keys, action)| keys == &[crate::i18n::tr("prefs.shift").to_owned()] && action == crate::i18n::tr("prefs.gesture_pan"))
|
||||
);
|
||||
assert!(rows.iter().any(|(keys, action)| keys == &["Alt/Option".to_owned()] && action == crate::i18n::tr("prefs.gesture_orbit")));
|
||||
assert!(!app.preferences.trackpad_pans());
|
||||
}
|
||||
}
|
||||
choose_nav_preset(&mut app.preferences, nav_preset(crate::mouse_gesture::MOUSE_MODE));
|
||||
app.preferences.mouse_gestures.enabled = true;
|
||||
let rows = navigation::mapping_rows(&app);
|
||||
assert!(rows.iter().any(|(_, action)| action == crate::i18n::tr("prefs.context_menu_ring")));
|
||||
assert!(!rows.iter().any(
|
||||
|(keys, action)| keys.contains(&crate::i18n::tr("prefs.button_right").to_owned()) && action == crate::i18n::tr("prefs.gesture_orbit")
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_dropdown_escape_retains_live_edits_then_cancels_the_snapshot() {
|
||||
for theme in ["light", "dark"] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", json!({"language":"en","theme":theme}));
|
||||
let before = h.app.preferences.clone();
|
||||
h.call("ui.prefs", json!({"open":"Navigation","zoom_reverse":true}));
|
||||
let edited = h.app.preferences.clone();
|
||||
scroll_to_and_click(&mut h, "prefs:nav");
|
||||
let popup = "dialog:list:creo";
|
||||
assert!(crate::scenario::handle_at(popup).is_some());
|
||||
h.step(&json!({"key":"Escape"})).unwrap();
|
||||
h.frames(2);
|
||||
assert!(h.app.prefs_window.open && h.app.prefs_window.snapshot.is_some());
|
||||
assert_eq!(h.app.preferences, edited);
|
||||
assert!(crate::scenario::handle_at(popup).is_none());
|
||||
h.step(&json!({"key":"Enter"})).unwrap();
|
||||
h.frames(2);
|
||||
assert!(crate::scenario::handle_at(popup).is_some(), "Escape restored focus to the mapping trigger");
|
||||
h.step(&json!({"key":"Escape"})).unwrap();
|
||||
h.frames(2);
|
||||
h.step(&json!({"key":"Escape"})).unwrap();
|
||||
h.frames(2);
|
||||
assert!(!h.app.prefs_window.open);
|
||||
assert_eq!(h.app.preferences, before);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn orbit_picture_cards_keep_legacy_migration_and_preferences_transactions() {
|
||||
let legacy = migrate(serde_json::from_value::<Prefs>(json!({"orbit_cursor":true})).unwrap());
|
||||
assert_eq!(legacy.orbit_around, OrbitAround::Cursor);
|
||||
assert!(!legacy.orbit_cursor);
|
||||
for theme in ["light", "dark"] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", json!({"language":"en","theme":theme,"open":"Navigation"}));
|
||||
let camera = h.app.cam;
|
||||
for (key, value) in [("Origin", OrbitAround::Origin), ("View center", OrbitAround::ViewCentre), ("Under the cursor", OrbitAround::Cursor)]
|
||||
{
|
||||
scroll_to_and_click(&mut h, &format!("prefs:orbit_around:{key}"));
|
||||
assert_eq!(h.app.preferences.orbit_around, value);
|
||||
assert_eq!(h.app.cam, camera, "choosing the pivot does not turn the camera");
|
||||
assert!(!h.app.preferences.orbit_cursor);
|
||||
}
|
||||
h.call("ui.prefs", json!({"button":"apply"}));
|
||||
h.call("ui.prefs", json!({"button":"defaults"}));
|
||||
assert_eq!(h.app.preferences.orbit_around, OrbitAround::ViewCentre);
|
||||
h.call("ui.prefs", json!({"button":"cancel"}));
|
||||
assert_eq!(h.app.preferences.orbit_around, OrbitAround::Cursor);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn free_orbit_defaults_off_and_follows_preferences_transactions() {
|
||||
let old: Prefs = serde_json::from_value(json!({"nav":"solidworks"})).unwrap();
|
||||
assert!(!old.free_orbit);
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.call("ui.prefs", json!({"open":"Navigation"}));
|
||||
h.step(&json!({"click":{"handle":"prefs:free_orbit"}})).unwrap();
|
||||
h.app.preferences.free_orbit_upright = true;
|
||||
h.frames(2);
|
||||
scroll_to_and_click(&mut h, "prefs:free_orbit_upright");
|
||||
assert!(h.app.preferences.free_orbit_upright, "the disabled upright control preserves its saved value");
|
||||
assert!(!h.app.preferences.free_orbit);
|
||||
scroll_to_and_click(&mut h, "prefs:free_orbit");
|
||||
assert!(h.app.preferences.free_orbit);
|
||||
let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
|
||||
restored.load_prefs(&h.app.prefs());
|
||||
|
||||
@@ -0,0 +1,396 @@
|
||||
//! 3D mouse preferences. Device state and all actions come from the live reader and existing jobs.
|
||||
use super::*;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_page(ui, |ui| {
|
||||
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
|
||||
ui_kit::settings_heading(ui, app.tr("prefs.structure.mouse3d"), app.tr("prefs.structure.mouse3d_note"));
|
||||
device(app, ui);
|
||||
orbit(app, ui);
|
||||
axes(app, ui);
|
||||
ui_kit::settings_section(ui, "space_mouse_buttons", app.tr("ui.3d_mouse_buttons"), |ui| space_mouse_buttons(app, ui));
|
||||
advanced(app, ui);
|
||||
});
|
||||
}
|
||||
|
||||
fn device(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get();
|
||||
ui_kit::settings_section(ui, "space_mouse_device", app.tr("prefs.navigation.device"), |ui| {
|
||||
// A confirmed input record identifies the device; an open reader alone does not.
|
||||
let card =
|
||||
ui_kit::settings_card(ui, |ui| {
|
||||
let device = app.space_mouse.device.clone();
|
||||
let saved = device.as_ref().is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));
|
||||
let denied = found_but_not_allowed(app.space_mouse.drivers);
|
||||
// Native wrapping labels use the initial row height as their first-line minimum.
|
||||
ui.allocate_ui_with_layout(
|
||||
egui::vec2(ui.available_width(), t.control_height),
|
||||
egui::Layout::left_to_right(egui::Align::Min).with_main_wrap(true),
|
||||
|ui| {
|
||||
if let Some(device) = &device {
|
||||
ui_kit::text(ui, device, ui_kit::Text::Inline);
|
||||
ui_kit::settings_state_badge(ui, app.tr("ui.nav_bridge_connected"), ui_kit::SettingsBadgeTone::Success);
|
||||
ui_kit::settings_state_badge(
|
||||
ui,
|
||||
app.tr(if saved { "ui.3d_mouse_calibrated" } else { "ui.3d_mouse_not_calibrated" }),
|
||||
if saved { ui_kit::SettingsBadgeTone::Success } else { ui_kit::SettingsBadgeTone::Warning },
|
||||
);
|
||||
} else {
|
||||
let status = app.tr(if denied {
|
||||
"ui.3d_mouse_denied_short"
|
||||
} else if waiting_for_a_record(app.space_mouse.drivers) {
|
||||
"ui.3d_mouse_calibrate_wait"
|
||||
} else {
|
||||
"ui.3d_mouse_none"
|
||||
});
|
||||
let response = ui_kit::text(ui, status, ui_kit::Text::Report("calibration_status", false))
|
||||
.on_hover_text(app.tr(if denied { "ui.3d_mouse_denied" } else { "ui.3d_mouse_wiggle" }));
|
||||
crate::scenario::publish_target("prefs:space_mouse_status", response.rect);
|
||||
}
|
||||
},
|
||||
);
|
||||
let calibrate_width = ui_kit::ContentWidth::button(ui, app.tr("ui.3d_mouse_calibrate"));
|
||||
let forget_width = ui_kit::ContentWidth::button(ui, app.tr("ui.3d_mouse_forget"));
|
||||
let available = ui.available_width();
|
||||
ui.allocate_ui_with_layout(
|
||||
egui::vec2(available, t.control_height),
|
||||
egui::Layout::left_to_right(egui::Align::Min).with_main_wrap(true),
|
||||
|ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_8;
|
||||
ui.allocate_ui_with_layout(
|
||||
egui::vec2(calibrate_width.min(available), t.control_height),
|
||||
egui::Layout::top_down(egui::Align::Min),
|
||||
|ui| {
|
||||
ui_kit::settings_form(ui, 0.0, |ui| {
|
||||
ui_kit::row(ui, app.tr("ui.3d_mouse_calibrate"), |ui| {
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled && device.is_some(), |ui| {
|
||||
let response = ui_kit::button(ui, app.tr("ui.3d_mouse_calibrate"), ui_kit::Button::Normal)
|
||||
.on_hover_text(app.tr("ui.3d_mouse_calibrate_tip"))
|
||||
.on_disabled_hover_text(app.tr(if device.is_none() {
|
||||
"ui.3d_mouse_calibrate_wait"
|
||||
} else {
|
||||
"ui.3d_mouse_calibrate_tip"
|
||||
}));
|
||||
crate::scenario::publish_target("prefs:space_mouse_calibrate", response.rect);
|
||||
crate::scenario::publish_target(
|
||||
&format!("dialog:button:Calibration:{}", app.tr("ui.3d_mouse_calibrate")),
|
||||
response.rect,
|
||||
);
|
||||
if response.clicked() {
|
||||
crate::space_mouse_calibration::start(app);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
if saved {
|
||||
ui.allocate_ui_with_layout(
|
||||
egui::vec2(forget_width.min(available), t.control_height),
|
||||
egui::Layout::top_down(egui::Align::Min),
|
||||
|ui| {
|
||||
ui_kit::settings_form(ui, 0.0, |ui| {
|
||||
ui_kit::row(ui, app.tr("ui.3d_mouse_forget"), |ui| {
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
|
||||
let response = ui_kit::button(ui, app.tr("ui.3d_mouse_forget"), ui_kit::Button::Normal);
|
||||
crate::scenario::publish_target("prefs:space_mouse_forget", response.rect);
|
||||
crate::scenario::publish_target(
|
||||
&format!("dialog:button:Calibration:{}", app.tr("ui.3d_mouse_forget")),
|
||||
response.rect,
|
||||
);
|
||||
if response.clicked()
|
||||
&& let Some(device) = &device
|
||||
{
|
||||
app.preferences.space_mouse_calibrations.remove(device);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
crate::scenario::publish_rect("prefs:space_mouse_device_card", card.response.rect);
|
||||
setting::space_mouse_enabled(app, ui).on_hover_text(crate::i18n::tr("ui.3d_mouse_hint"));
|
||||
setting::space_mouse_in_view(app, ui).on_hover_text(crate::i18n::tr("ui.3d_mouse_show_in_view_tip"));
|
||||
let names = [
|
||||
(SpaceMouseGhost::LeftViewport, app.tr("ui.3d_mouse_ghost_left_viewport").to_owned()),
|
||||
(SpaceMouseGhost::RightViewport, app.tr("ui.3d_mouse_ghost_right_viewport").to_owned()),
|
||||
(SpaceMouseGhost::LeftWindow, app.tr("ui.3d_mouse_ghost_left_window").to_owned()),
|
||||
];
|
||||
let label_width = ["prefs.overall_speed", "ui.3d_mouse_ghost_position"]
|
||||
.into_iter()
|
||||
.map(|id| ui_kit::ContentWidth::label(ui, app.tr(id)))
|
||||
.fold(0.0, f32::max);
|
||||
ui_kit::settings_form(ui, label_width, |ui| {
|
||||
ui_kit::row(ui, app.tr("prefs.overall_speed"), |ui| {
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
|
||||
let response = ui_kit::slider(
|
||||
ui,
|
||||
&mut app.preferences.space_mouse_speed,
|
||||
0.25..=5.0,
|
||||
ui_kit::Slider { step: Some(0.05), format: |value| format!("{value:.2}×"), ..Default::default() },
|
||||
);
|
||||
crate::scenario::publish_target("prefs:space_mouse_speed", response.rect);
|
||||
});
|
||||
});
|
||||
ui_kit::row(ui, app.tr("ui.3d_mouse_ghost_position"), |ui| {
|
||||
let (in_view, position) = (app.preferences.space_mouse_in_view, &mut app.preferences.space_mouse_ghost_position);
|
||||
ui.add_enabled_ui(in_view, |ui| {
|
||||
ui_kit::settings_control_width(ui, t.space_24 * 10.0, |ui| {
|
||||
let current = names.iter().find(|(choice, _)| choice == position).map_or("", |(_, name)| name.as_str());
|
||||
let response = ui_kit::dropdown_menu(ui, "sc_space_mouse_ghost", current, |ui| {
|
||||
for (choice, name) in &names {
|
||||
if ui_kit::list_picker(ui, name, name, choice == position).clicked() {
|
||||
*position = *choice;
|
||||
}
|
||||
}
|
||||
});
|
||||
crate::scenario::publish_target("prefs:space_mouse_ghost_position", response.rect);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn orbit(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "space_mouse_orbit", app.tr("ui.orbit"), |ui| {
|
||||
let orbits = [app.tr("ui.3d_mouse_orbit_traced").to_owned(), app.tr("ui.3d_mouse_orbit_classic").to_owned()];
|
||||
let label = app.tr("ui.3d_mouse_orbit");
|
||||
let help = app.tr("ui.3d_mouse_orbit_tip");
|
||||
let width = ui_kit::ContentWidth::label(ui, label) + Tokens::get().space_16 + Tokens::get().space_4;
|
||||
ui_kit::settings_form(ui, width, |ui| {
|
||||
ui_kit::settings_row_help(ui, label, help, |ui| {
|
||||
crate::prefs_search::note_choices(ui, &orbits.each_ref().map(String::as_str));
|
||||
let mut selected = usize::from(!app.preferences.space_mouse_model_pivot);
|
||||
let response = ui.scope(|ui| {
|
||||
ui_kit::segmented(
|
||||
ui,
|
||||
&mut selected,
|
||||
&orbits.each_ref().map(String::as_str),
|
||||
ui_kit::Segments {
|
||||
intrinsic: true,
|
||||
targets: &["prefs:3d_mouse_orbit_traced", "prefs:3d_mouse_orbit_classic"],
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
});
|
||||
if response.inner {
|
||||
app.preferences.space_mouse_model_pivot = selected == 0;
|
||||
}
|
||||
if !crate::prefs_search::texts_hit(ui, &[label]) {
|
||||
for option in &orbits {
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("dialog:{label}:{option}")) {
|
||||
crate::prefs_search::remember(ui, option, rect);
|
||||
crate::prefs_search::follow(ui, option, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {
|
||||
setting::space_mouse_sketch_orbit(app, ui).on_hover_text(crate::i18n::tr("ui.3d_mouse_sketch_orbit_tip"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn axes(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "space_mouse_axes", app.tr("prefs.axes"), |ui| {
|
||||
// Rows say what they do to the view, through the mapping navigation uses; the choices
|
||||
// are the device's calibrated motions. Neither names a kind of device.
|
||||
let mapping = app.space_mouse.mapping;
|
||||
let rows: Vec<(String, bool)> = (0..6)
|
||||
.map(|row| {
|
||||
let label = crate::space_mouse::row_label(mapping, row);
|
||||
let text = crate::i18n::Locale::for_language(&app.preferences.language).format(label, &[("n", &(row + 1).to_string())]);
|
||||
(text, label == "ui.3d_mouse_view_off")
|
||||
})
|
||||
.collect();
|
||||
let driven_by = app.tr("ui.3d_mouse_driven_by").to_owned();
|
||||
let off_tip = app.tr("ui.3d_mouse_view_off_tip").to_owned();
|
||||
let motions: Vec<String> = crate::space_mouse::MOTIONS.iter().map(|motion| app.tr(motion).to_owned()).collect();
|
||||
// The axes are a table of their own: each row is a live meter of the motion that drives that
|
||||
// view axis, then its Invert, Speed and the motion choice.
|
||||
let enabled = app.preferences.space_mouse_enabled;
|
||||
let raw: [i16; 6] = app.space_mouse.raw.into();
|
||||
// Frames come on input, so a reading that moved since the last one gets a frame to show it.
|
||||
let seen = ui.id().with("space_mouse_meter_raw");
|
||||
let before = ui.data_mut(|data| data.get_temp::<[i16; 6]>(seen));
|
||||
ui.data_mut(|data| data.insert_temp(seen, raw));
|
||||
if before.is_some_and(|before| before != raw) {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
let calibration = app.space_mouse.device.as_ref().and_then(|device| app.preferences.space_mouse_calibrations.get(device));
|
||||
let meters: [_; 6] = std::array::from_fn(|axis| axis_meter(calibration, raw, app.preferences.space_mouse_axis_source, axis));
|
||||
ui_kit::settings_axis_header(ui);
|
||||
for (axis, (name, off)) in rows.iter().enumerate() {
|
||||
ui.push_id(("space_mouse_axis", axis), |ui| {
|
||||
let (value, zone) = meters[axis];
|
||||
let prefs = &mut app.preferences;
|
||||
let (reverse, speed, source) =
|
||||
(prefs.space_mouse_reverse.get_mut(axis), prefs.space_mouse_axis_speed.get_mut(axis), &mut prefs.space_mouse_axis_source);
|
||||
ui_kit::settings_axis_row(
|
||||
ui,
|
||||
name,
|
||||
value,
|
||||
zone,
|
||||
// Invert and speed do nothing on a row the driver turns off. The motion choice
|
||||
// stays live, so a motion can still be swapped out of it.
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled && !off, |ui| {
|
||||
if let Some(reverse) = reverse {
|
||||
ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);
|
||||
}
|
||||
});
|
||||
},
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled && !off, |ui| {
|
||||
if let Some(speed) = speed {
|
||||
ui_kit::settings_axis_gain(ui, speed);
|
||||
}
|
||||
});
|
||||
},
|
||||
|ui| {
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
let current = source.get(axis).copied().unwrap_or(axis);
|
||||
let mut chosen = current;
|
||||
ui_kit::dropdown_menu(ui, ("sc_space_mouse_source", axis), motions.get(current).map_or("", String::as_str), |ui| {
|
||||
for (from, name) in motions.iter().enumerate() {
|
||||
if ui_kit::list_picker(ui, name, name, chosen == from).clicked() {
|
||||
chosen = from;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_hover_text(if *off { &off_tip } else { &driven_by });
|
||||
if chosen != current {
|
||||
crate::space_mouse::reassign(source, axis, chosen);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
let reassigned = app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES;
|
||||
ui.add_enabled_ui(app.preferences.space_mouse_enabled && reassigned, |ui| {
|
||||
let response = ui_kit::button(ui, app.tr("ui.3d_mouse_reset_axes"), ui_kit::Button::Normal);
|
||||
crate::scenario::publish_target("prefs:space_mouse_reset_axes", response.rect);
|
||||
if response.clicked() {
|
||||
app.preferences.space_mouse_axis_source = crate::space_mouse::SAME_AXES;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn advanced(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
ui_kit::settings_section(ui, "space_mouse_advanced", app.tr("Advanced"), |ui| {
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
// Only where the reader has seen the choice: Linux, with spacenavd and the device both there.
|
||||
if let Some(present) = app.space_mouse.drivers.filter(|present| present.spacenavd || (present.direct && !present.denied)) {
|
||||
let [label, auto, direct, only_spacenavd, only_direct] =
|
||||
["driver", "driver_auto", "driver_direct", "driver_only_spacenavd", "driver_only_direct"]
|
||||
.map(|key| app.tr(&format!("ui.3d_mouse_{key}")).to_owned());
|
||||
let driver = &mut app.preferences.space_mouse_driver;
|
||||
ui_kit::row(ui, &label, |ui| match (present.spacenavd, present.direct) {
|
||||
(true, true) => {
|
||||
let name = |driver| match driver {
|
||||
SpaceMouseDriver::Automatic => auto.as_str(),
|
||||
SpaceMouseDriver::Spacenavd => "spacenavd",
|
||||
SpaceMouseDriver::Direct => direct.as_str(),
|
||||
};
|
||||
ui_kit::settings_control_width(ui, Tokens::get().space_24 * 8.0 + Tokens::get().space_8, |ui| {
|
||||
ui_kit::dropdown_menu(ui, "sc_space_mouse_driver", name(*driver), |ui| {
|
||||
for choice in SpaceMouseDriver::ALL {
|
||||
if ui_kit::list_picker(ui, name(choice), name(choice), *driver == choice).clicked() {
|
||||
*driver = choice;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
(true, false) => {
|
||||
ui_kit::text(ui, &only_spacenavd, ui_kit::Text::Hint("space_mouse_driver"));
|
||||
}
|
||||
(false, _) => {
|
||||
ui_kit::text(ui, &only_direct, ui_kit::Text::Hint("space_mouse_driver"));
|
||||
}
|
||||
});
|
||||
}
|
||||
// The setting says what was asked for; this says what is read when that is not it: Direct or
|
||||
// Automatic with the daemon read because the device itself could not be opened.
|
||||
if let Some(present) = app.space_mouse.drivers
|
||||
&& present.spacenavd
|
||||
&& present.direct
|
||||
&& app.preferences.space_mouse_driver != SpaceMouseDriver::Spacenavd
|
||||
&& app.space_mouse.device.as_deref() == Some("spacenavd")
|
||||
{
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_driver_fallback"), "space_mouse_driver_fallback");
|
||||
}
|
||||
let enabled = app.preferences.space_mouse_enabled;
|
||||
let (label, tip) = (app.tr("ui.3d_mouse_dead_zone").to_owned(), app.tr("ui.3d_mouse_dead_zone_tip").to_owned());
|
||||
let device = app.space_mouse.device.clone();
|
||||
if let Some(calibration) = device.and_then(|device| app.preferences.space_mouse_calibrations.get_mut(&device)) {
|
||||
ui_kit::row(ui, &label, |ui| {
|
||||
ui.add_enabled_ui(enabled, |ui| {
|
||||
ui_kit::slider(
|
||||
ui,
|
||||
&mut calibration.dead_zone_share,
|
||||
0.0..=solidcraft_space_mouse::MAX_DEAD_ZONE_SHARE,
|
||||
ui_kit::Slider { step: Some(0.01), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
)
|
||||
.on_hover_text(tip);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
nav_bridge(app, ui);
|
||||
ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| {
|
||||
// Restore this section's settings (after asking); the calibration, the button mapping and the
|
||||
// test model are not touched.
|
||||
if app.space_mouse.restore_pending {
|
||||
// A short question on its own, not in a row (a row has one line's height and cut it off), so
|
||||
// that it wraps to its whole height at any width; the buttons are under it.
|
||||
hint_under_controls(ui, app.tr("ui.3d_mouse_restore_ask"), "space_mouse_restore_ask");
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_restore"), ui_kit::Button::Normal).clicked() {
|
||||
restore_space_mouse_defaults(app);
|
||||
app.space_mouse.restore_pending = false;
|
||||
}
|
||||
if ui_kit::button(ui, app.tr("ui.cancel"), ui_kit::Button::Normal).clicked() {
|
||||
app.space_mouse.restore_pending = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ui_kit::row(ui, "", |ui| {
|
||||
if ui_kit::button(ui, app.tr("ui.3d_mouse_restore"), ui_kit::Button::Normal).clicked() {
|
||||
app.space_mouse.restore_pending = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// The calibrated device moving as it does, with the test model beside it, then its dead zones.
|
||||
let (device, raw) = (app.space_mouse.device.clone(), app.space_mouse.raw.into());
|
||||
let (boat, motion, free_orbit) = (&mut app.space_mouse.boat, app.space_mouse.motion, app.preferences.free_orbit);
|
||||
if let Some(calibration) = device.as_ref().and_then(|device| app.preferences.space_mouse_calibrations.get_mut(device)) {
|
||||
ui_kit::divider(ui, "space_mouse_picture");
|
||||
// Under each circle's axes, what the view does with them: the rows' own labels.
|
||||
let stories = crate::space_mouse::stories(&app.preferences.language, app.space_mouse.mapping, app.preferences.space_mouse_axis_source);
|
||||
let help = crate::i18n::tr("ui.3d_mouse_circles_help").to_string();
|
||||
let pads = |ui: &mut egui::Ui| {
|
||||
crate::space_mouse_calibration::dead_zone_pads(ui, calibration, raw, false, &stories);
|
||||
ui_kit::text(ui, &help, ui_kit::Text::Hint("space_mouse_circles_help"));
|
||||
};
|
||||
picture_and_boat(ui, boat, motion, free_orbit, true, |ui| crate::space_mouse_model::live(ui, calibration, raw), pads);
|
||||
} else if device.is_some() {
|
||||
// Not calibrated: the test model alone.
|
||||
ui_kit::divider(ui, "space_mouse_picture");
|
||||
picture_and_boat(ui, boat, motion, free_orbit, false, |_| {}, |_| {});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,87 +1,81 @@
|
||||
//! Navigation preferences, composed from the shared settings controls and figures.
|
||||
//! Navigation preferences, composed from indexed shared controls and canonical figures.
|
||||
use super::*;
|
||||
|
||||
pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
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
|
||||
.iter()
|
||||
.filter(|binding| !(crate::mouse_gesture::active(app) && binding.button == NavButton::Right))
|
||||
.filter(|binding| app.preferences.right_drag_orbits || !(binding.button == NavButton::Right && binding.mode == NavMode::Orbit))
|
||||
.map(|binding| {
|
||||
let button = match binding.button {
|
||||
NavButton::Left => "prefs.button_left",
|
||||
NavButton::Middle => "prefs.button_middle",
|
||||
NavButton::Right => "prefs.button_right",
|
||||
};
|
||||
let mut keys = Vec::new();
|
||||
if binding.keys.shift {
|
||||
keys.push(crate::i18n::tr("prefs.shift"));
|
||||
}
|
||||
if binding.keys.ctrl {
|
||||
keys.push("Ctrl/Cmd");
|
||||
}
|
||||
if binding.keys.alt {
|
||||
keys.push("Alt/Option");
|
||||
}
|
||||
keys.push(crate::i18n::tr(button));
|
||||
let action = match binding.mode {
|
||||
NavMode::Orbit => "prefs.gesture_orbit",
|
||||
NavMode::Pan => "prefs.gesture_pan",
|
||||
NavMode::Zoom => "prefs.gesture_zoom",
|
||||
};
|
||||
(keys.into_iter().map(str::to_owned).collect::<Vec<_>>(), crate::i18n::tr(action).to_string())
|
||||
})
|
||||
.collect();
|
||||
gestures.extend([
|
||||
(
|
||||
vec![app.tr("prefs.wheel").to_owned()],
|
||||
app.tr(if app.preferences.zoom_to_cursor { "prefs.zoom_toward_cursor" } else { "prefs.gesture_zoom" }).to_owned(),
|
||||
),
|
||||
(vec![app.tr("prefs.left_click").to_owned()], app.tr("prefs.select").to_owned()),
|
||||
(
|
||||
vec![app.tr("prefs.right_click").to_owned()],
|
||||
app.tr(if app.preferences.mouse_gestures.enabled && app.preferences.nav == crate::mouse_gesture::MOUSE_MODE {
|
||||
"prefs.context_menu_ring"
|
||||
} else {
|
||||
"prefs.context_menu"
|
||||
})
|
||||
.to_owned(),
|
||||
),
|
||||
]);
|
||||
ui_kit::settings_mouse_mapping(ui, &gestures, |ui| {
|
||||
ui_kit::settings_form(ui, 110.0, |ui| {
|
||||
ui_kit::row(ui, app.tr("prefs.mouse_mapping"), |ui| {
|
||||
let picker = ui_kit::dropdown_menu(ui, "pref_nav", nav_preset(&app.preferences.nav).translated_label(), |ui| {
|
||||
for preset in NAV_PRESETS {
|
||||
if ui_kit::list_picker(ui, preset.id, preset.translated_label(), app.preferences.nav == preset.id).clicked() {
|
||||
choose_nav_preset(&mut app.preferences, preset);
|
||||
}
|
||||
}
|
||||
});
|
||||
crate::scenario::publish_target("dialog:Pan, zoom, orbit", picker.rect);
|
||||
picker.on_hover_text(nav_preset(&app.preferences.nav).translated_help());
|
||||
});
|
||||
});
|
||||
});
|
||||
// These are real navigation options absent from the static board; retain them below
|
||||
// the illustrated mapping rather than enlarging the diagram or repeating its legend.
|
||||
let free_orbit = setting::free_orbit(app, ui);
|
||||
crate::scenario::publish_target("prefs:free_orbit", free_orbit.rect);
|
||||
if app.preferences.free_orbit {
|
||||
ui_kit::text(ui, crate::i18n::tr("nav.free_orbit.snap_help"), ui_kit::Text::Hint("free_orbit"));
|
||||
let upright = setting::free_orbit_upright(app, ui);
|
||||
crate::scenario::publish_target("prefs:free_orbit_upright", upright.rect);
|
||||
if app.preferences.free_orbit_upright {
|
||||
ui_kit::text(ui, crate::i18n::tr("nav.free_orbit_upright.help"), ui_kit::Text::Hint("free_orbit_upright"));
|
||||
ui_kit::settings_page(ui, |ui| {
|
||||
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
|
||||
ui_kit::settings_heading_with_tag(
|
||||
ui,
|
||||
app.tr("prefs.navigation"),
|
||||
app.tr("prefs.structure.navigation_note"),
|
||||
Some(crate::settings_profiles::tag),
|
||||
);
|
||||
mouse(app, ui, t);
|
||||
orbit(app, ui, t);
|
||||
wheel(app, ui, t);
|
||||
view(app, ui, t);
|
||||
});
|
||||
}
|
||||
|
||||
/// The legend follows the runtime preset, ring ownership, wheel anchor and right-orbit switch.
|
||||
pub(super) fn mapping_rows(app: &SolveApp) -> Vec<(Vec<String>, String)> {
|
||||
let mut gestures: Vec<_> = nav_preset(&app.preferences.nav)
|
||||
.bindings
|
||||
.iter()
|
||||
.filter(|binding| !(crate::mouse_gesture::active(app) && binding.button == NavButton::Right))
|
||||
.filter(|binding| app.preferences.right_drag_orbits || !(binding.button == NavButton::Right && binding.mode == NavMode::Orbit))
|
||||
.map(|binding| {
|
||||
let button = match binding.button {
|
||||
NavButton::Left => "prefs.button_left",
|
||||
NavButton::Middle => "prefs.button_middle",
|
||||
NavButton::Right => "prefs.button_right",
|
||||
};
|
||||
let mut keys = Vec::new();
|
||||
if binding.keys.shift {
|
||||
keys.push(crate::i18n::tr("prefs.shift"));
|
||||
}
|
||||
}
|
||||
// Only shown where the mapping orbits on a right drag (#6492).
|
||||
if nav_preset(&app.preferences.nav).bindings.iter().any(|b| b.button == NavButton::Right && b.mode == NavMode::Orbit) {
|
||||
let right_drag = setting::right_drag_orbits(app, ui).on_hover_text(crate::i18n::tr("nav.right_drag_orbits.help"));
|
||||
crate::scenario::publish_target("prefs:right_drag_orbits", right_drag.rect);
|
||||
}
|
||||
if binding.keys.ctrl {
|
||||
keys.push("Ctrl/Cmd");
|
||||
}
|
||||
if binding.keys.alt {
|
||||
keys.push("Alt/Option");
|
||||
}
|
||||
keys.push(crate::i18n::tr(button));
|
||||
let action = match binding.mode {
|
||||
NavMode::Orbit => "prefs.gesture_orbit",
|
||||
NavMode::Pan => "prefs.gesture_pan",
|
||||
NavMode::Zoom => "prefs.gesture_zoom",
|
||||
};
|
||||
(keys.into_iter().map(str::to_owned).collect::<Vec<_>>(), crate::i18n::tr(action).to_string())
|
||||
})
|
||||
.collect();
|
||||
gestures.extend([
|
||||
(
|
||||
vec![app.tr("prefs.wheel").to_owned()],
|
||||
app.tr(if app.preferences.zoom_to_cursor { "prefs.zoom_toward_cursor" } else { "prefs.gesture_zoom" }).to_owned(),
|
||||
),
|
||||
(vec![app.tr("prefs.left_click").to_owned()], app.tr("prefs.select").to_owned()),
|
||||
(
|
||||
vec![app.tr("prefs.right_click").to_owned()],
|
||||
app.tr(if app.preferences.mouse_gestures.enabled && app.preferences.nav == crate::mouse_gesture::MOUSE_MODE {
|
||||
"prefs.context_menu_ring"
|
||||
} else {
|
||||
"prefs.context_menu"
|
||||
})
|
||||
.to_owned(),
|
||||
),
|
||||
]);
|
||||
if app.preferences.nav == TOUCHPAD_NAV {
|
||||
gestures.extend([
|
||||
(vec![app.tr("prefs.shift").to_owned()], app.tr("prefs.gesture_pan").to_owned()),
|
||||
(vec!["Alt/Option".to_owned()], app.tr("prefs.gesture_orbit").to_owned()),
|
||||
]);
|
||||
}
|
||||
gestures
|
||||
}
|
||||
|
||||
fn mouse(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_section(ui, "mouse", app.tr("prefs.mouse_heading"), |ui| {
|
||||
let help = if app.preferences.nav == TOUCHPAD_NAV {
|
||||
app.tr("nav.touchpad.help").to_owned()
|
||||
} else if !app.preferences.free_orbit && app.preferences.nav != OPENSCAD_NAV {
|
||||
@@ -89,78 +83,216 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
} else {
|
||||
app.tr("prefs.extra_navigation").to_owned()
|
||||
};
|
||||
ui_kit::text(ui, &help, ui_kit::Text::Hint("navigation"));
|
||||
let stop = setting::zoom_stop_at_model(app, ui).on_hover_text(crate::i18n::tr("prefs.zoom_stop_at_model_tip"));
|
||||
crate::scenario::publish_target("prefs:zoom_stop_at_model", stop.rect);
|
||||
let gestures = mapping_rows(app);
|
||||
ui_kit::settings_mouse_mapping(ui, &gestures, |ui| {
|
||||
let width = ui_kit::ContentWidth::label(ui, app.tr("prefs.mouse_mapping")) + t.space_16 + t.space_4;
|
||||
ui_kit::settings_form(ui, width, |ui| {
|
||||
ui_kit::settings_row_help(ui, app.tr("prefs.mouse_mapping"), &help, |ui| {
|
||||
ui_kit::settings_control_width(ui, t.space_24 * 9.0 + t.space_4, |ui| {
|
||||
let response = ui_kit::dropdown_menu(ui, "pref_nav", nav_preset(&app.preferences.nav).translated_label(), |ui| {
|
||||
for preset in NAV_PRESETS {
|
||||
if ui_kit::list_picker(ui, preset.id, preset.translated_label(), app.preferences.nav == preset.id)
|
||||
.on_hover_text(preset.translated_help())
|
||||
.clicked()
|
||||
{
|
||||
choose_nav_preset(&mut app.preferences, preset);
|
||||
}
|
||||
}
|
||||
});
|
||||
crate::scenario::publish_target("dialog:Pan, zoom, orbit", response.rect);
|
||||
crate::scenario::publish_target("prefs:nav", response.rect);
|
||||
response.on_hover_text(nav_preset(&app.preferences.nav).translated_help());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
if nav_preset(&app.preferences.nav).bindings.iter().any(|b| b.button == NavButton::Right && b.mode == NavMode::Orbit) {
|
||||
let response = setting::right_drag_orbits(app, ui).on_hover_text(crate::i18n::tr("nav.right_drag_orbits.help"));
|
||||
crate::scenario::publish_target("prefs:right_drag_orbits", response.rect);
|
||||
}
|
||||
setting::radial_context_menu(app, ui).on_hover_text(crate::i18n::tr("prefs.navigation.radial_help"));
|
||||
let label = app.tr("Middle double-click");
|
||||
let width = ui_kit::ContentWidth::label(ui, label);
|
||||
ui_kit::settings_form(ui, width, |ui| {
|
||||
ui_kit::row(ui, label, |ui| {
|
||||
let current = MiddleDoubleClick::of(app);
|
||||
ui_kit::settings_control_width(ui, t.space_24 * 9.0 + t.space_4, |ui| {
|
||||
let response = ui_kit::dropdown_menu(ui, "pref_middle_double_click", crate::i18n::tr_label(current.label()), |ui| {
|
||||
for (mode, id, label) in MiddleDoubleClick::ALL {
|
||||
if ui_kit::list_picker(ui, id, crate::i18n::tr_label(label), current == mode).clicked() {
|
||||
app.preferences.middle_double_click = id.into();
|
||||
}
|
||||
}
|
||||
});
|
||||
crate::scenario::publish_target("prefs:middle_double_click", response.rect);
|
||||
response.on_hover_text(crate::i18n::tr_label("Double-clicking the middle button in the view: Home (the home view, framing what is shown), Fit (frame what is shown, keeping the orientation) or nothing"));
|
||||
});
|
||||
});
|
||||
});
|
||||
crate::mouse_gesture::nav_rows(app, ui, t);
|
||||
});
|
||||
ui_kit::settings_section(ui, "orbit_pivot", app.tr_label("Orbit around"), |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_8;
|
||||
for (index, (mode, label)) in
|
||||
[(OrbitAround::Origin, "Origin"), (OrbitAround::ViewCentre, "View center"), (OrbitAround::Cursor, "prefs.under_cursor")]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
if ui_kit::option_card(
|
||||
ui,
|
||||
app.tr_label(label),
|
||||
None,
|
||||
app.preferences.orbit_around == mode,
|
||||
true,
|
||||
ui_kit::PreferenceFigure::Pivot(index),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
app.preferences.orbit_around = mode;
|
||||
}
|
||||
}
|
||||
|
||||
fn orbit(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_section(ui, "orbit_pivot", app.tr("ui.orbit_around"), |ui| {
|
||||
let options = [
|
||||
ui_kit::PictureChoice { key: "Origin", label: app.tr("ui.origin"), figure: ui_kit::paint_orbit_origin },
|
||||
ui_kit::PictureChoice { key: "View center", label: app.tr("ui.view_centre"), figure: ui_kit::paint_orbit_centre },
|
||||
ui_kit::PictureChoice { key: "Under the cursor", label: app.tr("prefs.under_cursor"), figure: ui_kit::paint_orbit_cursor },
|
||||
];
|
||||
let selected = match app.preferences.orbit_around {
|
||||
OrbitAround::Origin => 0,
|
||||
OrbitAround::ViewCentre => 1,
|
||||
OrbitAround::Cursor => 2,
|
||||
};
|
||||
if let Some(index) = ui_kit::settings_picture_choices_sized(
|
||||
ui,
|
||||
"orbit_around",
|
||||
app.tr("ui.orbit_around"),
|
||||
&options,
|
||||
selected,
|
||||
true,
|
||||
ui_kit::PictureChoiceSize { width: t.space_24 * 8.0 + t.space_4, aspect: 120.0 / 64.0, caption: false },
|
||||
) {
|
||||
app.preferences.orbit_around = match index {
|
||||
0 => OrbitAround::Origin,
|
||||
2 => OrbitAround::Cursor,
|
||||
_ => OrbitAround::ViewCentre,
|
||||
};
|
||||
}
|
||||
for option in &options {
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("prefs:orbit_around:{}", option.key)) {
|
||||
crate::scenario::publish_target(&format!("prefs:option:{}", option.label), rect);
|
||||
}
|
||||
}
|
||||
});
|
||||
ui_kit::settings_section(ui, "orbit_style", app.tr("prefs.navigation.orbit_style"), |ui| {
|
||||
let label = app.tr("ui.orbit");
|
||||
let help = app.tr("nav.free_orbit.snap_help");
|
||||
let width = ui_kit::ContentWidth::label(ui, label) + t.space_16 + t.space_4;
|
||||
ui_kit::settings_form(ui, width, |ui| {
|
||||
ui_kit::settings_row_help(ui, label, help, |ui| {
|
||||
let options = [crate::i18n::tr("prefs.navigation.turntable"), crate::i18n::tr("prefs.navigation.free")];
|
||||
crate::prefs_search::note_choices(ui, &options);
|
||||
let mut selected = usize::from(app.preferences.free_orbit);
|
||||
let response = ui.scope(|ui| {
|
||||
ui_kit::segmented(
|
||||
ui,
|
||||
&mut selected,
|
||||
&options,
|
||||
ui_kit::Segments { intrinsic: true, targets: &["prefs:turntable", "prefs:free_orbit"], ..Default::default() },
|
||||
)
|
||||
});
|
||||
if response.inner {
|
||||
app.preferences.free_orbit = selected == 1;
|
||||
}
|
||||
if !crate::prefs_search::texts_hit(ui, &[label]) {
|
||||
for option in options {
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("dialog:{label}:{option}")) {
|
||||
crate::prefs_search::remember(ui, option, rect);
|
||||
crate::prefs_search::follow(ui, option, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_enabled_ui(app.preferences.free_orbit, |ui| {
|
||||
let response = setting::free_orbit_upright(app, ui).on_hover_text(crate::i18n::tr("nav.free_orbit_upright.help"));
|
||||
crate::scenario::publish_target("prefs:free_orbit_upright", response.rect);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn wheel(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_section(ui, "wheel_trackpad", app.tr("prefs.wheel_trackpad"), |ui| {
|
||||
// Board order is column-major in meaning: zoom behavior at left, gesture behavior at
|
||||
// right. Each checkbox keeps its original shared-control label and scenario target.
|
||||
let width = (ui.available_width() - (t.space_16 + t.space_4)) * 0.5;
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_16 + t.space_4;
|
||||
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
let available = ui.available_width();
|
||||
let gap = t.space_24 + t.space_8;
|
||||
let natural = [
|
||||
["ui.zoom_to_the_cursor", "ui.reverse_zoom_direction", "ui.reverse_horizontal_pan_direction", "ui.reverse_vertical_pan_direction"],
|
||||
["ui.smooth_wheel_zoom", "ui.two_finger_scroll_pans", "ui.reverse_trackpad_orbit_direction", "prefs.zoom_stop_at_model"],
|
||||
]
|
||||
.map(|labels| labels.into_iter().map(|id| ui_kit::ContentWidth::label(ui, app.tr(id)) + t.space_24).fold(0.0, f32::max));
|
||||
let beside = available >= natural[0] + natural[1] + gap;
|
||||
let left = if beside { (available - gap) * natural[0] / (natural[0] + natural[1]).max(1.0) } else { available };
|
||||
let right = if beside { available - gap - left } else { available };
|
||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::Min).with_main_wrap(true), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = gap;
|
||||
ui.allocate_ui_with_layout(egui::vec2(left, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
setting::zoom_to_cursor(app, ui);
|
||||
setting::zoom_reverse(app, ui);
|
||||
setting::pan_reverse_x(app, ui);
|
||||
setting::pan_reverse_y(app, ui);
|
||||
setting::orbit_reverse(app, ui);
|
||||
});
|
||||
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
ui.allocate_ui_with_layout(egui::vec2(right, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
setting::smooth_wheel_zoom(app, ui);
|
||||
let touchpad = app.preferences.nav == TOUCHPAD_NAV;
|
||||
ui.add_enabled_ui(!touchpad, |ui| {
|
||||
ui_kit::checkbox(ui, crate::i18n::tr_label("Two-finger scroll pans"), &mut app.preferences.trackpad_pan)
|
||||
let response = ui_kit::checkbox(ui, crate::i18n::tr("ui.two_finger_scroll_pans"), &mut app.preferences.trackpad_pan)
|
||||
.on_hover_text(if touchpad { crate::i18n::tr("nav.touchpad.scroll") } else { crate::i18n::tr("ui.trackpad_pan_tip") });
|
||||
crate::scenario::publish_target("prefs:trackpad_pan", response.rect);
|
||||
});
|
||||
setting::radial_context_menu(app, ui);
|
||||
setting::orbit_reverse(app, ui);
|
||||
let response = setting::zoom_stop_at_model(app, ui).on_hover_text(crate::i18n::tr("prefs.zoom_stop_at_model_tip"));
|
||||
crate::scenario::publish_target("prefs:zoom_stop_at_model", response.rect);
|
||||
});
|
||||
});
|
||||
ui_kit::row(ui, app.tr("prefs.trackpad_zoom_modifier"), |ui| {
|
||||
let platform = crate::tool_modifiers::Platform::of(ui.ctx());
|
||||
let choice = &mut app.preferences.trackpad_zoom_modifier;
|
||||
ui_kit::dropdown_menu(ui, "pref_trackpad_zoom_modifier", crate::i18n::tr(choice.label_id(platform)), |ui| {
|
||||
for (index, value) in TrackpadZoomModifier::ALL.into_iter().enumerate() {
|
||||
if ui_kit::list_picker(
|
||||
ui,
|
||||
&format!("trackpad_zoom_modifier_{index}"),
|
||||
crate::i18n::tr(value.label_id(platform)),
|
||||
*choice == value,
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
*choice = value;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_hover_text(crate::i18n::tr("prefs.trackpad_zoom_modifier.help"));
|
||||
});
|
||||
ui_kit::divider(ui, "navigation_view_controls");
|
||||
ui_kit::settings_form(ui, 150.0, |ui| {
|
||||
let label_width = ["ui.wheel_zoom_speed", "prefs.trackpad_zoom_modifier"]
|
||||
.into_iter()
|
||||
.map(|id| ui_kit::ContentWidth::label(ui, app.tr(id)))
|
||||
.fold(0.0, f32::max);
|
||||
ui_kit::settings_form(ui, label_width, |ui| {
|
||||
setting::wheel_zoom_speed(app, ui);
|
||||
ui_kit::row(ui, app.tr("prefs.trackpad_zoom_modifier"), |ui| {
|
||||
let platform = crate::tool_modifiers::Platform::of(ui.ctx());
|
||||
let choice = &mut app.preferences.trackpad_zoom_modifier;
|
||||
ui_kit::settings_control_width(ui, t.space_24 * 7.0 + t.space_12, |ui| {
|
||||
let response = ui_kit::dropdown_menu(ui, "pref_trackpad_zoom_modifier", crate::i18n::tr(choice.label_id(platform)), |ui| {
|
||||
for (index, value) in TrackpadZoomModifier::ALL.into_iter().enumerate() {
|
||||
if ui_kit::list_picker(
|
||||
ui,
|
||||
&format!("trackpad_zoom_modifier_{index}"),
|
||||
crate::i18n::tr(value.label_id(platform)),
|
||||
*choice == value,
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
*choice = value;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_hover_text(crate::i18n::tr("prefs.trackpad_zoom_modifier.help"));
|
||||
crate::scenario::publish_target("prefs:trackpad_zoom_modifier", response.rect);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn view(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::settings_section(ui, "navigation_view", app.tr("ui.tab_view"), |ui| {
|
||||
let options = [
|
||||
ui_kit::PictureChoice { key: "Signed axes", label: app.tr("prefs.navigation.axes_signed"), figure: ui_kit::paint_navigation_axes },
|
||||
ui_kit::PictureChoice { key: "Cube", label: app.tr("prefs.navigation.cube_compact"), figure: ui_kit::paint_navigation_cube },
|
||||
];
|
||||
if let Some(index) = ui_kit::settings_picture_choices_sized(
|
||||
ui,
|
||||
"navigator",
|
||||
app.tr("View navigator"),
|
||||
&options,
|
||||
usize::from(app.preferences.navigator_style == NavigatorStyle::Cube),
|
||||
true,
|
||||
ui_kit::PictureChoiceSize { width: t.space_24 * 8.0 - t.space_2, aspect: 178.0 / 115.0, caption: true },
|
||||
) {
|
||||
app.preferences.navigator_style = if index == 0 { NavigatorStyle::Axes } else { NavigatorStyle::Cube };
|
||||
}
|
||||
if let (Some(a), Some(b)) = (crate::scenario::rect_of("prefs:navigator:Signed axes"), crate::scenario::rect_of("prefs:navigator:Cube")) {
|
||||
crate::scenario::publish_target("prefs:navigator", a.union(b));
|
||||
}
|
||||
setting::look_at_anim(app, ui);
|
||||
let width =
|
||||
["ui.animation_speed", "prefs.home_fit_size"].into_iter().map(|id| ui_kit::ContentWidth::label(ui, app.tr(id))).fold(0.0, f32::max);
|
||||
ui_kit::settings_form(ui, width, |ui| {
|
||||
setting::look_at_speed(app, ui);
|
||||
let (label, note) = (app.tr("prefs.home_fit_size").to_owned(), app.tr("prefs.home_fit_size_note").to_owned());
|
||||
ui_kit::row(ui, &label, |ui| {
|
||||
let response = ui_kit::slider(
|
||||
@@ -170,55 +302,17 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },
|
||||
);
|
||||
crate::scenario::publish_rect("prefs:home_fit_size", response.rect);
|
||||
response.on_hover_text(¬e)
|
||||
response.on_hover_text(note);
|
||||
});
|
||||
ui_kit::row(ui, app.tr_label("View navigator"), |ui| {
|
||||
let mut selected = usize::from(app.preferences.navigator_style == NavigatorStyle::Cube);
|
||||
if ui_kit::segmented(
|
||||
ui,
|
||||
&mut selected,
|
||||
&[app.tr("prefs.axes"), crate::i18n::tr_label("Cube")],
|
||||
ui_kit::Segments { intrinsic: true, ..Default::default() },
|
||||
) {
|
||||
app.preferences.navigator_style = if selected == 0 { NavigatorStyle::Axes } else { NavigatorStyle::Cube };
|
||||
}
|
||||
if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", crate::i18n::tr_label("View navigator"))) {
|
||||
crate::scenario::publish_target("prefs:navigator", rect);
|
||||
for (label, key) in [(app.tr("prefs.axes"), "Signed axes"), (crate::i18n::tr_label("Cube"), "Cube")] {
|
||||
if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{label}", crate::i18n::tr_label("View navigator"))) {
|
||||
crate::scenario::publish_target(
|
||||
&format!("prefs:navigator:{key}"),
|
||||
egui::Rect::from_center_size(at, egui::vec2(t.space_24, t.control_height)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let (label, note) = (app.tr("prefs.navigator_fit").to_owned(), app.tr("prefs.navigator_fit_note").to_owned());
|
||||
let fit = ui_kit::checkbox(ui, &label, &mut app.preferences.navigator_fit).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:navigator_fit", fit.rect);
|
||||
let (label, note) = (app.tr("prefs.invert_navigator_arrows").to_owned(), app.tr("prefs.invert_navigator_arrows_note").to_owned());
|
||||
let invert = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_navigator_arrows).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:invert_navigator_arrows", invert.rect);
|
||||
let (label, note) = (app.tr("prefs.invert_curved_roll_arrows").to_owned(), app.tr("prefs.invert_curved_roll_arrows_note").to_owned());
|
||||
let invert = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_curved_roll_arrows).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:invert_curved_roll_arrows", invert.rect);
|
||||
ui_kit::row(ui, app.tr_label("Middle double-click"), |ui| {
|
||||
let current = MiddleDoubleClick::of(app);
|
||||
ui_kit::settings_control_width(ui, t.form_label_width * 2.0 + t.space_24 * 2.0 + t.space_12, |ui| {
|
||||
ui_kit::dropdown_menu(ui, "pref_middle_double_click", crate::i18n::tr_label(current.label()), |ui| {
|
||||
for (mode, id, label) in MiddleDoubleClick::ALL {
|
||||
if ui_kit::list_picker(ui, id, crate::i18n::tr_label(label), current == mode).clicked() {
|
||||
app.preferences.middle_double_click = id.into();
|
||||
}
|
||||
}
|
||||
}).on_hover_text(crate::i18n::tr_label("Double-clicking the middle button in the view: Home (the home view, framing what is shown), Fit (frame what is shown, keeping the orientation) or nothing"));
|
||||
});
|
||||
});
|
||||
setting::look_at_anim(app, ui);
|
||||
setting::look_at_speed(app, ui);
|
||||
});
|
||||
// The existing ring editor is part of the real product and remains available.
|
||||
crate::mouse_gesture::nav_rows(app, ui, t);
|
||||
let (label, note) = (app.tr("prefs.navigator_fit").to_owned(), app.tr("prefs.navigator_fit_note").to_owned());
|
||||
let response = ui_kit::checkbox(ui, &label, &mut app.preferences.navigator_fit).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:navigator_fit", response.rect);
|
||||
let (label, note) = (app.tr("prefs.invert_navigator_arrows").to_owned(), app.tr("prefs.invert_navigator_arrows_note").to_owned());
|
||||
let response = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_navigator_arrows).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:invert_navigator_arrows", response.rect);
|
||||
let (label, note) = (app.tr("prefs.invert_curved_roll_arrows").to_owned(), app.tr("prefs.invert_curved_roll_arrows_note").to_owned());
|
||||
let response = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_curved_roll_arrows).on_hover_text(note);
|
||||
crate::scenario::publish_target("prefs:invert_curved_roll_arrows", response.rect);
|
||||
});
|
||||
}
|
||||
@@ -488,7 +488,11 @@ pub(crate) fn reveal(ui: &mut Ui) {
|
||||
}
|
||||
if draw_section {
|
||||
let response = ui.label(RichText::new(section.to_uppercase()).size(t.font_small).color(t.text_dim));
|
||||
remember(ui, §ion, response.rect);
|
||||
// A setting with the section's name owns its search stop and reveal target.
|
||||
let setting_owns_label = with(ui, |state| state.key.rsplit('\n').next() == Some(section.as_str())).unwrap_or(false);
|
||||
if !setting_owns_label {
|
||||
remember(ui, §ion, response.rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,6 +649,20 @@ fn keywords(text: &str) -> &'static [&'static str] {
|
||||
"single surface analysis" => &["use a single surface analysis"],
|
||||
"only while the view is still" => &["only when the view is still"],
|
||||
"supersampling" => &["supersampling (ssaa)"],
|
||||
"free" => &["free orbit"],
|
||||
"turn about the world's up axis" => &["turn around the vertical axis"],
|
||||
"reverse horizontal pan" => &["reverse horizontal pan direction"],
|
||||
"reverse vertical pan" => &["reverse vertical pan direction"],
|
||||
"reverse trackpad orbit" => &["reverse trackpad orbit direction"],
|
||||
"two-finger zoom while holding" => &["zoom with two-finger scroll while holding"],
|
||||
"show it in the 3d view" => &["show the 3d mouse in the 3d view"],
|
||||
"picture position" => &["position"],
|
||||
"turn the view while a sketch is edited" => &["turn sketches with the 3d mouse"],
|
||||
"model" => &["traced"],
|
||||
"view center" | "view centre" => &["classic"],
|
||||
"axes" | "axes (signed)" => &["axes", "signed axes", "axes (signed)"],
|
||||
"cube" | "cube (compact)" => &["cube", "cube (compact)"],
|
||||
"under cursor" => &["under the cursor"],
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
@@ -1197,7 +1215,7 @@ mod tests {
|
||||
h.frames(1);
|
||||
assert!(h.ctx.memory(|memory| memory.has_focus(egui::Id::new("prefs_search"))), "Cmd+F focuses search");
|
||||
h.step(&serde_json::json!({"text": "zo"})).expect("type");
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
assert!(h.widget("Reverse zoom direction").is_some(), "typed letters search from the open page");
|
||||
assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_GRAPHICS);
|
||||
let first = crate::scenario::handle_at("prefs:search:current");
|
||||
@@ -1334,6 +1352,46 @@ mod tests {
|
||||
|
||||
/// The selected match is scrolled to when the arrows move it, not on every frame, so the
|
||||
/// wheel can scroll the results away from it.
|
||||
#[test]
|
||||
fn navigation_and_mouse3d_search_hits_reveal_the_actual_cards_and_controls() {
|
||||
for theme in ["light", "dark"] {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.call("ui.resize", serde_json::json!({"width":1600,"height":1100}));
|
||||
h.call("ui.prefs", serde_json::json!({"language":"en","theme":theme}));
|
||||
for (query, page, target) in [
|
||||
("Orbit around", crate::prefs::PAGE_NAVIGATION, "prefs:orbit_around:View center"),
|
||||
("Under the cursor", crate::prefs::PAGE_NAVIGATION, "prefs:orbit_around:Under the cursor"),
|
||||
("Origin", crate::prefs::PAGE_NAVIGATION, "prefs:orbit_around:Origin"),
|
||||
("View navigator", crate::prefs::PAGE_NAVIGATION, "prefs:navigator:Signed axes"),
|
||||
("Axes", crate::prefs::PAGE_NAVIGATION, "prefs:navigator:Signed axes"),
|
||||
("Cube", crate::prefs::PAGE_NAVIGATION, "prefs:navigator:Cube"),
|
||||
("Turntable", crate::prefs::PAGE_NAVIGATION, "prefs:turntable"),
|
||||
("Wheel zoom speed", crate::prefs::PAGE_NAVIGATION, "prefs:wheel_zoom_speed"),
|
||||
("Zoom with two-finger scroll while holding", crate::prefs::PAGE_NAVIGATION, "prefs:trackpad_zoom_modifier"),
|
||||
("Overall speed", crate::prefs::PAGE_MOUSE3D, "prefs:space_mouse_speed"),
|
||||
("Traced", crate::prefs::PAGE_MOUSE3D, "prefs:3d_mouse_orbit_traced"),
|
||||
("Position", crate::prefs::PAGE_MOUSE3D, "prefs:space_mouse_ghost_position"),
|
||||
] {
|
||||
h.call("ui.prefs", serde_json::json!({"open":"General"}));
|
||||
h.app.prefs_window.filter = query.into();
|
||||
h.frames(5);
|
||||
let (_, _, hits) = nav(&h.ctx);
|
||||
let matching: Vec<_> =
|
||||
hits.iter().enumerate().filter(|(_, hit)| hit.page == page && (query != "Cube" || hit.label == "Cube")).collect();
|
||||
assert_eq!(matching.len(), 1, "{theme}: {query} has one indexed setting");
|
||||
set_cursor(&h.ctx, matching[0].0);
|
||||
h.frames(2);
|
||||
h.step(&serde_json::json!({"key":"Enter"})).unwrap();
|
||||
h.frames(20);
|
||||
assert_eq!(h.app.prefs_window.section, page);
|
||||
assert!(h.app.prefs_window.filter.is_empty());
|
||||
let body = crate::scenario::rect_of("dialog:page_body").unwrap();
|
||||
assert!(body.contains_rect(crate::scenario::rect_of(target).unwrap()), "{query} reveals its live control");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preferences_search_results_scroll_freely() {
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
@@ -1341,7 +1399,7 @@ mod tests {
|
||||
crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL);
|
||||
h.frames(2);
|
||||
h.app.prefs_window.filter = "view".into();
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
let first = crate::scenario::handle_at("prefs:search:current").expect("first match");
|
||||
let wheel = egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
@@ -1373,11 +1431,11 @@ mod tests {
|
||||
h.frames(2);
|
||||
assert!(h.widget("Units of new designs").is_none(), "another page stays put until a search");
|
||||
h.app.prefs_window.filter = "units".into();
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
assert!(h.widget("Units of new designs").is_some(), "a row is found from its label");
|
||||
assert!(h.widget("Reverse zoom direction").is_none());
|
||||
h.app.prefs_window.filter = "zoom".into();
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
assert!(h.widget("Reverse zoom direction").is_some());
|
||||
assert!(h.widget("Units of new designs").is_none());
|
||||
assert!(h.widget("Grid").is_none(), "a checkbox on another page stays hidden");
|
||||
@@ -1389,14 +1447,14 @@ mod tests {
|
||||
assert!(gap < 520.0, "search results leave a {gap:.0}px gap under the field");
|
||||
assert!(h.widget("Translation X").is_none(), "unmatched pages do not stack on the result");
|
||||
h.app.prefs_window.filter = "extrude".into();
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
assert!(crate::scenario::rect_of("prefs:search:shortcuts").is_some(), "shortcut matches collapse to one row");
|
||||
assert!(crate::scenario::rect_of("dialog:cell:Extrude").is_none(), "the shortcut list stays closed");
|
||||
h.step(&serde_json::json!({"click": {"handle": "prefs:search:clear"}})).expect("clear");
|
||||
h.frames(2);
|
||||
assert!(h.app.prefs_window.filter.is_empty(), "the search X clears the field");
|
||||
h.app.prefs_window.filter = "fusion".into();
|
||||
h.frames(3);
|
||||
h.frames(20);
|
||||
assert!(h.widget("Mouse mapping").is_some(), "the dropdown's current value counts");
|
||||
h.app.prefs_window.filter = "zzzz-no-setting".into();
|
||||
h.frames(2);
|
||||
|
||||
@@ -17,6 +17,7 @@ fn error(h: &mut Harness, id: &str, params: Value) -> String {
|
||||
#[test]
|
||||
fn a_profile_holds_input_and_interface_settings_but_not_the_machine() {
|
||||
let keys: Vec<&str> = keys().collect();
|
||||
assert_eq!(keys.len(), 98, "page presentation must not alter profile membership");
|
||||
for key in [
|
||||
"nav",
|
||||
"mouse_gestures",
|
||||
@@ -26,6 +27,8 @@ fn a_profile_holds_input_and_interface_settings_but_not_the_machine() {
|
||||
"ui_scale",
|
||||
"ui_font",
|
||||
"navigator_style",
|
||||
"nav_bridge_enabled",
|
||||
"nav_bridge_port",
|
||||
"language",
|
||||
"suppress_sketch_snap",
|
||||
] {
|
||||
@@ -35,6 +38,11 @@ fn a_profile_holds_input_and_interface_settings_but_not_the_machine() {
|
||||
"space_mouse_calibrations",
|
||||
"space_mouse_driver",
|
||||
"space_mouse_speed",
|
||||
"space_mouse_axis_source",
|
||||
"space_mouse_axis_speed",
|
||||
"space_mouse_reverse",
|
||||
"space_mouse_buttons",
|
||||
"space_mouse_enabled",
|
||||
"dark_parts_shading",
|
||||
"msaa",
|
||||
"window_system",
|
||||
|
||||
@@ -898,6 +898,90 @@ fn selection_field_has_three_distinct_looks_in_every_theme() {
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn navigation_dropdown_popups_own_escape_and_return_focus_without_canceling_the_window() {
|
||||
use std::cell::Cell;
|
||||
let previous = crate::theme::is_dark();
|
||||
for dark in [false, true] {
|
||||
crate::theme::set_dark(dark);
|
||||
for kind in ["plain", "compact", "editable"] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let action = Cell::new(Action::None);
|
||||
let trigger = Cell::new(None);
|
||||
let selected = Cell::new(0);
|
||||
let mut draw = |ui: &mut Ui| {
|
||||
let ctx = ui.ctx().clone();
|
||||
action.set(
|
||||
Window::new(egui::Id::new(("dropdown_escape", kind)), "settings", "Preferences")
|
||||
.cards(1.0)
|
||||
.fields()
|
||||
.actions("OK", "Cancel", None)
|
||||
.show(&ctx, true, |ui| {
|
||||
// An earlier, closed dropdown must not steal this popup's Escape or focus.
|
||||
row(ui, "Units", |ui| {
|
||||
dropdown(ui, "units", &mut 0, &["mm", "in"]);
|
||||
});
|
||||
row(ui, "Visual style", |ui| {
|
||||
let options = crate::navigation_bar::VISUAL_STYLES.map(|(_, label)| label);
|
||||
let mut choice = selected.get();
|
||||
let choices = |ui: &mut Ui| {
|
||||
for (index, option) in options.iter().enumerate() {
|
||||
let response = ui.selectable_label(selected.get() == index, *option);
|
||||
scenario::publish_target(&format!("dialog:Visual style:{option}"), response.rect);
|
||||
if response.clicked() {
|
||||
selected.set(index);
|
||||
}
|
||||
}
|
||||
};
|
||||
let response = match kind {
|
||||
"plain" => dropdown(ui, "styles", &mut choice, &options),
|
||||
"compact" => compact_dropdown_menu(ui, "styles", options[selected.get()], choices),
|
||||
_ => dropdown_menu_with_close_behavior(
|
||||
ui,
|
||||
"styles",
|
||||
options[selected.get()],
|
||||
egui::PopupCloseBehavior::CloseOnClickOutside,
|
||||
choices,
|
||||
),
|
||||
};
|
||||
trigger.set(Some(response.id));
|
||||
if kind == "plain" {
|
||||
selected.set(choice);
|
||||
}
|
||||
});
|
||||
})
|
||||
.1,
|
||||
);
|
||||
};
|
||||
for _ in 0..3 {
|
||||
frame(&ctx, vec![], &mut draw);
|
||||
}
|
||||
let at = scenario::handle_at("dialog:Visual style").unwrap();
|
||||
frame(&ctx, pointer(at, true), &mut draw);
|
||||
frame(&ctx, pointer(at, false), &mut draw);
|
||||
frame(&ctx, vec![], &mut draw);
|
||||
assert!(scenario::handle_at("dialog:Visual style:Wireframe").is_some(), "{kind}: popup opens");
|
||||
frame(&ctx, key(egui::Key::Escape), &mut draw);
|
||||
assert_eq!(action.get(), Action::None, "{kind}: first Escape belongs to the popup");
|
||||
assert!(ctx.memory(|m| m.has_focus(trigger.get().unwrap())), "{kind}: Escape refocuses its own trigger");
|
||||
frame(&ctx, vec![], &mut draw);
|
||||
assert!(scenario::handle_at("dialog:Visual style:Wireframe").is_none());
|
||||
frame(&ctx, key(egui::Key::Enter), &mut draw);
|
||||
assert_eq!(action.get(), Action::None, "{kind}: Enter reopens rather than submitting");
|
||||
frame(&ctx, vec![], &mut draw);
|
||||
assert!(scenario::handle_at("dialog:Visual style:Wireframe").is_some(), "{kind}: focused trigger reopens on Enter");
|
||||
frame(&ctx, key(egui::Key::Escape), &mut draw);
|
||||
assert_eq!(action.get(), Action::None);
|
||||
frame(&ctx, vec![], &mut draw);
|
||||
assert!(scenario::handle_at("dialog:Visual style:Wireframe").is_none());
|
||||
frame(&ctx, key(egui::Key::Escape), &mut draw);
|
||||
assert_eq!(action.get(), Action::Cancel, "{kind}: Escape without a popup cancels normally");
|
||||
assert_eq!(selected.get(), 0, "dismissal does not select an option");
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
// The text fields' right-click menu (#8875).
|
||||
|
||||
use super::super::text_menu::{self, Edit, Field, State, TEST_CLIPBOARD};
|
||||
|
||||
@@ -4,6 +4,218 @@ use crate::ui_kit::*;
|
||||
use crate::{scenario, theme::Tokens};
|
||||
use egui::Ui;
|
||||
|
||||
#[test]
|
||||
fn navigation_cards_keep_their_proportions_and_native_targets_at_narrow_widths() {
|
||||
let previous = crate::theme::is_dark();
|
||||
for dark in [false, true] {
|
||||
crate::theme::set_dark(dark);
|
||||
for available in [140.0, 280.0, 646.0] {
|
||||
for (label, width, aspect, options) in [
|
||||
(
|
||||
"Orbit around",
|
||||
196.0,
|
||||
120.0 / 64.0,
|
||||
vec![
|
||||
PictureChoice { key: "origin", label: "Origin", figure: paint_orbit_origin },
|
||||
PictureChoice { key: "centre", label: "View center", figure: paint_orbit_centre },
|
||||
PictureChoice { key: "cursor", label: "Under the cursor", figure: paint_orbit_cursor },
|
||||
],
|
||||
),
|
||||
(
|
||||
"View navigator",
|
||||
190.0,
|
||||
178.0 / 115.0,
|
||||
vec![
|
||||
PictureChoice { key: "axes", label: "Axes (signed)", figure: paint_navigation_axes },
|
||||
PictureChoice { key: "cube", label: "Cube (compact)", figure: paint_navigation_cube },
|
||||
],
|
||||
),
|
||||
] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let draw = |ui: &mut Ui| {
|
||||
ui.set_width(available);
|
||||
settings_picture_choices_sized(ui, "nav_geometry", label, &options, 0, true, PictureChoiceSize { width, aspect, caption: true })
|
||||
};
|
||||
frame(&ctx, vec![], |ui| {
|
||||
draw(ui);
|
||||
});
|
||||
let row = scenario::rect_of(&format!("dialog:row:{label}")).unwrap();
|
||||
for option in &options {
|
||||
let card = scenario::rect_of(&format!("prefs:nav_geometry:{}", option.key)).unwrap();
|
||||
assert!(row.expand(0.5).contains_rect(card), "{available}: {card:?} outside {row:?}");
|
||||
assert!(card.width() <= available + 0.5);
|
||||
if available == 646.0 {
|
||||
assert!((card.width() - width).abs() < 0.5);
|
||||
}
|
||||
}
|
||||
let at = scenario::handle_at(&format!("prefs:nav_geometry:{}", options[1].key)).unwrap();
|
||||
for down in [true, false] {
|
||||
frame(&ctx, pointer(at, down), |ui| {
|
||||
let picked = draw(ui);
|
||||
if !down {
|
||||
assert_eq!(picked, Some(1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn axis_gain_invert_and_source_stay_inside_the_same_row_when_it_stacks() {
|
||||
let previous = crate::theme::is_dark();
|
||||
for dark in [false, true] {
|
||||
crate::theme::set_dark(dark);
|
||||
for width in [180.0, 280.0, 646.0] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let mut reverse = false;
|
||||
let mut gain = 1.0;
|
||||
let mut source = 0;
|
||||
let (mut inverted, mut speed, mut motion) = (egui::Rect::NOTHING, egui::Rect::NOTHING, egui::Rect::NOTHING);
|
||||
let (mut invert_clip, mut speed_clip, mut source_clip) = (egui::Rect::NOTHING, egui::Rect::NOTHING, egui::Rect::NOTHING);
|
||||
let output = crate::test_support::frame(
|
||||
&ctx,
|
||||
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 1200.0))), ..Default::default() },
|
||||
|ui| {
|
||||
scope(ui, |ui| {
|
||||
ui.set_width(width);
|
||||
settings_axis_row(
|
||||
ui,
|
||||
"Pan X",
|
||||
0.5,
|
||||
[0.2, 0.3],
|
||||
|ui| {
|
||||
inverted = checkbox(ui, "Invert", &mut reverse).rect;
|
||||
invert_clip = ui.clip_rect();
|
||||
},
|
||||
|ui| {
|
||||
speed = settings_axis_gain(ui, &mut gain).rect;
|
||||
speed_clip = ui.clip_rect();
|
||||
},
|
||||
|ui| {
|
||||
motion = dropdown(ui, "axis_containment", &mut source, &["Translation X", "Translation Y"]).rect;
|
||||
source_clip = ui.clip_rect();
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
let row = scenario::rect_of("prefs:axis:Pan X").unwrap();
|
||||
let controls = [inverted, speed, motion];
|
||||
assert!(controls.into_iter().all(|control| row.expand(0.5).contains_rect(control)), "{width}: {controls:?} in {row:?}");
|
||||
for (control, clip) in controls.into_iter().zip([invert_clip, speed_clip, source_clip]) {
|
||||
assert!(clip.expand(0.5).contains_rect(control), "{width}: control {control:?} is clipped by {clip:?}");
|
||||
}
|
||||
assert_eq!(row, scenario::rect_of("dialog:control:Pan X").unwrap(), "paint bounds use the allocated row, not its centered cursor");
|
||||
let mut bars = 0;
|
||||
for clipped in &output.shapes {
|
||||
crate::test_support::each_shape(&clipped.shape, &mut |shape| match shape {
|
||||
egui::Shape::Text(text) => {
|
||||
let painted = text.galley.rect.translate(text.pos.to_vec2());
|
||||
assert!(
|
||||
clipped.clip_rect.expand(1.0).contains_rect(painted),
|
||||
"{width}: text {} clipped at {painted:?} by {:?}",
|
||||
text.galley.text(),
|
||||
clipped.clip_rect
|
||||
);
|
||||
}
|
||||
egui::Shape::Rect(rect)
|
||||
if rect.fill == Tokens::get().dialog_rule && (rect.rect.height() - Tokens::get().space_14).abs() < 0.5 =>
|
||||
{
|
||||
bars += 1;
|
||||
assert!(clipped.clip_rect.contains_rect(rect.rect), "{width}: live bar must be fully painted");
|
||||
}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
assert_eq!(bars, 1, "inspect the actual live-meter background");
|
||||
assert!(crate::test_support::text_shapes(&output).any(|text| text.galley.text() == "Pan X" && !text.galley.elided));
|
||||
assert_eq!((reverse, gain, source), (false, 1.0, 0));
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse_mapping_chords_and_actions_wrap_without_overpainting_each_other() {
|
||||
let previous = crate::theme::is_dark();
|
||||
for dark in [false, true] {
|
||||
crate::theme::set_dark(dark);
|
||||
for width in [160.0, 280.0, 528.0] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let mut bounds = egui::Rect::NOTHING;
|
||||
let output = crate::test_support::frame(
|
||||
&ctx,
|
||||
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 1600.0))), ..Default::default() },
|
||||
|ui| {
|
||||
ui.set_width(width);
|
||||
let group = ui.vertical(|ui| {
|
||||
settings_bindings(
|
||||
ui,
|
||||
&[
|
||||
(&["Ctrl/Cmd", "Shift", "Middle drag"], "Zoom toward the cursor"),
|
||||
(&["Alt/Option"], "Orbit"),
|
||||
(&["Right drag"], "Orbit"),
|
||||
(&["Wheel"], "Zoom"),
|
||||
(&["Left click"], "Select"),
|
||||
(&["Right click"], "Menu"),
|
||||
(&["Click"], "Select one"),
|
||||
(&["Shift", "Click"], "Add"),
|
||||
(&["Ctrl/Cmd", "Click"], "Toggle"),
|
||||
],
|
||||
)
|
||||
});
|
||||
bounds = group.response.rect;
|
||||
},
|
||||
);
|
||||
for label in ["Ctrl/Cmd", "Shift", "Middle drag", "Alt/Option", "Right drag", "Wheel", "Left click", "Right click", "Click"] {
|
||||
let caps: Vec<_> = crate::test_support::text_shapes(&output).filter(|text| text.galley.text() == label).collect();
|
||||
assert!(!caps.is_empty(), "{width}: the {label} keycap must be painted");
|
||||
assert!(caps.iter().all(|text| !text.galley.elided), "{width}: {label} must be complete");
|
||||
}
|
||||
for clipped in &output.shapes {
|
||||
crate::test_support::each_shape(&clipped.shape, &mut |shape| {
|
||||
if let egui::Shape::Text(text) = shape {
|
||||
assert!(
|
||||
clipped.clip_rect.expand(1.0).contains_rect(text.galley.rect.translate(text.pos.to_vec2())),
|
||||
"{width}: text must fit its real paint clip"
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
let text: Vec<_> = crate::test_support::text_shapes(&output).map(|text| text.galley.rect.translate(text.pos.to_vec2())).collect();
|
||||
assert!(text.iter().all(|rect| bounds.expand(1.0).contains_rect(*rect)), "{width}: {text:?} outside {bounds:?}");
|
||||
for (index, rect) in text.iter().enumerate() {
|
||||
assert!(text.iter().skip(index + 1).all(|other| !rect.intersects(*other)), "{width}: binding text must not overlap");
|
||||
}
|
||||
}
|
||||
}
|
||||
crate::theme::set_dark(previous);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse_mapping_search_keeps_main_gesture_chords_and_actions() {
|
||||
for query in ["Middle drag", "Zoom toward the cursor"] {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let output = crate::test_support::frame(&ctx, egui::RawInput::default(), |ui| {
|
||||
scope(ui, |ui| {
|
||||
ui.set_width(280.0);
|
||||
let _search = crate::prefs_search::begin(ui, query);
|
||||
settings_mouse_mapping(
|
||||
ui,
|
||||
&[(vec!["Ctrl/Cmd".into(), "Middle drag".into()], "Zoom toward the cursor".into()), (vec!["Alt/Option".into()], "Orbit".into())],
|
||||
|_| {},
|
||||
);
|
||||
});
|
||||
});
|
||||
let text: Vec<_> = crate::test_support::text_shapes(&output).map(|text| text.galley.text()).collect();
|
||||
assert!(text.contains(&"Ctrl/Cmd") && text.contains(&"Middle drag") && text.contains(&"Zoom toward the cursor"));
|
||||
assert!(!text.contains(&"Alt/Option") && !text.contains(&"Orbit"), "unmatched gestures stay hidden");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_lines_wrap_at_form_width_and_leave_room_for_the_next_row() {
|
||||
let previous_dark = crate::theme::is_dark();
|
||||
|
||||
@@ -432,6 +432,8 @@ fn settings_section_count_spaced<R>(
|
||||
if !gained {
|
||||
return Some(missed);
|
||||
}
|
||||
// Keep search headings outside wrapped rows in this section.
|
||||
crate::prefs_search::reveal(ui);
|
||||
let mut child = crate::prefs_search::detached_child(ui, ("prefs-search-section", key), false);
|
||||
let result = add(&mut child);
|
||||
crate::prefs_search::place_search_child(ui, &child);
|
||||
@@ -569,6 +571,7 @@ pub(crate) use super::preferences_figure_data::{
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum PreferenceFigure {
|
||||
#[cfg(test)]
|
||||
Pivot(usize),
|
||||
Quality(usize),
|
||||
Antialiasing(u32),
|
||||
@@ -737,6 +740,7 @@ pub(crate) fn paint_preference_figure(p: &egui::Painter, rect: Rect, figure: Pre
|
||||
}
|
||||
}
|
||||
PreferenceFigure::UpAxis(y_up) => super::preferences_figures::paint_orientation(&p, rect, y_up),
|
||||
#[cfg(test)]
|
||||
PreferenceFigure::Pivot(pivot) => super::preferences_figures::paint_orbit(&p, rect, pivot),
|
||||
PreferenceFigure::ContactShading(on) => super::preferences_figures::paint_contact_shading(&p, rect, on),
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ pub(super) fn card_width(available: f32, columns: usize, gap: f32) -> f32 {
|
||||
}
|
||||
|
||||
fn card_height(t: &Tokens, width: f32, card: &Card) -> f32 {
|
||||
let pad = t.space_6;
|
||||
let pad = t.space_4;
|
||||
let aspect = if card.aspect.is_finite() && card.aspect > 0.01 { card.aspect } else { 1.0 };
|
||||
let figure = ((width - 2.0 * pad).max(0.0) / aspect).min(dimension(f32::MAX));
|
||||
let sub = if card.sub.is_some() { t.space_14 } else { 0.0 };
|
||||
@@ -138,7 +138,7 @@ fn paint_card(ui: &mut Ui, card: &Card, width: f32, tile: bool) -> Response {
|
||||
if look.focus_ring {
|
||||
p.rect_stroke(rect.expand(t.space_2), radius + t.space_2, Stroke::new(t.space_2, t.form_primary), StrokeKind::Outside);
|
||||
}
|
||||
let inset = t.space_6;
|
||||
let inset = t.space_4;
|
||||
let figure = Rect::from_min_size(
|
||||
rect.min + vec2(inset, inset),
|
||||
vec2((rect.width() - 2.0 * inset).max(0.0), ((rect.width() - 2.0 * inset).max(0.0) / card.aspect.max(0.01)).min(rect.height())),
|
||||
@@ -147,7 +147,7 @@ fn paint_card(ui: &mut Ui, card: &Card, width: f32, tile: bool) -> Response {
|
||||
let figure_painter = p.with_clip_rect(figure.intersect(p.clip_rect()));
|
||||
(card.figure)(&figure_painter, figure);
|
||||
if !enabled {
|
||||
p.rect_filled(figure, 0.0, t.control_fill.gamma_multiply(0.5));
|
||||
p.rect_filled(figure, (radius - inset).max(0.0), t.control_fill.gamma_multiply(0.5));
|
||||
}
|
||||
}
|
||||
let ink = match look.ink {
|
||||
|
||||
@@ -2143,26 +2143,65 @@ pub(super) const MOUSE_MAPPING: Figure = Figure {
|
||||
size: [96.0, 120.0],
|
||||
ops: &[
|
||||
Op::Rect { r: [0.0, 0.0, 96.0, 120.0], radius: 0.0, fill: Some(P { ink: Ink::Ground, a: 1.0 }), line: None },
|
||||
Op::Rect {
|
||||
r: [26.0, 14.0, 44.0, 86.0],
|
||||
radius: 22.0,
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
[44.0, 14.0],
|
||||
[52.0, 14.0],
|
||||
[55.512, 14.346],
|
||||
[58.888, 15.37],
|
||||
[62.0, 17.034],
|
||||
[64.728, 19.272],
|
||||
[66.966, 22.0],
|
||||
[68.63, 25.112],
|
||||
[69.654, 28.488],
|
||||
[70.0, 32.0],
|
||||
[70.0, 78.0],
|
||||
[69.577, 82.292],
|
||||
[68.325, 86.419],
|
||||
[66.292, 90.223],
|
||||
[63.556, 93.556],
|
||||
[60.223, 96.292],
|
||||
[56.419, 98.325],
|
||||
[52.292, 99.577],
|
||||
[48.0, 100.0],
|
||||
[43.708, 99.577],
|
||||
[39.581, 98.325],
|
||||
[35.777, 96.292],
|
||||
[32.444, 93.556],
|
||||
[29.708, 90.223],
|
||||
[27.675, 86.419],
|
||||
[26.423, 82.292],
|
||||
[26.0, 78.0],
|
||||
[26.0, 32.0],
|
||||
[26.346, 28.488],
|
||||
[27.37, 25.112],
|
||||
[29.034, 22.0],
|
||||
[31.272, 19.272],
|
||||
[34.0, 17.034],
|
||||
[37.112, 15.37],
|
||||
[40.488, 14.346],
|
||||
[44.0, 14.0],
|
||||
],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Top, a: 1.0 }),
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.2, dash: [0.0, 0.0], round: false }),
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.5, dash: [0.0, 0.0], round: false }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[26.0, 56.0], [70.0, 56.0]],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.0, dash: [0.0, 0.0], round: false }),
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.3, dash: [0.0, 0.0], round: false }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[48.0, 14.0], [48.0, 56.0]],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.0, dash: [0.0, 0.0], round: false }),
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.3, dash: [0.0, 0.0], round: false }),
|
||||
},
|
||||
Op::Rect { r: [41.5, 22.5, 13.0, 23.0], radius: 6.5, fill: Some(P { ink: Ink::Ground, a: 1.0 }), line: None },
|
||||
Op::Rect { r: [43.0, 24.0, 10.0, 20.0], radius: 5.0, fill: Some(P { ink: Ink::Accent, a: 1.0 }), line: None },
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
@@ -2191,7 +2230,7 @@ pub(super) const MOUSE_MAPPING: Figure = Figure {
|
||||
},
|
||||
Op::Text { at: [36.0, 44.0], size: 8.0, anchor: 1, ink: Ink::Dim, a: 1.0, s: "L", bold: true },
|
||||
Op::Text { at: [60.0, 44.0], size: 8.0, anchor: 1, ink: Ink::Dim, a: 1.0, s: "R", bold: true },
|
||||
Op::Text { at: [48.0, 20.0], size: 7.0, anchor: 1, ink: Ink::Accent, a: 1.0, s: "M", bold: true },
|
||||
Op::Text { at: [48.0, 37.0], size: 7.0, anchor: 1, ink: Ink::Ground, a: 1.0, s: "M", bold: true },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -2287,83 +2326,131 @@ pub(super) const NAVIGATOR_CUBE: Figure = Figure {
|
||||
size: [120.0, 64.0],
|
||||
ops: &[
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
[82.2, 60.0],
|
||||
[81.773, 60.624],
|
||||
[80.51, 61.225],
|
||||
[78.459, 61.778],
|
||||
[75.698, 62.263],
|
||||
[72.334, 62.661],
|
||||
[68.496, 62.956],
|
||||
[64.331, 63.139],
|
||||
[60.0, 63.2],
|
||||
[55.669, 63.139],
|
||||
[51.504, 62.956],
|
||||
[47.666, 62.661],
|
||||
[44.302, 62.263],
|
||||
[41.541, 61.778],
|
||||
[39.49, 61.225],
|
||||
[38.227, 60.624],
|
||||
[37.8, 60.0],
|
||||
[38.227, 59.376],
|
||||
[39.49, 58.775],
|
||||
[41.541, 58.222],
|
||||
[44.302, 57.737],
|
||||
[47.666, 57.339],
|
||||
[51.504, 57.044],
|
||||
[55.669, 56.861],
|
||||
[60.0, 56.8],
|
||||
[64.331, 56.861],
|
||||
[68.496, 57.044],
|
||||
[72.334, 57.339],
|
||||
[75.698, 57.737],
|
||||
[78.459, 58.222],
|
||||
[80.51, 58.775],
|
||||
[81.773, 59.376],
|
||||
],
|
||||
pts: &[[60.0, 10.0], [79.053, 21.0], [60.0, 32.0], [40.947, 21.0]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Black, a: 0.12 }),
|
||||
fill: Some(P { ink: Ink::Top, a: 1.0 }),
|
||||
grad: None,
|
||||
line: None,
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[36.618, 18.5], [60.0, 32.0], [60.0, 59.0], [36.618, 45.5]],
|
||||
pts: &[[40.947, 21.0], [60.0, 32.0], [60.0, 54.0], [40.947, 43.0]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Left, a: 1.0 }),
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.8, dash: [0.0, 0.0], round: false }),
|
||||
line: None,
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[83.382, 18.5], [60.0, 32.0], [60.0, 59.0], [83.382, 45.5]],
|
||||
pts: &[[60.0, 32.0], [79.053, 21.0], [79.053, 43.0], [60.0, 54.0]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Right, a: 1.0 }),
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.8, dash: [0.0, 0.0], round: false }),
|
||||
line: None,
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[60.0, 5.0], [83.382, 18.5], [60.0, 32.0], [36.618, 18.5]],
|
||||
pts: &[[60.0, 10.0], [79.053, 21.0], [79.053, 43.0], [60.0, 54.0], [40.947, 43.0], [40.947, 21.0]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Top, a: 1.0 }),
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.8, dash: [0.0, 0.0], round: false }),
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.35, dash: [0.0, 0.0], round: true }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[60.0, 5.0], [83.382, 18.5], [60.0, 32.0], [36.618, 18.5]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Accent, a: 0.38 }),
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Accent, a: 1.0, w: 1.4, dash: [0.0, 0.0], round: false }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[60.0, 10.0], [75.4, 29.5]],
|
||||
pts: &[[40.947, 21.0], [60.0, 32.0], [79.053, 21.0]],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::White, a: 0.5, w: 1.0, dash: [0.0, 0.0], round: true }),
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.35, dash: [0.0, 0.0], round: true }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[60.0, 32.0], [60.0, 54.0]],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.35, dash: [0.0, 0.0], round: true }),
|
||||
},
|
||||
Op::Poly { pts: &[[60.0, 5.4], [57.5, 1.2], [62.5, 1.2]], closed: true, fill: Some(P { ink: Ink::Line, a: 1.0 }), grad: None, line: None },
|
||||
Op::Poly { pts: &[[60.0, 58.6], [62.5, 62.8], [57.5, 62.8]], closed: true, fill: Some(P { ink: Ink::Line, a: 1.0 }), grad: None, line: None },
|
||||
Op::Poly { pts: &[[35.4, 32.0], [31.2, 34.5], [31.2, 29.5]], closed: true, fill: Some(P { ink: Ink::Line, a: 1.0 }), grad: None, line: None },
|
||||
Op::Poly { pts: &[[84.6, 32.0], [88.8, 29.5], [88.8, 34.5]], closed: true, fill: Some(P { ink: Ink::Line, a: 1.0 }), grad: None, line: None },
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
[80.927, 8.977],
|
||||
[80.563, 8.68],
|
||||
[80.191, 8.393],
|
||||
[79.811, 8.117],
|
||||
[79.424, 7.851],
|
||||
[79.03, 7.596],
|
||||
[78.628, 7.352],
|
||||
[78.22, 7.119],
|
||||
[77.806, 6.898],
|
||||
[77.386, 6.688],
|
||||
[76.96, 6.49],
|
||||
[76.528, 6.304],
|
||||
[76.092, 6.129],
|
||||
[75.651, 5.967],
|
||||
[75.206, 5.817],
|
||||
[74.757, 5.679],
|
||||
[74.304, 5.554],
|
||||
[73.848, 5.441],
|
||||
[73.389, 5.341],
|
||||
[72.928, 5.254],
|
||||
[72.464, 5.179],
|
||||
[71.998, 5.118],
|
||||
[71.531, 5.069],
|
||||
[71.063, 5.033],
|
||||
[70.593, 5.01],
|
||||
],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.65, dash: [0.0, 0.0], round: true }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[69.094, 4.958], [72.662, 3.081], [72.522, 7.079]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Line, a: 1.0 }),
|
||||
grad: None,
|
||||
line: None,
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
[83.753, 12.008],
|
||||
[84.024, 12.391],
|
||||
[84.284, 12.783],
|
||||
[84.534, 13.181],
|
||||
[84.772, 13.586],
|
||||
[84.998, 13.997],
|
||||
[85.214, 14.415],
|
||||
[85.418, 14.838],
|
||||
[85.61, 15.267],
|
||||
[85.79, 15.701],
|
||||
[85.958, 16.139],
|
||||
[86.114, 16.582],
|
||||
[86.257, 17.03],
|
||||
[86.388, 17.481],
|
||||
[86.507, 17.935],
|
||||
[86.613, 18.393],
|
||||
[86.706, 18.853],
|
||||
[86.787, 19.316],
|
||||
[86.855, 19.781],
|
||||
[86.909, 20.248],
|
||||
[86.951, 20.715],
|
||||
[86.98, 21.184],
|
||||
[86.996, 21.654],
|
||||
[87.0, 22.124],
|
||||
[86.99, 22.593],
|
||||
],
|
||||
closed: false,
|
||||
fill: None,
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.65, dash: [0.0, 0.0], round: true }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[[86.937, 24.092], [85.061, 20.525], [89.058, 20.664]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Line, a: 1.0 }),
|
||||
grad: None,
|
||||
line: None,
|
||||
},
|
||||
Op::Text { at: [57.402, 20.0], size: 8.375, anchor: 1, ink: Ink::Text, a: 1.0, s: "TOP", bold: true },
|
||||
Op::Text { at: [48.309, 41.15], size: 6.8, anchor: 1, ink: Ink::Text, a: 1.0, s: "FRONT", bold: true },
|
||||
Op::Text { at: [71.691, 41.15], size: 6.8, anchor: 1, ink: Ink::Text, a: 1.0, s: "RIGHT", bold: true },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -2594,13 +2681,6 @@ pub(super) const ORBIT_ORIGIN: Figure = Figure {
|
||||
size: [120.0, 64.0],
|
||||
ops: &[
|
||||
Op::Rect { r: [0.0, 0.0, 120.0, 64.0], radius: 0.0, fill: Some(P { ink: Ink::Ground, a: 1.0 }), line: None },
|
||||
Op::Poly {
|
||||
pts: &[[60.0, 21.0], [94.0, 38.0], [60.0, 55.0], [26.0, 38.0]],
|
||||
closed: true,
|
||||
fill: Some(P { ink: Ink::Top, a: 0.35 }),
|
||||
grad: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 0.9, dash: [3.0, 3.0], round: false }),
|
||||
},
|
||||
Op::Poly {
|
||||
pts: &[
|
||||
[28.0, 38.0],
|
||||
@@ -4334,9 +4414,9 @@ pub(crate) fn paint_measure_axis_distances(p: &Painter, rect: Rect) {
|
||||
paint(p, rect, &MEASURE_AXIS_DISTANCES, None, None);
|
||||
}
|
||||
|
||||
/// The `mouse-mapping` figure of `docs/design/preferences/figures`.
|
||||
/// The mouse figure, with its own slightly heavier lettering.
|
||||
pub(crate) fn paint_mouse_mapping(p: &Painter, rect: Rect) {
|
||||
paint(p, rect, &MOUSE_MAPPING, None, None);
|
||||
super::preferences_figure_ops::paint_mouse(p, rect);
|
||||
}
|
||||
|
||||
/// The `navigator-axes` figure of `docs/design/preferences/figures`.
|
||||
|
||||
@@ -167,31 +167,58 @@ const MAX_POINTS: usize = 512;
|
||||
struct Ctx<'a> {
|
||||
t: &'a Tokens,
|
||||
sample: Option<&'a ThemeSample>,
|
||||
/// Only the Appearance samples interpret the legacy SVG colour roles semantically.
|
||||
colour_vision: Option<usize>,
|
||||
/// Scoped Figure, ColourVision and Navigator palettes interpret the canonical SVG colour roles.
|
||||
palette: Palette,
|
||||
origin: Pos2,
|
||||
scale: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum Palette {
|
||||
Figure,
|
||||
Mouse,
|
||||
ColourVision(usize),
|
||||
Navigator,
|
||||
}
|
||||
|
||||
impl Ctx<'_> {
|
||||
fn ink(&self, ink: Ink, a: f32) -> Color32 {
|
||||
let t = self.t;
|
||||
let semantic = match (self.colour_vision, ink) {
|
||||
(Some(0), Ink::Cv0) => Some(t.sketch_locked),
|
||||
(Some(1), Ink::Cv1) => Some(t.sketch_projected),
|
||||
(Some(2), Ink::Cv2 | Ink::AxisX) => Some(t.axis_x),
|
||||
(Some(2), Ink::Cv0 | Ink::AxisY) => Some(t.axis_y),
|
||||
(Some(2), Ink::AxisZ) => Some(t.axis_z),
|
||||
(Some(3), Ink::Cv1) => Some(t.bend_up),
|
||||
(Some(3), Ink::Cv3) => Some(t.bend_down),
|
||||
(Some(4), Ink::Cv3) => Some(crate::theme::srgb(t.analysis.draft[0])),
|
||||
(Some(4), Ink::Cv1) => Some(crate::theme::srgb(t.analysis.draft[1])),
|
||||
(Some(4), Ink::Cv4) => Some(crate::theme::srgb(t.analysis.draft[2])),
|
||||
(Some(4), Ink::Black) => Some(crate::theme::srgb(t.analysis.draft[2].map(|c| c * 0.6))),
|
||||
(Some(5), Ink::Cv2) => Some(t.error),
|
||||
(Some(5), Ink::NoteFill) => Some(t.timeline_item_error),
|
||||
let colour_vision = match self.palette {
|
||||
Palette::ColourVision(index) => Some(index),
|
||||
_ => None,
|
||||
};
|
||||
let semantic = if matches!(self.palette, Palette::Navigator) {
|
||||
match ink {
|
||||
Ink::Ground | Ink::Top => Some(t.cube_face),
|
||||
Ink::Left => Some(t.cube_face.lerp_to_gamma(t.cube_border, 0.12)),
|
||||
Ink::Right => Some(t.cube_face.lerp_to_gamma(t.cube_border, 0.24)),
|
||||
Ink::Line => Some(t.figure_line),
|
||||
Ink::Text => Some(t.cube_text),
|
||||
Ink::Accent => Some(t.cube_hover),
|
||||
Ink::AxisX => Some(t.axis_x),
|
||||
Ink::AxisY => Some(t.axis_y),
|
||||
Ink::AxisZ => Some(t.axis_z),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
match (colour_vision, ink) {
|
||||
(Some(0), Ink::Cv0) => Some(t.sketch_locked),
|
||||
(Some(1), Ink::Cv1) => Some(t.sketch_projected),
|
||||
(Some(2), Ink::Cv2 | Ink::AxisX) => Some(t.axis_x),
|
||||
(Some(2), Ink::Cv0 | Ink::AxisY) => Some(t.axis_y),
|
||||
(Some(2), Ink::AxisZ) => Some(t.axis_z),
|
||||
(Some(3), Ink::Cv1) => Some(t.bend_up),
|
||||
(Some(3), Ink::Cv3) => Some(t.bend_down),
|
||||
(Some(4), Ink::Cv3) => Some(crate::theme::srgb(t.analysis.draft[0])),
|
||||
(Some(4), Ink::Cv1) => Some(crate::theme::srgb(t.analysis.draft[1])),
|
||||
(Some(4), Ink::Cv4) => Some(crate::theme::srgb(t.analysis.draft[2])),
|
||||
(Some(4), Ink::Black) => Some(crate::theme::srgb(t.analysis.draft[2].map(|c| c * 0.6))),
|
||||
(Some(5), Ink::Cv2) => Some(t.error),
|
||||
(Some(5), Ink::NoteFill) => Some(t.timeline_item_error),
|
||||
_ => None,
|
||||
}
|
||||
};
|
||||
let c = semantic.unwrap_or_else(|| match ink {
|
||||
Ink::Ground => t.figure_ground,
|
||||
Ink::Line => t.figure_line,
|
||||
@@ -227,6 +254,32 @@ impl Ctx<'_> {
|
||||
if a >= 1.0 { c } else { c.gamma_multiply(a.clamp(0.0, 1.0)) }
|
||||
}
|
||||
|
||||
fn text_ink(&self, ink: Ink, a: f32, text: &str) -> Color32 {
|
||||
if matches!(self.palette, Palette::Navigator) {
|
||||
let t = self.t;
|
||||
let axis = match text.trim_start_matches('-') {
|
||||
"X" => Some(t.axis_x),
|
||||
"Y" => Some(t.axis_y),
|
||||
"Z" => Some(t.axis_z),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(axis) = axis {
|
||||
let ground = if matches!(ink, Ink::White) { axis } else { t.cube_face };
|
||||
let intended = if matches!(ink, Ink::White) { t.on_accent } else { axis };
|
||||
if crate::theme::contrast_ratio(intended, ground) >= 4.5 {
|
||||
return intended;
|
||||
}
|
||||
// Lettering has its own foreground role. Preserve the actual axis colour on
|
||||
// discs and strokes, choosing a legible token only for the tiny glyph.
|
||||
return [intended, t.cube_text, t.on_accent, t.tab_on_fill_dark]
|
||||
.into_iter()
|
||||
.max_by(|a, b| crate::theme::contrast_ratio(*a, ground).total_cmp(&crate::theme::contrast_ratio(*b, ground)))
|
||||
.unwrap_or(intended);
|
||||
}
|
||||
}
|
||||
self.ink(ink, a)
|
||||
}
|
||||
|
||||
fn at(&self, p: [f32; 2]) -> Pos2 {
|
||||
self.origin + vec2(p[0] * self.scale, p[1] * self.scale)
|
||||
}
|
||||
@@ -242,7 +295,7 @@ impl Ctx<'_> {
|
||||
|
||||
/// Paints `figure` into `rect`, scaled to fit and centred, with `Tokens::get()` colours.
|
||||
pub(super) fn paint(p: &Painter, rect: Rect, figure: &Figure, sample: Option<&ThemeSample>, clip: Option<&[[f32; 2]]>) {
|
||||
paint_with_tokens(p, rect, figure, sample, clip, &Tokens::get(), None);
|
||||
paint_with_tokens(p, rect, figure, sample, clip, &Tokens::get(), Palette::Figure);
|
||||
}
|
||||
|
||||
/// Reuse the six canonical figures with the semantic palette being previewed, without global state.
|
||||
@@ -257,7 +310,48 @@ pub(super) fn paint_colour_vision(p: &Painter, rect: Rect, index: usize, t: &Tok
|
||||
5 => &figures::COLOUR_VISION_FAILED,
|
||||
_ => return,
|
||||
};
|
||||
paint_with_tokens(p, rect, figure, None, None, t, Some(index));
|
||||
paint_with_tokens(p, rect, figure, None, None, t, Palette::ColourVision(index));
|
||||
}
|
||||
|
||||
/// Canonical navigator geometry with the real navigator palette; no global theme mutation.
|
||||
pub(crate) fn paint_navigation_axes(p: &Painter, rect: Rect) {
|
||||
let Some((p, scale)) = navigation_canvas(p, rect) else { return };
|
||||
let t = Tokens::get();
|
||||
let c = rect.center();
|
||||
p.circle(c, 46.0 * scale, t.overlay.gamma_multiply(0.35), Stroke::new(scale, t.border.gamma_multiply(0.75)));
|
||||
let cam = solidcraft_engine::render::Camera::default();
|
||||
let (right, up, back) = cam.basis();
|
||||
use solidcore_record::Vec3;
|
||||
use solidcraft_engine::geom::Vec3Geom;
|
||||
let mut tips: Vec<_> = [("x", Vec3::X), ("-x", -Vec3::X), ("y", Vec3::Y), ("-y", -Vec3::Y), ("z", Vec3::Z), ("-z", -Vec3::Z)]
|
||||
.into_iter()
|
||||
.map(|(name, d)| (name, d, c + vec2(d.dot(right) as f32, -d.dot(up) as f32) * (38.0 * 0.84 * scale), d.dot(back)))
|
||||
.collect();
|
||||
tips.sort_by(|a, b| a.3.total_cmp(&b.3));
|
||||
for (index, (name, direction, at, depth)) in tips.iter().enumerate() {
|
||||
if index == 3 {
|
||||
p.circle(c, 3.6 * scale, t.text.gamma_multiply(0.9), Stroke::new(1.4 * scale, t.panel));
|
||||
}
|
||||
crate::icons::navigation::axis_tip_scaled(&p, c, name, direction, *at, *depth, false, t, scale);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn paint_navigation_cube(p: &Painter, rect: Rect) {
|
||||
paint_with_tokens(p, rect, &super::preferences_figure_data::NAVIGATOR_CUBE, None, None, &Tokens::get(), Palette::Navigator);
|
||||
}
|
||||
|
||||
/// Preserve the mouse's figure palette, with slightly stronger lettering.
|
||||
pub(super) fn paint_mouse(p: &Painter, rect: Rect) {
|
||||
paint_with_tokens(p, rect, &super::preferences_figure_data::MOUSE_MAPPING, None, None, &Tokens::get(), Palette::Mouse);
|
||||
}
|
||||
|
||||
/// Match both cards' drawing scale and safely bound their painter.
|
||||
fn navigation_canvas(p: &Painter, rect: Rect) -> Option<(Painter, f32)> {
|
||||
let size = rect.size();
|
||||
if !rect.min.is_finite() || !size.is_finite() || size.min_elem() < 1.0 || size.max_elem() > MAX_SIDE {
|
||||
return None;
|
||||
}
|
||||
Some((p.with_clip_rect(rect.intersect(p.clip_rect())), (size.x / 172.5).min(size.y / 92.0)))
|
||||
}
|
||||
|
||||
fn paint_with_tokens(
|
||||
@@ -267,7 +361,7 @@ fn paint_with_tokens(
|
||||
sample: Option<&ThemeSample>,
|
||||
clip: Option<&[[f32; 2]]>,
|
||||
t: &Tokens,
|
||||
colour_vision: Option<usize>,
|
||||
palette: Palette,
|
||||
) {
|
||||
let size = rect.size();
|
||||
if !rect.min.is_finite() || !size.is_finite() || size.x < 1.0 || size.y < 1.0 || size.x > MAX_SIDE || size.y > MAX_SIDE {
|
||||
@@ -279,7 +373,7 @@ fn paint_with_tokens(
|
||||
}
|
||||
let scale = (size.x / fw).min(size.y / fh);
|
||||
let fitted = Rect::from_center_size(rect.center(), vec2(fw * scale, fh * scale));
|
||||
let ctx = Ctx { t, sample, colour_vision, origin: fitted.min, scale };
|
||||
let ctx = Ctx { t, sample, palette, origin: fitted.min, scale };
|
||||
let p = p.with_clip_rect(fitted.intersect(p.clip_rect()));
|
||||
let outer: Option<Vec<Pos2>> = clip.map(|c| c.iter().map(|&q| ctx.at(q)).collect());
|
||||
// Nested clips are inside one another in every figure, so the innermost one is the clip.
|
||||
@@ -291,6 +385,11 @@ fn paint_with_tokens(
|
||||
stack.pop();
|
||||
}
|
||||
Op::Clip(_) | Op::Unclip => {}
|
||||
Op::Rect { r, radius: 0.0, fill, line } if *r == [0.0, 0.0, fw, fh] => {
|
||||
// Shared card figures use concentric inner and outer corners.
|
||||
let radius = (f32::from(t.radius_lg) - t.space_4).max(0.0) / scale;
|
||||
draw(&p, &ctx, &Op::Rect { r: *r, radius, fill: *fill, line: *line }, outer.as_deref().or(stack.last().map(Vec::as_slice)));
|
||||
}
|
||||
_ => draw(&p, &ctx, op, outer.as_deref().or(stack.last().map(Vec::as_slice))),
|
||||
}
|
||||
}
|
||||
@@ -300,7 +399,7 @@ fn draw(p: &Painter, ctx: &Ctx, op: &Op, clip: Option<&[Pos2]>) {
|
||||
match op {
|
||||
Op::Rect { r, radius, fill, line } => {
|
||||
let rect = Rect::from_min_size(ctx.at([r[0], r[1]]), vec2(r[2] * ctx.scale, r[3] * ctx.scale));
|
||||
if clip.is_some() {
|
||||
if clip.is_some() || line.is_some_and(|l| l.dash[0] > 0.0 && l.dash[1] > 0.0) {
|
||||
let pts = rounded(rect, radius * ctx.scale);
|
||||
poly(p, ctx, &pts, true, fill, None, line, clip);
|
||||
return;
|
||||
@@ -381,7 +480,16 @@ fn draw(p: &Painter, ctx: &Ctx, op: &Op, clip: Option<&[Pos2]>) {
|
||||
};
|
||||
let size = (size * ctx.scale * grow).clamp(7.0, 256.0);
|
||||
let at = ctx.at(*at) - vec2(0.0, size * 0.36);
|
||||
p.text(at, align, s, FontId::monospace(size), ctx.ink(*ink, *a));
|
||||
let ink = ctx.text_ink(*ink, *a, s);
|
||||
let font = FontId::monospace(size);
|
||||
if matches!(ctx.palette, Palette::Mouse) {
|
||||
// A light optical emboldening preserves the original mono letterforms.
|
||||
let weight = 0.1 * ctx.scale;
|
||||
p.text(at - vec2(weight, 0.0), align, s, font.clone(), ink);
|
||||
p.text(at + vec2(weight, 0.0), align, s, font, ink);
|
||||
} else {
|
||||
p.text(at, align, s, font, ink);
|
||||
}
|
||||
}
|
||||
Op::Clip(_) | Op::Unclip => {}
|
||||
}
|
||||
@@ -639,6 +747,46 @@ fn clip_path(path: &[Pos2], clip: &[Pos2]) -> Vec<Vec<Pos2>> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn navigator_palette_preserves_axis_hues_and_uses_legible_lettering() {
|
||||
for t in [Tokens::light(), Tokens::dark()] {
|
||||
let ctx = Ctx { t: &t, sample: None, palette: Palette::Navigator, origin: Pos2::ZERO, scale: 1.0 };
|
||||
assert_eq!(ctx.ink(Ink::Ground, 1.0), t.cube_face);
|
||||
assert_eq!(ctx.ink(Ink::Line, 1.0), t.figure_line);
|
||||
assert_eq!(ctx.ink(Ink::Text, 1.0), t.cube_text);
|
||||
for (ink, axis, label) in [(Ink::AxisX, t.axis_x, "X"), (Ink::AxisY, t.axis_y, "Y"), (Ink::AxisZ, t.axis_z, "Z")] {
|
||||
assert_eq!(ctx.ink(ink, 1.0), axis, "the navigator's real axis palette");
|
||||
assert!(crate::theme::contrast_ratio(ctx.text_ink(Ink::White, 1.0, label), axis) >= 4.5);
|
||||
assert!(crate::theme::contrast_ratio(ctx.text_ink(ink, 1.0, label), t.cube_face) >= 4.5);
|
||||
}
|
||||
let ordinary = Ctx { palette: Palette::Figure, ..ctx };
|
||||
assert_eq!(ordinary.ink(Ink::AxisX, 1.0), t.figure_axis_x, "other illustrations keep their palette");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rounded_rectangle_preserves_its_authored_dashes() {
|
||||
let ctx = crate::fonts::test_context();
|
||||
let output = ctx.run_ui(egui::RawInput::default(), |ui| {
|
||||
let t = Tokens::light();
|
||||
let drawing = Ctx { t: &t, sample: None, palette: Palette::Figure, origin: pos2(10.0, 10.0), scale: 1.0 };
|
||||
draw(
|
||||
ui.painter(),
|
||||
&drawing,
|
||||
&Op::Rect {
|
||||
r: [0.0, 0.0, 104.0, 54.0],
|
||||
radius: 5.0,
|
||||
fill: None,
|
||||
line: Some(L { ink: Ink::Line, a: 1.0, w: 1.0, dash: [3.0, 3.0], round: false }),
|
||||
},
|
||||
None,
|
||||
);
|
||||
});
|
||||
// A dashed outline is separate path segments, never a solid rectangle stroke.
|
||||
assert!(output.shapes.len() > 4);
|
||||
assert!(output.shapes.iter().all(|shape| !matches!(shape.shape, Shape::Rect(_))));
|
||||
}
|
||||
|
||||
fn square() -> Vec<Pos2> {
|
||||
vec![pos2(0.0, 0.0), pos2(10.0, 0.0), pos2(10.0, 10.0), pos2(0.0, 10.0)]
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ fn radial_shadow(p: &Painter, centre: Pos2, radius: Vec2, ink: Color32) {
|
||||
|
||||
/// Orbit cards share a deliberately positioned model; only the pivot and its explanatory
|
||||
/// cue move. The arc's arrowhead is tangent to the projected ground-plane ellipse.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn paint_orbit(p: &Painter, rect: Rect, pivot: usize) {
|
||||
let t = Tokens::get();
|
||||
let c = Canvas { rect };
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//! Compact navigation preference compositions and explanatory figures.
|
||||
pub(crate) use super::preferences_figure_data::{paint_orbit_centre, paint_orbit_cursor, paint_orbit_origin};
|
||||
pub(crate) use super::preferences_figure_ops::{paint_navigation_axes, paint_navigation_cube};
|
||||
use super::{metrics::dimension, text::paint_text};
|
||||
use crate::theme::Tokens;
|
||||
use egui::{FontId, Rect, Sense, Stroke, Ui, pos2, vec2};
|
||||
@@ -6,77 +8,34 @@ use egui::{FontId, Rect, Sense, Stroke, Ui, pos2, vec2};
|
||||
/// One mouse silhouette beside the actual mapping selector and binding legend.
|
||||
/// The figure is descriptive content, not an icon asset or an application viewport.
|
||||
pub(crate) fn settings_mouse_mapping(ui: &mut Ui, bindings: &[(Vec<String>, String)], mapping: impl FnOnce(&mut Ui)) {
|
||||
let keys: Vec<Vec<&str>> = bindings.iter().map(|(keys, _)| keys.iter().map(String::as_str).collect()).collect();
|
||||
let rows: Vec<(&[&str], &str)> = bindings.iter().zip(&keys).map(|((_, action), keys)| (keys.as_slice(), action.as_str())).collect();
|
||||
if crate::prefs_search::suppress_chrome(ui) {
|
||||
mapping(ui);
|
||||
for (keys, action) in bindings.iter().take(10) {
|
||||
let chord = keys.join(" ");
|
||||
if crate::prefs_search::texts_hit(ui, &[action, &chord]) {
|
||||
crate::prefs_search::reveal(ui);
|
||||
settings_gesture(ui, keys, action);
|
||||
}
|
||||
}
|
||||
super::settings_bindings(ui, &rows);
|
||||
return;
|
||||
}
|
||||
let t = Tokens::get();
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = t.space_24 - t.space_2;
|
||||
let figure_size = vec2(t.form_label_width + t.space_24 + t.space_16, t.space_24 * 6.0 + t.space_16);
|
||||
let (figure, _) = ui.allocate_exact_size(figure_size, Sense::hover());
|
||||
let width = dimension(ui.available_width());
|
||||
let content = ui.allocate_ui_with_layout(vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
mapping(ui);
|
||||
ui.add_space(t.space_6);
|
||||
for (keys, action) in bindings.iter().take(10) {
|
||||
settings_gesture(ui, keys, action);
|
||||
}
|
||||
mapping(ui);
|
||||
ui.add_space(t.space_8);
|
||||
let available = dimension(ui.available_width());
|
||||
let figure_size = vec2(t.space_24 * 5.0, t.space_24 * 6.0);
|
||||
let gap = t.space_24 - t.space_2;
|
||||
let beside = available >= figure_size.x + gap + t.space_24 * 12.0;
|
||||
let content_width = if beside { available - figure_size.x - gap } else { available };
|
||||
ui.with_layout(egui::Layout::left_to_right(egui::Align::Min).with_main_wrap(true), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = gap;
|
||||
let (figure, _) = ui.allocate_exact_size(vec2(figure_size.x.min(available), figure_size.y), Sense::hover());
|
||||
let content = ui.allocate_ui_with_layout(vec2(content_width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
super::settings_bindings(ui, &rows);
|
||||
});
|
||||
let height = figure.height().max(content.response.rect.height());
|
||||
let figure = Rect::from_min_size(figure.min + vec2(0.0, (height - figure.height()) * 0.5), figure_size);
|
||||
let point = |x: f32, y: f32| figure.min + vec2(figure.width() * x / 110.0, figure.height() * y / 160.0);
|
||||
let mouse = Rect::from_min_max(point(12.0, 6.0), point(98.0, 154.0));
|
||||
let p = ui.painter();
|
||||
p.rect_filled(mouse, mouse.width() * 0.5, t.control_fill);
|
||||
let left = Rect::from_min_max(mouse.min, pos2(mouse.center().x, point(0.0, 68.0).y));
|
||||
p.with_clip_rect(left).rect_filled(mouse, mouse.width() * 0.5, t.selected_bg);
|
||||
let right = Rect::from_min_max(pos2(mouse.center().x, mouse.top()), pos2(mouse.right(), point(0.0, 68.0).y));
|
||||
p.with_clip_rect(right).rect_filled(mouse, mouse.width() * 0.5, t.warning.gamma_multiply(0.18));
|
||||
p.rect_stroke(mouse, mouse.width() * 0.5, Stroke::new(1.5, t.control_border), egui::StrokeKind::Inside);
|
||||
p.vline(mouse.center().x, mouse.top()..=point(0.0, 68.0).y, Stroke::new(1.2, t.control_border));
|
||||
p.hline(mouse.x_range(), point(0.0, 68.0).y, Stroke::new(1.2, t.control_border));
|
||||
p.rect_filled(Rect::from_min_max(point(48.0, 24.0), point(62.0, 54.0)), t.radius_lg, t.form_primary);
|
||||
let centre_y = if beside { content.response.rect.center().y } else { figure.center().y };
|
||||
let figure = Rect::from_center_size(pos2(figure.center().x, centre_y), figure.size());
|
||||
super::preferences_figure_ops::paint_mouse(&ui.painter_at(figure), figure);
|
||||
});
|
||||
}
|
||||
|
||||
/// Keyboard and pointer gestures use the same quiet keycap treatment as shortcuts.
|
||||
fn settings_gesture(ui: &mut Ui, keys: &[String], action: &str) {
|
||||
let t = Tokens::get();
|
||||
let width = dimension(ui.available_width());
|
||||
let (rect, response) = ui.allocate_exact_size(vec2(width, t.control_height + t.space_2), Sense::hover());
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{}: {action}", keys.join(" + "))));
|
||||
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
|
||||
let key_width = (t.form_label_width * 2.0 + t.space_24 + t.space_6).min(width * 0.57);
|
||||
let key_rect = Rect::from_min_size(rect.min, vec2(key_width, rect.height()));
|
||||
let p = ui.painter().with_clip_rect(key_rect);
|
||||
let mut x = key_rect.left();
|
||||
for (index, key) in keys.iter().enumerate() {
|
||||
if index > 0 {
|
||||
let join = Rect::from_min_size(pos2(x, rect.top()), vec2(t.space_12, rect.height()));
|
||||
paint_text(ui, join, "+", FontId::proportional(t.font_small), t.form_dim, true);
|
||||
x += t.space_12;
|
||||
}
|
||||
let galley = p.layout_no_wrap(key.to_owned(), FontId::proportional(t.font_small), t.form_ink);
|
||||
let cap = Rect::from_center_size(
|
||||
pos2(x + (galley.size().x + t.space_12) / 2.0, rect.center().y),
|
||||
vec2(galley.size().x + t.space_12, t.space_24 - t.space_2),
|
||||
);
|
||||
p.rect(cap, t.radius_sm, t.control_fill, t.container_border(t.control_border), egui::StrokeKind::Inside);
|
||||
p.galley(pos2(cap.center().x - galley.size().x / 2.0, cap.center().y - galley.size().y / 2.0), galley, t.form_ink);
|
||||
x = cap.right() + t.space_4;
|
||||
}
|
||||
let action_rect = Rect::from_min_max(pos2(key_rect.right() + t.space_8, rect.top()), rect.max);
|
||||
paint_text(ui, action_rect, action, FontId::proportional(t.font_label), t.form_ink, false);
|
||||
}
|
||||
|
||||
fn axis_columns(rect: Rect) -> [Rect; 5] {
|
||||
let t = Tokens::get();
|
||||
let gap = t.space_8;
|
||||
@@ -104,6 +63,14 @@ pub(crate) fn settings_axis_header(ui: &mut Ui) {
|
||||
}
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24), Sense::hover());
|
||||
if rect.width() < t.form_label_width * 5.0 + t.space_24 * 5.0 {
|
||||
let half = rect.width() * 0.5;
|
||||
for (index, label) in ["prefs.axis", "prefs.live_input"].into_iter().enumerate() {
|
||||
let cell = Rect::from_min_size(rect.min + vec2(half * index as f32, 0.0), vec2(half, rect.height()));
|
||||
paint_text(ui, cell, &crate::i18n::tr(label).to_uppercase(), crate::fonts::semibold(t.font_small), t.form_dim, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (column, label) in axis_columns(rect).into_iter().zip(["prefs.axis", "prefs.live_input", "", "prefs.speed", "prefs.source"]) {
|
||||
paint_text(ui, column, &crate::i18n::tr(label).to_uppercase(), crate::fonts::semibold(t.font_small), t.form_dim, false);
|
||||
}
|
||||
@@ -119,30 +86,47 @@ pub(crate) fn settings_axis_row(
|
||||
speed: impl FnOnce(&mut Ui),
|
||||
source: impl FnOnce(&mut Ui),
|
||||
) {
|
||||
if crate::prefs_search::querying(ui) && crate::prefs_search::suppress_chrome(ui) && !crate::prefs_search::texts_hit(ui, &[name]) {
|
||||
crate::prefs_search::run_hidden(ui, name, |ui| {
|
||||
invert(ui);
|
||||
speed(ui);
|
||||
source(ui);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if crate::prefs_search::querying(ui) {
|
||||
crate::prefs_search::reveal(ui);
|
||||
}
|
||||
let t = Tokens::get();
|
||||
let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.control_height + t.space_4), Sense::hover());
|
||||
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
|
||||
let [label_rect, live_rect, invert_rect, speed_rect, source_rect] = axis_columns(rect);
|
||||
paint_text(ui, label_rect, name, FontId::proportional(t.font_label), t.form_ink, false);
|
||||
ui.interact(label_rect, ui.id().with("axis_name"), Sense::hover()).on_hover_text(name);
|
||||
let live_rect = Rect::from_center_size(live_rect.center(), vec2(live_rect.width(), t.space_14));
|
||||
live_axis_bar_in(ui, live_rect, value, dead_zone);
|
||||
axis_control(ui, invert_rect, "invert", name, invert);
|
||||
axis_control(ui, speed_rect, "speed", name, speed);
|
||||
axis_control(ui, source_rect, "source", name, source);
|
||||
let narrow = ui.available_width() < t.form_label_width * 5.0 + t.space_24 * 5.0;
|
||||
let line = t.control_height + t.space_4;
|
||||
// A narrow row stacks the real controls instead of clipping its final source dropdown.
|
||||
let height = if narrow { line * 4.0 + t.space_8 * 3.0 } else { line };
|
||||
super::settings_form(ui, 0.0, |ui| {
|
||||
super::layout::sized_row(ui, name, height, |ui| {
|
||||
// The row already owns these bounds; its centered cursor is not the top edge.
|
||||
let rect = ui.max_rect();
|
||||
crate::scenario::publish_rect(&format!("prefs:axis:{name}"), rect);
|
||||
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
|
||||
if narrow {
|
||||
let label_rect = Rect::from_min_size(rect.min, vec2(rect.width() * 0.5, line));
|
||||
paint_text(ui, label_rect, name, FontId::proportional(t.font_label), t.form_ink, false);
|
||||
let live_rect = Rect::from_min_max(pos2(label_rect.right() + t.space_8, rect.center().y), pos2(rect.right(), rect.center().y));
|
||||
let live_rect =
|
||||
Rect::from_center_size(pos2(live_rect.center().x, label_rect.center().y), vec2(live_rect.width().max(0.0), t.space_14));
|
||||
live_axis_bar_in(ui, live_rect, value, dead_zone);
|
||||
let cell = |index: f32| Rect::from_min_size(pos2(rect.left(), rect.top() + (line + t.space_8) * index), vec2(rect.width(), line));
|
||||
axis_control(ui, cell(1.0), "invert", name, invert);
|
||||
let label_width = super::ContentWidth::label(ui, crate::i18n::tr("prefs.speed"))
|
||||
.max(super::ContentWidth::label(ui, crate::i18n::tr("prefs.source")));
|
||||
axis_control(ui, cell(2.0), "speed", name, |ui| {
|
||||
super::settings_form(ui, label_width, |ui| super::row(ui, crate::i18n::tr("prefs.speed"), speed));
|
||||
});
|
||||
axis_control(ui, cell(3.0), "source", name, |ui| {
|
||||
super::settings_form(ui, label_width, |ui| super::row(ui, crate::i18n::tr("prefs.source"), source));
|
||||
});
|
||||
} else {
|
||||
let [label_rect, live_rect, invert_rect, speed_rect, source_rect] = axis_columns(rect);
|
||||
paint_text(ui, label_rect, name, FontId::proportional(t.font_label), t.form_ink, false);
|
||||
ui.interact(label_rect, ui.id().with("axis_name"), Sense::hover()).on_hover_text(name);
|
||||
let live_rect = Rect::from_center_size(live_rect.center(), vec2(live_rect.width(), t.space_14));
|
||||
live_axis_bar_in(ui, live_rect, value, dead_zone);
|
||||
axis_control(ui, invert_rect, "invert", name, invert);
|
||||
axis_control(ui, speed_rect, "speed", name, speed);
|
||||
axis_control(ui, source_rect, "source", name, source);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn axis_control(ui: &mut Ui, rect: Rect, id: &str, label: &str, add: impl FnOnce(&mut Ui)) {
|
||||
ui.scope_builder(
|
||||
egui::UiBuilder::new()
|
||||
|
||||
@@ -312,32 +312,58 @@ pub(crate) fn settings_autosave_timeline(ui: &mut Ui, minutes: f64) {
|
||||
|
||||
/// A keyboard binding table: keycaps are separate from actions and never imply fixed bindings.
|
||||
pub(crate) fn settings_bindings(ui: &mut Ui, bindings: &[(&[&str], &str)]) {
|
||||
if crate::prefs_search::querying(ui) && !crate::prefs_search::shows_all(ui) {
|
||||
return;
|
||||
}
|
||||
let t = Tokens::get();
|
||||
let font = FontId::proportional(t.font_small);
|
||||
let key_width = bindings
|
||||
.iter()
|
||||
.map(|(keys, _)| {
|
||||
keys.iter()
|
||||
.map(|key| ui.painter().layout_no_wrap((*key).to_owned(), font.clone(), t.form_ink).size().x.ceil() + t.space_12 + t.space_4)
|
||||
.sum::<f32>()
|
||||
})
|
||||
.fold(t.space_24 * 8.0 + t.space_8, f32::max);
|
||||
for (keys, action) in bindings {
|
||||
let width = super::metrics::dimension(ui.available_width());
|
||||
let (r, _) = ui.allocate_exact_size(vec2(width, t.control_height + t.space_2), Sense::hover());
|
||||
t.secondary_hline(ui.painter(), r.x_range(), r.bottom(), t.dialog_rule);
|
||||
let mut left = r.left();
|
||||
for key in *keys {
|
||||
let galley = ui.painter().layout_no_wrap((*key).into(), FontId::proportional(t.font_small), t.form_ink);
|
||||
let key_rect = Rect::from_center_size(
|
||||
pos2(left + (galley.size().x + t.space_12) * 0.5, r.center().y),
|
||||
vec2(galley.size().x + t.space_12, t.control_height - t.space_8),
|
||||
);
|
||||
ui.painter().rect(key_rect, t.radius_sm, t.control_fill, t.container_border(t.control_border), egui::StrokeKind::Inside);
|
||||
ui.painter().galley(key_rect.center() - galley.size() * 0.5, galley, t.form_ink);
|
||||
left = key_rect.right() + t.space_4;
|
||||
if crate::prefs_search::querying(ui) && !crate::prefs_search::shows_all(ui) {
|
||||
if !crate::prefs_search::texts_hit(ui, &[action, &keys.join(" ")]) {
|
||||
continue;
|
||||
}
|
||||
crate::prefs_search::reveal(ui);
|
||||
}
|
||||
let text_rect = Rect::from_min_max(pos2(r.left() + (t.space_24 * 8.0 + t.space_8).min(width * 0.45) + t.space_10, r.top()), r.max);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(text_rect).layout(Layout::left_to_right(Align::Center)), |ui| {
|
||||
super::text(ui, action, super::Text::Inline);
|
||||
});
|
||||
let width = super::metrics::dimension(ui.available_width());
|
||||
let action_width = super::ContentWidth::label(ui, action);
|
||||
let beside = key_width + t.space_10 + action_width <= width;
|
||||
let limit = if beside { key_width } else { width };
|
||||
let cap_height = t.control_height - t.space_8;
|
||||
let mut caps = Vec::new();
|
||||
let (mut x, mut y) = (0.0, t.space_4);
|
||||
for key in *keys {
|
||||
let galley = ui.painter().layout_no_wrap((*key).to_owned(), font.clone(), t.form_ink);
|
||||
let cap_width = (galley.size().x.ceil() + t.space_12).min(limit);
|
||||
if x > 0.0 && x + cap_width > limit {
|
||||
x = 0.0;
|
||||
y += cap_height + t.space_4;
|
||||
}
|
||||
caps.push((*key, Rect::from_min_size(pos2(x, y), vec2(cap_width, cap_height))));
|
||||
x += cap_width + t.space_4;
|
||||
}
|
||||
let keys_bottom = y + cap_height + t.space_4;
|
||||
let action_left = if beside { key_width + t.space_10 } else { 0.0 };
|
||||
let action_top = if beside { 0.0 } else { keys_bottom };
|
||||
let action = ui.painter().layout((*action).to_owned(), FontId::proportional(t.font_label), t.form_ink, (width - action_left).max(0.0));
|
||||
let height = (action_top + action.size().y + t.space_4).max(keys_bottom).max(t.control_height + t.space_2);
|
||||
let (r, response) = ui.allocate_exact_size(vec2(width, height), Sense::hover());
|
||||
response
|
||||
.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{}: {}", keys.join(" + "), action.text())));
|
||||
t.secondary_hline(ui.painter(), r.x_range(), r.bottom(), t.dialog_rule);
|
||||
for (key, cap) in caps {
|
||||
let cap = cap.translate(r.min.to_vec2());
|
||||
ui.painter().rect(cap, t.radius_sm, t.control_fill, t.container_border(t.control_border), egui::StrokeKind::Inside);
|
||||
super::text::paint_text(ui, cap.shrink2(vec2(t.space_6.min(cap.width() / 2.0), 0.0)), key, font.clone(), t.form_ink, false);
|
||||
}
|
||||
let action_y = if beside { r.center().y - action.size().y / 2.0 } else { r.top() + action_top };
|
||||
ui.painter().with_clip_rect(r.intersect(ui.clip_rect())).galley(pos2(r.left() + action_left, action_y), action, t.form_ink);
|
||||
}
|
||||
}
|
||||
|
||||
/// Natural-width, dim monospaced numeric specimen beside a precision control.
|
||||
pub(crate) fn settings_precision_sample(ui: &mut Ui, text: &str) {
|
||||
let t = Tokens::get();
|
||||
|
||||
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 120" width="96" height="120"><rect width="96" height="120" fill="#1C1F26"/><rect x="26" y="14" width="44" height="86" rx="22" fill="#6B7790" stroke="#A3AEC2" stroke-width="1.2"/><path d="M26 56h44M48 14v42" stroke="#A3AEC2" stroke-width="1"/><rect x="43" y="24" width="10" height="20" rx="5" fill="#8CBEF5"/><path d="M26 56a22 22 0 0 1 0-12v-8a22 22 0 0 1 22-22v42z" fill="#8CBEF5" fill-opacity=".0"/><text x="36" y="44" font-size="8" font-weight="600" text-anchor="middle" fill="#B4BBC8" font-family="IBM Plex Mono, monospace">L</text><text x="60" y="44" font-size="8" font-weight="600" text-anchor="middle" fill="#B4BBC8" font-family="IBM Plex Mono, monospace">R</text><text x="48" y="20" font-size="7" font-weight="600" text-anchor="middle" fill="#8CBEF5" font-family="IBM Plex Mono, monospace">M</text></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 120" width="96" height="120"><rect width="96" height="120" fill="#1C1F26"/><path d="M44 14H52A18 18 0 0 1 70 32V78A22 22 0 0 1 26 78V32A18 18 0 0 1 44 14Z" fill="#6B7790" stroke="#A3AEC2" stroke-width="1.5"/><path d="M26 56h44M48 14v42" stroke="#A3AEC2" stroke-width="1.3"/><rect x="41.5" y="22.5" width="13" height="23" rx="6.5" fill="#1C1F26"/><rect x="43" y="24" width="10" height="20" rx="5" fill="#8CBEF5"/><path d="M26 56a22 22 0 0 1 0-12v-8a22 22 0 0 1 22-22v42z" fill="#8CBEF5" fill-opacity=".0"/><text x="36" y="44" font-size="8" font-weight="700" text-anchor="middle" fill="#B4BBC8" font-family="IBM Plex Mono, monospace">L</text><text x="60" y="44" font-size="8" font-weight="700" text-anchor="middle" fill="#B4BBC8" font-family="IBM Plex Mono, monospace">R</text><text x="48" y="37" font-size="7" font-weight="700" text-anchor="middle" fill="#1C1F26" font-family="IBM Plex Mono, monospace">M</text></svg>
|
||||
|
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 973 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 120" width="96" height="120"><rect width="96" height="120" fill="#F7F8FA"/><rect x="26" y="14" width="44" height="86" rx="22" fill="#FFFFFF" stroke="#6F7C8F" stroke-width="1.2"/><path d="M26 56h44M48 14v42" stroke="#6F7C8F" stroke-width="1"/><rect x="43" y="24" width="10" height="20" rx="5" fill="#236EAD"/><path d="M26 56a22 22 0 0 1 0-12v-8a22 22 0 0 1 22-22v42z" fill="#236EAD" fill-opacity=".0"/><text x="36" y="44" font-size="8" font-weight="600" text-anchor="middle" fill="#4A5868" font-family="IBM Plex Mono, monospace">L</text><text x="60" y="44" font-size="8" font-weight="600" text-anchor="middle" fill="#4A5868" font-family="IBM Plex Mono, monospace">R</text><text x="48" y="20" font-size="7" font-weight="600" text-anchor="middle" fill="#236EAD" font-family="IBM Plex Mono, monospace">M</text></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 120" width="96" height="120"><rect width="96" height="120" fill="#F7F8FA"/><path d="M44 14H52A18 18 0 0 1 70 32V78A22 22 0 0 1 26 78V32A18 18 0 0 1 44 14Z" fill="#FFFFFF" stroke="#6F7C8F" stroke-width="1.5"/><path d="M26 56h44M48 14v42" stroke="#6F7C8F" stroke-width="1.3"/><rect x="41.5" y="22.5" width="13" height="23" rx="6.5" fill="#F7F8FA"/><rect x="43" y="24" width="10" height="20" rx="5" fill="#236EAD"/><path d="M26 56a22 22 0 0 1 0-12v-8a22 22 0 0 1 22-22v42z" fill="#236EAD" fill-opacity=".0"/><text x="36" y="44" font-size="8" font-weight="700" text-anchor="middle" fill="#4A5868" font-family="IBM Plex Mono, monospace">L</text><text x="60" y="44" font-size="8" font-weight="700" text-anchor="middle" fill="#4A5868" font-family="IBM Plex Mono, monospace">R</text><text x="48" y="37" font-size="7" font-weight="700" text-anchor="middle" fill="#F7F8FA" font-family="IBM Plex Mono, monospace">M</text></svg>
|
||||
|
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 973 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><ellipse cx="60" cy="60" rx="22.2" ry="3.2" fill="#000" opacity="0.28"/><path d="M36.617999999999995 18.5l23.382 13.5v27l-23.382 -13.5z" fill="#515B72" stroke="#A3AEC2" stroke-width="1.8" stroke-linejoin="round"/><path d="M83.382 18.5l-23.382 13.5v27l23.382 -13.5z" fill="#394256" stroke="#A3AEC2" stroke-width="1.8" stroke-linejoin="round"/><path d="M60 5l23.382 13.5l-23.382 13.5l-23.382 -13.5z" fill="#6B7790" stroke="#A3AEC2" stroke-width="1.8" stroke-linejoin="round"/><path d="M60 5l23.382 13.5l-23.382 13.5l-23.382 -13.5z" fill="#8CBEF5" fill-opacity=".38" stroke="#8CBEF5" stroke-width="1.4" stroke-linejoin="round"/><path d="M60 10L75.4 29.5" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" opacity=".5" fill="none"/><g transform="matrix(0.866 0.5 -0.866 0.5 60 18.5)"><text x="0" y="3" font-size="9" font-weight="700" text-anchor="middle" fill="#DEE2E8" font-family="IBM Plex Mono, monospace">TOP</text></g><g transform="matrix(1 0.577 0 1 48.309 38.75)"><text x="0" y="2.4" font-size="6.8" font-weight="700" text-anchor="middle" fill="#DEE2E8" font-family="IBM Plex Mono, monospace">FRONT</text></g><g transform="matrix(1 -0.577 0 1 71.691 38.75)"><text x="0" y="2.4" font-size="6.8" font-weight="700" text-anchor="middle" fill="#DEE2E8" font-family="IBM Plex Mono, monospace">RIGHT</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><polygon points="60,10 79.053,21 60,32 40.947,21" fill="#6B7790"/><polygon points="40.947,21 60,32 60,54 40.947,43" fill="#515B72"/><polygon points="60,32 79.053,21 79.053,43 60,54" fill="#394256"/><path d="M60 10L79.053 21V43L60 54L40.947 43V21Z M40.947 21L60 32L79.053 21 M60 32V54" fill="none" stroke="#A3AEC2" stroke-width="1.35" stroke-linejoin="round" stroke-linecap="round"/><polygon points="60.000,5.400 57.500,1.200 62.500,1.200" fill="#A3AEC2"/><polygon points="60.000,58.600 62.500,62.800 57.500,62.800" fill="#A3AEC2"/><polygon points="35.400,32.000 31.200,34.500 31.200,29.500" fill="#A3AEC2"/><polygon points="84.600,32.000 88.800,29.500 88.800,34.500" fill="#A3AEC2"/><polyline points="80.927,8.977 80.563,8.680 80.191,8.393 79.811,8.117 79.424,7.851 79.030,7.596 78.628,7.352 78.220,7.119 77.806,6.898 77.386,6.688 76.960,6.490 76.528,6.304 76.092,6.129 75.651,5.967 75.206,5.817 74.757,5.679 74.304,5.554 73.848,5.441 73.389,5.341 72.928,5.254 72.464,5.179 71.998,5.118 71.531,5.069 71.063,5.033 70.593,5.010" fill="none" stroke="#A3AEC2" stroke-width="1.65" stroke-linecap="round"/><polygon points="69.094,4.958 72.662,3.081 72.522,7.079" fill="#A3AEC2"/><polyline points="83.753,12.008 84.024,12.391 84.284,12.783 84.534,13.181 84.772,13.586 84.998,13.997 85.214,14.415 85.418,14.838 85.610,15.267 85.790,15.701 85.958,16.139 86.114,16.582 86.257,17.030 86.388,17.481 86.507,17.935 86.613,18.393 86.706,18.853 86.787,19.316 86.855,19.781 86.909,20.248 86.951,20.715 86.980,21.184 86.996,21.654 87.000,22.124 86.990,22.593" fill="none" stroke="#A3AEC2" stroke-width="1.65" stroke-linecap="round"/><polygon points="86.937,24.092 85.061,20.525 89.058,20.664" fill="#A3AEC2"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><ellipse cx="60" cy="60" rx="22.2" ry="3.2" fill="#000" opacity="0.12"/><path d="M36.617999999999995 18.5l23.382 13.5v27l-23.382 -13.5z" fill="#E4E9F0" stroke="#6F7C8F" stroke-width="1.8" stroke-linejoin="round"/><path d="M83.382 18.5l-23.382 13.5v27l23.382 -13.5z" fill="#C9D2DE" stroke="#6F7C8F" stroke-width="1.8" stroke-linejoin="round"/><path d="M60 5l23.382 13.5l-23.382 13.5l-23.382 -13.5z" fill="#FFFFFF" stroke="#6F7C8F" stroke-width="1.8" stroke-linejoin="round"/><path d="M60 5l23.382 13.5l-23.382 13.5l-23.382 -13.5z" fill="#236EAD" fill-opacity=".38" stroke="#236EAD" stroke-width="1.4" stroke-linejoin="round"/><path d="M60 10L75.4 29.5" stroke="#FFFFFF" stroke-width="1" stroke-linecap="round" opacity=".5" fill="none"/><g transform="matrix(0.866 0.5 -0.866 0.5 60 18.5)"><text x="0" y="3" font-size="9" font-weight="700" text-anchor="middle" fill="#1B2430" font-family="IBM Plex Mono, monospace">TOP</text></g><g transform="matrix(1 0.577 0 1 48.309 38.75)"><text x="0" y="2.4" font-size="6.8" font-weight="700" text-anchor="middle" fill="#1B2430" font-family="IBM Plex Mono, monospace">FRONT</text></g><g transform="matrix(1 -0.577 0 1 71.691 38.75)"><text x="0" y="2.4" font-size="6.8" font-weight="700" text-anchor="middle" fill="#1B2430" font-family="IBM Plex Mono, monospace">RIGHT</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><polygon points="60,10 79.053,21 60,32 40.947,21" fill="#FFFFFF"/><polygon points="40.947,21 60,32 60,54 40.947,43" fill="#E4E9F0"/><polygon points="60,32 79.053,21 79.053,43 60,54" fill="#C9D2DE"/><path d="M60 10L79.053 21V43L60 54L40.947 43V21Z M40.947 21L60 32L79.053 21 M60 32V54" fill="none" stroke="#6F7C8F" stroke-width="1.35" stroke-linejoin="round" stroke-linecap="round"/><polygon points="60.000,5.400 57.500,1.200 62.500,1.200" fill="#6F7C8F"/><polygon points="60.000,58.600 62.500,62.800 57.500,62.800" fill="#6F7C8F"/><polygon points="35.400,32.000 31.200,34.500 31.200,29.500" fill="#6F7C8F"/><polygon points="84.600,32.000 88.800,29.500 88.800,34.500" fill="#6F7C8F"/><polyline points="80.927,8.977 80.563,8.680 80.191,8.393 79.811,8.117 79.424,7.851 79.030,7.596 78.628,7.352 78.220,7.119 77.806,6.898 77.386,6.688 76.960,6.490 76.528,6.304 76.092,6.129 75.651,5.967 75.206,5.817 74.757,5.679 74.304,5.554 73.848,5.441 73.389,5.341 72.928,5.254 72.464,5.179 71.998,5.118 71.531,5.069 71.063,5.033 70.593,5.010" fill="none" stroke="#6F7C8F" stroke-width="1.65" stroke-linecap="round"/><polygon points="69.094,4.958 72.662,3.081 72.522,7.079" fill="#6F7C8F"/><polyline points="83.753,12.008 84.024,12.391 84.284,12.783 84.534,13.181 84.772,13.586 84.998,13.997 85.214,14.415 85.418,14.838 85.610,15.267 85.790,15.701 85.958,16.139 86.114,16.582 86.257,17.030 86.388,17.481 86.507,17.935 86.613,18.393 86.706,18.853 86.787,19.316 86.855,19.781 86.909,20.248 86.951,20.715 86.980,21.184 86.996,21.654 87.000,22.124 86.990,22.593" fill="none" stroke="#6F7C8F" stroke-width="1.65" stroke-linecap="round"/><polygon points="86.937,24.092 85.061,20.525 89.058,20.664" fill="#6F7C8F"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><rect width="120" height="64" fill="#1C1F26"/><path d="M60 21L94 38L60 55L26 38Z" fill="#6B7790" fill-opacity=".35" stroke="#A3AEC2" stroke-width=".9" stroke-dasharray="3 3"/><path d="M28 38A32 9 0 0 1 92 38" fill="none" stroke="#8CBEF5" stroke-width="1.2" stroke-dasharray="3 3" opacity=".6"/><path d="M46.144 22.0l13.856 8.0v16l-13.856 -8.0z" fill="#515B72" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M73.856 22.0l-13.856 8.0v16l13.856 -8.0z" fill="#394256" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M60 14l13.856 8.0l-13.856 8.0l-13.856 -8.0z" fill="#6B7790" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M28 38A32 9 0 0 0 92 38" fill="none" stroke="#8CBEF5" stroke-width="2" stroke-linecap="round"/><path d="M92 32.5L88.6 38.8L95.4 38.8Z" fill="#8CBEF5"/><circle cx="60" cy="38" r="3.8" fill="#1C1F26" stroke="#E8C24A" stroke-width="1.5"/><circle cx="60" cy="38" r="1.4" fill="#E8C24A"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><rect width="120" height="64" fill="#1C1F26"/><path d="M28 38A32 9 0 0 1 92 38" fill="none" stroke="#8CBEF5" stroke-width="1.2" stroke-dasharray="3 3" opacity=".6"/><path d="M46.144 22.0l13.856 8.0v16l-13.856 -8.0z" fill="#515B72" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M73.856 22.0l-13.856 8.0v16l13.856 -8.0z" fill="#394256" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M60 14l13.856 8.0l-13.856 8.0l-13.856 -8.0z" fill="#6B7790" stroke="#A3AEC2" stroke-width="0.9" stroke-linejoin="round"/><path d="M28 38A32 9 0 0 0 92 38" fill="none" stroke="#8CBEF5" stroke-width="2" stroke-linecap="round"/><path d="M92 32.5L88.6 38.8L95.4 38.8Z" fill="#8CBEF5"/><circle cx="60" cy="38" r="3.8" fill="#1C1F26" stroke="#E8C24A" stroke-width="1.5"/><circle cx="60" cy="38" r="1.4" fill="#E8C24A"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 933 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><rect width="120" height="64" fill="#F7F8FA"/><path d="M60 21L94 38L60 55L26 38Z" fill="#FFFFFF" fill-opacity=".35" stroke="#6F7C8F" stroke-width=".9" stroke-dasharray="3 3"/><path d="M28 38A32 9 0 0 1 92 38" fill="none" stroke="#236EAD" stroke-width="1.2" stroke-dasharray="3 3" opacity=".6"/><path d="M46.144 22.0l13.856 8.0v16l-13.856 -8.0z" fill="#E4E9F0" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M73.856 22.0l-13.856 8.0v16l13.856 -8.0z" fill="#C9D2DE" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M60 14l13.856 8.0l-13.856 8.0l-13.856 -8.0z" fill="#FFFFFF" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M28 38A32 9 0 0 0 92 38" fill="none" stroke="#236EAD" stroke-width="2" stroke-linecap="round"/><path d="M92 32.5L88.6 38.8L95.4 38.8Z" fill="#236EAD"/><circle cx="60" cy="38" r="3.8" fill="#F7F8FA" stroke="#8A5300" stroke-width="1.5"/><circle cx="60" cy="38" r="1.4" fill="#8A5300"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 64" width="120" height="64"><rect width="120" height="64" fill="#F7F8FA"/><path d="M28 38A32 9 0 0 1 92 38" fill="none" stroke="#236EAD" stroke-width="1.2" stroke-dasharray="3 3" opacity=".6"/><path d="M46.144 22.0l13.856 8.0v16l-13.856 -8.0z" fill="#E4E9F0" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M73.856 22.0l-13.856 8.0v16l13.856 -8.0z" fill="#C9D2DE" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M60 14l13.856 8.0l-13.856 8.0l-13.856 -8.0z" fill="#FFFFFF" stroke="#6F7C8F" stroke-width="0.9" stroke-linejoin="round"/><path d="M28 38A32 9 0 0 0 92 38" fill="none" stroke="#236EAD" stroke-width="2" stroke-linecap="round"/><path d="M92 32.5L88.6 38.8L95.4 38.8Z" fill="#236EAD"/><circle cx="60" cy="38" r="3.8" fill="#F7F8FA" stroke="#8A5300" stroke-width="1.5"/><circle cx="60" cy="38" r="1.4" fill="#8A5300"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 933 B |
@@ -30,7 +30,7 @@ A table with the columns "Axis", "Live input", "Speed" and a "Reset axes" button
|
||||
| Row | Control | Edits | Default | Hover | Figure | Notes |
|
||||
|---|---|---|---|---|---|---|
|
||||
| Push X, Push Y, Push Z, Tilt X, Tilt Y, Tilt Z | Per row: a live bar with a dead-zone mark, an "Invert" checkbox, a speed readout ("1.00x"; Tilt Z shows 0.80x as a sample) | `Prefs.space_mouse_reverse[6]`, `Prefs.space_mouse_axis_speed[6]`, `Prefs.space_mouse_axis_source[6]` (`space_mouse::SAME_AXES`) | no inversion, 1.0, same axes | none | none | The live bars read the device; the dead zone is the device's calibration. `space_mouse_axis_source` (which physical axis feeds which row) has no control on the board. |
|
||||
| Reset axes | Button | resets the three arrays | n/a | none | none | |
|
||||
| Reset axis assignment | Button | resets `space_mouse_axis_source` to `SAME_AXES` only | n/a | none | none | Enabled only when the 3D mouse is on and an assignment differs. Leaves inversion and gains unchanged. The separate confirmed Restore defaults action keeps its broader scope. |
|
||||
|
||||
## Buttons
|
||||
|
||||
@@ -50,3 +50,4 @@ A table with the columns "Axis", "Live input", "Speed" and a "Reset axes" button
|
||||
|
||||
* `space_mouse_offer_never` and `space_mouse_offered` (the "offer to use the 3D mouse" memory) have no control.
|
||||
* The live bars and the dead zone are new drawing, not a setting.
|
||||
* The board omits the shipped per-row motion/source dropdowns. Keep them and their swap semantics; Reset axis assignment restores source assignments only.
|
||||
@@ -576,6 +576,9 @@ def main():
|
||||
parts.append('\n'.join(slot_table) + '\n')
|
||||
parts.append('use egui::{Painter, Rect};\nuse super::preferences_figure_ops::paint;\n')
|
||||
for n in names:
|
||||
if n == 'mouse-mapping':
|
||||
parts.append('/// The mouse figure, with its own slightly heavier lettering.\npub(crate) fn paint_mouse_mapping(p: &Painter, rect: Rect) {\n super::preferences_figure_ops::paint_mouse(p, rect);\n}\n')
|
||||
continue
|
||||
parts.append('/// The `%s` figure of `docs/design/preferences/figures`.\npub(crate) fn %s(p: &Painter, rect: Rect) {\n paint(p, rect, &%s, None, None);\n}\n' % (n, fn_name(n), const_name(n)))
|
||||
parts.append('/// Every figure painter by file name, for the gallery and the tests.\npub(crate) const FIGURES: &[(&str, [f32; 2], fn(&Painter, Rect))] = &[\n%s];\n' % ''.join(' ("%s", %s.size, %s),\n' % (n, const_name(n), fn_name(n)) for n in names))
|
||||
open(OUT, 'w', encoding='utf8', newline='\n').write('\n'.join(parts))
|
||||
|
||||