Move some more menu commands to ACTIONs.

This commit is contained in:
Jeff Young 2019-05-28 14:51:47 +01:00
parent 01326d1304
commit a27e4246e0
37 changed files with 435 additions and 1026 deletions

View File

@ -375,11 +375,6 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
}
void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
}
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
{
}
@ -618,12 +613,7 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
}
void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
{
}
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
void EDA_DRAW_FRAME::UseGalCanvas()
{
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
@ -633,7 +623,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
galCanvas->SetEvtHandlerEnabled( aEnable );
galCanvas->SetEvtHandlerEnabled( true );
galCanvas->StartDrawing();
// Reset current tool on switch();
@ -641,17 +631,12 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
}
bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
// JEY TODO: unravel this...
auto galCanvas = GetGalCanvas();
wxCHECK( galCanvas, false );
bool use_gal = galCanvas->SwitchBackend( aCanvasType );
use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
UseGalCanvas( use_gal );
m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
GetGalCanvas()->SwitchBackend( aCanvasType );
m_canvasType = GetGalCanvas()->GetBackend();
return use_gal;
UseGalCanvas();
}

View File

@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file draw_frame.cpp
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
@ -396,11 +392,6 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
return result;
}
void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
}
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
{
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
@ -784,219 +775,7 @@ static const double MAX_AXIS = INT_MAX - 100;
#define VIRT_MAX (MAX_AXIS/2.0) ///< max X or Y coordinate in virtual space
void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
{
BASE_SCREEN* screen = GetScreen();
if( !screen || !m_canvas )
return;
double scale = screen->GetScalingFactor();
wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
aCenterPositionIU.x, aCenterPositionIU.y, scale );
// Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level.
// visible viewport in device units ~ pixels
wxSize clientSizeDU = m_canvas->GetClientSize();
// Size of the client window in IU
DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
// Full drawing or "page" rectangle in internal units
DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
// Remark: if something is modified here, perhaps EDA_DRAW_FRAME::RedrawScreen2()
// will need changes accordint to the way the center is computed
// Account for scrollbars
wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
// The upper left corner of the client rectangle in internal units.
double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
// If drawn around the center, adjust the client rectangle accordingly.
if( screen->m_Center )
{
// half page offset.
xIU += pageRectIU.GetWidth() / 2.0;
yIU += pageRectIU.GetHeight() / 2.0;
}
DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
wxPoint centerPositionIU;
// put "int" limits on the clientRect
if( clientRectIU.GetLeft() < VIRT_MIN )
clientRectIU.MoveLeftTo( VIRT_MIN );
if( clientRectIU.GetTop() < VIRT_MIN )
clientRectIU.MoveTopTo( VIRT_MIN );
if( clientRectIU.GetRight() > VIRT_MAX )
clientRectIU.MoveRightTo( VIRT_MAX );
if( clientRectIU.GetBottom() > VIRT_MAX )
clientRectIU.MoveBottomTo( VIRT_MAX );
centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
if( screen->m_Center )
{
centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
}
DSIZE virtualSizeIU;
if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
{
virtualSizeIU.x = pageRectIU.GetSize().x;
}
else
{
double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
{
if( pageCenterX > clientCenterX )
virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
else if( pageCenterX < clientCenterX )
virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
else
virtualSizeIU.x = clientRectIU.GetWidth();
}
else
{
if( pageCenterX > clientCenterX )
virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
else if( pageCenterX < clientCenterX )
virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
else
virtualSizeIU.x = pageRectIU.GetWidth();
}
}
if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
{
virtualSizeIU.y = pageRectIU.GetSize().y;
}
else
{
double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
{
if( pageCenterY > clientCenterY )
virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
else if( pageCenterY < clientCenterY )
virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
else
virtualSizeIU.y = clientRectIU.GetHeight();
}
else
{
if( pageCenterY > clientCenterY )
virtualSizeIU.y = pageRectIU.GetHeight() +
( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
else if( pageCenterY < clientCenterY )
virtualSizeIU.y = pageRectIU.GetHeight() +
( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
else
virtualSizeIU.y = pageRectIU.GetHeight();
}
}
// put "int" limits on the virtualSizeIU
virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
if( screen->m_Center )
{
screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
}
else
{
screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
}
/* Always set scrollbar pixels per unit to 1 unless you want the zoom
* around cursor to jump around. This reported problem occurs when the
* zoom point is not on a pixel per unit increment. If you set the
* pixels per unit to 10, you have potential for the zoom point to
* jump around +/-5 pixels from the nearest grid point.
*/
screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
// Number of scroll bar units for the given zoom level in device units.
double unitsX = virtualSizeIU.x * scale;
double unitsY = virtualSizeIU.y * scale;
// Store the requested center position for later use
SetScrollCenterPosition( aCenterPositionIU );
// Calculate the scroll bar position in internal units to place the
// center position at the center of client rectangle.
double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
// Convert scroll bar position to device units.
posX = KiROUND( posX * scale );
posY = KiROUND( posY * scale );
if( posX < 0 )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
posX = 0;
}
if( posX > unitsX )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
posX = unitsX;
}
if( posY < 0 )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
posY = 0;
}
if( posY > unitsY )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
posY = unitsY;
}
screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
wxLogTrace( traceScrollSettings,
wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
screen->m_DrawOrg.x, screen->m_DrawOrg.y,
screen->m_ScrollPixelsPerUnitX, screen->m_ScrollPixelsPerUnitY,
screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
bool noRefresh = true;
m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
screen->m_ScrollPixelsPerUnitY,
screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x,
screen->m_ScrollbarPos.y, noRefresh );
}
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
void EDA_DRAW_FRAME::UseGalCanvas()
{
KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
@ -1011,8 +790,8 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
viewControls->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
m_canvas->SetEvtHandlerEnabled( !aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
m_canvas->SetEvtHandlerEnabled( false );
GetGalCanvas()->SetEvtHandlerEnabled( true );
GetGalCanvas()->StartDrawing();
@ -1027,16 +806,12 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
}
bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
auto galCanvas = GetGalCanvas();
wxCHECK( galCanvas, false );
bool use_gal = galCanvas->SwitchBackend( aCanvasType );
use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
UseGalCanvas( use_gal );
m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
GetGalCanvas()->SwitchBackend( aCanvasType );
m_canvasType = GetGalCanvas()->GetBackend();
return use_gal;
UseGalCanvas();
}

View File

