refactoring some UI-related colors

This commit is contained in:
Dustin Carlino 2020-02-03 11:14:17 -08:00
parent 8a2d73ae23
commit 59f2f03acb
19 changed files with 96 additions and 71 deletions

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::game::{State, Transition, WizardState}; use crate::game::{State, Transition, WizardState};
use crate::managed::{ManagedGUIState, WrappedComposite}; use crate::managed::{ManagedGUIState, WrappedComposite};
@ -139,7 +140,7 @@ pub fn challenges_picker(ctx: &mut EventCtx, ui: &UI) -> Box<dyn State> {
flex_row.push(ManagedWidget::btn(Button::text_bg( flex_row.push(ManagedWidget::btn(Button::text_bg(
Text::from(Line(&name).size(40).fg(Color::BLACK)), Text::from(Line(&name).size(40).fg(Color::BLACK)),
Color::WHITE, Color::WHITE,
Color::ORANGE, colors::HOVERING,
hotkey(Key::NUM_KEYS[idx]), hotkey(Key::NUM_KEYS[idx]),
&name, &name,
ctx, ctx,

9
game/src/colors.rs Normal file
View File

@ -0,0 +1,9 @@
// TODO Still can't decide how to arrange colorschemes. Trying this out.
//before: 256
use ezgui::Color;
pub const HOVERING: Color = Color::ORANGE;
pub const PANEL_BG: Color = Color::grey(0.4);
pub const SECTION_BG: Color = Color::grey(0.5);

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::managed::WrappedComposite; use crate::managed::WrappedComposite;
use crate::render::MIN_ZOOM_FOR_DETAIL; use crate::render::MIN_ZOOM_FOR_DETAIL;
use crate::ui::UI; use crate::ui::UI;
@ -144,7 +145,7 @@ impl ColorerBuilder {
for (label, color) in self.prioritized_colors { for (label, color) in self.prioritized_colors {
col.push(ColorLegend::row(ctx, color, label)); col.push(ColorLegend::row(ctx, color, label));
} }
let legend = Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) let legend = Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx); .build(ctx);

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::{ColorLegend, CommonState, Warping}; use crate::common::{ColorLegend, CommonState, Warping};
use crate::game::{msg, Transition}; use crate::game::{msg, Transition};
use crate::helpers::{rotating_color, rotating_color_map, ID}; use crate::helpers::{rotating_color, rotating_color_map, ID};
@ -55,7 +56,7 @@ impl InfoPanel {
"assets/tools/locate.svg", "assets/tools/locate.svg",
"jump to object", "jump to object",
hotkey(Key::J), hotkey(Key::J),
RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
ctx, ctx,
)), )),
WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(), WrappedComposite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
@ -67,8 +68,8 @@ impl InfoPanel {
txt.append(Line(format!(" - {}", label))); txt.append(Line(format!(" - {}", label)));
col.push(ManagedWidget::btn(Button::text_bg( col.push(ManagedWidget::btn(Button::text_bg(
txt, txt,
Color::grey(0.5), colors::SECTION_BG,
Color::ORANGE, colors::HOVERING,
hotkey(*key), hotkey(*key),
label, label,
ctx, ctx,
@ -146,7 +147,7 @@ impl InfoPanel {
actions, actions,
trip_details, trip_details,
time: ui.primary.sim.time(), time: ui.primary.sim.time(),
composite: Composite::new(ManagedWidget::col(col).bg(Color::grey(0.3))) composite: Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned( .aligned(
HorizontalAlignment::Percent(0.02), HorizontalAlignment::Percent(0.02),
VerticalAlignment::Percent(0.2), VerticalAlignment::Percent(0.2),
@ -298,7 +299,7 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec<ManagedWidget> {
ctx, ctx,
Text::from(Line("throughput in 20 minute buckets (entire road)")), Text::from(Line("throughput in 20 minute buckets (entire road)")),
) )
.bg(Color::grey(0.5)), .bg(colors::SECTION_BG),
); );
rows.push( rows.push(
road_throughput( road_throughput(
@ -307,7 +308,7 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec<ManagedWidget> {
ctx, ctx,
ui, ui,
) )
.bg(Color::grey(0.5)) .bg(colors::SECTION_BG)
.margin(10), .margin(10),
); );
} }
@ -345,21 +346,21 @@ fn info_for(id: ID, ctx: &EventCtx, ui: &UI) -> Vec<ManagedWidget> {
if ui.primary.map.get_i(id).is_traffic_signal() { if ui.primary.map.get_i(id).is_traffic_signal() {
rows.push( rows.push(
ManagedWidget::draw_text(ctx, Text::from(Line("delay in 20 minute buckets"))) ManagedWidget::draw_text(ctx, Text::from(Line("delay in 20 minute buckets")))
.bg(Color::grey(0.5)), .bg(colors::SECTION_BG),
); );
rows.push( rows.push(
intersection_delay(id, Duration::minutes(20), ctx, ui) intersection_delay(id, Duration::minutes(20), ctx, ui)
.bg(Color::grey(0.5)) .bg(colors::SECTION_BG)
.margin(10), .margin(10),
); );
} }
rows.push( rows.push(
ManagedWidget::draw_text(ctx, Text::from(Line("throughput in 20 minute buckets"))) ManagedWidget::draw_text(ctx, Text::from(Line("throughput in 20 minute buckets")))
.bg(Color::grey(0.5)), .bg(colors::SECTION_BG),
); );
rows.push( rows.push(
intersection_throughput(id, Duration::minutes(20), ctx, ui) intersection_throughput(id, Duration::minutes(20), ctx, ui)
.bg(Color::grey(0.5)) .bg(colors::SECTION_BG)
.margin(10), .margin(10),
); );
} }

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::{navigate, shortcuts, Overlays, Warping}; use crate::common::{navigate, shortcuts, Overlays, Warping};
use crate::game::{Transition, WizardState}; use crate::game::{Transition, WizardState};
use crate::managed::WrappedComposite; use crate::managed::WrappedComposite;
@ -277,7 +278,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
"assets/speed/speed_up.svg", "assets/speed/speed_up.svg",
"zoom in", "zoom in",
None, None,
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
))]; ))];
for i in (0..=3).rev() { for i in (0..=3).rev() {
@ -295,7 +296,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
), ),
DrawBoth::new( DrawBoth::new(
ctx, ctx,
GeomBatch::from(vec![(Color::ORANGE, rect.clone())]), GeomBatch::from(vec![(colors::HOVERING, rect.clone())]),
Vec::new(), Vec::new(),
), ),
None, None,
@ -307,7 +308,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
"assets/speed/slow_down.svg", "assets/speed/slow_down.svg",
"zoom out", "zoom out",
None, None,
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
))); )));
@ -339,7 +340,7 @@ fn make_minimap_panel(ctx: &mut EventCtx, acs: &AgentColorScheme, zoom_lvl: usiz
]) ])
.centered(), .centered(),
]) ])
.bg(Color::grey(0.5)), .bg(colors::PANEL_BG),
) )
.aligned( .aligned(
HorizontalAlignment::Right, HorizontalAlignment::Right,
@ -411,7 +412,7 @@ fn make_viz_panel(ctx: &mut EventCtx, acs: &AgentColorScheme) -> ManagedWidget {
} else { } else {
RewriteColor::ChangeAll(Color::WHITE.alpha(0.5)) RewriteColor::ChangeAll(Color::WHITE.alpha(0.5))
}, },
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)) ))
.margin(3), .margin(3),
@ -441,5 +442,5 @@ fn make_viz_panel(ctx: &mut EventCtx, acs: &AgentColorScheme) -> ManagedWidget {
.centered_cross(), .centered_cross(),
); );
} }
ManagedWidget::col(col).bg(Color::grey(0.4)) ManagedWidget::col(col).bg(colors::PANEL_BG)
} }

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::{ColorLegend, Colorer, ShowBusRoute, Warping}; use crate::common::{ColorLegend, Colorer, ShowBusRoute, Warping};
use crate::game::Transition; use crate::game::Transition;
use crate::helpers::rotating_color_total; use crate::helpers::rotating_color_total;
@ -224,35 +225,35 @@ impl Overlays {
"assets/layers/parking_avail.svg", "assets/layers/parking_avail.svg",
"parking availability", "parking availability",
hotkey(Key::P), hotkey(Key::P),
RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
ctx, ctx,
)), )),
ManagedWidget::btn(Button::rectangle_svg( ManagedWidget::btn(Button::rectangle_svg(
"assets/layers/intersection_delay.svg", "assets/layers/intersection_delay.svg",
"intersection delay", "intersection delay",
hotkey(Key::I), hotkey(Key::I),
RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
ctx, ctx,
)), )),
ManagedWidget::btn(Button::rectangle_svg( ManagedWidget::btn(Button::rectangle_svg(
"assets/layers/throughput.svg", "assets/layers/throughput.svg",
"throughput", "throughput",
hotkey(Key::T), hotkey(Key::T),
RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
ctx, ctx,
)), )),
ManagedWidget::btn(Button::rectangle_svg( ManagedWidget::btn(Button::rectangle_svg(
"assets/layers/bike_network.svg", "assets/layers/bike_network.svg",
"bike network", "bike network",
hotkey(Key::B), hotkey(Key::B),
RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
ctx, ctx,
)), )),
ManagedWidget::btn(Button::rectangle_svg( ManagedWidget::btn(Button::rectangle_svg(
"assets/layers/bus_network.svg", "assets/layers/bus_network.svg",
"bus network", "bus network",
hotkey(Key::U), hotkey(Key::U),
RewriteColor::Change(Color::hex("#F2F2F2"), Color::ORANGE), RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING),
ctx, ctx,
)), )),
]; ];
@ -306,7 +307,7 @@ impl Overlays {
]), ]),
ManagedWidget::row(choices).flex_wrap(ctx, 20), ManagedWidget::row(choices).flex_wrap(ctx, 20),
]) ])
.bg(Color::hex("#5B5B5B")), .bg(colors::PANEL_BG),
) )
.max_size_percent(30, 50) .max_size_percent(30, 50)
.build(ctx), .build(ctx),
@ -595,7 +596,7 @@ impl Overlays {
ctx, ctx,
), ),
]) ])
.bg(Color::grey(0.4)), .bg(colors::PANEL_BG),
) )
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx), .build(ctx),
@ -637,7 +638,7 @@ impl Overlays {
"assets/tools/locate.svg", "assets/tools/locate.svg",
"intersection demand", "intersection demand",
None, None,
RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
ctx, ctx,
)), )),
WrappedComposite::text_button(ctx, "X", None).align_right(), WrappedComposite::text_button(ctx, "X", None).align_right(),
@ -648,7 +649,7 @@ impl Overlays {
ui.primary.sim.time(), ui.primary.sim.time(),
i, i,
batch.upload(ctx), batch.upload(ctx),
Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx), .build(ctx),
) )
@ -678,7 +679,7 @@ impl Overlays {
"assets/tools/locate.svg", "assets/tools/locate.svg",
&format!("Stop {}", idx + 1), &format!("Stop {}", idx + 1),
None, None,
RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE), RewriteColor::Change(Color::hex("#CC4121"), colors::HOVERING),
ctx, ctx,
)), )),
]; ];
@ -729,7 +730,7 @@ impl Overlays {
])); ]));
let mut c = WrappedComposite::new( let mut c = WrappedComposite::new(
Composite::new(ManagedWidget::col(master_col).bg(Color::grey(0.4))) Composite::new(ManagedWidget::col(master_col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
.build(ctx), .build(ctx),
); );
@ -788,7 +789,7 @@ impl Overlays {
]), ]),
Plot::new_duration(series, ctx).margin(10), Plot::new_duration(series, ctx).margin(10),
]) ])
.bg(Color::grey(0.3)), .bg(colors::PANEL_BG),
) )
// TODO Doesn't fit // TODO Doesn't fit
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center) .aligned(HorizontalAlignment::Right, VerticalAlignment::Center)

