mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-29 12:43:38 +03:00
goodbye eyes, hello colored checkboxes. also switch to a vertical
visibility panel when unzoomed. [rebuild]
This commit is contained in:
parent
eedbb2b967
commit
af2708df67
@ -158,11 +158,10 @@ bc920c3406bd82b4f54b63845fede3ca data/system/assets/speed/pause.svg
|
||||
a28c5fa18d32c3325a5f7326fed876fa data/system/assets/speed/reset.svg
|
||||
e348fda658d0fcb6bb8abdcec23d1dab data/system/assets/speed/speed_up.svg
|
||||
d15fe87c4174463e84b9a440162129ed data/system/assets/tools/undo.svg
|
||||
3b1d7fddf0babf8722be242c76094faf data/system/assets/tools/invisible.svg
|
||||
841a6304950389f8ede9581d04c1021f data/system/assets/tools/visible.svg
|
||||
5f3912d972b47419295ded39c52e647d data/system/assets/tools/next.svg
|
||||
e469148085a2046afd447d31a54d15ab data/system/assets/tools/search.svg
|
||||
8aeb89a0a9ef4e84d0202fb45f65d642 data/system/assets/tools/location.svg
|
||||
e26e99e490443b1c2f6296586cda4551 data/system/assets/tools/checkmark.svg
|
||||
4a5d6456d7c3d9ad94fc1a9e456d6f06 data/system/assets/tools/prev.svg
|
||||
fe358c0fdf48b65117f7c4970fa35d91 data/system/assets/tools/settings.svg
|
||||
1e0135f13d0aea11650460d6a61b5463 data/system/assets/tools/edit.svg
|
||||
|
4
data/system/assets/tools/checkmark.svg
Normal file
4
data/system/assets/tools/checkmark.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="32" height="32" rx="16" fill="black"/>
|
||||
<path d="M11.4528 22.1072L5.89284 16.5472L3.99951 18.4272L11.4528 25.8805L27.4528 9.88049L25.5728 8.00049L11.4528 22.1072Z" fill="white"/>
|
||||
</svg>
|
After Width: | Height: | Size: 294 B |
@ -1,3 +0,0 @@
|
||||
<svg width="22" height="19" viewBox="0 0 22 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M11 4C13.76 4 16 6.24 16 9C16 9.65 15.87 10.26 15.64 10.83L18.56 13.75C20.07 12.49 21.26 10.86 21.99 9C20.26 4.61 15.99 1.5 10.99 1.5C9.59 1.5 8.25 1.75 7.01 2.2L9.17 4.36C9.74 4.13 10.35 4 11 4ZM1 1.27L3.28 3.55L3.74 4.01C2.08 5.3 0.78 7.02 0 9C1.73 13.39 6 16.5 11 16.5C12.55 16.5 14.03 16.2 15.38 15.66L15.8 16.08L18.73 19L20 17.73L2.27 0L1 1.27ZM6.53 6.8L8.08 8.35C8.03 8.56 8 8.78 8 9C8 10.66 9.34 12 11 12C11.22 12 11.44 11.97 11.65 11.92L13.2 13.47C12.53 13.8 11.79 14 11 14C8.24 14 6 11.76 6 9C6 8.21 6.2 7.47 6.53 6.8ZM10.84 6.02L13.99 9.17L14.01 9.01C14.01 7.35 12.67 6.01 11.01 6.01L10.84 6.02Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 734 B |
@ -1,3 +0,0 @@
|
||||
<svg width="21" height="15" viewBox="0 0 21 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.8" d="M10.5 0.5C5.72727 0.5 1.65136 3.40267 0 7.5C1.65136 11.5973 5.72727 14.5 10.5 14.5C15.2727 14.5 19.3486 11.5973 21 7.5C19.3486 3.40267 15.2727 0.5 10.5 0.5ZM10.5 12.1667C7.86545 12.1667 5.72727 10.076 5.72727 7.5C5.72727 4.924 7.86545 2.83333 10.5 2.83333C13.1345 2.83333 15.2727 4.924 15.2727 7.5C15.2727 10.076 13.1345 12.1667 10.5 12.1667ZM10.5 4.7C8.91545 4.7 7.63636 5.95067 7.63636 7.5C7.63636 9.04933 8.91545 10.3 10.5 10.3C12.0845 10.3 13.3636 9.04933 13.3636 7.5C13.3636 5.95067 12.0845 4.7 10.5 4.7Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 652 B |
@ -120,6 +120,13 @@ impl GeomBatch {
|
||||
*c = to;
|
||||
}
|
||||
}
|
||||
RewriteColor::ChangeMore(ref list) => {
|
||||
for (from, to) in list {
|
||||
if c == from {
|
||||
*c = *to;
|
||||
}
|
||||
}
|
||||
}
|
||||
RewriteColor::ChangeAll(to) => {
|
||||
*c = to;
|
||||
}
|
||||
@ -178,5 +185,6 @@ impl GeomBatch {
|
||||
pub enum RewriteColor {
|
||||
NoOp,
|
||||
Change(Color, Color),
|
||||
ChangeMore(Vec<(Color, Color)>),
|
||||
ChangeAll(Color),
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ use crate::render::MIN_ZOOM_FOR_DETAIL;
|
||||
use abstutil::clamp;
|
||||
use ezgui::{
|
||||
hotkey, Btn, Color, Composite, EventCtx, Filler, GeomBatch, GfxCtx, HorizontalAlignment, Key,
|
||||
Line, Outcome, RewriteColor, ScreenDims, ScreenPt, Text, VerticalAlignment, Widget,
|
||||
Line, Outcome, RewriteColor, ScreenDims, ScreenPt, VerticalAlignment, Widget,
|
||||
};
|
||||
use geom::{Circle, Distance, Polygon, Pt2D, Ring};
|
||||
use geom::{Distance, Polygon, Pt2D, Ring};
|
||||
|
||||
// TODO Some of the math in here might assume map bound minimums start at (0, 0).
|
||||
pub struct Minimap {
|
||||
@ -242,13 +242,12 @@ impl Minimap {
|
||||
|
||||
fn make_minimap_panel(ctx: &mut EventCtx, app: &App, zoom_lvl: usize) -> Composite {
|
||||
if ctx.canvas.cam_zoom < MIN_ZOOM_FOR_DETAIL {
|
||||
return Composite::new(
|
||||
Widget::col(vec![
|
||||
make_tool_panel(ctx, app).align_right().margin_below(5),
|
||||
make_viz_panel(ctx, app).bg(colors::PANEL_BG),
|
||||
])
|
||||
.padding(7),
|
||||
)
|
||||
return Composite::new(Widget::row(vec![
|
||||
make_tool_panel(ctx, app).align_right().margin_right(16),
|
||||
make_vert_viz_panel(ctx, app)
|
||||
.bg(colors::PANEL_BG)
|
||||
.padding(7),
|
||||
]))
|
||||
.aligned(
|
||||
HorizontalAlignment::Right,
|
||||
VerticalAlignment::BottomAboveOSD,
|
||||
@ -315,7 +314,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, app: &App, zoom_lvl: usize) -> Composi
|
||||
make_tool_panel(ctx, app).margin_right(16),
|
||||
Widget::col(vec![
|
||||
Widget::row(vec![minimap_controls, zoom_col]),
|
||||
make_viz_panel(ctx, app),
|
||||
make_horiz_viz_panel(ctx, app),
|
||||
])
|
||||
.padding(7)
|
||||
.bg(colors::PANEL_BG),
|
||||
@ -347,13 +346,12 @@ fn make_tool_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
.padding(9)
|
||||
.margin_below(16),
|
||||
Btn::svg_def("../data/system/assets/tools/layers.svg")
|
||||
.normal_color(if app.overlay.is_empty() {
|
||||
RewriteColor::NoOp
|
||||
} else {
|
||||
RewriteColor::ChangeAll(Color::BLUE)
|
||||
})
|
||||
.build(ctx, "change overlay", hotkey(Key::L))
|
||||
.bg(colors::INNER_PANEL)
|
||||
.bg(if app.overlay.is_empty() {
|
||||
colors::INNER_PANEL
|
||||
} else {
|
||||
colors::HOVERING
|
||||
})
|
||||
.padding(9)
|
||||
.margin_below(16),
|
||||
Btn::svg_def("../data/system/assets/tools/search.svg")
|
||||
@ -368,7 +366,7 @@ fn make_tool_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
])
|
||||
}
|
||||
|
||||
fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
fn make_horiz_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
let mut col = Vec::new();
|
||||
|
||||
// TODO Really rethink this
|
||||
@ -379,7 +377,7 @@ fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
Widget::draw_svg_transform(
|
||||
ctx,
|
||||
"../data/system/assets/tools/layers.svg",
|
||||
RewriteColor::ChangeAll(Color::BLUE),
|
||||
RewriteColor::ChangeAll(colors::HOVERING),
|
||||
)
|
||||
.margin(5),
|
||||
Line(name).small().draw(ctx),
|
||||
@ -388,39 +386,56 @@ fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
}
|
||||
|
||||
let mut row = Vec::new();
|
||||
let radius = 10.0;
|
||||
for (label, color, enabled) in &app.agent_cs.rows {
|
||||
// TODO Make sure the dims of these two fit
|
||||
row.push(if *enabled {
|
||||
Btn::svg_def("../data/system/assets/tools/visible.svg")
|
||||
.build(ctx, format!("hide {}", label), None)
|
||||
.margin(3)
|
||||
} else {
|
||||
Btn::svg_def("../data/system/assets/tools/invisible.svg")
|
||||
.build(ctx, format!("show {}", label), None)
|
||||
.margin(3)
|
||||
});
|
||||
row.push(
|
||||
Widget::draw_batch(
|
||||
ctx,
|
||||
GeomBatch::from(vec![(
|
||||
color.alpha(if *enabled { 1.0 } else { 0.5 }),
|
||||
Circle::new(Pt2D::new(radius, radius), Distance::meters(radius)).to_polygon(),
|
||||
)]),
|
||||
)
|
||||
.margin(3),
|
||||
);
|
||||
row.push(
|
||||
Text::from(if *enabled {
|
||||
Line(label).small()
|
||||
} else {
|
||||
Line(label).small().fg(Color::WHITE.alpha(0.5))
|
||||
})
|
||||
.draw(ctx)
|
||||
.margin(3),
|
||||
);
|
||||
row.push(colored_checkbox(ctx, label, *color, *enabled).margin_right(8));
|
||||
row.push(Line(label).draw(ctx).margin_right(24));
|
||||
}
|
||||
let last = row.pop().unwrap();
|
||||
row.push(last.margin_right(0));
|
||||
col.push(Widget::row(row));
|
||||
|
||||
Widget::col(col)
|
||||
}
|
||||
|
||||
fn make_vert_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
|
||||
let mut col = Vec::new();
|
||||
|
||||
for (label, color, enabled) in &app.agent_cs.rows {
|
||||
let mut row = Vec::new();
|
||||
row.push(colored_checkbox(ctx, label, *color, *enabled).margin_right(8));
|
||||
row.push(Line(label).draw(ctx));
|
||||
col.push(Widget::row(row).margin_below(7));
|
||||
}
|
||||
let last = col.pop().unwrap();
|
||||
col.push(last.margin_below(0));
|
||||
|
||||
Widget::col(col)
|
||||
}
|
||||
|
||||
fn colored_checkbox(ctx: &EventCtx, label: &str, color: Color, enabled: bool) -> Widget {
|
||||
if enabled {
|
||||
Btn::svg(
|
||||
"../data/system/assets/tools/checkmark.svg",
|
||||
RewriteColor::ChangeMore(vec![
|
||||
(Color::BLACK, color),
|
||||
(Color::WHITE, colors::HOVERING),
|
||||
]),
|
||||
)
|
||||
.normal_color(RewriteColor::Change(Color::BLACK, color))
|
||||
.build(ctx, format!("hide {}", label), None)
|
||||
} else {
|
||||
// Fancy way of saying a circle ;)
|
||||
Btn::svg(
|
||||
"../data/system/assets/tools/checkmark.svg",
|
||||
RewriteColor::ChangeMore(vec![
|
||||
(Color::BLACK, color),
|
||||
(Color::WHITE, Color::INVISIBLE),
|
||||
]),
|
||||
)
|
||||
.normal_color(RewriteColor::ChangeMore(vec![
|
||||
(Color::BLACK, color.alpha(0.3)),
|
||||
(Color::WHITE, Color::INVISIBLE),
|
||||
]))
|
||||
.build(ctx, format!("show {}", label), None)
|
||||
}
|
||||
}
|
||||
|
@ -469,23 +469,23 @@ impl AgentColorScheme {
|
||||
AgentColorScheme {
|
||||
rows: vec![
|
||||
(
|
||||
"car".to_string(),
|
||||
"Car".to_string(),
|
||||
cs.get_def("unzoomed car", Color::hex("#A32015")).alpha(0.8),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"bike".to_string(),
|
||||
"Bike".to_string(),
|
||||
cs.get_def("unzoomed bike", Color::hex("#5D9630"))
|
||||
.alpha(0.8),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"bus".to_string(),
|
||||
"Bus".to_string(),
|
||||
cs.get_def("unzoomed bus", Color::hex("#12409D")).alpha(0.8),
|
||||
true,
|
||||
),
|
||||
(
|
||||
"pedestrian".to_string(),
|
||||
"Pedestrian".to_string(),
|
||||
cs.get_def("unzoomed pedestrian", Color::hex("#DF8C3D").alpha(0.8)),
|
||||
true,
|
||||
),
|
||||
@ -505,10 +505,10 @@ impl AgentColorScheme {
|
||||
|
||||
fn color(&self, agent: &UnzoomedAgent) -> Option<Color> {
|
||||
let category = match agent.vehicle_type {
|
||||
Some(VehicleType::Car) => "car".to_string(),
|
||||
Some(VehicleType::Bike) => "bike".to_string(),
|
||||
Some(VehicleType::Bus) => "bus".to_string(),
|
||||
None => "pedestrian".to_string(),
|
||||
Some(VehicleType::Car) => "Car".to_string(),
|
||||
Some(VehicleType::Bike) => "Bike".to_string(),
|
||||
Some(VehicleType::Bus) => "Bus".to_string(),
|
||||
None => "Pedestrian".to_string(),
|
||||
};
|
||||
for (name, color, enabled) in &self.rows {
|
||||
if name == &category {
|
||||
|
Loading…
Reference in New Issue
Block a user