mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Only enable controls when they do something
This commit is contained in:
parent
3493c834af
commit
871cbf7ecf
@ -70,6 +70,10 @@ impl SavedTrips {
|
||||
}
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
self.trips.len()
|
||||
}
|
||||
|
||||
fn new_name(&self) -> String {
|
||||
let mut i = self.trips.len() + 1;
|
||||
loop {
|
||||
@ -110,19 +114,24 @@ impl TripManagement {
|
||||
ctx.style()
|
||||
.btn_plain_destructive
|
||||
.icon_text("system/assets/tools/trash.svg", "Delete")
|
||||
.disabled(self.current.waypoints.len() == 0)
|
||||
.build_def(ctx),
|
||||
]),
|
||||
Widget::row(vec![
|
||||
ctx.style().btn_plain.text("Start new trip").build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.text("Start new trip")
|
||||
.disabled(self.current.waypoints.len() == 0)
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_prev()
|
||||
.hotkey(Key::LeftArrow)
|
||||
.disabled(self.all.prev(current_name).is_none())
|
||||
.build_widget(ctx, "previous trip"),
|
||||
// TODO Autosave first?
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.text("Load another trip")
|
||||
.disabled(self.all.len() < 2)
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_next()
|
||||
|
Loading…
Reference in New Issue
Block a user