Skip to content

Commit a1dc955

Browse files
Improve quick measurement overlays across all possible arrangement scenarios (#2147)
* setup single edge crossing handling for quick measure tool * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. * setup single edge crossing handling for quick measure tool * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. Add a dashed_line_with_pattern function that gives more granular control over dash_width and gap_width. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. Add a dashed_line_with_pattern function that gives more granular control over dash_width and gap_width. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. Add a dashed_line_with_pattern function that gives more granular control over dash_width and gap_width. * Setup quick measure functionality for intersecting objects and handle centerline cases for non intersecting objects. Add a dashed_line_with_pattern function that gives more granular control over dash_width and gap_width. * Nit picks * Define wrapper for Overlay_context line method * Comments and consolidating lines of code --------- Co-authored-by: Keavon Chambers <[email protected]>
1 parent bc47d06 commit a1dc955

File tree

3 files changed

+412
-30
lines changed

3 files changed

+412
-30
lines changed

editor/src/messages/portfolio/document/overlays/grid_overlays.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ fn grid_overlay_isometric_dot(document: &DocumentMessageHandler, overlay_context
184184
document_to_viewport.transform_point2(end),
185185
Some(&("#".to_string() + &grid_color.rgba_hex())),
186186
Some((spacing_x / cos_a) * document_to_viewport.matrix2.x_axis.length()),
187+
None,
187188
);
188189
}
189190
}

editor/src/messages/portfolio/document/overlays/utility_types.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ impl OverlayContext {
4646
}
4747

4848
pub fn line(&mut self, start: DVec2, end: DVec2, color: Option<&str>) {
49-
self.dashed_line(start, end, color, None)
49+
self.dashed_line(start, end, color, None, None)
5050
}
5151

52-
pub fn dashed_line(&mut self, start: DVec2, end: DVec2, color: Option<&str>, dash_width: Option<f64>) {
52+
pub fn dashed_line(&mut self, start: DVec2, end: DVec2, color: Option<&str>, dash_width: Option<f64>, gap_width: Option<f64>) {
5353
let start = start.round() - DVec2::splat(0.5);
5454
let end = end.round() - DVec2::splat(0.5);
5555
if let Some(dash_width) = dash_width {
56+
let gap_width = gap_width.unwrap_or(1.);
5657
let array = js_sys::Array::new();
57-
array.push(&JsValue::from(1));
5858
array.push(&JsValue::from(dash_width - 1.));
59+
array.push(&JsValue::from(gap_width));
5960
self.render_context
6061
.set_line_dash(&JsValue::from(array))
6162
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
@@ -72,6 +73,12 @@ impl OverlayContext {
7273
self.render_context.line_to(end.x, end.y);
7374
self.render_context.set_stroke_style_str(color.unwrap_or(COLOR_OVERLAY_BLUE));
7475
self.render_context.stroke();
76+
77+
// Reset the dash pattern to solid after drawing
78+
self.render_context
79+
.set_line_dash(&JsValue::from(js_sys::Array::new()))
80+
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
81+
.ok();
7582
}
7683

7784
pub fn manipulator_handle(&mut self, position: DVec2, selected: bool) {

0 commit comments

Comments
 (0)