@ -9,6 +9,11 @@ TOOL_ACTION ACTIONS::doNew( "common.Control.new",
_( "New..." ), _( "Create a new document in the editor" ),
new_generic_xpm );
TOOL_ACTION ACTIONS::newLibrary( "common.Control.newLibrary",
AS_GLOBAL, 0,
_( "New Library..." ), _( "Create a new library folder" ),
new_generic_xpm );
TOOL_ACTION ACTIONS::open( "common.Control.open",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_OPEN ),
_( "Open..." ), _( "Open existing document" ),
@ -34,6 +39,11 @@ TOOL_ACTION ACTIONS::saveAll( "common.Control.saveAll",
_( "Save All" ), _( "Save all changes" ),
save_xpm );
TOOL_ACTION ACTIONS::revert( "common.Control.revert",
AS_GLOBAL, 0,
_( "Revert" ), _( "Throw away changes" ),
undo_xpm );
TOOL_ACTION ACTIONS::pageSettings( "common.Control.pageSettings",
AS_GLOBAL, 0,
_( "Page Settings..." ), _( "Settings for paper size and frame references" ),
@ -297,7 +307,6 @@ TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits",
_( "Switch units" ), _( "Switch between inches and millimeters" ),
unit_mm_xpm );
TOOL_ACTION ACTIONS::togglePolarCoords( "common.Control.togglePolarCoords",
AS_GLOBAL, 0,
_( "Polar Coordinates" ), _( "Switch between polar and cartesian coordinate systems" ),
@ -308,12 +317,21 @@ TOOL_ACTION ACTIONS::toggleCursor( "common.Control.toggleCursor",
_( "Always Show Cursor" ), _( "Display crosshairs even in selection tool" ),
cursor_xpm );
TOOL_ACTION ACTIONS::toggleCursorStyle( "common.Control.toggleCursorStyle",
AS_GLOBAL, 0,
_( "Full-Window Crosshairs" ), _( "Switch display of full-window crosshairs" ),
cursor_shape_xpm );
TOOL_ACTION ACTIONS::acceleratedGraphics( "common.Control.acceleratedGraphics",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_OPENGL ),
_( "Accelerated Graphics" ), _( "Use hardware-accelerated graphics (recommended)" ),
tools_xpm );
TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CANVAS_CAIRO ),
_( "Standard Graphics" ), _( "Use software graphics (fall-back)" ),
tools_xpm );
// System-wide selection Events

View File

@ -484,6 +484,19 @@ int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent )
{
if( aEvent.IsAction( &ACTIONS::acceleratedGraphics ) )
m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
else if( aEvent.IsAction( &ACTIONS::standardGraphics ) )
m_frame->SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
else
wxFAIL_MSG( "Unknown canvas type" );
return 0;
}
void COMMON_TOOLS::setTransitions()
{
// Cursor control
@ -530,6 +543,9 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::acceleratedGraphics.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::acceleratedGraphics.MakeEvent() );
}

View File

@ -173,7 +173,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( true );
UseGalCanvas();
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
GetGalCanvas()->GetView()->SetScale( m_lastZoom );

View File

@ -121,8 +121,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
EVT_MENU( ID_MENU_CANVAS_CAIRO, LIB_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, LIB_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( wxID_PREFERENCES, LIB_EDIT_FRAME::OnPreferencesOptions )
@ -139,8 +137,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnUpdateDeMorganConvert )
EVT_UPDATE_UI_RANGE( ID_LIBEDIT_PIN_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, LIB_EDIT_FRAME::OnUpdateSwitchCanvas )
END_EVENT_TABLE()
@ -1025,10 +1021,10 @@ void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
}
void LIB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
void LIB_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
// switches currently used canvas ( Cairo / OpenGL):
SCH_BASE_FRAME::OnSwitchCanvas( aEvent );
SCH_BASE_FRAME::SwitchCanvas( aCanvasType );
// Set options specific to symbol editor (axies are always enabled):
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );

View File

@ -129,7 +129,7 @@ public:
/**
* switches currently used canvas ( Cairo / OpenGL).
*/
void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
/** The nickname of the current library being edited and empty string if none. */
wxString GetCurLib() const;

View File

@ -44,7 +44,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar();
wxString text;
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
LIB_ID libId = getTargetLibId();
@ -58,8 +57,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
};
//
// Menu File:
//-- File menu -----------------------------------------------
//
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
@ -113,8 +111,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways );
//
// Edit menu
//-- Edit menu -----------------------------------------------
//
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
@ -141,8 +138,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
editMenu->AddItem( EE_ACTIONS::symbolProperties, havePartCondition );
editMenu->AddItem( EE_ACTIONS::pinTable, havePartCondition );
//
// Menu View:
//-- View menu -----------------------------------------------
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
@ -188,8 +184,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AddSeparator();
viewMenu->AddCheckItem( EE_ACTIONS::showComponentTree, compTreeShownCondition );
//
// Menu Place:
//-- Place menu -----------------------------------------------
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
@ -200,15 +195,13 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddItem( EE_ACTIONS::drawSymbolArc, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSymbolLines, EE_CONDITIONS::ShowAlways );
//
// Menu Inspect:
//-- Inspect menu -----------------------------------------------
//
wxMenu* inspectMenu = new wxMenu;
text = AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hotkeys_Descr, HK_LIBEDIT_VIEW_DOC );
AddMenuItem( inspectMenu,
ID_LIBEDIT_VIEW_DOC,
text,
AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hotkeys_Descr, HK_LIBEDIT_VIEW_DOC ),
_( "Open associated datasheet in web browser" ),
KiBitmap( datasheet_xpm ) );
@ -218,47 +211,36 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
_( "Check duplicate and off grid pins" ),
KiBitmap( erc_xpm ) );
// Menu Preferences:
wxMenu* preferencesMenu = new wxMenu;
//-- Preferences menu -----------------------------------------------
//
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool );
// Environment varialbes
AddMenuItem( preferencesMenu,
ID_PREFERENCES_CONFIGURE_PATHS,
_( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
KiBitmap( path_xpm ) );
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
// Library list
AddMenuItem( preferencesMenu,
ID_EDIT_SYM_LIB_TABLE,
_( "Manage &Symbol Libraries..." ),
_( "Edit the global and project symbol library tables." ),
KiBitmap( library_table_xpm ) );
prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
path_xpm, EE_CONDITIONS::ShowAlways );
preferencesMenu->AppendSeparator();
prefsMenu->AddItem( ID_EDIT_SYM_LIB_TABLE, _( "Manage &Symbol Libraries..." ),
_( "Edit the global and project symbol library tables." ),
library_table_xpm, EE_CONDITIONS::ShowAlways );
// Default values and options
text = AddHotkeyName( _( "&Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES );
AddMenuItem( preferencesMenu, wxID_PREFERENCES, text,
_( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) );
prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "&Preferences..." ), g_Libedit_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ),
preference_xpm, EE_CONDITIONS::ShowAlways );
// Language submenu
Pgm().AddMenuLanguageList( preferencesMenu );
prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu );
preferencesMenu->AppendSeparator();
text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), g_Libedit_Hotkeys_Descr,
HK_CANVAS_OPENGL );
AddMenuItem( preferencesMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Modern Toolset (Fallba&ck)" ), g_Libedit_Hotkeys_Descr,
HK_CANVAS_CAIRO );
AddMenuItem( preferencesMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use Modern Toolset with software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
prefsMenu->AddSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
//
// Create the menubar and append all submenus
@ -268,7 +250,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( preferencesMenu, _( "P&references" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );

View File

@ -45,9 +45,6 @@ class CONDITIONAL_MENU;
// Build the tools menu
static void prepareToolsMenu( wxMenu* aParentMenu );
// Build the preferences menu
static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
void SCH_EDIT_FRAME::ReCreateMenuBar()
{
@ -56,15 +53,13 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar();
wxString text;
auto modifiedDocumentCondition = [] ( const SELECTION& sel ) {
SCH_SHEET_LIST sheetList( g_RootSheet );
return sheetList.IsModified();
};
//
// Menu File:
//-- File menu -----------------------------------------------------------
//
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
static ACTION_MENU* openRecentMenu;
@ -141,8 +136,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, EE_CONDITIONS::ShowAlways );
//
// Menu Edit:
//-- Edit menu -----------------------------------------------------------
//
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
@ -176,8 +170,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
_( "Sets symbol fields to original library values" ),
update_fields_xpm, EE_CONDITIONS::ShowAlways );
//
// Menu View:
//-- View menu -----------------------------------------------------------
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
@ -232,8 +225,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AppendSeparator();
#endif
//
// Menu place:
//-- Place menu -----------------------------------------------------------
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
@ -259,33 +251,57 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways );
//
// Menu Inspect:
//-- Inspect menu -----------------------------------------------
//
wxMenu* inspectMenu = new wxMenu;
AddMenuItem( inspectMenu, ID_GET_ERC, _( "Electrical Rules &Checker" ),
_( "Perform electrical rules check" ), KiBitmap( erc_xpm ) );
//
// Menu Tools:
//-- Tools menu -----------------------------------------------
//
wxMenu* toolsMenu = new wxMenu;
prepareToolsMenu( toolsMenu );
//-- Preferences menu -----------------------------------------------
//
// Menu Preferences:
//
wxMenu* preferencesMenu = new wxMenu;
preparePreferencesMenu( this, preferencesMenu );
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool );
// Create the menubar and append all submenus
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "Configure Pa&ths..." ),
_( "Edit path configuration environment variables" ),
path_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddItem( ID_EDIT_SYM_LIB_TABLE, _( "Manage Symbol Libraries..." ),
_( "Edit the global and project symbol library lists" ),
library_table_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "&Preferences..." ), g_Eeschema_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ),
preference_xpm, EE_CONDITIONS::ShowAlways );
prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu );
prefsMenu->AddSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
//-- Menubar -----------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( preferencesMenu, _( "P&references" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );
@ -366,52 +382,3 @@ void prepareToolsMenu( wxMenu* aParentMenu )
}
static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu )
{
// Path configuration edit dialog.
AddMenuItem( aParentMenu, ID_PREFERENCES_CONFIGURE_PATHS, _( "Configure Pa&ths..." ),
_( "Edit path configuration environment variables" ),
KiBitmap( path_xpm ) );
// Library
AddMenuItem( aParentMenu, ID_EDIT_SYM_LIB_TABLE, _( "Manage Symbol Libraries..." ),
_( "Edit the global and project symbol library lists" ),
KiBitmap( library_table_xpm ) );
// Options (Preferences on WXMAC)
wxString text = AddHotkeyName( _( "&Preferences..." ), g_Eeschema_Hotkeys_Descr, HK_PREFERENCES );
AddMenuItem( aParentMenu, wxID_PREFERENCES, text,
_( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) );
aParentMenu->AppendSeparator();
// Language submenu
Pgm().AddMenuLanguageList( aParentMenu );
aParentMenu->AppendSeparator();
text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), g_Eeschema_Hotkeys_Descr,
HK_CANVAS_OPENGL );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Modern Toolset (Fallba&ck)" ), g_Eeschema_Hotkeys_Descr,
HK_CANVAS_CAIRO );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use Modern Toolset with software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
aParentMenu->AppendSeparator();
// Import/export
AddMenuItem( aParentMenu, ID_CONFIG_SAVE, _( "&Save Project File..." ),
_( "Save project preferences into a project file" ),
KiBitmap( save_setup_xpm ) );
AddMenuItem( aParentMenu, ID_CONFIG_READ, _( "Load P&roject File..." ),
_( "Load project preferences from a project file" ),
KiBitmap( import_setup_xpm ) );
}

