mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 16:58:11 +08:00
Improve layer panel positioning for upstream nodes (#1928)
* Improve layer panel positioning for upstream nodes * highlight parents * Final improvements * Fill for selection box, bug fixes * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
da13f21486
commit
2bd213f1aa
@@ -38,10 +38,10 @@ fn grid_overlay_rectangular(document: &DocumentMessageHandler, overlay_context:
|
||||
} else {
|
||||
DVec2::new(secondary_pos, primary_end)
|
||||
};
|
||||
overlay_context.colored_line(
|
||||
overlay_context.line(
|
||||
document_to_viewport.transform_point2(start),
|
||||
document_to_viewport.transform_point2(end),
|
||||
&("#".to_string() + &grid_color.rgba_hex()),
|
||||
Some(&("#".to_string() + &grid_color.rgba_hex())),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -114,10 +114,10 @@ fn grid_overlay_isometric(document: &DocumentMessageHandler, overlay_context: &m
|
||||
let x_pos = (((min_x - origin.x) / spacing).ceil() + line_index as f64) * spacing + origin.x;
|
||||
let start = DVec2::new(x_pos, min_y);
|
||||
let end = DVec2::new(x_pos, max_y);
|
||||
overlay_context.colored_line(
|
||||
overlay_context.line(
|
||||
document_to_viewport.transform_point2(start),
|
||||
document_to_viewport.transform_point2(end),
|
||||
&("#".to_string() + &grid_color.rgba_hex()),
|
||||
Some(&("#".to_string() + &grid_color.rgba_hex())),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,10 +132,10 @@ fn grid_overlay_isometric(document: &DocumentMessageHandler, overlay_context: &m
|
||||
let y_pos = (((inverse_project(&min_y) - origin.y) / spacing).ceil() + line_index as f64) * spacing + origin.y;
|
||||
let start = DVec2::new(min_x, project(&DVec2::new(min_x, y_pos)));
|
||||
let end = DVec2::new(max_x, project(&DVec2::new(max_x, y_pos)));
|
||||
overlay_context.colored_line(
|
||||
overlay_context.line(
|
||||
document_to_viewport.transform_point2(start),
|
||||
document_to_viewport.transform_point2(end),
|
||||
&("#".to_string() + &grid_color.rgba_hex()),
|
||||
Some(&("#".to_string() + &grid_color.rgba_hex())),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,17 @@ pub fn path_overlays(document: &DocumentMessageHandler, shape_editor: &mut Shape
|
||||
let not_under_anchor = |position: DVec2, anchor: DVec2| position.distance_squared(anchor) >= HIDE_HANDLE_DISTANCE * HIDE_HANDLE_DISTANCE;
|
||||
match bezier.handles {
|
||||
bezier_rs::BezierHandles::Quadratic { handle } if not_under_anchor(handle, bezier.start) && not_under_anchor(handle, bezier.end) => {
|
||||
overlay_context.line(handle, bezier.start);
|
||||
overlay_context.line(handle, bezier.end);
|
||||
overlay_context.line(handle, bezier.start, None);
|
||||
overlay_context.line(handle, bezier.end, None);
|
||||
overlay_context.manipulator_handle(handle, is_selected(selected, ManipulatorPointId::PrimaryHandle(segment_id)));
|
||||
}
|
||||
bezier_rs::BezierHandles::Cubic { handle_start, handle_end } => {
|
||||
if not_under_anchor(handle_start, bezier.start) {
|
||||
overlay_context.line(handle_start, bezier.start);
|
||||
overlay_context.line(handle_start, bezier.start, None);
|
||||
overlay_context.manipulator_handle(handle_start, is_selected(selected, ManipulatorPointId::PrimaryHandle(segment_id)));
|
||||
}
|
||||
if not_under_anchor(handle_end, bezier.end) {
|
||||
overlay_context.line(handle_end, bezier.end);
|
||||
overlay_context.line(handle_end, bezier.end, None);
|
||||
overlay_context.manipulator_handle(handle_end, is_selected(selected, ManipulatorPointId::EndHandle(segment_id)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,22 +31,22 @@ impl core::hash::Hash for OverlayContext {
|
||||
}
|
||||
|
||||
impl OverlayContext {
|
||||
pub fn quad(&mut self, quad: Quad) {
|
||||
pub fn quad(&mut self, quad: Quad, color_fill: Option<&str>) {
|
||||
self.render_context.begin_path();
|
||||
self.render_context.move_to(quad.0[3].x.round() - 0.5, quad.0[3].y.round() - 0.5);
|
||||
for i in 0..4 {
|
||||
self.render_context.line_to(quad.0[i].x.round() - 0.5, quad.0[i].y.round() - 0.5);
|
||||
}
|
||||
if let Some(color_fill) = color_fill {
|
||||
self.render_context.set_fill_style(&wasm_bindgen::JsValue::from_str(color_fill));
|
||||
self.render_context.fill();
|
||||
}
|
||||
self.render_context.set_stroke_style(&wasm_bindgen::JsValue::from_str(COLOR_OVERLAY_BLUE));
|
||||
self.render_context.stroke();
|
||||
}
|
||||
|
||||
pub fn line(&mut self, start: DVec2, end: DVec2) {
|
||||
self.dashed_line(start, end, None, None)
|
||||
}
|
||||
|
||||
pub fn colored_line(&mut self, start: DVec2, end: DVec2, color: &str) {
|
||||
self.dashed_line(start, end, Some(color), None)
|
||||
pub fn line(&mut self, start: DVec2, end: DVec2, color: Option<&str>) {
|
||||
self.dashed_line(start, end, color, None)
|
||||
}
|
||||
|
||||
pub fn dashed_line(&mut self, start: DVec2, end: DVec2, color: Option<&str>, dash_width: Option<f64>) {
|
||||
|
||||
Reference in New Issue
Block a user