Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions assets/locales/pending/hover-edge-width.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"en": {
"prefs.hover_edge_width": "Hover edge width"
},
"en-GB": {
"prefs.hover_edge_width": "Hover edge width"
},
"de": {
"prefs.hover_edge_width": "Breite der Kante unter dem Zeiger"
},
"ja": {
"prefs.hover_edge_width": "ポインター下のエッジの太さ"
},
"zh": {
"prefs.hover_edge_width": "指针下边线的宽度"
},
"ko": {
"prefs.hover_edge_width": "포인터 아래 모서리 두께"
},
"ar": {
"prefs.hover_edge_width": "عرض الحافة تحت المؤشر"
},
"he": {
"prefs.hover_edge_width": "עובי הקצה שמתחת לסמן"
},
"vi": {
"prefs.hover_edge_width": "Độ dày cạnh dưới con trỏ"
}
}
15 changes: 15 additions & 0 deletions crates/ui-egui/src/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,9 @@ pub const DIMENSION_STEP_DEG: std::ops::RangeInclusive<f64> = 0.001..=180.0;
/// How far a sketch dimension's text may be scaled (Preferences › Sketch › Dimension text size).
pub const DIMENSION_TEXT_SCALE: std::ops::RangeInclusive<f32> = 0.5..=2.5;

/// The widths Preferences › Appearance offers for the edge under the pointer, in points (#22042).
pub const HOVER_EDGE_WIDTH: std::ops::RangeInclusive<f32> = 1.0..=6.0;

/// How far the origin planes' squares may be scaled (Preferences › Design › Origin › Origin plane
/// size, #21191).
pub const ORIGIN_PLANE_SCALE: std::ops::RangeInclusive<f32> = 0.5..=4.0;
Expand Down Expand Up @@ -1499,6 +1502,12 @@ pub fn dimension_text_scale(p: &Prefs) -> f32 {
if accepted::dimension_text_scale(p) { p.dimension_text_scale } else { 1.0 }
}

/// How wide the edge under the pointer is drawn: the preference, or 2 when a saved value is
/// outside the accepted range (a hand edit).
pub fn hover_edge_width(p: &Prefs) -> f32 {
if accepted::hover_edge_width(p) { p.hover_edge_width } else { 2.0 }
}

