A two-sided offset drew only the Distance dimension. Distance 2 now gets its own value box and arrow, the other way from Distance.
This commit is contained in:
committed by
GitHub
parent
f11ad0ce28
commit
0e9e175e79
@@ -552,6 +552,29 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
|
||||
if radius_spline_handles(app, ui, painter, proj, d) {
|
||||
dir = None;
|
||||
}
|
||||
// Two-sided sketch offset: Distance 2 is its own dimension, the other way from Distance.
|
||||
// One Side and Symmetric keep the single Distance box.
|
||||
if let Kind::SketchModify(crate::sketch_modify_ui::Mod::Offset { distance2, mode, .. }) = &mut d.kind
|
||||
&& crate::sketch_modify_ui::offset_two_sides(*mode)
|
||||
&& let Some(n) = dir
|
||||
&& let Some(l2) = app.session.doc.eval(distance2, ValueKind::Length).ok().filter(|v| v.is_finite())
|
||||
{
|
||||
let before = distance2.clone();
|
||||
if let Some(ts) =
|
||||
drag_arrow(ui, painter, proj, base, bs, -n, l2.abs(), false, egui::Id::new("sc_manipulator_offset2"), half_height, distance2)
|
||||
{
|
||||
// Its own area and field, so it does not share Distance's focus or text.
|
||||
value_box_in(
|
||||
ui,
|
||||
(egui::Id::new("sc_canvas_area2"), egui::Id::new("sc_canvas_value2")),
|
||||
"Distance 2",
|
||||
distance2,
|
||||
(ts + vec2(14.0, 8.0), egui::Align2::LEFT_TOP),
|
||||
*distance2 != before,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
let Some((label, kind, value)) = d.primary() else { return };
|
||||
let len = all_span.or_else(|| {
|
||||
if to_span.is_some() && value.trim().is_empty() { Some(0.0) } else { app.session.doc.eval(value, kind).ok().filter(|v| v.is_finite()) }
|
||||
|
||||
@@ -78,6 +78,11 @@ pub(crate) fn offset_symmetric(mode: usize) -> bool {
|
||||
mode == SYMMETRIC
|
||||
}
|
||||
|
||||
/// Whether an offset mode index is Two Sides (Distance and an independent Distance 2).
|
||||
pub(crate) fn offset_two_sides(mode: usize) -> bool {
|
||||
mode == TWO_SIDES
|
||||
}
|
||||
|
||||
/// A sketch modify tool window's values.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Mod {
|
||||
|
||||
@@ -467,6 +467,27 @@ fn rect(h: &mut crate::scenario::Harness, count: &str, spacing: &str, count2: &s
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_sided_offset_shows_a_dimension_for_each_distance() {
|
||||
let (mut h, id) = open("sketch.offset");
|
||||
{
|
||||
let d = h.app.dialog.as_mut().unwrap();
|
||||
d.inputs[0].items = vec![Sel::SketchCurve { id }];
|
||||
}
|
||||
h.frames(2);
|
||||
assert!(crate::scenario::handle_at("arrow").is_some(), "Distance has its dimension");
|
||||
assert!(crate::scenario::handle_at("arrow2").is_none(), "one side draws a single dimension");
|
||||
if let Kind::SketchModify(Mod::Offset { distance, distance2, mode, .. }) = &mut h.app.dialog.as_mut().unwrap().kind {
|
||||
*mode = 1;
|
||||
*distance = "9 mm".into();
|
||||
*distance2 = "2 mm".into();
|
||||
}
|
||||
h.frames(2);
|
||||
let first = crate::scenario::handle_at("arrow").expect("Distance stays on the sketch");
|
||||
let second = crate::scenario::handle_at("arrow2").expect("Distance 2 gets its own dimension");
|
||||
assert!(first.distance(second) > 20.0, "the two dimensions sit on opposite sides: {first:?} {second:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rectangular_pattern_window_opens_instead_of_a_click_tool() {
|
||||
let (h, _) = open("sketch.pattern.rectangular");
|
||||
|
||||
Reference in New Issue
Block a user