From c6062e2666689c826b92edfd3bda268e861524ab Mon Sep 17 00:00:00 2001 From: starlord Date: Wed, 8 Nov 2023 01:23:01 +0400 Subject: [PATCH] fixed selected edges drawing --- src/draw/edge.rs | 36 +++++++++++++++++++++++++++--------- src/elements/edge.rs | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/draw/edge.rs b/src/draw/edge.rs index 489546c..c61a68c 100644 --- a/src/draw/edge.rs +++ b/src/draw/edge.rs @@ -75,15 +75,23 @@ fn draw_edge_basic( tip_end - e.tip_size() * state.meta.zoom * rotate_vector(dir, -e.tip_angle()); let shape = Shape::line_segment([edge_start, edge_end], stroke_edge); - l.add(shape); + match e.selected() { + true => l.add_top(shape), + false => l.add(shape), + } - // draw tips for directed edges - if state.g.is_directed() { - let shape_tip = - Shape::convex_polygon(vec![tip_end, tip_start_1, tip_start_2], color, stroke_tip); - l.add(shape_tip); + if !state.g.is_directed() { + return; } + // draw tips for directed edges + let shape_tip = + Shape::convex_polygon(vec![tip_end, tip_start_1, tip_start_2], color, stroke_tip); + match e.selected() { + true => l.add_top(shape_tip), + false => l.add(shape_tip), + }; + return; } @@ -113,11 +121,18 @@ fn draw_edge_basic( Color32::TRANSPARENT, stroke_edge, ); - l.add(shape_curved); + + match e.selected() { + true => l.add_top(shape_curved), + false => l.add(shape_curved), + } let shape_tip_curved = Shape::convex_polygon(vec![tip_end, tip_start_1, tip_start_2], color, stroke_tip); - l.add(shape_tip_curved); + match e.selected() { + true => l.add_top(shape_tip_curved), + false => l.add(shape_tip_curved), + }; } fn draw_edge_looped( @@ -149,7 +164,10 @@ fn draw_edge_looped( stroke, ); - l.add(shape); + match e.selected() { + true => l.add_top(shape), + false => l.add(shape), + } } /// rotates vector by angle diff --git a/src/elements/edge.rs b/src/elements/edge.rs index a3fdfe3..bd57971 100644 --- a/src/elements/edge.rs +++ b/src/elements/edge.rs @@ -43,7 +43,7 @@ impl Edge { pub fn color(&self, ctx: &Context) -> Color32 { if self.selected { - return ctx.style().visuals.widgets.active.fg_stroke.color; + return ctx.style().visuals.widgets.hovered.fg_stroke.color; } ctx.style()