mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 23:43:25 +03:00
continue button refactor
This commit is contained in:
parent
5a2986d6c9
commit
2ae6992a3e
@ -1,8 +1,8 @@
|
|||||||
use crate::layout::Widget;
|
use crate::layout::Widget;
|
||||||
use crate::widgets::{Checkbox, Dropdown, PopupMenu, TextBox};
|
use crate::widgets::{Checkbox, Dropdown, PopupMenu, TextBox};
|
||||||
use crate::{
|
use crate::{
|
||||||
Button, Choice, Color, Drawable, EventCtx, Filler, GeomBatch, GfxCtx, Histogram,
|
Btn, Button, Choice, Color, Drawable, EventCtx, Filler, GeomBatch, GfxCtx, Histogram,
|
||||||
HorizontalAlignment, JustDraw, Line, MultiKey, Plot, RewriteColor, ScreenDims, ScreenPt,
|
HorizontalAlignment, JustDraw, MultiKey, Plot, RewriteColor, ScreenDims, ScreenPt,
|
||||||
ScreenRectangle, Slider, Text, VerticalAlignment,
|
ScreenRectangle, Slider, Text, VerticalAlignment,
|
||||||
};
|
};
|
||||||
use abstutil::Cloneable;
|
use abstutil::Cloneable;
|
||||||
@ -285,32 +285,17 @@ impl ManagedWidget {
|
|||||||
hotkey: Option<MultiKey>,
|
hotkey: Option<MultiKey>,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
) -> ManagedWidget {
|
) -> ManagedWidget {
|
||||||
// TODO Just a copy of WrappedComposite::nice_text_button essentially...
|
fn take_btn(w: ManagedWidget) -> Button {
|
||||||
fn make_btn(
|
match w.widget {
|
||||||
ctx: &EventCtx,
|
WidgetType::Btn(btn) => btn,
|
||||||
label: &str,
|
_ => unreachable!(),
|
||||||
hotkey: Option<MultiKey>,
|
}
|
||||||
enabled: bool,
|
|
||||||
) -> Button {
|
|
||||||
let txt = Text::from(Line(format!(
|
|
||||||
"{} {}",
|
|
||||||
if enabled { "☑" } else { "☐" },
|
|
||||||
label
|
|
||||||
)));
|
|
||||||
Button::text_no_bg(
|
|
||||||
txt.clone(),
|
|
||||||
txt.change_fg(Color::ORANGE),
|
|
||||||
hotkey,
|
|
||||||
label,
|
|
||||||
true,
|
|
||||||
ctx,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ManagedWidget::custom_checkbox(
|
ManagedWidget::custom_checkbox(
|
||||||
enabled,
|
enabled,
|
||||||
make_btn(ctx, label, hotkey.clone(), false),
|
take_btn(Btn::text_fg(format!("☐ {}", label)).build(ctx, label, hotkey.clone())),
|
||||||
make_btn(ctx, label, hotkey, true),
|
take_btn(Btn::text_fg(format!("☑ {}", label)).build(ctx, label, hotkey)),
|
||||||
)
|
)
|
||||||
.outline(2.0, Color::WHITE)
|
.outline(2.0, Color::WHITE)
|
||||||
.named(label)
|
.named(label)
|
||||||
|
@ -265,10 +265,11 @@ impl Button {
|
|||||||
pub struct Btn {}
|
pub struct Btn {}
|
||||||
|
|
||||||
impl Btn {
|
impl Btn {
|
||||||
pub fn svg(path: &str, hover: RewriteColor) -> BtnBuilder {
|
pub fn svg<I: Into<String>>(path: I, hover: RewriteColor) -> BtnBuilder {
|
||||||
BtnBuilder::SVG(path.to_string(), hover)
|
BtnBuilder::SVG(path.into(), hover)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as WrappedComposite::text_button
|
||||||
pub fn text_fg<I: Into<String>>(label: I) -> BtnBuilder {
|
pub fn text_fg<I: Into<String>>(label: I) -> BtnBuilder {
|
||||||
BtnBuilder::TextFG(label.into())
|
BtnBuilder::TextFG(label.into())
|
||||||
}
|
}
|
||||||
@ -277,12 +278,18 @@ impl Btn {
|
|||||||
pub fn text_bg1<I: Into<String>>(label: I) -> BtnBuilder {
|
pub fn text_bg1<I: Into<String>>(label: I) -> BtnBuilder {
|
||||||
BtnBuilder::TextBG1(label.into())
|
BtnBuilder::TextBG1(label.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The white background. WrappedComposite::text_bg_button.
|
||||||
|
pub fn text_bg2<I: Into<String>>(label: I) -> BtnBuilder {
|
||||||
|
BtnBuilder::TextBG2(label.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum BtnBuilder {
|
pub enum BtnBuilder {
|
||||||
SVG(String, RewriteColor),
|
SVG(String, RewriteColor),
|
||||||
TextFG(String),
|
TextFG(String),
|
||||||
TextBG1(String),
|
TextBG1(String),
|
||||||
|
TextBG2(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BtnBuilder {
|
impl BtnBuilder {
|
||||||
@ -317,6 +324,27 @@ impl BtnBuilder {
|
|||||||
&action_tooltip.into(),
|
&action_tooltip.into(),
|
||||||
ctx,
|
ctx,
|
||||||
)),
|
)),
|
||||||
|
BtnBuilder::TextBG2(label) => ManagedWidget::btn(Button::text_bg(
|
||||||
|
Text::from(Line(label).fg(Color::BLACK)),
|
||||||
|
Color::WHITE,
|
||||||
|
Color::ORANGE,
|
||||||
|
key,
|
||||||
|
&action_tooltip.into(),
|
||||||
|
ctx,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the text as the action
|
||||||
|
pub fn build_def(self, ctx: &EventCtx, hotkey: Option<MultiKey>) -> ManagedWidget {
|
||||||
|
match self {
|
||||||
|
BtnBuilder::SVG(_, _) => panic!("Can't use build_def on an SVG button"),
|
||||||
|
BtnBuilder::TextFG(ref label)
|
||||||
|
| BtnBuilder::TextBG1(ref label)
|
||||||
|
| BtnBuilder::TextBG2(ref label) => {
|
||||||
|
let copy = label.clone();
|
||||||
|
self.build(ctx, copy, hotkey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::widgets::PopupMenu;
|
use crate::widgets::PopupMenu;
|
||||||
use crate::{
|
use crate::{
|
||||||
hotkey, Button, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, InputResult, Key,
|
hotkey, Btn, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, InputResult, Key, Line,
|
||||||
Line, ManagedWidget, MultiKey, Outcome, Text, VerticalAlignment,
|
ManagedWidget, MultiKey, Outcome, Text, VerticalAlignment,
|
||||||
};
|
};
|
||||||
use abstutil::Cloneable;
|
use abstutil::Cloneable;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
@ -87,28 +87,14 @@ impl Wizard {
|
|||||||
ManagedWidget::col(vec![
|
ManagedWidget::col(vec![
|
||||||
ManagedWidget::row(vec![
|
ManagedWidget::row(vec![
|
||||||
Line(query).roboto_bold().draw(ctx),
|
Line(query).roboto_bold().draw(ctx),
|
||||||
// TODO nice text button
|
Btn::text_fg("X")
|
||||||
ManagedWidget::btn(Button::text_bg(
|
.build(ctx, "quit", hotkey(Key::Escape))
|
||||||
Text::from(Line("X").fg(Color::BLACK)),
|
.margin(5)
|
||||||
Color::WHITE,
|
.align_right(),
|
||||||
Color::ORANGE,
|
|
||||||
hotkey(Key::Escape),
|
|
||||||
"quit",
|
|
||||||
ctx,
|
|
||||||
))
|
|
||||||
.margin(5)
|
|
||||||
.align_right(),
|
|
||||||
]),
|
]),
|
||||||
ManagedWidget::text_entry(ctx, prefilled.unwrap_or_else(String::new), true)
|
ManagedWidget::text_entry(ctx, prefilled.unwrap_or_else(String::new), true)
|
||||||
.named("input"),
|
.named("input"),
|
||||||
ManagedWidget::btn(Button::text_bg(
|
Btn::text_bg2("Done").build(ctx, "done", hotkey(Key::Enter)),
|
||||||
Text::from(Line("Done").fg(Color::BLACK)),
|
|
||||||
Color::WHITE,
|
|
||||||
Color::ORANGE,
|
|
||||||
hotkey(Key::Enter),
|
|
||||||
"done",
|
|
||||||
ctx,
|
|
||||||
)),
|
|
||||||
])
|
])
|
||||||
.bg(Color::grey(0.4))
|
.bg(Color::grey(0.4))
|
||||||
.outline(5.0, Color::WHITE)
|
.outline(5.0, Color::WHITE)
|
||||||
@ -272,16 +258,9 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
|
|||||||
Composite::new(
|
Composite::new(
|
||||||
ManagedWidget::row(vec![
|
ManagedWidget::row(vec![
|
||||||
ManagedWidget::col(col),
|
ManagedWidget::col(col),
|
||||||
// TODO nice text button
|
Btn::text_fg("X")
|
||||||
ManagedWidget::btn(Button::text_bg(
|
.build(self.ctx, "quit", hotkey(Key::Escape))
|
||||||
Text::from(Line("X").fg(Color::BLACK)),
|
.margin(5),
|
||||||
Color::WHITE,
|
|
||||||
Color::ORANGE,
|
|
||||||
hotkey(Key::Escape),
|
|
||||||
"quit",
|
|
||||||
self.ctx,
|
|
||||||
))
|
|
||||||
.margin(5),
|
|
||||||
])
|
])
|
||||||
.bg(Color::grey(0.4))
|
.bg(Color::grey(0.4))
|
||||||
.outline(5.0, Color::WHITE)
|
.outline(5.0, Color::WHITE)
|
||||||
@ -408,15 +387,9 @@ impl<'a, 'b> WrappedWizard<'a, 'b> {
|
|||||||
Composite::new(
|
Composite::new(
|
||||||
ManagedWidget::col(vec![
|
ManagedWidget::col(vec![
|
||||||
txt.draw(self.ctx),
|
txt.draw(self.ctx),
|
||||||
ManagedWidget::btn(Button::text_bg(
|
Btn::text_bg2("OK")
|
||||||
Text::from(Line("OK")),
|
.build(self.ctx, "OK", hotkey(Key::Enter))
|
||||||
Color::grey(0.6),
|
.margin(5),
|
||||||
Color::ORANGE,
|
|
||||||
hotkey(Key::Enter),
|
|
||||||
"OK",
|
|
||||||
self.ctx,
|
|
||||||
))
|
|
||||||
.margin(5),
|
|
||||||
])
|
])
|
||||||
.bg(Color::grey(0.4))
|
.bg(Color::grey(0.4))
|
||||||
.outline(10.0, Color::WHITE)
|
.outline(10.0, Color::WHITE)
|
||||||
|
@ -6,7 +6,7 @@ use crate::managed::WrappedComposite;
|
|||||||
use crate::render::{AgentColorScheme, MIN_ZOOM_FOR_DETAIL};
|
use crate::render::{AgentColorScheme, MIN_ZOOM_FOR_DETAIL};
|
||||||
use abstutil::clamp;
|
use abstutil::clamp;
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Choice, Color, Composite, EventCtx, Filler, GeomBatch, GfxCtx,
|
hotkey, Btn, Button, Choice, Color, Composite, EventCtx, Filler, GeomBatch, GfxCtx,
|
||||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, ScreenDims, ScreenPt,
|
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, RewriteColor, ScreenDims, ScreenPt,
|
||||||
Text, VerticalAlignment,
|
Text, VerticalAlignment,
|
||||||
};
|
};
|
||||||
@ -282,13 +282,11 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
let square_len = 0.15 * ctx.canvas.window_width;
|
let square_len = 0.15 * ctx.canvas.window_width;
|
||||||
let mut zoom_col = vec![ManagedWidget::btn(Button::rectangle_svg(
|
let mut zoom_col = vec![Btn::svg(
|
||||||
"../data/system/assets/speed/speed_up.svg",
|
"../data/system/assets/speed/speed_up.svg",
|
||||||
"zoom in",
|
|
||||||
None,
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
))];
|
.build(ctx, "zoom in", None)];
|
||||||
for i in (0..=3).rev() {
|
for i in (0..=3).rev() {
|
||||||
let color = if zoom_lvl < i {
|
let color = if zoom_lvl < i {
|
||||||
Color::grey(0.2)
|
Color::grey(0.2)
|
||||||
@ -305,13 +303,13 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
|
|||||||
rect,
|
rect,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
zoom_col.push(ManagedWidget::btn(Button::rectangle_svg(
|
zoom_col.push(
|
||||||
"../data/system/assets/speed/slow_down.svg",
|
Btn::svg(
|
||||||
"zoom out",
|
"../data/system/assets/speed/slow_down.svg",
|
||||||
None,
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
)
|
||||||
ctx,
|
.build(ctx, "zoom out", None),
|
||||||
)));
|
);
|
||||||
|
|
||||||
Composite::new(
|
Composite::new(
|
||||||
ManagedWidget::row(vec![
|
ManagedWidget::row(vec![
|
||||||
|
@ -7,7 +7,7 @@ use crate::helpers::ID;
|
|||||||
use crate::managed::{ManagedGUIState, WrappedComposite, WrappedOutcome};
|
use crate::managed::{ManagedGUIState, WrappedComposite, WrappedOutcome};
|
||||||
use abstutil::{prettyprint_usize, Counter};
|
use abstutil::{prettyprint_usize, Counter};
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx, Histogram,
|
hotkey, Btn, Button, Color, Composite, Drawable, EventCtx, GeomBatch, GfxCtx, Histogram,
|
||||||
HorizontalAlignment, JustDraw, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions,
|
HorizontalAlignment, JustDraw, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions,
|
||||||
RewriteColor, Series, Text, TextExt, VerticalAlignment,
|
RewriteColor, Series, Text, TextExt, VerticalAlignment,
|
||||||
};
|
};
|
||||||
@ -235,45 +235,35 @@ impl Overlays {
|
|||||||
|
|
||||||
pub fn change_overlays(ctx: &mut EventCtx, app: &App) -> Option<Transition> {
|
pub fn change_overlays(ctx: &mut EventCtx, app: &App) -> Option<Transition> {
|
||||||
let mut choices = vec![
|
let mut choices = vec![
|
||||||
WrappedComposite::text_button(ctx, "None", hotkey(Key::N)),
|
Btn::text_fg("None").build_def(ctx, hotkey(Key::N)),
|
||||||
WrappedComposite::text_button(ctx, "map edits", hotkey(Key::E)),
|
Btn::text_fg("map edits").build_def(ctx, hotkey(Key::E)),
|
||||||
WrappedComposite::text_button(ctx, "worst traffic jams", hotkey(Key::G)),
|
Btn::text_fg("worst traffic jams").build_def(ctx, hotkey(Key::G)),
|
||||||
WrappedComposite::text_button(ctx, "elevation", hotkey(Key::S)),
|
Btn::text_fg("elevation").build_def(ctx, hotkey(Key::S)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/layers/parking_avail.svg",
|
"../data/system/assets/layers/parking_avail.svg",
|
||||||
"parking availability",
|
|
||||||
hotkey(Key::P),
|
|
||||||
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "parking availability", hotkey(Key::P)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/layers/intersection_delay.svg",
|
"../data/system/assets/layers/intersection_delay.svg",
|
||||||
"intersection delay",
|
|
||||||
hotkey(Key::I),
|
|
||||||
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "intersection delay", hotkey(Key::I)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/layers/throughput.svg",
|
"../data/system/assets/layers/throughput.svg",
|
||||||
"throughput",
|
|
||||||
hotkey(Key::T),
|
|
||||||
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "throughput", hotkey(Key::T)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/layers/bike_network.svg",
|
"../data/system/assets/layers/bike_network.svg",
|
||||||
"bike network",
|
|
||||||
hotkey(Key::B),
|
|
||||||
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "bike network", hotkey(Key::B)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/layers/bus_network.svg",
|
"../data/system/assets/layers/bus_network.svg",
|
||||||
"bus network",
|
|
||||||
hotkey(Key::U),
|
|
||||||
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "bus network", hotkey(Key::U)),
|
||||||
];
|
];
|
||||||
// TODO Grey out the inactive SVGs, and add the green checkmark
|
// TODO Grey out the inactive SVGs, and add the green checkmark
|
||||||
if let Some((find, replace)) = match app.overlay {
|
if let Some((find, replace)) = match app.overlay {
|
||||||
@ -321,7 +311,9 @@ impl Overlays {
|
|||||||
ManagedWidget::col(vec![
|
ManagedWidget::col(vec![
|
||||||
ManagedWidget::row(vec![
|
ManagedWidget::row(vec![
|
||||||
"Heat Map Layers".draw_text(ctx),
|
"Heat Map Layers".draw_text(ctx),
|
||||||
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
|
Btn::text_fg("X")
|
||||||
|
.build(ctx, "close", hotkey(Key::Escape))
|
||||||
|
.align_right(),
|
||||||
]),
|
]),
|
||||||
ManagedWidget::row(choices).flex_wrap(ctx, 20),
|
ManagedWidget::row(choices).flex_wrap(ctx, 20),
|
||||||
])
|
])
|
||||||
@ -332,7 +324,7 @@ impl Overlays {
|
|||||||
.max_size_percent(30, 50)
|
.max_size_percent(30, 50)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.cb("X", Box::new(|_, _| Some(Transition::Pop)))
|
.cb("close", Box::new(|_, _| Some(Transition::Pop)))
|
||||||
.maybe_cb(
|
.maybe_cb(
|
||||||
"None",
|
"None",
|
||||||
Box::new(|_, app| {
|
Box::new(|_, app| {
|
||||||
@ -774,13 +766,11 @@ impl Overlays {
|
|||||||
let col = vec![
|
let col = vec![
|
||||||
ManagedWidget::row(vec![
|
ManagedWidget::row(vec![
|
||||||
"intersection demand".draw_text(ctx),
|
"intersection demand".draw_text(ctx),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/tools/locate.svg",
|
"../data/system/assets/tools/locate.svg",
|
||||||
"intersection demand",
|
|
||||||
None,
|
|
||||||
RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "intersection demand", None),
|
||||||
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
WrappedComposite::text_button(ctx, "X", None).align_right(),
|
||||||
]),
|
]),
|
||||||
ColorLegend::row(ctx, Color::RED, "current demand"),
|
ColorLegend::row(ctx, Color::RED, "current demand"),
|
||||||
@ -818,13 +808,11 @@ impl Overlays {
|
|||||||
for idx in 0..route.stops.len() {
|
for idx in 0..route.stops.len() {
|
||||||
col.push(ManagedWidget::row(vec![
|
col.push(ManagedWidget::row(vec![
|
||||||
format!("Stop {}", idx + 1).draw_text(ctx),
|
format!("Stop {}", idx + 1).draw_text(ctx),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/tools/locate.svg",
|
"../data/system/assets/tools/locate.svg",
|
||||||
&format!("Stop {}", idx + 1),
|
|
||||||
None,
|
|
||||||
RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
|
RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, format!("Stop {}", idx + 1), None),
|
||||||
if let Some(hgram) = delay_per_stop.remove(&route.stops[idx]) {
|
if let Some(hgram) = delay_per_stop.remove(&route.stops[idx]) {
|
||||||
format!(
|
format!(
|
||||||
": {} (avg {})",
|
": {} (avg {})",
|
||||||
|
@ -3,7 +3,7 @@ use crate::game::Transition;
|
|||||||
use crate::managed::WrappedComposite;
|
use crate::managed::WrappedComposite;
|
||||||
use crate::options;
|
use crate::options;
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, RewriteColor,
|
hotkey, Btn, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, RewriteColor,
|
||||||
VerticalAlignment,
|
VerticalAlignment,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -11,21 +11,17 @@ pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite {
|
|||||||
let row = vec![
|
let row = vec![
|
||||||
// TODO Maybe this is confusing -- it doesn't jump to the title screen necessarily.
|
// TODO Maybe this is confusing -- it doesn't jump to the title screen necessarily.
|
||||||
// Caller has to handle this one
|
// Caller has to handle this one
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/tools/home.svg",
|
"../data/system/assets/tools/home.svg",
|
||||||
"back",
|
|
||||||
hotkey(Key::Escape),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
))
|
.build(ctx, "back", hotkey(Key::Escape))
|
||||||
.margin(10),
|
.margin(10),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/tools/settings.svg",
|
"../data/system/assets/tools/settings.svg",
|
||||||
"settings",
|
|
||||||
None,
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
))
|
.build(ctx, "settings", None)
|
||||||
.margin(10),
|
.margin(10),
|
||||||
];
|
];
|
||||||
WrappedComposite::new(
|
WrappedComposite::new(
|
||||||
|
@ -7,7 +7,7 @@ use crate::helpers::ID;
|
|||||||
use crate::managed::WrappedComposite;
|
use crate::managed::WrappedComposite;
|
||||||
use crate::render::Renderable;
|
use crate::render::Renderable;
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Choice, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key,
|
hotkey, Btn, Button, Choice, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key,
|
||||||
ManagedWidget, Outcome, RewriteColor, TextExt, VerticalAlignment,
|
ManagedWidget, Outcome, RewriteColor, TextExt, VerticalAlignment,
|
||||||
};
|
};
|
||||||
use map_model::{EditCmd, LaneID, LaneType, Map, RoadID};
|
use map_model::{EditCmd, LaneID, LaneType, Map, RoadID};
|
||||||
@ -57,13 +57,11 @@ impl LaneEditor {
|
|||||||
] {
|
] {
|
||||||
row.push(
|
row.push(
|
||||||
if active {
|
if active {
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
&format!("../data/system/assets/edit/{}.svg", icon),
|
format!("../data/system/assets/edit/{}.svg", icon),
|
||||||
label,
|
|
||||||
hotkey(key),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
))
|
.build(ctx, label, hotkey(key))
|
||||||
} else {
|
} else {
|
||||||
ManagedWidget::draw_svg_transform(
|
ManagedWidget::draw_svg_transform(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -2,7 +2,7 @@ use crate::app::App;
|
|||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::game::{DrawBaselayer, State, Transition};
|
use crate::game::{DrawBaselayer, State, Transition};
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
hotkey, Btn, Button, Color, Composite, EventCtx, GfxCtx, HorizontalAlignment, Key, Line,
|
||||||
ManagedWidget, MultiKey, Outcome, RewriteColor, Text, VerticalAlignment,
|
ManagedWidget, MultiKey, Outcome, RewriteColor, Text, VerticalAlignment,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -64,13 +64,11 @@ impl WrappedComposite {
|
|||||||
tooltip: &str,
|
tooltip: &str,
|
||||||
hotkey: Option<MultiKey>,
|
hotkey: Option<MultiKey>,
|
||||||
) -> ManagedWidget {
|
) -> ManagedWidget {
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
filename,
|
filename,
|
||||||
tooltip,
|
|
||||||
hotkey,
|
|
||||||
RewriteColor::Change(Color::WHITE, colors::HOVERING),
|
RewriteColor::Change(Color::WHITE, colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
))
|
.build(ctx, tooltip, hotkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nice_text_button(
|
pub fn nice_text_button(
|
||||||
@ -91,18 +89,11 @@ impl WrappedComposite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn text_button(ctx: &EventCtx, label: &str, hotkey: Option<MultiKey>) -> ManagedWidget {
|
pub fn text_button(ctx: &EventCtx, label: &str, hotkey: Option<MultiKey>) -> ManagedWidget {
|
||||||
WrappedComposite::nice_text_button(ctx, Text::from(Line(label)), hotkey, label)
|
Btn::text_fg(label).build_def(ctx, hotkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text_bg_button(ctx: &EventCtx, label: &str, hotkey: Option<MultiKey>) -> ManagedWidget {
|
pub fn text_bg_button(ctx: &EventCtx, label: &str, hotkey: Option<MultiKey>) -> ManagedWidget {
|
||||||
ManagedWidget::btn(Button::text_bg(
|
Btn::text_bg2(label).build_def(ctx, hotkey)
|
||||||
Text::from(Line(label).fg(Color::BLACK)),
|
|
||||||
Color::WHITE,
|
|
||||||
colors::HOVERING,
|
|
||||||
hotkey,
|
|
||||||
label,
|
|
||||||
ctx,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always includes a built-in "X" quit option
|
// Always includes a built-in "X" quit option
|
||||||
|
@ -6,7 +6,7 @@ use crate::helpers::ID;
|
|||||||
use crate::managed::{WrappedComposite, WrappedOutcome};
|
use crate::managed::{WrappedComposite, WrappedOutcome};
|
||||||
use crate::sandbox::{GameplayMode, SandboxMode};
|
use crate::sandbox::{GameplayMode, SandboxMode};
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Button, Color, Composite, EventCtx, EventLoopMode, GeomBatch, GfxCtx,
|
hotkey, Btn, Button, Color, Composite, EventCtx, EventLoopMode, GeomBatch, GfxCtx,
|
||||||
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions, RewriteColor,
|
HorizontalAlignment, Key, Line, ManagedWidget, Outcome, Plot, PlotOptions, RewriteColor,
|
||||||
Series, Slider, Text, VerticalAlignment,
|
Series, Slider, Text, VerticalAlignment,
|
||||||
};
|
};
|
||||||
@ -37,23 +37,19 @@ impl SpeedControls {
|
|||||||
fn make_panel(ctx: &mut EventCtx, paused: bool, setting: SpeedSetting) -> WrappedComposite {
|
fn make_panel(ctx: &mut EventCtx, paused: bool, setting: SpeedSetting) -> WrappedComposite {
|
||||||
let mut row = Vec::new();
|
let mut row = Vec::new();
|
||||||
row.push(
|
row.push(
|
||||||
ManagedWidget::btn(if paused {
|
if paused {
|
||||||
Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/speed/triangle.svg",
|
"../data/system/assets/speed/triangle.svg",
|
||||||
"play",
|
|
||||||
hotkey(Key::Space),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
|
||||||
)
|
)
|
||||||
|
.build(ctx, "play", hotkey(Key::Space))
|
||||||
} else {
|
} else {
|
||||||
Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/speed/pause.svg",
|
"../data/system/assets/speed/pause.svg",
|
||||||
"pause",
|
|
||||||
hotkey(Key::Space),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
|
||||||
)
|
)
|
||||||
})
|
.build(ctx, "pause", hotkey(Key::Space))
|
||||||
|
}
|
||||||
.margin(5)
|
.margin(5)
|
||||||
.centered_vert()
|
.centered_vert()
|
||||||
.bg(colors::SECTION_BG),
|
.bg(colors::SECTION_BG),
|
||||||
@ -117,20 +113,16 @@ impl SpeedControls {
|
|||||||
false,
|
false,
|
||||||
ctx,
|
ctx,
|
||||||
)),
|
)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/speed/jump_to_time.svg",
|
"../data/system/assets/speed/jump_to_time.svg",
|
||||||
"jump to specific time",
|
|
||||||
hotkey(Key::B),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "jump to specific time", hotkey(Key::B)),
|
||||||
ManagedWidget::btn(Button::rectangle_svg(
|
Btn::svg(
|
||||||
"../data/system/assets/speed/reset.svg",
|
"../data/system/assets/speed/reset.svg",
|
||||||
"reset to midnight",
|
|
||||||
hotkey(Key::X),
|
|
||||||
RewriteColor::ChangeAll(colors::HOVERING),
|
RewriteColor::ChangeAll(colors::HOVERING),
|
||||||
ctx,
|
)
|
||||||
)),
|
.build(ctx, "reset to midnight", hotkey(Key::X)),
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|x| x.margin(5))
|
.map(|x| x.margin(5))
|
||||||
|
Loading…
Reference in New Issue
Block a user