update the route panel waypoint icons with the same color as the map waypoints
@@ -73,7 +73,7 @@ impl InputWaypoints {
let bounds = batch.get_bounds();
let image = Image::from_batch(batch, bounds)
.untinted()
- .bg_color(Color::RED)
+ .bg_color(self.get_waypoint_color(idx))
.padding(10)
.dims(16)
.corner_rounding(CornerRounding::FullyRounded);
@@ -216,11 +216,8 @@ impl InputWaypoints {
g.redraw(&self.draw_hover);
}
- fn update_waypoints_drawable(&mut self, ctx: &mut EventCtx) {
- let mut batch = GeomBatch::new();
+ fn get_waypoint_color(&self, idx: usize) -> Color {
let total_waypoints = self.waypoints.len();
- for (idx, waypt) in &mut self.waypoints.iter().enumerate() {
- let geom = {
let wp = {
match idx {
0 => WaypointPosition::Start,
@@ -230,15 +227,18 @@ impl InputWaypoints {
}
};
- let color = {
match wp {
WaypointPosition::Start => Color::GREEN,
WaypointPosition::End => Color::RED,
- WaypointPosition::Middle => {
- [Color::BLUE, Color::ORANGE, Color::PURPLE][idx % 3]
+ WaypointPosition::Middle => [Color::BLUE, Color::ORANGE, Color::PURPLE][idx % 3],
}
}
- };
+
+ fn update_waypoints_drawable(&mut self, ctx: &mut EventCtx) {
+ let mut batch = GeomBatch::new();
+ for (idx, waypt) in &mut self.waypoints.iter().enumerate() {
+ let geom = {
+ let color = self.get_waypoint_color(idx);
let mut geom = GeomBatch::new();
