Use radio buttons in canvas selection menu items
This commit is contained in:
parent
053dac45c1
commit
d442009e84
|
@ -1031,15 +1031,6 @@ bool PCB_BASE_FRAME::SaveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
|
||||||
|
|
||||||
void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
|
void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
|
||||||
{
|
{
|
||||||
// In switch canvas options menus, add a symbol before the menu label,
|
|
||||||
// to show what mode is currently selected
|
|
||||||
// the symbol is SYMB_SELECTION
|
|
||||||
//
|
|
||||||
// I did not used menuitems with wxCHECK_MENU option, because bitmaps are not
|
|
||||||
// accepted on some OS in menuitems with wxCHECK_MENU option
|
|
||||||
|
|
||||||
#define SYMB_SELECTION "** "
|
|
||||||
|
|
||||||
wxMenuBar* menuBar = GetMenuBar();
|
wxMenuBar* menuBar = GetMenuBar();
|
||||||
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
|
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||||
|
@ -1047,35 +1038,16 @@ void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
|
||||||
if( IsGalCanvasActive() && gal_canvas )
|
if( IsGalCanvasActive() && gal_canvas )
|
||||||
canvasType = gal_canvas->GetBackend();
|
canvasType = gal_canvas->GetBackend();
|
||||||
|
|
||||||
int menuIdList[] =
|
struct { int menuId; int galType; } menuList[] =
|
||||||
{
|
{
|
||||||
ID_MENU_CANVAS_LEGACY, ID_MENU_CANVAS_OPENGL, ID_MENU_CANVAS_CAIRO
|
{ ID_MENU_CANVAS_LEGACY, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE },
|
||||||
|
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
|
||||||
|
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
|
||||||
};
|
};
|
||||||
|
|
||||||
int galtype[] =
|
for( auto ii: menuList )
|
||||||
{ // Must be ordered like menuIdList
|
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE,
|
|
||||||
EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL,
|
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO
|
|
||||||
};
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < DIM( menuIdList ); ii++ )
|
|
||||||
{
|
{
|
||||||
wxMenuItem* item = menuBar->FindItem( menuIdList[ii] );
|
wxMenuItem* item = menuBar->FindItem( ii.menuId );
|
||||||
wxString label = item->GetItemLabel();
|
item->Check( ii.galType == canvasType );
|
||||||
wxString labelBase;
|
|
||||||
|
|
||||||
if( label.StartsWith( SYMB_SELECTION, &labelBase ) )
|
|
||||||
{
|
|
||||||
if( galtype[ii] == canvasType )
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
item->SetItemLabel( labelBase );
|
|
||||||
}
|
|
||||||
else if( galtype[ii] == canvasType )
|
|
||||||
{
|
|
||||||
labelBase = SYMB_SELECTION + label;
|
|
||||||
item->SetItemLabel( labelBase );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,26 +239,26 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
|
||||||
// Add canvas selection
|
// Add canvas selection
|
||||||
viewMenu->AppendSeparator();
|
viewMenu->AppendSeparator();
|
||||||
|
|
||||||
text = AddHotkeyName( _( "&Switch Canvas to Legacy" ), m_hotkeysDescrList,
|
text = AddHotkeyName( _( "Legacy Canva&s" ), m_hotkeysDescrList,
|
||||||
HK_CANVAS_LEGACY );
|
HK_CANVAS_LEGACY );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_LEGACY,
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_LEGACY,
|
||||||
text, _( "Switch the canvas implementation to Legacy" ),
|
text, _( "Switch the canvas implementation to Legacy" ),
|
||||||
KiBitmap( tools_xpm ) );
|
KiBitmap( tools_xpm ), wxITEM_RADIO );
|
||||||
|
|
||||||
text = AddHotkeyName( _( "Switch Canvas to Open&GL" ), m_hotkeysDescrList,
|
text = AddHotkeyName( _( "Open&GL Canvas" ), m_hotkeysDescrList,
|
||||||
HK_CANVAS_OPENGL );
|
HK_CANVAS_OPENGL );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
||||||
text, _( "Switch the canvas implementation to OpenGL" ),
|
text, _( "Switch the canvas implementation to OpenGL" ),
|
||||||
KiBitmap( tools_xpm ) );
|
KiBitmap( tools_xpm ), wxITEM_RADIO );
|
||||||
|
|
||||||
text = AddHotkeyName( _( "Switch Canvas to &Cairo" ), m_hotkeysDescrList,
|
text = AddHotkeyName( _( "&Cairo Canvas" ), m_hotkeysDescrList,
|
||||||
HK_CANVAS_CAIRO );
|
HK_CANVAS_CAIRO );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
|
AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
|
||||||
text, _( "Switch the canvas implementation to Cairo" ),
|
text, _( "Switch the canvas implementation to Cairo" ),
|
||||||
KiBitmap( tools_xpm ) );
|
KiBitmap( tools_xpm ), wxITEM_RADIO );
|
||||||
|
|
||||||
//-------- Place menu --------------------
|
//-------- Place menu --------------------
|
||||||
wxMenu* placeMenu = new wxMenu;
|
wxMenu* placeMenu = new wxMenu;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -376,26 +376,29 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
|
|
||||||
viewMenu->AppendSeparator();
|
viewMenu->AppendSeparator();
|
||||||
|
|
||||||
text = AddHotkeyName( _( "&Switch Canvas to Legacy" ), g_Pcbnew_Editor_Hokeys_Descr,
|
text = AddHotkeyName( _( "Legacy Canva&s" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
HK_CANVAS_LEGACY );
|
HK_CANVAS_LEGACY );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_LEGACY,
|
viewMenu->Append(
|
||||||
text, _( "Switch the canvas implementation to Legacy" ),
|
new wxMenuItem( viewMenu, ID_MENU_CANVAS_LEGACY,
|
||||||
KiBitmap( graphic_mode_option_xpm ) );
|
text, _( "Switch the canvas implementation to Legacy" ),
|
||||||
|
wxITEM_RADIO ) );
|
||||||
|
|
||||||
text = AddHotkeyName( _( "Switch Canvas to Open&GL" ), g_Pcbnew_Editor_Hokeys_Descr,
|
text = AddHotkeyName( _( "Open&GL Canvas" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
HK_CANVAS_OPENGL );
|
HK_CANVAS_OPENGL );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
viewMenu->Append(
|
||||||
text, _( "Switch the canvas implementation to OpenGL" ),
|
new wxMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
|
||||||
KiBitmap( graphic_mode_option_xpm ) );
|
text, _( "Switch the canvas implementation to OpenGL" ),
|
||||||
|
wxITEM_RADIO ) );
|
||||||
|
|
||||||
text = AddHotkeyName( _( "Switch Canvas to &Cairo" ), g_Pcbnew_Editor_Hokeys_Descr,
|
text = AddHotkeyName( _( "&Cairo Canvas" ), g_Pcbnew_Editor_Hokeys_Descr,
|
||||||
HK_CANVAS_CAIRO );
|
HK_CANVAS_CAIRO );
|
||||||
|
|
||||||
AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
|
viewMenu->Append(
|
||||||
text, _( "Switch the canvas implementation to Cairo" ),
|
new wxMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
|
||||||
KiBitmap( graphic_mode_option_xpm ) );
|
text, _( "Switch the canvas implementation to Cairo" ),
|
||||||
|
wxITEM_RADIO ) );
|
||||||
|
|
||||||
//----- Place Menu ----------------------------------------------------------
|
//----- Place Menu ----------------------------------------------------------
|
||||||
wxMenu* placeMenu = new wxMenu;
|
wxMenu* placeMenu = new wxMenu;
|
||||||
|
|
Loading…
Reference in New Issue