1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
mod commuter;
mod generic_trip_table;
mod misc;
mod parking_overhead;
mod summaries;
mod table;
mod traffic_signals;
mod trip_table;
use crate::app::App;
use crate::game::Transition;
pub use commuter::CommuterPatterns;
pub use traffic_signals::TrafficSignalDemand;
pub use trip_table::FinishedTripTable;
use widgetry::{Btn, Color, EventCtx, Key, Widget};
#[derive(Clone, Copy, PartialEq)]
pub enum DashTab {
FinishedTripTable,
CancelledTripTable,
UnfinishedTripTable,
TripSummaries,
ParkingOverhead,
ActiveTraffic,
TransitRoutes,
CommuterPatterns,
TrafficSignals,
}
impl DashTab {
pub fn picker(self, ctx: &EventCtx, app: &App) -> Widget {
let mut row = Vec::new();
for (name, tab) in vec![
("trip table", DashTab::FinishedTripTable),
("trip summaries", DashTab::TripSummaries),
("parking overhead", DashTab::ParkingOverhead),
("active traffic", DashTab::ActiveTraffic),
("transit routes", DashTab::TransitRoutes),
("commuter patterns", DashTab::CommuterPatterns),
("traffic signal demand", DashTab::TrafficSignals),
] {
if tab == DashTab::TripSummaries && app.has_prebaked().is_none() {
continue;
}
if self == tab {
row.push(Btn::text_bg2(name).inactive(ctx));
} else {
row.push(Btn::text_bg2(name).build_def(ctx, None));
}
}
Widget::custom_row(vec![
Widget::custom_row(row).bg(Color::WHITE).margin_vert(16),
Btn::plaintext("X")
.build(ctx, "close", Key::Escape)
.align_right(),
])
}
pub fn transition(self, ctx: &mut EventCtx, app: &mut App, action: &str) -> Transition {
match action {
"close" => Transition::Pop,
"trip table" => Transition::Replace(FinishedTripTable::new(ctx, app)),
"trip summaries" => Transition::Replace(summaries::TripSummaries::new(
ctx,
app,
summaries::Filter::new(),
)),
"parking overhead" => {
Transition::Replace(parking_overhead::ParkingOverhead::new(ctx, app))
}
"active traffic" => Transition::Replace(misc::ActiveTraffic::new(ctx, app)),
"transit routes" => Transition::Replace(misc::TransitRoutes::new(ctx, app)),
"commuter patterns" => Transition::Replace(CommuterPatterns::new(ctx, app)),
"traffic signal demand" => Transition::Replace(TrafficSignalDemand::new(ctx, app)),
"finished trips" => Transition::Replace(FinishedTripTable::new(ctx, app)),
"cancelled trips" => Transition::Replace(trip_table::CancelledTripTable::new(ctx, app)),
"unfinished trips" => {
Transition::Replace(trip_table::UnfinishedTripTable::new(ctx, app))
}
_ => unreachable!(),
}
}
}