From 5492fafdf443c07da9869a96d953b49a3fedd61f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 11 Jun 2021 09:32:47 +0200 Subject: [PATCH] Pcbnew: allows access Layers context menu when right clicking from below layers list Fixes #6614 https://gitlab.com/kicad/code/kicad/issues/6614 --- pcbnew/widgets/appearance_controls.cpp | 42 ++++++++++++++------------ pcbnew/widgets/appearance_controls.h | 4 ++- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index a4b8dd74c9..03896a803d 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021 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 @@ -1429,10 +1429,10 @@ void APPEARANCE_CONTROLS::rebuildLayers() aSetting->ctl_color = swatch; aSetting->ctl_text = label; - panel->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this ); - indicator->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this ); - swatch->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this ); - label->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerClick, this ); + panel->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this ); + indicator->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this ); + swatch->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this ); + label->Bind( wxEVT_LEFT_DOWN, &APPEARANCE_CONTROLS::onLayerLeftClick, this ); btn_visible->Bind( TOGGLE_CHANGED, [&]( wxCommandEvent& aEvent ) @@ -1459,21 +1459,17 @@ void APPEARANCE_CONTROLS::rebuildLayers() this ) ); swatch->SetReadOnly( readOnly ); - auto rightClickHandler = - [&]( wxMouseEvent& aEvent ) - { - wxASSERT( m_layerContextMenu ); - PopupMenu( m_layerContextMenu ); - passOnFocus(); - }; - - panel->Bind( wxEVT_RIGHT_DOWN, rightClickHandler ); - indicator->Bind( wxEVT_RIGHT_DOWN, rightClickHandler ); - swatch->Bind( wxEVT_RIGHT_DOWN, rightClickHandler ); - btn_visible->Bind( wxEVT_RIGHT_DOWN, rightClickHandler ); - label->Bind( wxEVT_RIGHT_DOWN, rightClickHandler ); + panel->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); + indicator->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); + swatch->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); + btn_visible->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); + label->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); }; + // Add right click handling to show the conterxt menu when clicking to the free area in + // m_windowLayers (below the layer items) + m_windowLayers->Bind( wxEVT_RIGHT_DOWN, &APPEARANCE_CONTROLS::rightClickHandler, this ); + wxString dsc; // show all coppers first, with front on top, back on bottom, then technical layers @@ -1779,7 +1775,7 @@ void APPEARANCE_CONTROLS::syncColorsAndVisibility() } -void APPEARANCE_CONTROLS::onLayerClick( wxMouseEvent& aEvent ) +void APPEARANCE_CONTROLS::onLayerLeftClick( wxMouseEvent& aEvent ) { auto eventSource = static_cast( aEvent.GetEventObject() ); @@ -1793,6 +1789,14 @@ void APPEARANCE_CONTROLS::onLayerClick( wxMouseEvent& aEvent ) } +void APPEARANCE_CONTROLS::rightClickHandler( wxMouseEvent& aEvent ) +{ + wxASSERT( m_layerContextMenu ); + PopupMenu( m_layerContextMenu ); + passOnFocus(); +}; + + void APPEARANCE_CONTROLS::onLayerVisibilityChanged( PCB_LAYER_ID aLayer, bool isVisible, bool isFinal ) { diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index a6c2c1a908..533f89f126 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -311,7 +311,9 @@ private: void syncLayerPresetSelection(); - void onLayerClick( wxMouseEvent& aEvent ); + void onLayerLeftClick( wxMouseEvent& aEvent ); + + void rightClickHandler( wxMouseEvent& aEvent ); void onLayerVisibilityChanged( PCB_LAYER_ID aLayer, bool isVisible, bool isFinal );