rearrange minimap controls. nearly matching the new design.

This commit is contained in:
Dustin Carlino 2020-04-03 16:46:11 -07:00
parent e0acc4973b
commit eedbb2b967
4 changed files with 158 additions and 133 deletions

View File

@ -197,9 +197,9 @@ f71b2ce735102531e11934781fe748b1 data/system/assets/edit/parking.svg
2f15de4a863cc755984726da0c29c0a4 data/system/assets/edit/driving.svg
cad08c84562d640c5a4d4e45cd3731b2 data/system/assets/minimap/right.svg
39eb3adcf91244c50092f0aad6628e1a data/system/assets/minimap/left.svg
65c3dfeadeb35e91f45038292226ab36 data/system/assets/minimap/zoom_in_fully.svg
c063a7b561f00f4b2ccad16390d3c5f0 data/system/assets/minimap/zoom_in_fully.svg
55598346b4b038899f8972d7468a20a6 data/system/assets/minimap/down.svg
e761e1d1f6c9b8befe53296e0411cef2 data/system/assets/minimap/zoom_out_fully.svg
add7f832f0a7b501a59c505b63a0c5b5 data/system/assets/minimap/zoom_out_fully.svg
9caf97939884d4859accca34265f45fb data/system/assets/minimap/up.svg
a5e849fa8883569519976ebfef3ae269 data/system/night_colors.json
1909af5ebfefe7ad4102335c9e789d24 data/system/override_colors.json

View File

@ -1,3 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 14.1429H3.85714V18H6.42857V11.5714H0V14.1429ZM3.85714 3.85714H0V6.42857H6.42857V0H3.85714V3.85714ZM11.5714 18H14.1429V14.1429H18V11.5714H11.5714V18ZM14.1429 3.85714V0H11.5714V6.42857H18V3.85714H14.1429Z" fill="white"/>
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 23.1429H12.8571V27H15.4286V20.5714H9V23.1429ZM12.8571 12.8571H9V15.4286H15.4286V9H12.8571V12.8571ZM20.5714 27H23.1429V23.1429H27V20.5714H20.5714V27ZM23.1429 12.8571V9H20.5714V15.4286H27V12.8571H23.1429Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 334 B

After

Width:  |  Height:  |  Size: 334 B

View File

@ -1,3 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.57143 11.5714H0V18H6.42857V15.4286H2.57143V11.5714ZM0 6.42857H2.57143V2.57143H6.42857V0H0V6.42857ZM15.4286 15.4286H11.5714V18H18V11.5714H15.4286V15.4286ZM11.5714 0V2.57143H15.4286V6.42857H18V0H11.5714Z" fill="white"/>
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5714 20.5714H9V27H15.4286V24.4286H11.5714V20.5714ZM9 15.4286H11.5714V11.5714H15.4286V9H9V15.4286ZM24.4286 24.4286H20.5714V27H27V20.5714H24.4286V24.4286ZM20.5714 9V11.5714H24.4286V15.4286H27V9H20.5714Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 333 B

View File