View File

@ -1,9 +1,10 @@
use crate::colors;
use crate::game::Transition; use crate::game::Transition;
use crate::managed::WrappedComposite; use crate::managed::WrappedComposite;
use crate::options; use crate::options;
use ezgui::{ use ezgui::{
hotkey, Button, Color, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, hotkey, Button, Composite, EventCtx, HorizontalAlignment, Key, ManagedWidget, RewriteColor,
RewriteColor, VerticalAlignment, VerticalAlignment,
}; };
pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite { pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite {
@ -14,7 +15,7 @@ pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite {
"assets/tools/home.svg", "assets/tools/home.svg",
"back", "back",
hotkey(Key::Escape), hotkey(Key::Escape),
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)) ))
.margin(10), .margin(10),
@ -22,13 +23,13 @@ pub fn tool_panel(ctx: &mut EventCtx) -> WrappedComposite {
"assets/tools/settings.svg", "assets/tools/settings.svg",
"settings", "settings",
None, None,
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)) ))
.margin(10), .margin(10),
]; ];
WrappedComposite::new( WrappedComposite::new(
Composite::new(ManagedWidget::row(row).bg(Color::grey(0.4))) Composite::new(ManagedWidget::row(row).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Left, VerticalAlignment::BottomAboveOSD) .aligned(HorizontalAlignment::Left, VerticalAlignment::BottomAboveOSD)
.build(ctx), .build(ctx),
) )

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::game::{State, Transition}; use crate::game::{State, Transition};
use crate::helpers::plain_list_names; use crate::helpers::plain_list_names;
use crate::helpers::ID; use crate::helpers::ID;
@ -334,7 +335,7 @@ fn make_diagram(i: IntersectionID, selected: usize, ui: &UI, ctx: &mut EventCtx)
); );
} }
Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454"))) Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
.max_size_percent(30, 90) .max_size_percent(30, 90)
.build(ctx) .build(ctx)

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::Colorer; use crate::common::Colorer;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::game::{msg, State, Transition, WizardState}; use crate::game::{msg, State, Transition, WizardState};
@ -220,7 +221,7 @@ fn make_brush_panel(ctx: &mut EventCtx, brush: Brush) -> Composite {
} else { } else {
RewriteColor::NoOp RewriteColor::NoOp
}, },
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
))]) ))])
.padding(5), .padding(5),
@ -231,7 +232,7 @@ fn make_brush_panel(ctx: &mut EventCtx, brush: Brush) -> Composite {
ManagedWidget::draw_text(ctx, Text::from(Line("Modify lanes"))).centered_horiz(), ManagedWidget::draw_text(ctx, Text::from(Line("Modify lanes"))).centered_horiz(),
ManagedWidget::row(row).centered(), ManagedWidget::row(row).centered(),
]) ])
.bg(Color::hex("#4C4C4C")) .bg(colors::PANEL_BG)
.padding(10), .padding(10),
) )
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top)

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::CommonState; use crate::common::CommonState;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::game::{msg, State, Transition, WizardState}; use crate::game::{msg, State, Transition, WizardState};
@ -389,7 +390,7 @@ fn make_top_panel(can_undo: bool, can_redo: bool, ctx: &mut EventCtx) -> Composi
}) })
.margin(15), .margin(15),
]; ];
Composite::new(ManagedWidget::row(row).bg(Color::hex("#545454"))) Composite::new(ManagedWidget::row(row).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx) .build(ctx)
} }
@ -565,7 +566,7 @@ fn make_diagram(i: IntersectionID, selected: usize, ui: &UI, ctx: &mut EventCtx)
); );
} }
Composite::new(ManagedWidget::col(col).bg(Color::hex("#545454"))) Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
.max_size_percent(30, 90) .max_size_percent(30, 90)
.build(ctx) .build(ctx)

