mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
render selected turn icons better, just highlighting the circle
This commit is contained in:
parent
e6a3b02689
commit
c728210b2d
@ -66,7 +66,7 @@ impl StopSignEditor {
|
||||
}
|
||||
if self.selected_sign.is_none() {
|
||||
for t in &ui.primary.draw_map.get_turns(self.id, &ui.primary.map) {
|
||||
if t.icon_circle.contains_pt(pt) {
|
||||
if t.contains_pt(pt) {
|
||||
self.selected_turn = Some(t.id);
|
||||
break;
|
||||
}
|
||||
@ -148,7 +148,7 @@ impl StopSignEditor {
|
||||
}
|
||||
|
||||
for t in &state.ui.primary.draw_map.get_turns(self.id, map) {
|
||||
let color = match sign.get_priority(t.id) {
|
||||
let arrow_color = match sign.get_priority(t.id) {
|
||||
TurnPriority::Priority => {
|
||||
state.ui.cs.get_def("priority stop sign turn", Color::GREEN)
|
||||
}
|
||||
@ -156,14 +156,14 @@ impl StopSignEditor {
|
||||
TurnPriority::Stop => state.ui.cs.get_def("stop turn", Color::RED),
|
||||
TurnPriority::Banned => state.ui.cs.get_def("banned turn", Color::BLACK),
|
||||
};
|
||||
t.draw_icon(&mut batch, &state.ui.cs, color);
|
||||
t.draw_icon(
|
||||
&mut batch,
|
||||
&state.ui.cs,
|
||||
arrow_color,
|
||||
self.selected_turn == Some(t.id),
|
||||
);
|
||||
}
|
||||
if let Some(id) = self.selected_turn {
|
||||
batch.push(
|
||||
state.ui.cs.get("selected"),
|
||||
// TODO thin ring
|
||||
state.ui.primary.draw_map.get_t(id).icon_circle.to_polygon(),
|
||||
);
|
||||
DrawTurn::draw_dashed(
|
||||
map.get_t(id),
|
||||
&mut batch,
|
||||
|
@ -64,7 +64,7 @@ impl TrafficSignalEditor {
|
||||
if let Some(pt) = ctx.canvas.get_cursor_in_map_space() {
|
||||
self.icon_selected = None;
|
||||
for t in ui.primary.draw_map.get_turns(self.i, &ui.primary.map) {
|
||||
if t.icon_circle.contains_pt(pt) {
|
||||
if t.contains_pt(pt) {
|
||||
self.icon_selected = Some(t.id);
|
||||
break;
|
||||
}
|
||||
@ -244,7 +244,7 @@ impl TrafficSignalEditor {
|
||||
let map = &state.ui.primary.map;
|
||||
let cycle = &map.get_traffic_signal(self.i).cycles[self.current_cycle];
|
||||
for t in &state.ui.primary.draw_map.get_turns(self.i, map) {
|
||||
let color = match cycle.get_priority(t.id) {
|
||||
let arrow_color = match cycle.get_priority(t.id) {
|
||||
TurnPriority::Priority => state
|
||||
.ui
|
||||
.cs
|
||||
@ -259,15 +259,15 @@ impl TrafficSignalEditor {
|
||||
.get_def("turn not in current cycle", Color::BLACK),
|
||||
TurnPriority::Stop => panic!("Can't have TurnPriority::Stop in a traffic signal"),
|
||||
};
|
||||
t.draw_icon(&mut batch, &ctx.cs, color);
|
||||
t.draw_icon(
|
||||
&mut batch,
|
||||
&ctx.cs,
|
||||
arrow_color,
|
||||
self.icon_selected == Some(t.id),
|
||||
);
|
||||
}
|
||||
draw_signal_cycle(cycle, None, g, &ctx);
|
||||
if let Some(id) = self.icon_selected {
|
||||
batch.push(
|
||||
state.ui.cs.get("selected"),
|
||||
// TODO thin ring
|
||||
state.ui.primary.draw_map.get_t(id).icon_circle.to_polygon(),
|
||||
);
|
||||
DrawTurn::draw_dashed(map.get_t(id), &mut batch, state.ui.cs.get("selected turn"));
|
||||
}
|
||||
batch.draw(g);
|
||||
|
@ -4,13 +4,13 @@ use crate::render::{
|
||||
TURN_ICON_ARROW_THICKNESS,
|
||||
};
|
||||
use ezgui::{Color, Drawable, GeomBatch, GfxCtx, Prerender};
|
||||
use geom::{Circle, Distance, Line};
|
||||
use geom::{Circle, Distance, Line, Polygon, Pt2D};
|
||||
use map_model::{Map, Turn, TurnID, LANE_THICKNESS};
|
||||
|
||||
pub struct DrawTurn {
|
||||
pub id: TurnID,
|
||||
pub icon_circle: Circle,
|
||||
icon_arrow: Line,
|
||||
icon_circle: Circle,
|
||||
icon_arrow: Vec<Polygon>,
|
||||
}
|
||||
|
||||
impl DrawTurn {
|
||||
@ -28,7 +28,10 @@ impl DrawTurn {
|
||||
|
||||
let icon_src = icon_center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle.opposite());
|
||||
let icon_dst = icon_center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle);
|
||||
let icon_arrow = Line::new(icon_src, icon_dst);
|
||||
let icon_arrow = Line::new(icon_src, icon_dst)
|
||||
.to_polyline()
|
||||
.make_arrow(TURN_ICON_ARROW_THICKNESS)
|
||||
.unwrap();
|
||||
|
||||
DrawTurn {
|
||||
id: turn.id,
|
||||
@ -86,18 +89,26 @@ impl DrawTurn {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn draw_icon(&self, batch: &mut GeomBatch, cs: &ColorScheme, arrow_color: Color) {
|
||||
pub fn draw_icon(
|
||||
&self,
|
||||
batch: &mut GeomBatch,
|
||||
cs: &ColorScheme,
|
||||
arrow_color: Color,
|
||||
selected: bool,
|
||||
) {
|
||||
batch.push(
|
||||
cs.get_def("turn icon circle", Color::grey(0.6)),
|
||||
if selected {
|
||||
cs.get("selected")
|
||||
} else {
|
||||
cs.get_def("turn icon circle", Color::grey(0.6))
|
||||
},
|
||||
self.icon_circle.to_polygon(),
|
||||
);
|
||||
batch.extend(
|
||||
arrow_color,
|
||||
self.icon_arrow
|
||||
.to_polyline()
|
||||
.make_arrow(TURN_ICON_ARROW_THICKNESS)
|
||||
.unwrap(),
|
||||
);
|
||||
batch.extend(arrow_color, self.icon_arrow.clone());
|
||||
}
|
||||
|
||||
pub fn contains_pt(&self, pt: Pt2D) -> bool {
|
||||
self.icon_circle.contains_pt(pt)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user