jump to info panel object

This commit is contained in:
Dustin Carlino 2020-01-16 15:43:01 -08:00
parent 497d05552a
commit 5f0dd70d43
2 changed files with 21 additions and 3 deletions

View File

@ -4,7 +4,7 @@ use crate::ui::UI;
use abstutil::prettyprint_usize;
use ezgui::{
hotkey, Button, Color, Composite, EventCtx, HorizontalAlignment, Key, Line, ManagedWidget,
Plot, Series, Text, VerticalAlignment,
Plot, RewriteColor, Series, Text, VerticalAlignment,
};
use geom::{Duration, Statistic, Time};
use map_model::{IntersectionID, RoadID};
@ -24,6 +24,13 @@ impl InfoPanel {
txt.highlight_last_line(Color::BLUE);
ManagedWidget::draw_text(ctx, txt)
},
ManagedWidget::btn(Button::rectangle_svg(
"assets/tools/locate.svg",
"jump to object",
hotkey(Key::J),
RewriteColor::Change(Color::hex("#CC4121"), Color::ORANGE),
ctx,
)),
crate::managed::Composite::text_button(ctx, "X", hotkey(Key::Escape)).align_right(),
])];

View File

@ -23,7 +23,7 @@ use crate::helpers::{list_names, ID};
use crate::render::DrawOptions;
use crate::ui::UI;
use ezgui::{
hotkey, lctrl, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Text,
lctrl, Color, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Text,
VerticalAlignment,
};
use std::collections::BTreeSet;
@ -47,7 +47,7 @@ impl CommonState {
if ctx.input.new_was_pressed(lctrl(Key::S).unwrap()) {
ui.opts.dev = !ui.opts.dev;
}
if ui.opts.dev && ctx.input.new_was_pressed(hotkey(Key::J).unwrap()) {
if ui.opts.dev && ctx.input.new_was_pressed(lctrl(Key::J).unwrap()) {
return Some(Transition::Push(warp::EnteringWarp::new()));
}
@ -80,6 +80,17 @@ impl CommonState {
self.info_panel = None;
assert!(ui.per_obj.info_panel_open);
ui.per_obj.info_panel_open = false;
} else if action == "jump to object" {
return Some(Transition::PushWithMode(
Warping::new(
ctx,
info.id.canonical_point(&ui.primary).unwrap(),
Some(10.0),
Some(info.id.clone()),
&mut ui.primary,
),
EventLoopMode::Animation,
));
} else {
// TODO If the action was conditional on some other stuff, it might
// still go unused.