View File

@ -1,5 +1,6 @@
mod abtest; mod abtest;
mod challenges; mod challenges;
mod colors;
mod common; mod common;
mod debug; mod debug;
mod edit; mod edit;

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::CommonState; use crate::common::CommonState;
use crate::game::{State, Transition}; use crate::game::{State, Transition};
use crate::ui::UI; use crate::ui::UI;
@ -68,7 +69,7 @@ impl WrappedComposite {
filename, filename,
tooltip, tooltip,
hotkey, hotkey,
RewriteColor::Change(Color::WHITE, Color::ORANGE), RewriteColor::Change(Color::WHITE, colors::HOVERING),
ctx, ctx,
)) ))
} }
@ -81,7 +82,7 @@ impl WrappedComposite {
) -> ManagedWidget { ) -> ManagedWidget {
ManagedWidget::btn(Button::text_no_bg( ManagedWidget::btn(Button::text_no_bg(
txt.clone(), txt.clone(),
txt.change_fg(Color::ORANGE), txt.change_fg(colors::HOVERING),
hotkey, hotkey,
label, label,
true, true,
@ -98,7 +99,7 @@ impl WrappedComposite {
ManagedWidget::btn(Button::text_bg( ManagedWidget::btn(Button::text_bg(
Text::from(Line(label).fg(Color::BLACK)), Text::from(Line(label).fg(Color::BLACK)),
Color::WHITE, Color::WHITE,
Color::ORANGE, colors::HOVERING,
hotkey, hotkey,
label, label,
ctx, ctx,

View File

@ -1,5 +1,6 @@
use crate::abtest::setup::PickABTest; use crate::abtest::setup::PickABTest;
use crate::challenges::challenges_picker; use crate::challenges::challenges_picker;
use crate::colors;
use crate::game::{State, Transition}; use crate::game::{State, Transition};
use crate::managed::{ManagedGUIState, WrappedComposite, WrappedOutcome}; use crate::managed::{ManagedGUIState, WrappedComposite, WrappedOutcome};
use crate::mission::MissionEditMode; use crate::mission::MissionEditMode;
@ -35,7 +36,7 @@ impl TitleScreen {
ManagedWidget::btn(Button::text_bg( ManagedWidget::btn(Button::text_bg(
Text::from(Line("PLAY")), Text::from(Line("PLAY")),
Color::BLUE, Color::BLUE,
Color::ORANGE, colors::HOVERING,
hotkey(Key::Space), hotkey(Key::Space),
"start game", "start game",
ctx, ctx,

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::ShowBusRoute; use crate::common::ShowBusRoute;
use crate::game::{State, Transition}; use crate::game::{State, Transition};
use crate::helpers::ID; use crate::helpers::ID;
@ -59,7 +60,7 @@ pub fn make(ctx: &mut EventCtx, ui: &UI, tab: Tab) -> Box<dyn State> {
Composite::new(ManagedWidget::col(vec![ Composite::new(ManagedWidget::col(vec![
ManagedWidget::row(tabs) ManagedWidget::row(tabs)
.evenly_spaced() .evenly_spaced()
.bg(Color::grey(0.6)) .bg(colors::PANEL_BG)
.padding(10), .padding(10),
content, content,
])) ]))
@ -151,7 +152,7 @@ fn finished_trips_summary_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget {
// TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that! // TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that!
ManagedWidget::col(vec![ ManagedWidget::col(vec![
ManagedWidget::draw_text(ctx, txt), ManagedWidget::draw_text(ctx, txt),
finished_trips_plot(ctx, ui).bg(Color::grey(0.3)), finished_trips_plot(ctx, ui).bg(colors::SECTION_BG),
ManagedWidget::draw_text( ManagedWidget::draw_text(
ctx, ctx,
Text::from(Line( Text::from(Line(
@ -165,7 +166,7 @@ fn finished_trips_summary_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget {
.finished_trip_deltas(ui.primary.sim.time(), ui.prebaked()), .finished_trip_deltas(ui.primary.sim.time(), ui.prebaked()),
ctx, ctx,
) )
.bg(Color::grey(0.3)), .bg(colors::SECTION_BG),
]) ])
} }
@ -213,7 +214,7 @@ fn finished_trips_summary_not_prebaked(ctx: &EventCtx, ui: &UI) -> ManagedWidget
// TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that! // TODO The x-axes for the plot and histogram get stretched to the full screen. Don't do that!
ManagedWidget::col(vec![ ManagedWidget::col(vec![
ManagedWidget::draw_text(ctx, txt), ManagedWidget::draw_text(ctx, txt),
finished_trips_plot(ctx, ui).bg(Color::grey(0.3)), finished_trips_plot(ctx, ui).bg(colors::SECTION_BG),
]) ])
} }

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::game::{State, Transition, WizardState}; use crate::game::{State, Transition, WizardState};
use crate::helpers::{nice_map_name, ID}; use crate::helpers::{nice_map_name, ID};
@ -114,7 +115,7 @@ pub fn freeform_controller(
.margin(5), .margin(5),
]) ])
.centered() .centered()
.bg(Color::grey(0.4)), .bg(colors::PANEL_BG),
) )
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx), .build(ctx),

View File

@ -10,6 +10,7 @@ mod tutorial;
pub use self::tutorial::{Tutorial, TutorialState}; pub use self::tutorial::{Tutorial, TutorialState};
use crate::challenges; use crate::challenges;
use crate::challenges::challenges_picker; use crate::challenges::challenges_picker;
use crate::colors;
use crate::common::{CommonState, Overlays}; use crate::common::{CommonState, Overlays};
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::game::{msg, State, Transition}; use crate::game::{msg, State, Transition};
@ -312,7 +313,7 @@ fn challenge_controller(
rows.extend(extra_rows); rows.extend(extra_rows);
WrappedComposite::new( WrappedComposite::new(
Composite::new(ManagedWidget::col(rows).bg(Color::grey(0.4))) Composite::new(ManagedWidget::col(rows).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx), .build(ctx),
) )
@ -352,7 +353,7 @@ impl FinalScore {
]) ])
.centered(), .centered(),
]) ])
.bg(Color::grey(0.4)) .bg(colors::PANEL_BG)
.outline(10.0, Color::WHITE) .outline(10.0, Color::WHITE)
.padding(10), .padding(10),
) )

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::common::{tool_panel, Minimap, Overlays, Warping}; use crate::common::{tool_panel, Minimap, Overlays, Warping};
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::game::{msg, Transition}; use crate::game::{msg, Transition};
@ -690,7 +691,7 @@ impl TutorialState {
); );
} }
Composite::new(ManagedWidget::col(col).bg(Color::grey(0.4))) Composite::new(ManagedWidget::col(col).bg(colors::PANEL_BG))
.aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top)
.build(ctx) .build(ctx)
} }
@ -742,7 +743,7 @@ impl TutorialState {
WrappedComposite::text_button(ctx, "OK", hotkey(Key::Enter)) WrappedComposite::text_button(ctx, "OK", hotkey(Key::Enter))
.centered_horiz(), .centered_horiz(),
]) ])
.bg(Color::grey(0.4)) .bg(colors::PANEL_BG)
.outline(5.0, Color::WHITE) .outline(5.0, Color::WHITE)
.padding(5), .padding(5),
) )

