From bfaf8a5921a4c28f946dee6582ec378ba86ac77a Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 7 May 2015 14:43:33 -0300 Subject: [PATCH] Add ability to change the Preview zoom using 1...6 keys above the Preview --- src/app/commands/cmd_zoom.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/commands/cmd_zoom.cpp b/src/app/commands/cmd_zoom.cpp index f0e1f1edb..56454508a 100644 --- a/src/app/commands/cmd_zoom.cpp +++ b/src/app/commands/cmd_zoom.cpp @@ -15,6 +15,8 @@ #include "app/ui/editor/editor.h" #include "base/convert_to.h" #include "render/zoom.h" +#include "ui/manager.h" +#include "ui/system.h" namespace app { @@ -61,12 +63,20 @@ void ZoomCommand::onLoadParams(const Params& params) bool ZoomCommand::onEnabled(Context* context) { - return current_editor != NULL; + return (current_editor != NULL); } void ZoomCommand::onExecute(Context* context) { - render::Zoom zoom = current_editor->zoom(); + // Use the current editor by default. + Editor* editor = current_editor; + + // Try to use the editor above the mouse. + ui::Widget* pick = ui::Manager::getDefault()->pick(ui::get_mouse_position()); + if (pick && pick->getType() == editor_type()) + editor = static_cast(pick); + + render::Zoom zoom = editor->zoom(); switch (m_action) { case In: @@ -80,7 +90,7 @@ void ZoomCommand::onExecute(Context* context) break; } - current_editor->setEditorZoom(zoom); + editor->setEditorZoom(zoom); } std::string ZoomCommand::onGetFriendlyName() const