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