View File

@ -2,6 +2,7 @@ mod dashboards;
mod gameplay; mod gameplay;
mod speed; mod speed;
use crate::colors;
use crate::common::{tool_panel, CommonState, Minimap, Overlays, ShowBusRoute}; use crate::common::{tool_panel, CommonState, Minimap, Overlays, ShowBusRoute};
use crate::debug::DebugMode; use crate::debug::DebugMode;
use crate::edit::{apply_map_edits, save_edits, EditMode, StopSignEditor, TrafficSignalEditor}; use crate::edit::{apply_map_edits, save_edits, EditMode, StopSignEditor, TrafficSignalEditor};
@ -14,8 +15,8 @@ use crate::sandbox::gameplay::Tutorial;
pub use crate::sandbox::gameplay::TutorialState; pub use crate::sandbox::gameplay::TutorialState;
use crate::ui::{ShowEverything, UI}; use crate::ui::{ShowEverything, UI};
use ezgui::{ use ezgui::{
hotkey, lctrl, Choice, Color, Composite, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, hotkey, lctrl, Choice, Composite, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key,
Key, Line, ManagedWidget, Outcome, Text, VerticalAlignment, Wizard, Line, ManagedWidget, Outcome, Text, VerticalAlignment, Wizard,
}; };
pub use gameplay::spawner::spawn_agents_around; pub use gameplay::spawner::spawn_agents_around;
pub use gameplay::GameplayMode; pub use gameplay::GameplayMode;
@ -368,7 +369,7 @@ impl AgentMeter {
// TODO The SVG button uses clip and doesn't seem to work // TODO The SVG button uses clip and doesn't seem to work
WrappedComposite::text_button(ctx, "view finished trip data", hotkey(Key::Q)), WrappedComposite::text_button(ctx, "view finished trip data", hotkey(Key::Q)),
]) ])
.bg(Color::grey(0.4)) .bg(colors::PANEL_BG)
.padding(20), .padding(20),
) )
.aligned(HorizontalAlignment::Right, VerticalAlignment::Top) .aligned(HorizontalAlignment::Right, VerticalAlignment::Top)

