From 5cae4cf91881cd21d525f72e0dbeed4cec6514e9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 30 May 2022 11:30:09 +0100 Subject: [PATCH] Give zoom tool its own menu. Fixes https://gitlab.com/kicad/code/kicad/issues/11702 --- common/tool/zoom_tool.cpp | 25 ++++++++++++++++++++++--- include/tool/zoom_tool.h | 5 ++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index a638c7a3e4..05d0c75960 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -19,13 +19,11 @@ #include #include -#include #include #include #include #include #include -#include ZOOM_TOOL::ZOOM_TOOL() : @@ -38,6 +36,22 @@ ZOOM_TOOL::ZOOM_TOOL() : ZOOM_TOOL::~ZOOM_TOOL() {} + +bool ZOOM_TOOL::Init() +{ + auto& ctxMenu = m_menu.GetMenu(); + + // cancel current tool goes in main context menu at the top if present + ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 ); + ctxMenu.AddSeparator( 1 ); + + // Finally, add the standard zoom/grid items + getEditFrame()->AddStandardSubMenus( m_menu ); + + return true; +} + + void ZOOM_TOOL::Reset( RESET_REASON aReason ) { m_frame = getEditFrame(); @@ -71,6 +85,11 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent ) if( selectRegion() ) break; } + else if( evt->IsClick( BUT_RIGHT ) ) + { + SELECTION dummy; + m_menu.ShowContextMenu( dummy ); + } else { evt->SetPassEvent(); diff --git a/include/tool/zoom_tool.h b/include/tool/zoom_tool.h index e3ad31a159..08d8a21d25 100644 --- a/include/tool/zoom_tool.h +++ b/include/tool/zoom_tool.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -31,6 +31,9 @@ public: ZOOM_TOOL(); ~ZOOM_TOOL(); + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + /// @copydoc TOOL_BASE::Reset() void Reset( RESET_REASON aReason ) override;