diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index d484f9a4e5..e67a8a5fd9 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -72,9 +72,6 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo Connect( ID_LAYER_MANAGER_START, ID_LAYER_MANAGER_END, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GERBER_LAYER_WIDGET::onPopupSelection ), NULL, this ); - - // install the right click handler into each control at end of ReFill() - // using installRightLayerClickHandler } GERBER_FILE_IMAGE_LIST* GERBER_LAYER_WIDGET::GetImagesList() @@ -126,27 +123,9 @@ void GERBER_LAYER_WIDGET::ReFillRender() AppendRenderRows( renderRows, DIM(renderRows) ); } -void GERBER_LAYER_WIDGET::installRightLayerClickHandler() + +void GERBER_LAYER_WIDGET::AddRightClickMenuItems( wxMenu& menu ) { - int rowCount = GetLayerRowCount(); - - for( int row=0; rowConnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( - GERBER_LAYER_WIDGET::onRightDownLayers ), NULL, this ); - } - } -} - - -void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event ) -{ - wxMenu menu; - // Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt) menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS, _("Show All Layers") ) ); @@ -163,6 +142,14 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event ) menu.AppendSeparator(); menu.Append( new wxMenuItem( &menu, ID_SORT_GBR_LAYERS, _( "Sort Layers if X2 Mode" ) ) ); +} + + +void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event ) +{ + wxMenu menu; + + AddRightClickMenuItems( menu ); PopupMenu( &menu ); passOnFocus(); @@ -246,12 +233,15 @@ void GERBER_LAYER_WIDGET::ReFill() } Thaw(); - - installRightLayerClickHandler(); } //------------------------------------------------ +void GERBER_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu ) +{ + AddRightClickMenuItems( aMenu ); +} + void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) { myframe->SetLayerColor( aLayer, aColor ); diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h index dcac8a7811..3ef8870bf9 100644 --- a/gerbview/class_gerbview_layer_widget.h +++ b/gerbview/class_gerbview_layer_widget.h @@ -33,18 +33,6 @@ #include -// popup menu ids. in layer manager -enum LAYER_MANAGER -{ - ID_LAYER_MANAGER_START = wxID_HIGHEST+1, - ID_SHOW_ALL_LAYERS = ID_LAYER_MANAGER_START, - ID_SHOW_NO_LAYERS, - ID_SHOW_NO_LAYERS_BUT_ACTIVE, - ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, - ID_SORT_GBR_LAYERS, - ID_LAYER_MANAGER_END = ID_SORT_GBR_LAYERS, -}; - /** * Class GERBER_LAYER_WIDGET * is here to implement the abtract functions of LAYER_WIDGET so they @@ -100,6 +88,7 @@ public: void ReFillRender(); //---------------- + void OnLayerRightClick( wxMenu& aMenu ) override; void OnLayerColorChange( int aLayer, COLOR4D aColor ) override; bool OnLayerSelect( int aLayer ) override; void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override; @@ -125,6 +114,26 @@ public: bool OnLayerSelected(); // postprocess after an active layer selection // ensure active layer visible if // m_alwaysShowActiveCopperLayer is true; + + /** + * Function addRightClickMenuItems + * add menu items to a menu that should be shown when right-clicking + * the Gerber layer widget. + */ + void AddRightClickMenuItems( wxMenu& menu ); + +protected: + // popup menu ids. in layer manager + enum LAYER_MANAGER + { + ID_LAYER_MANAGER_START = LAYER_WIDGET::ID_LAST_VALUE, + ID_SHOW_ALL_LAYERS = ID_LAYER_MANAGER_START, + ID_SHOW_NO_LAYERS, + ID_SHOW_NO_LAYERS_BUT_ACTIVE, + ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, + ID_SORT_GBR_LAYERS, + ID_LAYER_MANAGER_END = ID_SORT_GBR_LAYERS, + }; }; #endif // _CLASS_GERBER_LAYER_WIDGET_H_