View File

@ -1,3 +1,4 @@
use crate::colors;
use crate::game::{State, Transition, WizardState}; use crate::game::{State, Transition, WizardState};
use crate::managed::{WrappedComposite, WrappedOutcome}; use crate::managed::{WrappedComposite, WrappedOutcome};
use crate::ui::UI; use crate::ui::UI;
@ -29,8 +30,6 @@ enum SpeedSetting {
impl SpeedControls { 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 bg = Color::hex("#7C7C7C");
let mut row = Vec::new(); let mut row = Vec::new();
row.push( row.push(
ManagedWidget::btn(if paused { ManagedWidget::btn(if paused {
@ -38,7 +37,7 @@ impl SpeedControls {
"assets/speed/triangle.svg", "assets/speed/triangle.svg",
"play", "play",
hotkey(Key::Space), hotkey(Key::Space),
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
) )
} else { } else {
@ -46,13 +45,13 @@ impl SpeedControls {
"assets/speed/pause.svg", "assets/speed/pause.svg",
"pause", "pause",
hotkey(Key::Space), hotkey(Key::Space),
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
) )
}) })
.margin(5) .margin(5)
.centered_vert() .centered_vert()
.bg(bg), .bg(colors::SECTION_BG),
); );
row.push( row.push(
@ -74,14 +73,14 @@ impl SpeedControls {
} else { } else {
RewriteColor::ChangeAll(Color::WHITE.alpha(0.2)) RewriteColor::ChangeAll(Color::WHITE.alpha(0.2))
}, },
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)) ))
.margin(5) .margin(5)
}) })
.collect(), .collect(),
) )
.bg(bg) .bg(colors::SECTION_BG)
.centered(), .centered(),
); );
@ -90,7 +89,7 @@ impl SpeedControls {
vec![ vec![
ManagedWidget::btn(Button::text_no_bg( ManagedWidget::btn(Button::text_no_bg(
Text::from(Line("+0.1s").fg(Color::WHITE).size(21).roboto()), Text::from(Line("+0.1s").fg(Color::WHITE).size(21).roboto()),
Text::from(Line("+0.1s").fg(Color::ORANGE).size(21).roboto()), Text::from(Line("+0.1s").fg(colors::HOVERING).size(21).roboto()),
hotkey(Key::M), hotkey(Key::M),
"step forwards 0.1 seconds", "step forwards 0.1 seconds",
false, false,
@ -98,7 +97,7 @@ impl SpeedControls {
)), )),
ManagedWidget::btn(Button::text_no_bg( ManagedWidget::btn(Button::text_no_bg(
Text::from(Line("+1h").fg(Color::WHITE).size(21).roboto()), Text::from(Line("+1h").fg(Color::WHITE).size(21).roboto()),
Text::from(Line("+1h").fg(Color::ORANGE).size(21).roboto()), Text::from(Line("+1h").fg(colors::HOVERING).size(21).roboto()),
hotkey(Key::N), hotkey(Key::N),
"step forwards 1 hour", "step forwards 1 hour",
false, false,
@ -108,14 +107,14 @@ impl SpeedControls {
"assets/speed/jump_to_time.svg", "assets/speed/jump_to_time.svg",
"jump to specific time", "jump to specific time",
hotkey(Key::B), hotkey(Key::B),
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)), )),
ManagedWidget::btn(Button::rectangle_svg( ManagedWidget::btn(Button::rectangle_svg(
"assets/speed/reset.svg", "assets/speed/reset.svg",
"reset to midnight", "reset to midnight",
hotkey(Key::X), hotkey(Key::X),
RewriteColor::ChangeAll(Color::ORANGE), RewriteColor::ChangeAll(colors::HOVERING),
ctx, ctx,
)), )),
] ]
@ -123,14 +122,14 @@ impl SpeedControls {
.map(|x| x.margin(5)) .map(|x| x.margin(5))
.collect(), .collect(),
) )
.bg(bg) .bg(colors::SECTION_BG)
.centered(), .centered(),
); );
WrappedComposite::new( WrappedComposite::new(
Composite::new( Composite::new(
ManagedWidget::row(row.into_iter().map(|x| x.margin(5)).collect()) ManagedWidget::row(row.into_iter().map(|x| x.margin(5)).collect())
.bg(Color::hex("#4C4C4C")), .bg(colors::PANEL_BG),
) )
.aligned( .aligned(
HorizontalAlignment::Center, HorizontalAlignment::Center,
@ -395,7 +394,7 @@ impl TimePanel {
batch.push(Color::WHITE, Polygon::rectangle(width, height)); batch.push(Color::WHITE, Polygon::rectangle(width, height));
if percent != 0.0 { if percent != 0.0 {
batch.push( batch.push(
Color::grey(0.5), colors::SECTION_BG,
Polygon::rectangle(percent * width, height), Polygon::rectangle(percent * width, height),
); );
} }
@ -412,7 +411,7 @@ impl TimePanel {
.evenly_spaced(), .evenly_spaced(),
]) ])
.padding(10) .padding(10)
.bg(Color::hex("#4C4C4C")), .bg(colors::PANEL_BG),
) )
.aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
.build(ctx), .build(ctx),