buttons to zoom in/out fully. poor animation for now.

This commit is contained in:
Dustin Carlino 2020-01-02 12:21:47 -06:00
parent d21676ea11
commit 852ee69430
3 changed files with 56 additions and 3 deletions

View File

@ -0,0 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 14.1429H3.85714V18H6.42857V11.5714H0V14.1429ZM3.85714 3.85714H0V6.42857H6.42857V0H3.85714V3.85714ZM11.5714 18H14.1429V14.1429H18V11.5714H11.5714V18ZM14.1429 3.85714V0H11.5714V6.42857H18V3.85714H14.1429Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 334 B

View File

@ -0,0 +1,3 @@
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.57143 11.5714H0V18H6.42857V15.4286H2.57143V11.5714ZM0 6.42857H2.57143V2.57143H6.42857V0H0V6.42857ZM15.4286 15.4286H11.5714V18H18V11.5714H15.4286V15.4286ZM11.5714 0V2.57143H15.4286V6.42857H18V0H11.5714Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 333 B

View File

@ -1,4 +1,4 @@
use crate::common::{navigate, shortcuts};
use crate::common::{navigate, shortcuts, Warping};
use crate::edit::EditMode;
use crate::game::Transition;
use crate::managed::Composite;
@ -6,8 +6,8 @@ use crate::options;
use crate::sandbox::GameplayMode;
use crate::ui::UI;
use ezgui::{
hotkey, lctrl, Button, Color, EventCtx, HorizontalAlignment, Key, Line, ManagedWidget,
RewriteColor, Text, VerticalAlignment,
hotkey, lctrl, Button, Color, EventCtx, EventLoopMode, HorizontalAlignment, Key, Line,
ManagedWidget, RewriteColor, Text, VerticalAlignment,
};
// TODO Rethink this API.
@ -36,6 +36,19 @@ pub fn tool_panel(ctx: &EventCtx, extra_buttons: Vec<ManagedWidget>) -> Composit
"shortcuts",
hotkey(Key::SingleQuote),
),
// TODO Mutex
Composite::svg_button(
ctx,
"assets/minimap/zoom_out_fully.svg",
"zoom out fully",
None,
),
Composite::svg_button(
ctx,
"assets/minimap/zoom_in_fully.svg",
"zoom in fully",
None,
),
];
row.extend(extra_buttons);
@ -56,6 +69,40 @@ pub fn tool_panel(ctx: &EventCtx, extra_buttons: Vec<ManagedWidget>) -> Composit
"shortcuts",
Box::new(|_, _| Some(Transition::Push(shortcuts::ChoosingShortcut::new()))),
)
.cb(
"zoom out fully",
// TODO The zoom out level should show the full width/height -- that's kind of in minimap
// code
Box::new(|ctx, ui| {
Some(Transition::PushWithMode(
Warping::new(
ctx,
// TODO The animated zooming is too quick. Need to specify that we want to
// interpolate over the zoom factor.
ctx.canvas.center_to_map_pt().offset(1.0, 1.0),
Some(0.1),
None,
&mut ui.primary,
),
EventLoopMode::Animation,
))
}),
)
.cb(
"zoom in fully",
Box::new(|ctx, ui| {
Some(Transition::PushWithMode(
Warping::new(
ctx,
ctx.canvas.center_to_map_pt().offset(1.0, 1.0),
Some(10.0),
None,
&mut ui.primary,
),
EventLoopMode::Animation,
))
}),
)
}
pub fn edit_map_panel(ctx: &EventCtx, ui: &UI, gameplay: GameplayMode) -> Composite {