/// The factor the origin planes' squares are drawn at, of the size they take on screen by default:
/// the preference, or 1 when a saved value is outside the accepted range (a hand edit).
pub fn origin_plane_scale(p: &Prefs) -> f64 {
Expand Down Expand Up @@ -4613,6 +4622,9 @@ pub fn migrate(mut p: Prefs) -> Prefs {
if !accepted::dimension_text_scale(&p) {
p.dimension_text_scale = Prefs::default().dimension_text_scale;
}
if !accepted::hover_edge_width(&p) {
p.hover_edge_width = Prefs::default().hover_edge_width;
}
if !accepted::forms_cad_tolerance(&p) {
p.forms_cad_tolerance = Prefs::default().forms_cad_tolerance;
}
Expand Down Expand Up @@ -4934,6 +4946,9 @@ fn prepare_preferences(
if !accepted::dimension_text_scale(&new) {
return Err("`dimension_text_scale` must be 0.5…2.5".into());
}
if !accepted::hover_edge_width(&new) {
return Err("`hover_edge_width` must be 1…6".into());
}
if !accepted::forms_cad_tolerance(&new) {
return Err("`forms_cad_tolerance` must be 0.000001…1 mm".into());
}
Expand Down
3 changes: 3 additions & 0 deletions crates/ui-egui/src/prefs/fields/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ macro_rules! appearance_preferences {
background_image: String = String::new(), PAGE_APPEARANCE;
/// Colour vision mode (#778): `off`, `protan`, `deutan` or `tritan`.
color_vision: solidcraft_theme::ColorVision = solidcraft_theme::ColorVision::Off, PAGE_APPEARANCE;
/// How wide the edge under the pointer is drawn, in points (#22042): 2, the default, as
/// before; up to 6 to make it easier to see.
hover_edge_width: f32 = 2.0, PAGE_APPEARANCE, accept(HOVER_EDGE_WIDTH) => slider("prefs.hover_edge_width", HOVER_EDGE_WIDTH, 0.5, |v| format!("{v:.1} pt"), "prefs:hover_edge_width");
/// The application bar's logo in the theme's accent instead of the theme's logo colours.
logo_accent: bool = false, PAGE_APPEARANCE;
/// `dark`, `light` or `system` (follow the operating system), or a theme file's id: a
Expand Down
5 changes: 4 additions & 1 deletion crates/ui-egui/src/prefs/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ impl AppearanceHost for SolveApp {
}

/// The 3D view's rows of the Appearance page, above the accent: the view in the theme's colours,
/// or the Light or Dark theme's (#4146), its background, a picture behind the model and the logo.
/// or the Light or Dark theme's (#4146), its background, a picture behind the model, the logo and
/// the width of the edge under the pointer.
fn viewport_rows(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
// The view's background: the theme's gradient, one colour of the user's (#7688), or a
Expand Down Expand Up @@ -253,6 +254,8 @@ fn viewport_rows(app: &mut SolveApp, ui: &mut egui::Ui) {
app.preferences.logo_accent = selected == 1;
}
});
// The width of the edge under the pointer (#22042): 2 pt as before, up to 6 for a thicker hover.
setting::hover_edge_width(app, ui);
}

/// Renders the Layout & Panels preferences page, configuring interface density, window layout, dock placement, and timeline display style.
Expand Down
44 changes: 42 additions & 2 deletions crates/ui-egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8416,6 +8416,8 @@ fn highlight_geometry_key_with(app: &SolveApp, model_key: u64, selected: &[Sel])
hover_drawn(&crate::snap_wake::lit_face(app)).hash(&mut h);
hovered_body(app).hash(&mut h);
app.preferences.show_selected_hidden_edges.hash(&mut h);
// The edge under the pointer is drawn at the width Preferences › Appearance sets (#22042).
crate::prefs::hover_edge_width(&app.preferences).to_bits().hash(&mut h);
app.viewport.hover_feature.hash(&mut h);
app.viewport.hover_bodies.hash(&mut h);
crate::select_other::hovered_body(app).hash(&mut h);
Expand Down Expand Up @@ -9922,8 +9924,13 @@ fn build_highlight_with_projection(app: &SolveApp, projection: impl FnOnce() ->
}
Some(Hit::Edge { body, index, mid, .. }) if !moving(body) => {
if let Some(b) = st.body(body).filter(|_| app.display_opacity(body) > 0.0) {
// Lit over the drawn edges (finer away from Normal display quality).
let (lit, w) = if lights_hovered_edge(app) { (lit_edge_colours(&mut feedback, &t), LIT_EDGE_W) } else { (hover_edge, 2.0) };
// Lit over the drawn edges (finer away from Normal display quality). The edge under
// the pointer is drawn at the width Preferences › Appearance sets (#22042).
let (lit, w) = if lights_hovered_edge(app) {
(lit_edge_colours(&mut feedback, &t), LIT_EDGE_W)
} else {
(hover_edge, crate::prefs::hover_edge_width(&app.preferences))
};
let m = drawn(b);
// Measure measures the piece picked of an edge a seam splits: light that piece.
let pieces = if measuring_mesh_edges(app) { m.circular_rim(*index) } else { edge_pieces(b, &m, *index) };
Expand Down Expand Up @@ -21800,6 +21807,39 @@ mod tests {
assert!(!has(&app, t.hover_edge_lit), "off: the face lights up as before");
}

/// The edge under the pointer is drawn at the width Preferences › Appearance sets (#22042):
/// 2 points by default, as before; a wider setting widens the same lines, and a hand edit
/// outside 1…6 draws as by default.
#[test]
fn the_hovered_edge_is_drawn_at_the_width_preferences_set() {
let mut app = cylinder_app();
let st = app.session.world_state().unwrap();
let b = &st.bodies[0];
let m = b.mesh();
let top = m.edges.iter().position(|e| e.len() > 3 && e.iter().all(|p| (p.z - 20.0).abs() < 1e-6)).unwrap();
let mid = polyline_mid(&m.edges[top]);
app.viewport.hover = Some(Hit::Edge { body: b.name.clone(), index: top, mid, point: mid });
assert_eq!(app.preferences.hover_edge_width, 2.0, "the default");
let scene = build_highlight(&app);
assert!(scene.palette.entries().contains(&c4(Tokens::get().hover_edge)), "in the theme's hover colour");
// A line's width word: an `f32`, or a lifted line's eighths of a pixel under its top bit.
let width = |word: u32| if word & 0x8000_0000 == 0 { f32::from_bits(word) } else { ((word >> 24) & 0x7F) as f32 / 8.0 };
let widths = |a: &SolveApp| {
let merged = build_highlight(a).merged();
[&merged.lines, &merged.overlay]
.into_iter()
.flat_map(|bytes| bytes.as_chunks::<{ crate::gpu::LINE_SIZE }>().0)
.map(|line| width(u32::from_le_bytes([line[28], line[29], line[30], line[31]])))
.collect::<Vec<f32>>()
};
let default = widths(&app);
assert!(default.contains(&2.0), "drawn 2 pt wide by default: {default:?}");
app.preferences.hover_edge_width = 5.0;
assert!(widths(&app).contains(&5.0), "drawn at the width set");
app.preferences.hover_edge_width = f32::NAN;
assert_eq!(widths(&app), default, "a width outside 1…6 (a hand edit) draws as by default");
}

/// With nothing running, the faces of the feature that made the face under the pointer are
/// outlined in `hover_feature_edge` (#10912): a fillet's own faces, not the cylinder's. Off by
/// default, and with a command running only the face lights up, as before.
Expand Down
Loading