@ -242,66 +242,84 @@ 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(make_viz_panel(ctx, app))
.aligned(
HorizontalAlignment::Right,
VerticalAlignment::BottomAboveOSD,
)
.build(ctx);
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),
)
.aligned(
HorizontalAlignment::Right,
VerticalAlignment::BottomAboveOSD,
)
.build(ctx);
}
let zoom_col = {
let mut col = vec![Btn::svg_def("../data/system/assets/speed/speed_up.svg")
.build(ctx, "zoom in", None)
.margin(12)];
for i in (0..=3).rev() {
let color = if zoom_lvl < i {
Color::WHITE.alpha(0.2)
} else {
Color::WHITE
};
let rect = Polygon::rectangle(20.0, 8.0);
col.push(
Btn::custom(
GeomBatch::from(vec![(color, rect.clone())]),
GeomBatch::from(vec![(colors::HOVERING, rect.clone())]),
rect,
)
.build(ctx, format!("zoom to level {}", i + 1), None)
.margin(12),
);
}
col.push(
Btn::svg_def("../data/system/assets/speed/slow_down.svg")
.build(ctx, "zoom out", None)
.margin(12),
);
// The zoom column should start below the "pan up" arrow. But if we put it on the row with
// <, minimap, and > then it messes up the horizontal alignment of the pan up arrow.
// Also, double column to avoid the background color stretching to the bottom of the row.
Widget::col(vec![Widget::col(col).bg(colors::INNER_PANEL)]).margin_above(26)
};
let square_len = 0.15 * ctx.canvas.window_width;
let mut zoom_col =
vec![Btn::svg_def("../data/system/assets/speed/speed_up.svg").build(ctx, "zoom in", None)];
for i in (0..=3).rev() {
let color = if zoom_lvl < i {
Color::grey(0.2)
} else {
Color::WHITE
};
let rect = Polygon::rectangle(20.0, 8.0);
zoom_col.push(
Btn::custom(
GeomBatch::from(vec![(color, rect.clone())]),
GeomBatch::from(vec![(colors::HOVERING, rect.clone())]),
rect,
)
.build(ctx, format!("zoom to level {}", i + 1), None),
);
}
zoom_col.push(
Btn::svg_def("../data/system/assets/speed/slow_down.svg").build(ctx, "zoom out", None),
);
Composite::new(
let minimap_controls = Widget::col(vec![
Btn::svg_def("../data/system/assets/minimap/up.svg")
.build(ctx, "pan up", None)
.margin(5)
.centered_horiz(),
Widget::row(vec![
Widget::col(zoom_col).margin(5).centered(),
Widget::col(vec![
Btn::svg_def("../data/system/assets/minimap/up.svg")
.build(ctx, "pan up", None)
.margin(5)
.centered_horiz(),
Widget::row(vec![
Btn::svg_def("../data/system/assets/minimap/left.svg")
.build(ctx, "pan left", None)
.margin(5)
.centered_vert(),
Filler::new(ScreenDims::new(square_len, square_len)).named("minimap"),
Btn::svg_def("../data/system/assets/minimap/right.svg")
.build(ctx, "pan right", None)
.margin(5)
.centered_vert(),
]),
Btn::svg_def("../data/system/assets/minimap/down.svg")
.build(ctx, "pan down", None)
.margin(5)
.centered_horiz(),
])
.centered(),
make_viz_panel(ctx, app).centered_vert(),
Btn::svg_def("../data/system/assets/minimap/left.svg")
.build(ctx, "pan left", None)
.margin(5)
.centered_vert(),
Filler::new(ScreenDims::new(square_len, square_len)).named("minimap"),
Btn::svg_def("../data/system/assets/minimap/right.svg")
.build(ctx, "pan right", None)
.margin(5)
.centered_vert(),
]),
Btn::svg_def("../data/system/assets/minimap/down.svg")
.build(ctx, "pan down", None)
.margin(5)
.centered_horiz(),
]);
Composite::new(Widget::row(vec![
make_tool_panel(ctx, app).margin_right(16),
Widget::col(vec![
Widget::row(vec![minimap_controls, zoom_col]),
make_viz_panel(ctx, app),
])
.padding(7)
.bg(colors::PANEL_BG),
)
]))
.aligned(
HorizontalAlignment::Right,
VerticalAlignment::BottomAboveOSD,
@ -309,24 +327,25 @@ fn make_minimap_panel(ctx: &mut EventCtx, app: &App, zoom_lvl: usize) -> Composi
.build(ctx)
}
fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
let radius = 10.0;
let mut col = vec![Widget::row(vec![
Btn::svg_def("../data/system/assets/tools/search.svg")
.build(ctx, "search", hotkey(Key::K))
.margin(10),
Btn::svg_def("../data/system/assets/tools/shortcuts.svg")
.build(ctx, "shortcuts", hotkey(Key::SingleQuote))
.margin(10),
if ctx.canvas.cam_zoom >= MIN_ZOOM_FOR_DETAIL {
Btn::svg_def("../data/system/assets/minimap/zoom_out_fully.svg")
.build(ctx, "zoom out fully", None)
.margin(10)
fn make_tool_panel(ctx: &mut EventCtx, app: &App) -> Widget {
// TODO Apply something to everything in the column
Widget::col(vec![
(if ctx.canvas.cam_zoom >= MIN_ZOOM_FOR_DETAIL {
Btn::svg_def("../data/system/assets/minimap/zoom_out_fully.svg").build(
ctx,
"zoom out fully",
None,
)
} else {
Btn::svg_def("../data/system/assets/minimap/zoom_in_fully.svg")
.build(ctx, "zoom in fully", None)
.margin(10)
},
Btn::svg_def("../data/system/assets/minimap/zoom_in_fully.svg").build(
ctx,
"zoom in fully",
None,
)
})
.bg(colors::INNER_PANEL)
.padding(9)
.margin_below(16),
Btn::svg_def("../data/system/assets/tools/layers.svg")
.normal_color(if app.overlay.is_empty() {
RewriteColor::NoOp
@ -334,68 +353,74 @@ fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
RewriteColor::ChangeAll(Color::BLUE)
})
.build(ctx, "change overlay", hotkey(Key::L))
.margin(10),
.bg(colors::INNER_PANEL)
.padding(9)
.margin_below(16),
Btn::svg_def("../data/system/assets/tools/search.svg")
.build(ctx, "search", hotkey(Key::K))
.bg(colors::INNER_PANEL)
.padding(9)
.margin_below(16),
Btn::svg_def("../data/system/assets/tools/shortcuts.svg")
.build(ctx, "shortcuts", hotkey(Key::SingleQuote))
.bg(colors::INNER_PANEL)
.padding(9),
])
.centered()];
for (label, color, enabled) in &app.agent_cs.rows {
col.push(
Widget::row(vec![
// TODO Make sure the dims of these two fit
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)
},
Widget::draw_batch(
ctx,
GeomBatch::from(vec![(
Color::WHITE.alpha(0.5),
Polygon::rectangle(2.0, 1.5 * radius),
)]),
)
.margin(3),
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),
Text::from(if *enabled {
Line(label).small()
} else {
Line(label).small().fg(Color::WHITE.alpha(0.5))
})
.draw(ctx)
.margin(3),
])
.centered_cross(),
);
}
}
fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
let mut col = Vec::new();
// TODO Really rethink this
if ctx.canvas.cam_zoom >= MIN_ZOOM_FOR_DETAIL {
if let Some(name) = app.overlay.zoomed_name() {
// TODO Should the full legend have this icon too?
col.insert(
0,
Widget::row(vec![
Widget::draw_svg_transform(
ctx,
"../data/system/assets/tools/layers.svg",
RewriteColor::ChangeAll(Color::BLUE),
)
.margin(5),
Line(name).small().draw(ctx),
]),
);
col.push(Widget::row(vec![
Widget::draw_svg_transform(
ctx,
"../data/system/assets/tools/layers.svg",
RewriteColor::ChangeAll(Color::BLUE),
)
.margin(5),
Line(name).small().draw(ctx),
]));
}
}
Widget::col(col).bg(colors::PANEL_BG).padding(5)
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),
);
}
col.push(Widget::row(row));
Widget::col(col)
}