From de7791cc8ba94d133402f1a6b42cec14864756a8 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 11 Jun 2018 11:37:05 +0100 Subject: [PATCH] Add context menu to footprint viewer for zoom & grid. Fixes: lp:1776126 * https://bugs.launchpad.net/kicad/+bug/1776126 --- pcbnew/footprint_viewer_frame.cpp | 3 +++ pcbnew/tools/selection_tool.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 028b3e09e0..a92e26ad35 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -56,6 +56,7 @@ #include #include #include +#include "tools/selection_tool.h" #include "tools/pcbnew_control.h" #include "tools/pcb_actions.h" @@ -216,8 +217,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent drawPanel->SetEventDispatcher( m_toolDispatcher ); m_toolManager->RegisterTool( new PCBNEW_CONTROL ); + m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid) m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->InitTools(); + m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); // If a footprint was previously loaded, reload it if( getCurNickname().size() && getCurFootprintName().size() ) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 0fb901aaaa..ecbfd43c05 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -54,6 +54,7 @@ using namespace std::placeholders; #include #include #include +#include #include "tool_event_utils.h" #include "selection_tool.h" @@ -206,6 +207,15 @@ SELECTION_TOOL::~SELECTION_TOOL() bool SELECTION_TOOL::Init() { + auto frame = getEditFrame(); + + if( frame && ( frame->IsType( FRAME_PCB_MODULE_VIEWER ) + || frame->IsType( FRAME_PCB_MODULE_VIEWER_MODAL ) ) ) + { + m_menu.AddStandardSubMenus( *frame ); + return true; + } + auto selectMenu = std::make_shared(); selectMenu->SetTool( this ); m_menu.AddSubMenu( selectMenu ); @@ -215,8 +225,6 @@ bool SELECTION_TOOL::Init() menu.AddMenu( selectMenu.get(), false, SELECTION_CONDITIONS::NotEmpty ); menu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 ); - auto frame = getEditFrame(); - if( frame ) { m_menu.AddStandardSubMenus( *frame );