View File

@ -108,42 +108,6 @@ SCH_BASE_FRAME::~SCH_BASE_FRAME()
}
void SCH_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
{
wxMenuBar* menuBar = GetMenuBar();
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = gal_canvas->GetBackend();
struct { int menuId; int galType; } menuList[] =
{
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
};
for( auto ii: menuList )
{
wxMenuItem* item = menuBar->FindItem( ii.menuId );
if( ii.galType == canvasType )
item->Check( true );
}
}
void SCH_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{
auto new_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
if( aEvent.GetId() == ID_MENU_CANVAS_CAIRO )
new_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
if( m_canvasType == new_type )
return;
GetGalCanvas()->SwitchBackend( new_type );
m_canvasType = new_type;
}
void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
@ -451,14 +415,14 @@ void SCH_BASE_FRAME::createCanvas()
m_useSingleCanvasPane = true;
SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
SetGalCanvas( static_cast<SCH_DRAW_PANEL*>( m_canvas ) );
// Set up viewport
KIGFX::VIEW* view = GetGalCanvas()->GetView();
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( true );
UseGalCanvas();
}

View File

@ -125,16 +125,6 @@ public:
bool GetShowElectricalType() { return m_showPinElectricalTypeName; }
void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; }
/**
* switches currently used canvas ( Cairo / OpenGL).
*/
virtual void OnSwitchCanvas( wxCommandEvent& aEvent );
/**
* Update UI called when switches currently used canvas (Cairo / OpenGL).
*/
void OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent );
/**
* @return the increment value of the position of an item
* for the repeat command

View File

@ -256,13 +256,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )
#endif /* KICAD_SPICE */
EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
/* Handle user interface update events. */
EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
END_EVENT_TABLE()

View File

@ -85,10 +85,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, GERBVIEW_FRAME::Process_Config )
EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::Process_Config )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnSwitchCanvas )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
@ -142,6 +138,7 @@ END_EVENT_TABLE()
*/
void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
// JEY TODO: OBSOLETE?
int id = event.GetId();
GERBER_DRAW_ITEM* currItem = (GERBER_DRAW_ITEM*) GetScreen()->GetCurItem();
@ -372,40 +369,3 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
if( needs_refresh )
UpdateDisplayOptions( options );
}
void GERBVIEW_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{
switch( aEvent.GetId() )
{
case ID_MENU_CANVAS_CAIRO:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break;
case ID_MENU_CANVAS_OPENGL:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
break;
}
}
void GERBVIEW_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
{
wxMenuBar* menuBar = GetMenuBar();
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = gal_canvas->GetBackend();
struct { int menuId; int galType; } menuList[] =
{
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
};
for( auto ii : menuList )
{
wxMenuItem* item = menuBar->FindItem( ii.menuId );
if( item && ii.galType == canvasType )
item->Check( true );
}
}

View File

@ -213,7 +213,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
}
GetGalCanvas()->SwitchBackend( canvasType );
UseGalCanvas( true );
UseGalCanvas();
// Enable the axes to match legacy draw style
auto& galOptions = GetGalDisplayOptions();
@ -1136,44 +1136,28 @@ void GERBVIEW_FRAME::unitsChangeRefresh()
}
void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
void GERBVIEW_FRAME::UseGalCanvas()
{
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
EDA_DRAW_FRAME::UseGalCanvas();
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
if( m_toolManager )
{
m_toolManager->SetEnvironment( m_gerberLayout, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
if( aEnable )
{
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
m_colorsSettings->SetLegacyMode( false );
galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) );
SetPageSettings( GetPageSettings() );
galCanvas->GetView()->RecacheAllItems();
galCanvas->SetEventDispatcher( m_toolDispatcher );
galCanvas->StartDrawing();
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
}
else
{
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
galCanvas->StopDrawing();
m_colorsSettings->SetLegacyMode( false );
// Redirect all events to the legacy canvas
galCanvas->SetEventDispatcher( NULL );
galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) );
m_colorsSettings->SetLegacyMode( true );
m_canvas->Refresh();
}
SetPageSettings( GetPageSettings() );
galCanvas->GetView()->RecacheAllItems();
galCanvas->SetEventDispatcher( m_toolDispatcher );
galCanvas->StartDrawing();
m_LayersManager->ReFill();
m_LayersManager->ReFillRender();

