gerbview layer manager: fix a minor issue, and and icons in context menu, similar to pcbnew layer manager context menu

This commit is contained in:
jean-pierre charras 2018-02-28 10:21:37 +01:00
parent 2c54f6fe32
commit 2c85de3ab2
2 changed files with 24 additions and 19 deletions

View File

@ -34,6 +34,7 @@
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <macros.h> #include <macros.h>
#include <gbr_layer_box_selector.h> #include <gbr_layer_box_selector.h>
#include <menus_helpers.h>
#include <gerbview.h> #include <gerbview.h>
#include <gerbview_frame.h> #include <gerbview_frame.h>
@ -134,24 +135,26 @@ void GERBER_LAYER_WIDGET::ReFillRender()
} }
void GERBER_LAYER_WIDGET::AddRightClickMenuItems( wxMenu& menu ) void GERBER_LAYER_WIDGET::AddRightClickMenuItems( wxMenu* aMenu )
{ {
// Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt) // Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt)
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS, AddMenuItem( aMenu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
_("Show All Layers") ) ); KiBitmap( show_all_layers_xpm ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS_BUT_ACTIVE, AddMenuItem( aMenu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
_( "Hide All Layers But Active" ) ) ); _( "Hide All Layers But Active" ),
KiBitmap( select_w_layer_xpm ) );
menu.Append( new wxMenuItem( &menu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE, AddMenuItem( aMenu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
_( "Always Hide All Layers But Active" ) ) ); _( "Always Hide All Layers But Active" ),
KiBitmap( select_w_layer_xpm ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS, AddMenuItem( aMenu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
_( "Hide All Layers" ) ) ); KiBitmap( show_no_layers_xpm ) );
menu.AppendSeparator(); aMenu->AppendSeparator();
menu.Append( new wxMenuItem( &menu, ID_SORT_GBR_LAYERS, AddMenuItem( aMenu, ID_SORT_GBR_LAYERS, _( "Sort Layers if X2 Mode" ),
_( "Sort Layers if X2 Mode" ) ) ); KiBitmap( reload_xpm ) );
} }
@ -159,7 +162,7 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
{ {
wxMenu menu; wxMenu menu;
AddRightClickMenuItems( menu ); AddRightClickMenuItems( &menu );
PopupMenu( &menu ); PopupMenu( &menu );
passOnFocus(); passOnFocus();
@ -173,16 +176,17 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
long visibleLayers = 0; long visibleLayers = 0;
bool force_active_layer_visible; bool force_active_layer_visible;
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
switch( menuId ) switch( menuId )
{ {
case ID_SHOW_ALL_LAYERS: case ID_SHOW_ALL_LAYERS:
case ID_SHOW_NO_LAYERS: case ID_SHOW_NO_LAYERS:
case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE: case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE:
case ID_SHOW_NO_LAYERS_BUT_ACTIVE: case ID_SHOW_NO_LAYERS_BUT_ACTIVE:
// Set the display layers options. Sorting layers has no effect to these options
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
// Update icons and check boxes
rowCount = GetLayerRowCount(); rowCount = GetLayerRowCount();
for( int row=0; row < rowCount; ++row ) for( int row=0; row < rowCount; ++row )
{ {
@ -260,7 +264,7 @@ void GERBER_LAYER_WIDGET::ReFill()
void GERBER_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu ) void GERBER_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu )
{ {
AddRightClickMenuItems( aMenu ); AddRightClickMenuItems( &aMenu );
} }
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor ) void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )

View File

@ -121,8 +121,9 @@ public:
* Function addRightClickMenuItems * Function addRightClickMenuItems
* add menu items to a menu that should be shown when right-clicking * add menu items to a menu that should be shown when right-clicking
* the Gerber layer widget. * the Gerber layer widget.
* @param aMenu is the menu to modify: menuitems will be added to aMenu
*/ */
void AddRightClickMenuItems( wxMenu& menu ); void AddRightClickMenuItems( wxMenu* aMenu );
protected: protected:
// popup menu ids. in layer manager // popup menu ids. in layer manager