make the details button in signal challenge inactivate

This commit is contained in:
Dustin Carlino 2020-02-03 12:01:13 -08:00
parent 28dcf63c8e
commit 92c2fca55e
2 changed files with 19 additions and 11 deletions

View File

@ -277,11 +277,10 @@ impl Button {
} }
// TODO Extreme wackiness. // TODO Extreme wackiness.
pub fn inactive_button<S: Into<String>>(label: S, ctx: &EventCtx) -> ManagedWidget { pub fn inactive_btn(ctx: &EventCtx, mut txt: Text) -> ManagedWidget {
let horiz_padding = 15.0; let horiz_padding = 15.0;
let vert_padding = 8.0; let vert_padding = 8.0;
let color = Color::grey(0.5); txt = txt.change_fg(Color::grey(0.5));
let txt = Text::from(Line(label).fg(color));
let dims = ctx.text_dims(&txt); let dims = ctx.text_dims(&txt);
let mut draw = DrawBoth::new( let mut draw = DrawBoth::new(
@ -298,4 +297,7 @@ impl Button {
])); ]));
ManagedWidget::just_draw(JustDraw::wrap(draw)).outline(2.0, Color::WHITE) ManagedWidget::just_draw(JustDraw::wrap(draw)).outline(2.0, Color::WHITE)
} }
pub fn inactive_button<S: Into<String>>(label: S, ctx: &EventCtx) -> ManagedWidget {
Button::inactive_btn(ctx, Text::from(Line(label)))
}
} }

View File

@ -4,7 +4,7 @@ use crate::helpers::cmp_duration_shorter;
use crate::managed::{WrappedComposite, WrappedOutcome}; use crate::managed::{WrappedComposite, WrappedOutcome};
use crate::sandbox::gameplay::{challenge_controller, FinalScore, GameplayMode, GameplayState}; use crate::sandbox::gameplay::{challenge_controller, FinalScore, GameplayMode, GameplayState};
use crate::ui::UI; 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 geom::{Duration, Statistic, Time};
use map_model::{IntersectionID, Map}; use map_model::{IntersectionID, Map};
use sim::{BorderSpawnOverTime, OriginDestination, Scenario}; use sim::{BorderSpawnOverTime, OriginDestination, Scenario};
@ -91,12 +91,18 @@ fn make_top_center(ctx: &mut EventCtx, ui: &UI, mode: GameplayMode) -> WrappedCo
vec![ vec![
ManagedWidget::row(vec![ ManagedWidget::row(vec![
ManagedWidget::draw_text(ctx, txt).margin(5), ManagedWidget::draw_text(ctx, txt).margin(5),
WrappedComposite::nice_text_button( // 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, ctx,
Text::from(Line("details").size(20)), Text::from(Line("details").size(20)),
None, None,
"details", "details",
) ),
}
.align_right(), .align_right(),
]), ]),
ManagedWidget::draw_text( ManagedWidget::draw_text(
@ -106,7 +112,7 @@ fn make_top_center(ctx: &mut EventCtx, ui: &UI, mode: GameplayMode) -> WrappedCo
.margin(5), .margin(5),
], ],
) )
.cb( .maybe_cb(
"details", "details",
Box::new(|ctx, ui| { Box::new(|ctx, ui| {
ui.overlay = Overlays::finished_trips_histogram(ctx, ui); ui.overlay = Overlays::finished_trips_histogram(ctx, ui);