mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
small tweaks after a quick round of UX testing: [rebuild]
- flip order of +.1s, +1h buttons to match qwerty keybindings - arrow keys for changing speed - escape key applies to info panels first - click out of some Composites to cancel them
This commit is contained in:
parent
1268890b75
commit
bba71844fd
@ -904,6 +904,11 @@ impl Composite {
|
||||
|
||||
self.recompute_layout(ctx, true);
|
||||
}
|
||||
|
||||
pub fn clicked_outside(&self, ctx: &mut EventCtx) -> bool {
|
||||
// TODO No great way to populate OSD from here with "click to cancel"
|
||||
!self.top_level.rect.contains(ctx.canvas.get_cursor()) && ctx.normal_left_click()
|
||||
}
|
||||
}
|
||||
|
||||
impl CompositeBuilder {
|
||||
|
@ -130,13 +130,19 @@ impl ManagedGUIState {
|
||||
impl State for ManagedGUIState {
|
||||
fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> Transition {
|
||||
match self.composite.event(ctx, ui) {
|
||||
Some(WrappedOutcome::Transition(t)) => t,
|
||||
Some(WrappedOutcome::Transition(t)) => {
|
||||
return t;
|
||||
}
|
||||
Some(WrappedOutcome::Clicked(x)) => panic!(
|
||||
"Can't have a button {} without a callback in ManagedGUIState",
|
||||
x
|
||||
),
|
||||
None => Transition::Keep,
|
||||
None => {}
|
||||
}
|
||||
if !self.fullscreen && self.composite.inner.clicked_outside(ctx) {
|
||||
return Transition::Pop;
|
||||
}
|
||||
Transition::Keep
|
||||
}
|
||||
|
||||
fn draw_baselayer(&self) -> DrawBaselayer {
|
||||
|
@ -214,6 +214,15 @@ impl State for SandboxMode {
|
||||
}
|
||||
}
|
||||
|
||||
// Fragile ordering. Don't call this before all the per_obj actions have been called. But
|
||||
// also let this work before tool_panel, so Key::Escape from the info panel beats the one
|
||||
// to quit.
|
||||
if let Some(ref mut c) = self.common {
|
||||
if let Some(t) = c.event(ctx, ui, self.controls.speed.as_mut()) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref mut tp) = self.controls.time_panel {
|
||||
tp.event(ctx, ui);
|
||||
}
|
||||
@ -244,12 +253,6 @@ impl State for SandboxMode {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref mut c) = self.common {
|
||||
if let Some(t) = c.event(ctx, ui, self.controls.speed.as_mut()) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
if self
|
||||
.controls
|
||||
.speed
|
||||
|
@ -67,9 +67,9 @@ impl SpeedControls {
|
||||
.into_iter()
|
||||
.map(|(s, label)| {
|
||||
let mut tooltip = Text::from(Line(label).size(20)).with_bg();
|
||||
tooltip.add(Line("[").fg(Color::GREEN).size(20));
|
||||
tooltip.add(Line(Key::LeftArrow.describe()).fg(Color::GREEN).size(20));
|
||||
tooltip.append(Line(" - slow down"));
|
||||
tooltip.add(Line("]").fg(Color::GREEN).size(20));
|
||||
tooltip.add(Line(Key::RightArrow.describe()).fg(Color::GREEN).size(20));
|
||||
tooltip.append(Line(" - speed up"));
|
||||
|
||||
ManagedWidget::btn(
|
||||
@ -98,14 +98,6 @@ impl SpeedControls {
|
||||
row.push(
|
||||
ManagedWidget::row(
|
||||
vec![
|
||||
ManagedWidget::btn(Button::text_no_bg(
|
||||
Text::from(Line("+0.1s").fg(Color::WHITE).size(21).roboto()),
|
||||
Text::from(Line("+0.1s").fg(colors::HOVERING).size(21).roboto()),
|
||||
hotkey(Key::M),
|
||||
"step forwards 0.1 seconds",
|
||||
false,
|
||||
ctx,
|
||||
)),
|
||||
ManagedWidget::btn(Button::text_no_bg(
|
||||
Text::from(Line("+1h").fg(Color::WHITE).size(21).roboto()),
|
||||
Text::from(Line("+1h").fg(colors::HOVERING).size(21).roboto()),
|
||||
@ -114,6 +106,14 @@ impl SpeedControls {
|
||||
false,
|
||||
ctx,
|
||||
)),
|
||||
ManagedWidget::btn(Button::text_no_bg(
|
||||
Text::from(Line("+0.1s").fg(Color::WHITE).size(21).roboto()),
|
||||
Text::from(Line("+0.1s").fg(colors::HOVERING).size(21).roboto()),
|
||||
hotkey(Key::M),
|
||||
"step forwards 0.1 seconds",
|
||||
false,
|
||||
ctx,
|
||||
)),
|
||||
ManagedWidget::btn(Button::rectangle_svg(
|
||||
"../data/system/assets/speed/jump_to_time.svg",
|
||||
"jump to specific time",
|
||||
@ -245,8 +245,7 @@ impl SpeedControls {
|
||||
None => {}
|
||||
}
|
||||
|
||||
// TODO How to communicate these keys?
|
||||
if ctx.input.new_was_pressed(hotkey(Key::LeftBracket).unwrap()) {
|
||||
if ctx.input.new_was_pressed(hotkey(Key::LeftArrow).unwrap()) {
|
||||
match self.setting {
|
||||
SpeedSetting::Realtime => self.pause(ctx),
|
||||
SpeedSetting::Fast => {
|
||||
@ -263,10 +262,7 @@ impl SpeedControls {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ctx
|
||||
.input
|
||||
.new_was_pressed(hotkey(Key::RightBracket).unwrap())
|
||||
{
|
||||
if ctx.input.new_was_pressed(hotkey(Key::RightArrow).unwrap()) {
|
||||
match self.setting {
|
||||
SpeedSetting::Realtime => {
|
||||
if self.paused {
|
||||
@ -448,6 +444,9 @@ impl State for JumpToTime {
|
||||
.named("target time"),
|
||||
);
|
||||
}
|
||||
if self.composite.clicked_outside(ctx) {
|
||||
return Transition::Pop;
|
||||
}
|
||||
|
||||
Transition::Keep
|
||||
}
|
||||
@ -494,7 +493,8 @@ impl State for TimeWarpScreen {
|
||||
);
|
||||
// TODO secondary for a/b test mode
|
||||
|
||||
let mut txt = Text::from(Line("Warping through time...").roboto_bold());
|
||||
// I'm covered in shame for not doing this from the start.
|
||||
let mut txt = Text::from(Line("Let's do the time warp again!").roboto_bold());
|
||||
txt.add(Line(format!(
|
||||
"Simulating until it's {}",
|
||||
self.target.ampm_tostring()
|
||||
@ -527,6 +527,9 @@ impl State for TimeWarpScreen {
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
if self.composite.clicked_outside(ctx) {
|
||||
return Transition::Pop;
|
||||
}
|
||||
|
||||
Transition::KeepWithMode(EventLoopMode::Animation)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user