View File

@ -599,17 +599,7 @@ public:
}
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
virtual void UseGalCanvas( bool aEnable ) override;
/**
* switches currently used canvas (default / Cairo / OpenGL).
*/
void OnSwitchCanvas( wxCommandEvent& aEvent );
/**
* Update UI called when switches currently used canvas (default / Cairo / OpenGL).
*/
void OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent );
virtual void UseGalCanvas() override;
/**
* Allows Gerbview to install its preferences panels into the preferences dialog.

View File

@ -180,11 +180,11 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
viewMenu->AppendSeparator();
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomTool, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomTool, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AppendSeparator();
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
@ -238,34 +238,30 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
//-- Preferences menu -----------------------------------------------
//
wxMenu* preferencesMenu = new wxMenu;
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
CONDITIONAL_MENU* preferencesMenu = new CONDITIONAL_MENU( false, selTool );
// Options (Preferences on WXMAC)
text = AddHotkeyName( _( "&Preferences..." ), GerbviewHotkeysDescr, HK_PREFERENCES );
AddMenuItem( preferencesMenu, wxID_PREFERENCES, text,
_( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) );
preferencesMenu->AddItem( wxID_PREFERENCES, text, _( "Show preferences for all open tools" ),
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
// Canvas selection
preferencesMenu->AppendSeparator();
text = AddHotkeyName( _( "Accelerated Graphics" ), GerbviewHotkeysDescr, HK_CANVAS_OPENGL );
AddMenuItem( preferencesMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Standard Graphics" ), GerbviewHotkeysDescr, HK_CANVAS_CAIRO );
AddMenuItem( preferencesMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
preferencesMenu->AppendSeparator();
// Language submenu
preferencesMenu->AddSeparator();
Pgm().AddMenuLanguageList( preferencesMenu );
//
// Append menus to the menubar
preferencesMenu->AddSeparator();
preferencesMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
preferencesMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
preferencesMenu->AppendSeparator();
//-- Menubar -----------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( viewMenu, _( "&View" ) );

View File

@ -703,8 +703,6 @@ public:
wxString GetToolMsg() { return m_toolMsg; }
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) {}
virtual void ToolOnRightClick( wxCommandEvent& event );
void AdjustScrollBars( const wxPoint& aCenterPosition );
/**
* Called when modifying the page settings.
@ -812,18 +810,14 @@ public:
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting();
/**
* Use to switch between standard and GAL-based canvas.
*
* @param aEnable True for GAL-based canvas, false for standard canvas.
* Use to start up the GAL drawing canvas.
*/
virtual void UseGalCanvas( bool aEnable );
virtual void UseGalCanvas();
/**
* Changes the current rendering backend.
* aCanvasType is the new rendering backend type.
* @return true if any kind of GAL canvas is used.
*/
virtual bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
virtual void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
/**
* Return a pointer to GAL-based canvas of given EDA draw frame.

View File

@ -514,8 +514,6 @@ public:
void OnToggleEdgeDrawMode( wxCommandEvent& aEvent );
void OnToggleTextDrawMode( wxCommandEvent& aEvent );
virtual void OnSwitchCanvas( wxCommandEvent& aEvent );
// User interface update event handlers.
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
@ -536,12 +534,7 @@ public:
void SetFastGrid2();
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
virtual void UseGalCanvas( bool aEnable ) override;
/**
* Update UI called when switches currently used canvas (default / Cairo / OpenGL).
*/
void OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent );
virtual void UseGalCanvas() override;
PCB_GENERAL_SETTINGS& Settings()
{

View File

@ -46,11 +46,13 @@ public:
// Generic document actions
static TOOL_ACTION doNew; // sadly 'new' is a reserved word
static TOOL_ACTION newLibrary;
static TOOL_ACTION open;
static TOOL_ACTION save;
static TOOL_ACTION saveAs;
static TOOL_ACTION saveCopyAs;
static TOOL_ACTION saveAll;
static TOOL_ACTION revert;
static TOOL_ACTION pageSettings;
static TOOL_ACTION print;
static TOOL_ACTION plot;
@ -128,6 +130,10 @@ public:
static TOOL_ACTION toggleUnits;
static TOOL_ACTION togglePolarCoords;
// Misc
static TOOL_ACTION acceleratedGraphics;
static TOOL_ACTION standardGraphics;
/**
* Function TranslateLegacyId()
* Translates legacy tool ids to the corresponding TOOL_ACTION name.

View File

@ -78,6 +78,8 @@ public:
int ToggleGrid( const TOOL_EVENT& aEvent );
int GridProperties( const TOOL_EVENT& aEvent );
int SwitchCanvas( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -180,7 +180,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( true );
UseGalCanvas();
m_auimgr.Update();

View File

@ -293,7 +293,6 @@ set( PCBNEW_CLASS_SRCS
text_mod_grid_table.cpp
toolbars_footprint_editor.cpp
toolbars_footprint_viewer.cpp
toolbar_onrightclick.cpp
toolbars_pcb_editor.cpp
tracks_cleaner.cpp
undo_redo.cpp

View File

@ -145,15 +145,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
// Switching canvases
EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas )
// UI update events.
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
EVT_UPDATE_UI( ID_MODEDIT_SAVE, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
EVT_UPDATE_UI( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs )
EVT_UPDATE_UI( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateSave )
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
@ -291,7 +283,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
UseGalCanvas();
m_auimgr.Update();
updateTitle();
@ -313,15 +305,15 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
// switches currently used canvas (default / Cairo / OpenGL).
PCB_BASE_FRAME::OnSwitchCanvas( aEvent );
// switches currently used canvas (Cairo / OpenGL).
PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
// The base class method *does not reinit* the layers manager.
// We must upate the layer widget to match board visibility states,
// both layers and render columns, and and some settings dependent on the canvas.
// The base class method *does not reinit* the layers manager. We must upate the layer
// widget to match board visibility states, both layers and render columns, and and some
// settings dependent on the canvas.
UpdateUserInterface();
}
@ -572,29 +564,6 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent )
}
void FOOTPRINT_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
{
if( aEvent.GetId() == ID_MODEDIT_SAVE )
{
wxString text = IsCurrentFPFromBoard() ? _( "&Update Footprint on Board" ) : _( "&Save" );
text = AddHotkeyName( text, m_hotkeysDescrList, HK_SAVE );
aEvent.SetText( text );
}
aEvent.Enable( GetBoard()->m_Modules && GetScreen()->IsModify() );
}
void FOOTPRINT_EDIT_FRAME::OnUpdateSaveAs( wxUpdateUIEvent& aEvent )
{
LIB_ID libId = getTargetFPID();
const wxString& libName = libId.GetLibNickname();
const wxString& partName = libId.GetLibItemName();
aEvent.Enable( !libName.IsEmpty() || !partName.IsEmpty() );
}
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
{
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );
@ -940,16 +909,13 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
}
void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
void FOOTPRINT_EDIT_FRAME::UseGalCanvas()
{
PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
PCB_BASE_EDIT_FRAME::UseGalCanvas();
if( aEnable )
{
// Be sure the axis are enabled:
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
updateView();
}
// Be sure the axis are enabled:
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
updateView();
ReCreateMenuBar();

View File

@ -92,10 +92,10 @@ public:
void CloseModuleEditor( wxCommandEvent& Event );
/**
* switches currently used canvas (default / Cairo / OpenGL).
* switches currently used canvas (Cairo / OpenGL).
* It also reinit the layers manager that slightly changes with canvases
*/
void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
/**
* Update the layer manager and other widgets from the board setup
@ -133,7 +133,6 @@ public:
// The Tool Framework initalization, for GAL mode
void setupTools();
void ToolOnRightClick( wxCommandEvent& event ) override;
void OnConfigurePaths( wxCommandEvent& aEvent );
void OnToggleSearchTree( wxCommandEvent& event );
@ -321,7 +320,7 @@ public:
void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void UseGalCanvas( bool aEnable ) override;
void UseGalCanvas() override;
/**
* Load a KiCad board (.kicad_pcb) from \a aFileName.

View File

@ -239,7 +239,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( true );
UseGalCanvas();
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
GetGalCanvas()->GetView()->SetScale( m_lastZoom );

View File

@ -236,7 +236,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
UseGalCanvas();
updateView();
SetActiveLayer( F_Cu );

View File

@ -47,105 +47,92 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar();
wxString text;
// Recreate all menus:
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
return GetBoard()->m_Modules && GetScreen()->IsModify();
};
auto libraryPartCondition = [ this ] ( const SELECTION& sel ) {
LIB_ID libId = getTargetFPID();
const wxString& libName = libId.GetLibNickname();
const wxString& partName = libId.GetLibItemName();
// Menu File:
wxMenu* fileMenu = new wxMenu;
return( !libName.IsEmpty() || !partName.IsEmpty() );
};
AddMenuItem( fileMenu,
ID_MODEDIT_CREATE_NEW_LIB,
_( "New Library..." ),
_( "Creates an empty library" ),
KiBitmap( new_library_xpm ) );
//-- File menu -----------------------------------------------
//
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
AddMenuItem( fileMenu,
ID_MODEDIT_ADD_LIBRARY,
_( "Add Library..." ),
_( "Adds a previously created library" ),
KiBitmap( add_library_xpm ) );
fileMenu->AddItem( ID_MODEDIT_CREATE_NEW_LIB,
_( "New Library..." ),
_( "Creates an empty library" ),
new_library_xpm, SELECTION_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW );
AddMenuItem( fileMenu, ID_MODEDIT_NEW_MODULE,
text, _( "Create a new footprint" ),
KiBitmap( new_footprint_xpm ) );
fileMenu->AddItem( ID_MODEDIT_ADD_LIBRARY,
_( "Add Library..." ),
_( "Adds a previously created library" ),
add_library_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE,
AddHotkeyName( _( "&New Footprint..." ), m_hotkeysDescrList, HK_NEW ),
_( "Create a new footprint" ),
new_footprint_xpm, SELECTION_CONDITIONS::ShowAlways );
#ifdef KICAD_SCRIPTING
AddMenuItem( fileMenu, ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
_( "&Create Footprint..." ),
_( "Create a new footprint using the footprint wizard" ),
KiBitmap( module_wizard_xpm ) );
fileMenu->AddItem( ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
_( "&Create Footprint..." ),
_( "Create a new footprint using the footprint wizard" ),
module_wizard_xpm, SELECTION_CONDITIONS::ShowAlways );
#endif
fileMenu->AppendSeparator();
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
fileMenu->AddItem( ACTIONS::saveAs, libraryPartCondition );
fileMenu->AddItem( ID_MODEDIT_REVERT_PART,
_( "Revert" ),
_( "Throw away changes" ),
undo_xpm, modifiedDocumentCondition );
text = AddHotkeyName( _( "&Save" ), m_hotkeysDescrList, HK_SAVE );
AddMenuItem( fileMenu, ID_MODEDIT_SAVE, text,
_( "Save changes" ),
KiBitmap( save_xpm ) );
fileMenu->AddSeparator();
text = AddHotkeyName( _( "Save &As..." ), m_hotkeysDescrList, HK_SAVEAS );
AddMenuItem( fileMenu, ID_MODEDIT_SAVE_AS, text,
_( "Save a copy to a new name and/or location" ),
KiBitmap( save_as_xpm ) );
ACTION_MENU* submenuImport = new ACTION_MENU();
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( import_xpm );
AddMenuItem( fileMenu, ID_MODEDIT_REVERT_PART,
_( "&Revert" ),
_( "Throw away changes" ),
KiBitmap( undo_xpm ) );
submenuImport->Add( _( "&Footprint..." ),
_( "Import a footprint from file" ),
ID_MODEDIT_IMPORT_PART, import_module_xpm );
fileMenu->AppendSeparator();
submenuImport->Add( _( "&Graphics..." ),
_( "Import 2D Drawing file to Footprint Editor on Drawings layer" ),
ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm );
wxMenu* submenuImport = new wxMenu();
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways );
AddMenuItem( submenuImport, ID_MODEDIT_IMPORT_PART,
_( "&Footprint..." ),
_( "Import a footprint from file" ),
KiBitmap( import_module_xpm ) );
CONDITIONAL_MENU* submenuExport = new CONDITIONAL_MENU( false, selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm );
AddMenuItem( submenuImport, ID_GEN_IMPORT_GRAPHICS_FILE,
_( "&Graphics..." ),
_( "Import 2D Drawing file to Footprint Editor on Drawings layer" ),
KiBitmap( import_vector_xpm ) );
submenuExport->AddItem( ID_MODEDIT_EXPORT_PART, _( "&Footprint..." ),
_( "Export current footprint to a file" ),
export_module_xpm, modifiedDocumentCondition );
AddMenuItem( fileMenu, submenuImport,
ID_GEN_IMPORT_FILE, _( "&Import" ),
_( "Import files" ), KiBitmap( import_xpm ) );
submenuExport->AddItem( ID_MODEDIT_SAVE_PNG, _( "View as &PNG..." ),
_( "Create a PNG file from the current view" ),
plot_xpm, SELECTION_CONDITIONS::ShowAlways );
wxMenu* submenuExport = new wxMenu();
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways );
AddMenuItem( submenuExport, ID_MODEDIT_EXPORT_PART,
_( "&Footprint..." ),
_( "Export current footprint to a file" ),
KiBitmap( export_module_xpm ) );
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
AddMenuItem( submenuExport, ID_MODEDIT_SAVE_PNG,
_( "View as &PNG..." ),
_( "Create a PNG file from the current view" ),
KiBitmap( plot_xpm ) );
fileMenu->AddSeparator();
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
AddMenuItem( fileMenu, submenuExport,
ID_GEN_EXPORT_FILE, _( "&Export" ),
_( "Export files" ), KiBitmap( export_xpm ) );
fileMenu->AppendSeparator();
// Print
text = AddHotkeyName( _( "&Print..." ), m_hotkeysDescrList, HK_PRINT );
AddMenuItem( fileMenu, wxID_PRINT, text,
_( "Print current footprint" ),
KiBitmap( print_button_xpm ) );
fileMenu->AppendSeparator();
// Close editor
AddMenuItem( fileMenu, wxID_EXIT,
_( "&Exit" ),
_( "Close footprint editor" ),
KiBitmap( exit_xpm ) );
//----- Edit menu ------------------
//-- Edit menu -----------------------------------------------
//
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) {
@ -158,7 +145,6 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
return GetToolId() == ID_NO_TOOL_SELECTED;
};
text = AddHotkeyName( _( "&Undo" ), g_Board_Editor_Hotkeys_Descr, HK_UNDO );
editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
@ -185,7 +171,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
_( "Delete the current footprint" ),
KiBitmap( delete_xpm ) );
//--------- View menu ----------------
//-- View menu -----------------------------------------------
//
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
auto gridShownCondition = [ this ] ( const SELECTION& aSel ) {
@ -217,12 +204,13 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
};
viewMenu->AddItem( ID_OPEN_MODULE_VIEWER,
_( "Footprint &Library Browser" ), _( "Browse footprint libraries" ),
_( "Footprint &Library Browser" ),
_( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&3D Viewer" ), m_hotkeysDescrList, HK_3D_VIEWER );
viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME,
text, _( "Show footprint in 3D viewer" ),
AddHotkeyName( _( "&3D Viewer" ), m_hotkeysDescrList, HK_3D_VIEWER ),
_( "Show footprint in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
@ -272,8 +260,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
_( "&Search Tree" ), _( "Toggles the search tree visibility" ),
search_tree_xpm, searchTreeShownCondition );
//-------- Place menu --------------------
//-- Place menu -----------------------------------------------
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
placeMenu->AddItem( PCB_ACTIONS::placePad, SELECTION_CONDITIONS::ShowAlways );
@ -290,15 +278,17 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways );
//----- Inspect menu ---------------------
//-- Inspect menu -----------------------------------------------
//
wxMenu* inspectMenu = new wxMenu;
text = AddHotkeyName( _( "&Measure" ), m_hotkeysDescrList, HK_MEASURE_TOOL );
AddMenuItem( inspectMenu, ID_MODEDIT_MEASUREMENT_TOOL,
text, _( "Measure distance" ),
AddHotkeyName( _( "&Measure" ), m_hotkeysDescrList, HK_MEASURE_TOOL ),
_( "Measure distance" ),
KiBitmap( measurement_xpm ) );
//----- Tools menu ---------------------
//-- Tools menu -----------------------------------------------
//
wxMenu* toolsMenu = new wxMenu;
AddMenuItem( toolsMenu, ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
@ -312,52 +302,46 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
KiBitmap( insert_module_board_xpm ) );
//----- Preferences menu -----------------
wxMenu* prefs_menu = new wxMenu;
//-- Preferences menu -----------------------------------------------
//
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool );
// Path configuration edit dialog.
AddMenuItem( prefs_menu,
ID_PREFERENCES_CONFIGURE_PATHS,
_( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
KiBitmap( path_xpm ) );
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
AddMenuItem( prefs_menu, ID_PCB_LIB_TABLE_EDIT,
_( "Manage &Footprint Libraries..." ), _( "Configure footprint library table" ),
KiBitmap( library_table_xpm ) );
prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
path_xpm, SELECTION_CONDITIONS::ShowAlways );
// Settings
text = AddHotkeyName( _( "&Preferences..." ), m_hotkeysDescrList, HK_PREFERENCES );
AddMenuItem( prefs_menu, wxID_PREFERENCES, text,
_( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) );
prefsMenu->AddItem( ID_PCB_LIB_TABLE_EDIT, _( "Manage &Footprint Libraries..." ),
_( "Edit the global and project footprint library tables." ),
library_table_xpm, SELECTION_CONDITIONS::ShowAlways );
prefs_menu->AppendSeparator();
prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "&Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ),
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "Accelerated Graphics" ), m_hotkeysDescrList, HK_CANVAS_OPENGL );
AddMenuItem( prefs_menu, ID_MENU_CANVAS_OPENGL, text,
_( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu );
text = AddHotkeyName( _( "Standard Graphics" ), m_hotkeysDescrList, HK_CANVAS_CAIRO );
AddMenuItem( prefs_menu, ID_MENU_CANVAS_CAIRO, text,
_( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
prefsMenu->AddSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
prefs_menu->AppendSeparator();
// Language submenu
Pgm().AddMenuLanguageList( prefs_menu );
//------------------------------------
// Append menus to the menubar
//--MenuBar -----------------------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( prefs_menu, _( "P&references" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );

View File

@ -42,21 +42,9 @@
#include "pcbnew_id.h"
// Build the place submenu
static void preparePlaceMenu( CONDITIONAL_MENU* aPlaceMenu, SELECTION_TOOL* aSelectionTool );
// Build the route menu
static void prepareRouteMenu( wxMenu* aParentMenu );
// Build the inspect menu
static void prepareInspectMenu( wxMenu* aParentMenu );
// Build the library management menu
static void prepareLibraryMenu( wxMenu* aParentMenu );
// Build the preferences menu
static void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
// Build the tools menu
static void prepareToolsMenu( wxMenu* aParentMenu );
@ -68,7 +56,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
wxMenuBar* menuBar = new wxMenuBar();
wxString text;
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen()->IsModify();
@ -76,7 +63,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Recreate all menus:
//----- Edit menu -----------------------------------------------------------
//-- File menu -----------------------------------------------------------
//
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
static ACTION_MENU* openRecentMenu;
@ -134,7 +122,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddSeparator();
//----- Import submenu ------------------------------------------------------
// Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU();
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) );
@ -149,7 +137,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways );
//----- Export submenu ------------------------------------------------------
// Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU();
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) );
@ -175,7 +163,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways );
//----- Fabrication Outputs submenu -----------------------------------------
// Fabrication Outputs submenu
ACTION_MENU* submenuFabOutputs = new ACTION_MENU();
submenuFabOutputs->SetTool( selTool );
submenuFabOutputs->SetTitle( _( "Fabrication Outputs" ) );
@ -214,7 +202,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::plot, SELECTION_CONDITIONS::ShowAlways );
//----- archive submenu -----------------------------------------------------
// Archive submenu
ACTION_MENU* submenuArchive = new ACTION_MENU();
submenuArchive->SetTool( selTool );
submenuArchive->SetTitle( _( "Archive Footprints" ) );
@ -237,7 +225,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via wxID_EXIT
fileMenu->AddItem( wxID_EXIT, _( "Quit" ), "", exit_xpm, SELECTION_CONDITIONS::ShowAlways );
//----- Edit menu -----------------------------------------------------------
//-- Edit menu -----------------------------------------------------------
//
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) {
@ -349,15 +338,18 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
_( "Show La&yers Manager" ), HELP_SHOW_HIDE_LAYERMANAGER,
layers_manager_xpm, layersPaletteShownCondition );
viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
_( "Show Microwa&ve Toolbar" ), HELP_SHOW_HIDE_MICROWAVE_TOOLS,
mw_toolbar_xpm, microwaveToolbarShownCondition );
viewMenu->AddItem( ID_OPEN_MODULE_VIEWER,
_( "Footprint &Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&3D Viewer" ), g_Board_Editor_Hotkeys_Descr, HK_3D_VIEWER );
viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME,
text, _( "Show board in 3D viewer" ),
AddHotkeyName( _( "&3D Viewer" ), g_Board_Editor_Hotkeys_Descr, HK_3D_VIEWER ),
_( "Show board in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
@ -420,30 +412,110 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AppendSeparator();
#endif
//----- Place Menu ----------------------------------------------------------
//-- Place Menu ----------------------------------------------------------
//
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
preparePlaceMenu( placeMenu, selTool );
//----- Route Menu ----------------------------------------------------------
placeMenu->AddItem( PCB_ACTIONS::placeModule, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawVia, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawZone, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( PCB_ACTIONS::drawDimension, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( PCB_ACTIONS::placeTarget, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( PCB_ACTIONS::drillOrigin, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
ACTION_MENU* autoplaceSubmenu = new ACTION_MENU;
autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) );
autoplaceSubmenu->SetTool( selTool );
autoplaceSubmenu->SetIcon( mode_module_xpm );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents );
placeMenu->AddMenu( autoplaceSubmenu );
//-- Route Menu ----------------------------------------------------------
//
wxMenu* routeMenu = new wxMenu;
prepareRouteMenu( routeMenu );
//----- Inspect Menu --------------------------------------------------------
//-- Inspect Menu --------------------------------------------------------
//
wxMenu* inspectMenu = new wxMenu;
prepareInspectMenu( inspectMenu );
//----- Tools menu ----------------------------------------------------------
AddMenuItem( inspectMenu, ID_MENU_LIST_NETS,
_( "&List Nets" ),
_( "View list of nets with names and IDs" ),
KiBitmap( list_nets_xpm ) );
AddMenuItem( inspectMenu, ID_PCB_MEASUREMENT_TOOL,
AddHotkeyName( _( "&Measure" ), g_Board_Editor_Hotkeys_Descr, HK_MEASURE_TOOL ),
_( "Measure distance" ),
KiBitmap( measurement_xpm ) );
inspectMenu->AppendSeparator();
AddMenuItem( inspectMenu, ID_DRC_CONTROL,
_( "&Design Rules Checker" ),
_( "Perform design rules check" ),
KiBitmap( erc_xpm ) );
//-- Tools menu ----------------------------------------------------------
//
wxMenu* toolsMenu = new wxMenu;
prepareToolsMenu( toolsMenu );
//----- Preferences and configuration menu ----------------------------------
wxMenu* configmenu = new wxMenu;
prepareLibraryMenu( configmenu );
configmenu->AppendSeparator();
//-- Preferences menu ----------------------------------------------------
//
CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool );
preparePreferencesMenu( this, configmenu );
auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
};
auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
};
//------ Append all menus to the menuBar ------------------------------------
prefsMenu->AddItem( ID_PREFERENCES_CONFIGURE_PATHS, _( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
path_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddItem( ID_PCB_LIB_TABLE_EDIT, _( "Manage &Footprint Libraries..." ),
_( "Edit the global and project footprint library tables." ),
library_table_xpm, SELECTION_CONDITIONS::ShowAlways );
#ifdef BUILD_GITHUB_PLUGIN
prefsMenu->AddItem( ID_PCB_3DSHAPELIB_WIZARD, _( "Add &3D Shapes Libraries Wizard..." ),
_( "Download 3D shape libraries from GitHub" ),
import3d_xpm, SELECTION_CONDITIONS::ShowAlways );
#endif
prefsMenu->AddItem( wxID_PREFERENCES,
AddHotkeyName( _( "&Preferences..." ), g_Module_Editor_Hotkeys_Descr, HK_PREFERENCES ),
_( "Show preferences for all open tools" ),
preference_xpm, SELECTION_CONDITIONS::ShowAlways );
prefsMenu->AddSeparator();
Pgm().AddMenuLanguageList( prefsMenu );
prefsMenu->AddSeparator();
prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition );
prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition );
//--MenuBar -----------------------------------------------------------
//
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
@ -451,7 +523,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
menuBar->Append( routeMenu, _( "Ro&ute" ) );
menuBar->Append( inspectMenu, _( "&Inspect" ) );
menuBar->Append( toolsMenu, _( "&Tools" ) );
menuBar->Append( configmenu, _( "P&references" ) );
menuBar->Append( prefsMenu, _( "P&references" ) );
AddStandardHelpMenu( menuBar );
SetMenuBar( menuBar );
@ -465,73 +537,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
}
// Build the preferences menu
void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu )
{
wxString text;
text = AddHotkeyName( _( "&Preferences..." ), g_Board_Editor_Hotkeys_Descr, HK_PREFERENCES );
AddMenuItem( aParentMenu, wxID_PREFERENCES, text,
_( "Show preferences for all open tools" ),
KiBitmap( preference_xpm ) );
text = AddHotkeyName( _( "Accelerated Graphics" ), g_Board_Editor_Hotkeys_Descr,
HK_CANVAS_OPENGL );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, text,
_( "Use hardware-accelerated graphics (recommended)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
text = AddHotkeyName( _( "Standard Graphics" ), g_Board_Editor_Hotkeys_Descr,
HK_CANVAS_CAIRO );
AddMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, text,
_( "Use software graphics (fall-back)" ),
KiBitmap( tools_xpm ), wxITEM_RADIO );
aParentMenu->AppendSeparator();
// Language submenu
Pgm().AddMenuLanguageList( aParentMenu );
}
// Build the place submenu
void preparePlaceMenu( CONDITIONAL_MENU* aPlaceMenu, SELECTION_TOOL* aSelectionTool )
{
aPlaceMenu->AddItem( PCB_ACTIONS::placeModule, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawVia, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawZone, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddSeparator();
aPlaceMenu->AddItem( PCB_ACTIONS::drawDimension, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddSeparator();
aPlaceMenu->AddItem( PCB_ACTIONS::placeTarget, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddSeparator();
aPlaceMenu->AddItem( PCB_ACTIONS::drillOrigin, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddItem( ACTIONS::gridSetOrigin, SELECTION_CONDITIONS::ShowAlways );
aPlaceMenu->AddSeparator();
ACTION_MENU* autoplaceSubmenu = new ACTION_MENU;
autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) );
autoplaceSubmenu->SetTool( aSelectionTool );
autoplaceSubmenu->SetIcon( mode_module_xpm );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceSelectedComponents );
aPlaceMenu->AddMenu( autoplaceSubmenu );
}
// Build the route menu
void prepareRouteMenu( wxMenu* aParentMenu )
{
@ -584,53 +589,6 @@ void prepareRouteMenu( wxMenu* aParentMenu )
}
// Build the inspect menu
void prepareInspectMenu( wxMenu* aParentMenu )
{
wxString text;
AddMenuItem( aParentMenu, ID_MENU_LIST_NETS,
_( "&List Nets" ),
_( "View list of nets with names and IDs" ),
KiBitmap( list_nets_xpm ) );
text = AddHotkeyName( _( "&Measure" ), g_Board_Editor_Hotkeys_Descr, HK_MEASURE_TOOL );
AddMenuItem( aParentMenu, ID_PCB_MEASUREMENT_TOOL, text,
_( "Measure distance" ),
KiBitmap( measurement_xpm ) );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_DRC_CONTROL,
_( "&Design Rules Checker" ),
_( "Perform design rules check" ),
KiBitmap( erc_xpm ) );
}
// Build the library management menu
void prepareLibraryMenu( wxMenu* aParentMenu )
{
AddMenuItem( aParentMenu,
ID_PREFERENCES_CONFIGURE_PATHS,
_( "&Configure Paths..." ),
_( "Edit path configuration environment variables" ),
KiBitmap( path_xpm ) );
AddMenuItem( aParentMenu, ID_PCB_LIB_TABLE_EDIT,
_( "Manage &Footprint Libraries..." ),
_( "Edit the global and project footprint library lists" ),
KiBitmap( library_table_xpm ) );
#ifdef BUILD_GITHUB_PLUGIN
AddMenuItem( aParentMenu, ID_PCB_3DSHAPELIB_WIZARD,
_( "Add &3D Shapes Libraries Wizard..." ),
_( "Download 3D shape libraries from GitHub" ),
KiBitmap( import3d_xpm ) );
#endif
}
// Build the tools menu
void prepareToolsMenu( wxMenu* aParentMenu )
{

View File

@ -62,15 +62,11 @@ void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
}
void PCB_BASE_EDIT_FRAME::UseGalCanvas( bool aEnable )
void PCB_BASE_EDIT_FRAME::UseGalCanvas()
{
PCB_BASE_FRAME::UseGalCanvas( aEnable );
PCB_BASE_FRAME::UseGalCanvas();
// No matter what, reenable undo/redo on switching to the legacy canvas
if( !aEnable )
UndoRedoBlock( false );
else
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
}

View File

@ -173,7 +173,7 @@ public:
void InstallGraphicItemPropertiesDialog( BOARD_ITEM* aItem );
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void UseGalCanvas( bool aEnable ) override;
void UseGalCanvas() override;
///> @copydoc PCB_BASE_FRAME::SetBoard()
virtual void SetBoard( BOARD* aBoard ) override;

View File

@ -88,9 +88,6 @@ BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
// Switching canvases
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, PCB_BASE_FRAME::OnUpdateSelectZoom )
END_EVENT_TABLE()
@ -593,21 +590,6 @@ void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
}
void PCB_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{
switch( aEvent.GetId() )
{
case ID_MENU_CANVAS_CAIRO:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break;
case ID_MENU_CANVAS_OPENGL:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
break;
}
}
void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
{
if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
@ -998,62 +980,29 @@ void PCB_BASE_FRAME::SetFastGrid2()
}
void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
void PCB_BASE_FRAME::UseGalCanvas()
{
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
EDA_DRAW_FRAME::UseGalCanvas();
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
GetGalCanvas()->GetViewControls(), this );
if( aEnable )
{
SetBoard( m_Pcb );
SetBoard( m_Pcb );
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
// Transfer latest current display options from legacy to GAL canvas:
auto painter = static_cast<KIGFX::PCB_PAINTER*>( galCanvas->GetView()->GetPainter() );
auto settings = painter->GetSettings();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
// Transfer latest current display options from legacy to GAL canvas:
auto painter = static_cast<KIGFX::PCB_PAINTER*>( galCanvas->GetView()->GetPainter() );
auto settings = painter->GetSettings();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
galCanvas->GetView()->RecacheAllItems();
galCanvas->SetEventDispatcher( m_toolDispatcher );
galCanvas->StartDrawing();
}
else
{
if( m_toolManager )
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
// Redirect all events to the legacy canvas
galCanvas->SetEventDispatcher( NULL );
}
galCanvas->GetView()->RecacheAllItems();
galCanvas->SetEventDispatcher( m_toolDispatcher );
galCanvas->StartDrawing();
}
void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
{
wxMenuBar* menuBar = GetMenuBar();
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
canvasType = gal_canvas->GetBackend();
struct { int menuId; int galType; } menuList[] =
{
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
};
for( auto ii: menuList )
{
wxMenuItem* item = menuBar->FindItem( ii.menuId );
if( item && ii.galType == canvasType )
item->Check( true );
}
}

View File

@ -385,10 +385,10 @@ void PCB_DRAW_PANEL_GAL::OnShow()
{
// Fallback to software renderer
DisplayError( frame, e.what() );
bool use_gal = SwitchBackend( GAL_TYPE_CAIRO );
SwitchBackend( GAL_TYPE_CAIRO );
if( frame )
frame->UseGalCanvas( use_gal );
frame->UseGalCanvas();
}
if( frame )

View File

@ -182,10 +182,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
// Switching canvases
EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::OnSwitchCanvas )
// Menu Get Design Rules Editor
EVT_MENU( ID_BOARD_SETUP_DIALOG, PCB_EDIT_FRAME::ShowBoardSetupDialog )
@ -411,7 +407,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
UseGalCanvas( true );
UseGalCanvas();
// disable Export STEP item if kicad2step does not exist
wxString strK2S = Pgm().GetExecutablePath();
@ -628,9 +624,9 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
}
void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
void PCB_EDIT_FRAME::UseGalCanvas()
{
PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
PCB_BASE_EDIT_FRAME::UseGalCanvas();
COLORS_DESIGN_SETTINGS& cds = Settings().Colors();
cds.SetLegacyMode( false );
@ -999,14 +995,13 @@ void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
}
void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
void PCB_EDIT_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
// switches currently used canvas (Cairo / OpenGL).
PCB_BASE_FRAME::OnSwitchCanvas( aEvent );
PCB_BASE_FRAME::SwitchCanvas( aCanvasType );
// The base class method *does not reinit* the layers manager.
// We must upate the layer widget to match board visibility states,
// both layers and render columns.
// The base class method *does not reinit* the layers manager. We must upate the
// layer widget to match board visibility states, both layers and render columns.
syncLayerVisibilities();
syncLayerWidgetLayer();
syncRenderStates();

View File

@ -103,10 +103,10 @@ protected:
wxString createBackupFile( const wxString& aFileName );
/**
* switches currently used canvas (default / Cairo / OpenGL).
* switches currently used canvas (Cairo / OpenGL).
* It also reinit the layers manager that slightly changes with canvases
*/
void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
void SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
/**
@ -573,7 +573,7 @@ public:
void Show3D_Frame( wxCommandEvent& event ) override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void UseGalCanvas( bool aEnable ) override;
void UseGalCanvas() override;
/**
* Function ShowBoardSetupDialog
@ -588,7 +588,6 @@ public:
void OnSelectOptionToolbar( wxCommandEvent& event );
void OnFlipPcbView( wxCommandEvent& event );
void ToolOnRightClick( wxCommandEvent& event ) override;
void InstallPcbGlobalDeleteFrame( const wxPoint& pos );

View File

@ -380,7 +380,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
GetScreen()->PushCommandToUndoList( oldBuffer );
UseGalCanvas( GetGalCanvas() );
UseGalCanvas();
}

View File

@ -158,7 +158,7 @@ void Refresh()
auto gal_canvas = static_cast<PCB_DRAW_PANEL_GAL*>( s_PcbEditFrame->GetGalCanvas() );
// Reinit everything: this is the easy way to do that
s_PcbEditFrame->UseGalCanvas( true );
s_PcbEditFrame->UseGalCanvas();
gal_canvas->Refresh();
}
}

View File

@ -1,49 +0,0 @@
/**
* @file tool_onrightclick.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2012 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 Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <confirm.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <footprint_edit_frame.h>
#include <pcbnew_id.h>
void PCB_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
if( event.GetSelection() == ID_PCB_PLACE_GRID_COORD_BUTT )
InvokeDialogGrid();
}
void FOOTPRINT_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
if( event.GetSelection() == ID_PCB_PLACE_GRID_COORD_BUTT )
InvokeDialogGrid();
}