diff --git a/ezgui/src/widgets/button.rs b/ezgui/src/widgets/button.rs index e1af1db860..c2b6c3fa73 100644 --- a/ezgui/src/widgets/button.rs +++ b/ezgui/src/widgets/button.rs @@ -277,11 +277,10 @@ impl Button { } // TODO Extreme wackiness. - pub fn inactive_button>(label: S, ctx: &EventCtx) -> ManagedWidget { + pub fn inactive_btn(ctx: &EventCtx, mut txt: Text) -> ManagedWidget { let horiz_padding = 15.0; let vert_padding = 8.0; - let color = Color::grey(0.5); - let txt = Text::from(Line(label).fg(color)); + txt = txt.change_fg(Color::grey(0.5)); let dims = ctx.text_dims(&txt); let mut draw = DrawBoth::new( @@ -298,4 +297,7 @@ impl Button { ])); ManagedWidget::just_draw(JustDraw::wrap(draw)).outline(2.0, Color::WHITE) } + pub fn inactive_button>(label: S, ctx: &EventCtx) -> ManagedWidget { + Button::inactive_btn(ctx, Text::from(Line(label))) + } } diff --git a/game/src/sandbox/gameplay/fix_traffic_signals.rs b/game/src/sandbox/gameplay/fix_traffic_signals.rs index 665353ad5f..51701aab69 100644 --- a/game/src/sandbox/gameplay/fix_traffic_signals.rs +++ b/game/src/sandbox/gameplay/fix_traffic_signals.rs @@ -4,7 +4,7 @@ use crate::helpers::cmp_duration_shorter; use crate::managed::{WrappedComposite, WrappedOutcome}; use crate::sandbox::gameplay::{challenge_controller, FinalScore, GameplayMode, GameplayState}; use crate::ui::UI; -use ezgui::{EventCtx, GfxCtx, Line, ManagedWidget, Text}; +use ezgui::{Button, EventCtx, GfxCtx, Line, ManagedWidget, Text}; use geom::{Duration, Statistic, Time}; use map_model::{IntersectionID, Map}; use sim::{BorderSpawnOverTime, OriginDestination, Scenario}; @@ -91,12 +91,18 @@ fn make_top_center(ctx: &mut EventCtx, ui: &UI, mode: GameplayMode) -> WrappedCo vec![ ManagedWidget::row(vec![ ManagedWidget::draw_text(ctx, txt).margin(5), - WrappedComposite::nice_text_button( - ctx, - Text::from(Line("details").size(20)), - None, - "details", - ) + // TODO Should also recalculate if the overlay changes, but this is close enough + match ui.overlay { + Overlays::FinishedTripsHistogram(_, _) => { + Button::inactive_btn(ctx, Text::from(Line("details").size(20))) + } + _ => WrappedComposite::nice_text_button( + ctx, + Text::from(Line("details").size(20)), + None, + "details", + ), + } .align_right(), ]), ManagedWidget::draw_text( @@ -106,7 +112,7 @@ fn make_top_center(ctx: &mut EventCtx, ui: &UI, mode: GameplayMode) -> WrappedCo .margin(5), ], ) - .cb( + .maybe_cb( "details", Box::new(|ctx, ui| { ui.overlay = Overlays::finished_trips_histogram(ctx, ui);