From 852ee69430748a038bd5a2df170b02b9bec613a9 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 2 Jan 2020 12:21:47 -0600 Subject: [PATCH] buttons to zoom in/out fully. poor animation for now. --- game/assets/minimap/zoom_in_fully.svg | 3 ++ game/assets/minimap/zoom_out_fully.svg | 3 ++ game/src/common/panels.rs | 53 ++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 game/assets/minimap/zoom_in_fully.svg create mode 100644 game/assets/minimap/zoom_out_fully.svg diff --git a/game/assets/minimap/zoom_in_fully.svg b/game/assets/minimap/zoom_in_fully.svg new file mode 100644 index 0000000000..08fee6cae4 --- /dev/null +++ b/game/assets/minimap/zoom_in_fully.svg @@ -0,0 +1,3 @@ + + + diff --git a/game/assets/minimap/zoom_out_fully.svg b/game/assets/minimap/zoom_out_fully.svg new file mode 100644 index 0000000000..fda9fb68f3 --- /dev/null +++ b/game/assets/minimap/zoom_out_fully.svg @@ -0,0 +1,3 @@ + + + diff --git a/game/src/common/panels.rs b/game/src/common/panels.rs index 9a5c46d403..d862838da7 100644 --- a/game/src/common/panels.rs +++ b/game/src/common/panels.rs @@ -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) -> 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) -> 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 {