* claim: #8980 Hide constraint glyphs when zoomed out (claim). Co-authored-by: ReDead <ReDead@users.noreply.github.com> * Sketch: hide constraint glyphs when zoomed out (#8980) Fixed-size constraint glyphs stayed visible at every zoom and cluttered the view when far out. Hide them below a sketch-plane scale threshold, with the old always-on behaviour behind hide_constraint_glyphs_zoomed_out. Co-authored-by: ReDead <ReDead@users.noreply.github.com> * i18n: complete-catalog strings for zoom-hide preference (#8980) Add ar/he/vi translations for prefs.hide_constraint_glyphs_zoomed_out (and its note) so cargo xtask i18n --check no longer reports 6 gaps in complete catalogs. Co-authored-by: ReDead <ReDead@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: ReDead <ReDead@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"en": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "Hide constraint glyphs when zoomed out",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "Constraint glyphs leave the view when the sketch is zoomed out far enough that they would clutter it. Off: they stay at a fixed screen size at every zoom."
|
||||
},
|
||||
"ar": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "إخفاء رموز القيود عند التصغير",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "تختفي رموز القيود عندما تُصغَّر المسودة بما يكفي حتى لا تزحم العرض. معطّل: تبقى بحجم شاشة ثابت عند أي تكبير."
|
||||
},
|
||||
"de": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "Bindungssymbole bei starkem Herauszoomen ausblenden",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "Bindungssymbole verschwinden, wenn die Skizze so weit herausgezoomt ist, dass sie sie überladen würden. Aus: sie behalten bei jedem Zoom eine feste Bildschirmgröße."
|
||||
},
|
||||
"he": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "הסתרת סמלי אילוצים בהקטנה",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "סמלי האילוצים נעלמים כשהשרטוט מוקטן מספיק כדי שלא יעמיסו על התצוגה. כבוי: הם נשארים בגודל מסך קבוע בכל זום."
|
||||
},
|
||||
"ja": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "ズームアウト時に拘束グリフを隠す",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "スケッチを十分にズームアウトすると、拘束グリフは表示されず画面を散らかしません。オフ: ズームに関係なく固定の画面サイズのままです。"
|
||||
},
|
||||
"ko": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "축소 시 구속 조건 기호 숨기기",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "스케치를 충분히 축소하면 구속 조건 기호가 가려지지 않도록 숨깁니다. 끄기: 확대/축소와 관계없이 고정된 화면 크기를 유지합니다."
|
||||
},
|
||||
"vi": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "Ẩn biểu tượng ràng buộc khi thu nhỏ",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "Biểu tượng ràng buộc biến mất khi bản phác được thu nhỏ đủ xa để không làm rối khung nhìn. Tắt: chúng giữ kích thước màn hình cố định ở mọi mức thu phóng."
|
||||
},
|
||||
"zh": {
|
||||
"prefs.hide_constraint_glyphs_zoomed_out": "缩小时隐藏约束符号",
|
||||
"prefs.hide_constraint_glyphs_zoomed_out_note": "草图缩小到一定程度时隐藏约束符号,以免遮挡草图。关闭:任意缩放比例下符号仍保持固定屏幕大小。"
|
||||
}
|
||||
}
|
||||
@@ -1350,6 +1350,10 @@ preference_settings! {
|
||||
/// holds, and its glyph or dimension, are drawn in `sketch_conflict` (#7244). Off: only the
|
||||
/// glyphs and dimensions are red, in `error`, as before.
|
||||
sketch_conflict_colour: bool = true, PAGE_SKETCH => check_id("prefs.sketch_conflict_colour");
|
||||
/// Hide constraint glyphs when the sketch is zoomed out so far that a millimetre of the plane
|
||||
/// is smaller than `sketch_tools::MIN_GLYPH_PX_PER_MM` on screen (#8980). Off: glyphs stay at a
|
||||
/// fixed screen size at every zoom, as before.
|
||||
hide_constraint_glyphs_zoomed_out: bool = true, PAGE_SKETCH => check_id("prefs.hide_constraint_glyphs_zoomed_out");
|
||||
/// Drive Joints shows the moved parts' old place as a ghost (its Show ghost box, #5905).
|
||||
drive_joints_ghost: bool = true, PAGE_DESIGN;
|
||||
/// Plugin ids turned off (Preferences › Plugins). An installed plugin whose id is absent is on.
|
||||
@@ -5037,6 +5041,7 @@ mod tests {
|
||||
("selection_shift_add_only", json!(true), PAGE_SKETCH),
|
||||
("select_other_hidden", json!(false), PAGE_SKETCH),
|
||||
("sketch_conflict_colour", json!(false), PAGE_SKETCH),
|
||||
("hide_constraint_glyphs_zoomed_out", json!(false), PAGE_SKETCH),
|
||||
("suppress_sketch_snap", json!(ModifierCombo::NONE), PAGE_SKETCH),
|
||||
("sketch_state_icons", json!(false), PAGE_SKETCH),
|
||||
("sketch_tracking_guides", json!(false), PAGE_SKETCH),
|
||||
|
||||
@@ -76,6 +76,9 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
// Conflicting curves and points in the conflict colour (#7244).
|
||||
let check = setting::sketch_conflict_colour(app, ui).on_hover_text(app.tr("prefs.sketch_conflict_colour_note"));
|
||||
crate::scenario::publish_target("prefs:sketch_conflict_colour", check.rect);
|
||||
// Constraint glyphs hide when zoomed out (#8980).
|
||||
let check = setting::hide_constraint_glyphs_zoomed_out(app, ui).on_hover_text(app.tr("prefs.hide_constraint_glyphs_zoomed_out_note"));
|
||||
crate::scenario::publish_target("prefs:hide_constraint_glyphs_zoomed_out", check.rect);
|
||||
});
|
||||
ui_kit::settings_section(ui, "selection", app.tr("prefs.selecting"), |ui| {
|
||||
ui_kit::checkbox(ui, crate::i18n::tr_label("Click selects whole bodies"), &mut app.ui.pick_bodies);
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::cell::{Cell, RefCell};
|
||||
|
||||
use egui::{Pos2, Stroke};
|
||||
use serde_json::{Value, json};
|
||||
use solidcraft_engine::geom::{Vec2, Vec3};
|
||||
use solidcraft_engine::geom::{Plane, Vec2, Vec3};
|
||||
|
||||
use crate::SolveApp;
|
||||
use crate::tool_modifiers::{Audit, Binding, Match, ModAction, ModifierCombo, Scope, ToolModifiers, Trigger};
|
||||
@@ -1515,6 +1515,23 @@ pub fn preview(app: &SolveApp, t: &Tool, painter: &egui::Painter, proj: &Proj) {
|
||||
/// Glyph size and spacing (screen pixels).
|
||||
const GLYPH: f32 = 15.0;
|
||||
|
||||
/// Screen pixels per millimetre of the sketch plane below which constraint glyphs hide when the
|
||||
/// `hide_constraint_glyphs_zoomed_out` preference is on (#8980). About two pixels per millimetre:
|
||||
/// a 10 mm feature is then smaller than a glyph.
|
||||
pub const MIN_GLYPH_PX_PER_MM: f32 = 2.0;
|
||||
|
||||
/// Whether constraint glyphs should draw at this sketch-plane scale (#8980).
|
||||
pub fn constraint_glyphs_visible_at_scale(px_per_mm: f32, hide_when_zoomed_out: bool) -> bool {
|
||||
!hide_when_zoomed_out || px_per_mm >= MIN_GLYPH_PX_PER_MM
|
||||
}
|
||||
|
||||
/// Pixels on screen for one millimetre along the sketch plane's U axis, near the plane origin.
|
||||
fn sketch_px_per_mm(plane: &Plane, proj: &Proj) -> Option<f32> {
|
||||
let a = proj.to_screen(plane.to_world(Vec2::ZERO))?;
|
||||
let b = proj.to_screen(plane.to_world(Vec2::new(1.0, 0.0)))?;
|
||||
Some(a.distance(b))
|
||||
}
|
||||
|
||||
fn glyphs(app: &SolveApp, painter: &egui::Painter, proj: &Proj, hover: Option<Pos2>) {
|
||||
let Some(sid) = active_sketch(app) else { return };
|
||||
let st = app.session.world_state();
|
||||
@@ -1523,6 +1540,13 @@ fn glyphs(app: &SolveApp, painter: &egui::Painter, proj: &Proj, hover: Option<Po
|
||||
GLYPHS.with(|g| g.borrow_mut().clear());
|
||||
return;
|
||||
}
|
||||
// Zoomed out far enough: fixed-size glyphs would dominate the sketch (#8980).
|
||||
if let Some(scale) = sketch_px_per_mm(&ss.plane, proj)
|
||||
&& !constraint_glyphs_visible_at_scale(scale, app.preferences.hide_constraint_glyphs_zoomed_out)
|
||||
{
|
||||
GLYPHS.with(|g| g.borrow_mut().clear());
|
||||
return;
|
||||
}
|
||||
let tk = crate::theme::Tokens::get();
|
||||
let picked = PICKED.with(|p| p.borrow().clone());
|
||||
// Where each glyph goes: beside its entity (to its left, away from the line), every entity
|
||||
@@ -1779,6 +1803,29 @@ pub fn show(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter, proj: &P
|
||||
continuity_legend(app, painter, proj);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod glyph_zoom_tests {
|
||||
use super::{MIN_GLYPH_PX_PER_MM, constraint_glyphs_visible_at_scale};
|
||||
|
||||
#[test]
|
||||
fn glyphs_stay_visible_when_zoomed_in() {
|
||||
assert!(constraint_glyphs_visible_at_scale(MIN_GLYPH_PX_PER_MM, true));
|
||||
assert!(constraint_glyphs_visible_at_scale(10.0, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glyphs_hide_below_the_zoom_threshold() {
|
||||
assert!(!constraint_glyphs_visible_at_scale(MIN_GLYPH_PX_PER_MM - f32::EPSILON, true));
|
||||
assert!(!constraint_glyphs_visible_at_scale(0.5, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preference_off_keeps_glyphs_at_every_zoom() {
|
||||
assert!(constraint_glyphs_visible_at_scale(0.1, false));
|
||||
assert!(constraint_glyphs_visible_at_scale(MIN_GLYPH_PX_PER_MM - 1.0, false));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "sketch_corner_ui_tests.rs"]
|
||||
mod corner_ui_tests;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[
|
||||
{"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY"}}},
|
||||
{"call": "engine.execute", "params": {"command": "sketch.line", "params": {"points": [[0, 0], [0, 40]]}}},
|
||||
{"call": "engine.execute", "params": {"command": "sketch.constraint.horizontal_vertical", "params": {"line": "l1", "mode": "vertical"}}},
|
||||
{"call": "engine.execute", "params": {"command": "sketch.constraint.horizontal_vertical", "params": {"line": "l1", "mode": "vertical"}}},
|
||||
{"call": "ui.view", "params": {"view": "top"}},
|
||||
{"call": "ui.view", "params": {"view": "fit"}},
|
||||
{"expect": {"glyphs": {"k1": 1, "k2": 1}}},
|
||||
{"call": "ui.camera", "params": {"distance": 20000}},
|
||||
{"expect": {"glyphs": {"k1": 0, "k2": 0}}},
|
||||
{"call": "ui.prefs", "params": {"hide_constraint_glyphs_zoomed_out": false}},
|
||||
{"expect": {"glyphs": {"k1": 1, "k2": 1}}},
|
||||
{"call": "ui.prefs", "params": {"hide_constraint_glyphs_zoomed_out": true}},
|
||||
{"call": "ui.view", "params": {"view": "fit"}},
|
||||
{"expect": {"glyphs": {"k1": 1, "k2": 1}}}
|
||||
]
|
||||
Reference in New Issue
Block a user