mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
make the details button in signal challenge inactivate
This commit is contained in:
parent
28dcf63c8e
commit
92c2fca55e
@ -277,11 +277,10 @@ impl Button {
|
||||
}
|
||||
|
||||
// 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 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<S: Into<String>>(label: S, ctx: &EventCtx) -> ManagedWidget {
|
||||
Button::inactive_btn(ctx, Text::from(Line(label)))
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user