Skip to content

Commit

Permalink
Merge pull request #85 from agentsim/vertically_centred_wedge
Browse files Browse the repository at this point in the history
Vertically centre the wedge
  • Loading branch information
richard-uk1 authored Nov 9, 2021
2 parents ce263f3 + 587caac commit 1d14641
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/wedge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Widget<bool> for Wedge {
}

fn paint(&mut self, ctx: &mut PaintCtx, expanded: &bool, env: &Env) {
let y_offset = ((ctx.size().height - 8.0) / 2.0).floor();
let stroke_color = if ctx.is_hot() {
env.get(theme::FOREGROUND_LIGHT)
} else {
Expand All @@ -71,14 +72,14 @@ impl Widget<bool> for Wedge {
let mut path = BezPath::new();
if *expanded {
// expanded: 'V' shape
path.move_to((5.0, 7.0));
path.line_to((9.0, 13.0));
path.line_to((13.0, 7.0));
path.move_to((5.0, y_offset + 2.0));
path.line_to((9.0, y_offset + 8.0));
path.line_to((13.0, y_offset + 2.0));
} else {
// collapsed: '>' shape
path.move_to((7.0, 5.0));
path.line_to((13.0, 9.0));
path.line_to((7.0, 13.0));
path.move_to((7.0, y_offset));
path.line_to((13.0, y_offset + 4.0));
path.line_to((7.0, y_offset + 8.0));
}
let style = StrokeStyle::new()
.line_cap(LineCap::Round)
Expand Down

0 comments on commit 1d14641

Please sign in to comment.