Start moving some LibEdit and SchEdit menubar menus to actions.

Also includes a bunch of bug fixes that got intermingled.

Fixes: lp:1828826
* https://bugs.launchpad.net/kicad/+bug/1828826

Fixes: lp:1828826
* https://bugs.launchpad.net/kicad/+bug/1828826

Fixes: lp:1828793
* https://bugs.launchpad.net/kicad/+bug/1828793
This commit is contained in:
Jeff Young 2019-05-13 21:42:40 +01:00
parent d290154dd3
commit ef5c69167a
52 changed files with 543 additions and 564 deletions

View File

@ -110,10 +110,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
EDA_DRAW_FRAME::OnUpdateUnits )
END_EVENT_TABLE()
@ -323,6 +319,7 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
SetGridVisibility( !IsGridVisible() );
if( IsGalCanvasActive() )
@ -363,6 +360,7 @@ void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
auto& galOpts = GetGalDisplayOptions();
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
@ -387,29 +385,10 @@ void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
}
void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
{
bool enable;
enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (m_UserUnits == MILLIMETRES))
|| ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (m_UserUnits == INCHES)) );
aEvent.Check( enable );
DisplayUnitsMsg();
}
void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
{
wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
aEvent.Check( IsGridVisible() );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{
// JEY TODO: obsolete when everything moves to COMMON_TOOLS
// No need to update the grid select box if it doesn't exist or the grid setting change
// was made using the select box.
if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
@ -431,12 +410,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
}
void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
}
void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar()
{
}

View File

@ -10,38 +10,49 @@ TOOL_ACTION ACTIONS::cancelInteractive( "common.Interactive.cancel",
_( "Cancel" ), _( "Cancel current tool" ),
cancel_xpm, AF_NONE );
TOOL_ACTION ACTIONS::updateMenu( "common.Interactive.updateMenu",
AS_GLOBAL, 0, "", "" ); // This is an internal event
// View Controls
TOOL_ACTION ACTIONS::zoomRedraw( "common.Control.zoomRedraw",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_REDRAW ),
_( "Refresh View" ), "", zoom_redraw_xpm );
_( "Refresh View" ), "",
zoom_redraw_xpm );
TOOL_ACTION ACTIONS::zoomIn( "common.Control.zoomIn",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_IN ),
_( "Zoom In" ), "", zoom_in_xpm );
_( "Zoom In" ), "",
zoom_in_xpm );
TOOL_ACTION ACTIONS::zoomOut( "common.Control.zoomOut",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_OUT ),
_( "Zoom Out" ), "", zoom_out_xpm );
_( "Zoom Out" ), "",
zoom_out_xpm );
TOOL_ACTION ACTIONS::zoomInCenter( "common.Control.zoomInCenter",
AS_GLOBAL, 0,
"", "" );
_( "Zoom In" ), "",
zoom_in_xpm );
TOOL_ACTION ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter",
AS_GLOBAL, 0,
"", "" );
_( "Zoom Out" ), "",
zoom_out_xpm );
TOOL_ACTION ACTIONS::zoomCenter( "common.Control.zoomCenter",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_CENTER ),
_( "Center" ), "", zoom_center_on_screen_xpm );
_( "Center" ), "",
zoom_center_on_screen_xpm );
TOOL_ACTION ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_AUTO ),
_( "Zoom Auto" ), "", zoom_fit_in_page_xpm );
_( "Zoom to Fit" ), "",
zoom_fit_in_page_xpm );
TOOL_ACTION ACTIONS::zoomTool( "common.Control.zoomTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_SELECTION ),
_( "Zoom to Selection" ), "", NULL, AF_ACTIVATE );
_( "Zoom to Selection" ), "",
zoom_area_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::zoomPreset( "common.Control.zoomPreset",
AS_GLOBAL, 0,
@ -140,6 +151,31 @@ TOOL_ACTION ACTIONS::gridPreset( "common.Control.gridPreset",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION ACTIONS::toggleGrid( "common.Control.toggleGrid",
AS_GLOBAL, 0,
_( "Show Grid" ), _( "Display grid dots or lines in the edit window" ),
grid_xpm );
TOOL_ACTION ACTIONS::gridProperties( "common.Control.gridProperties",
AS_GLOBAL, 0,
_( "Grid Properties..." ), _( "Set grid dimensions" ),
grid_xpm );
TOOL_ACTION ACTIONS::imperialUnits( "common.Control.imperialUnits",
AS_GLOBAL, 0,
_( "Imperial" ), _( "Use inches and mils" ),
unit_inch_xpm );
TOOL_ACTION ACTIONS::metricUnits( "common.Control.metricUnits",
AS_GLOBAL, 0,
_( "Metric" ), _( "Use millimeters" ),
unit_mm_xpm );
TOOL_ACTION ACTIONS::toggleUnits( "common.Control.toggleUnits",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ),
_( "Switch units" ), _( "Switch between inches and millimeters" ),
unit_mm_xpm );
// System-wide selection Events

View File

@ -35,10 +35,16 @@
#include <tool/common_tools.h>
static TOOL_ACTION ACT_toggleCursor( "common.Control.toggleCursor",
TOOL_ACTION ACTIONS::toggleCursor( "common.Control.toggleCursor",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_TOGGLE_CURSOR ),
_( "Toggle Always Show Cursor" ),
_( "Toggle display of the cursor, even when not in an interactive tool" ) );
_( "Always Show Cursor" ),
_( "Switch whether the cursor is displayed even when not in an editing tool" ) );
TOOL_ACTION ACTIONS::toggleCursorStyle( "common.Control.toggleCursorStyle",
AS_GLOBAL, 0,
_( "Full-Window Crosshairs" ),
_( "Switch display of full-window crosshairs" ) );
COMMON_TOOLS::COMMON_TOOLS() :
@ -394,6 +400,52 @@ int COMMON_TOOLS::doGridPreset( int idx )
}
int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent )
{
m_frame->SetGridVisibility( !m_frame->IsGridVisible() );
m_frame->GetGalCanvas()->GetGAL()->SetGridVisibility( m_frame->IsGridVisible() );
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
m_frame->GetGalCanvas()->Refresh();
return 0;
}
int COMMON_TOOLS::MetricUnits( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
m_frame->ProcessEvent( cmd );
return 0;
}
int COMMON_TOOLS::ImperialUnits( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( cmd );
return 0;
}
int COMMON_TOOLS::ToggleUnits( const TOOL_EVENT& aEvent )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetId( ( m_frame->GetUserUnits() == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM
: ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( cmd );
return 0;
}
int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent )
{
auto& galOpts = m_frame->GetGalDisplayOptions();
@ -405,6 +457,17 @@ int COMMON_TOOLS::ToggleCursor( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::ToggleCursorStyle( const TOOL_EVENT& aEvent )
{
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = m_frame->GetGalDisplayOptions();
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
galOpts.NotifyChanged();
return 0;
}
void COMMON_TOOLS::setTransitions()
{
// Cursor control
@ -441,8 +504,14 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() );
Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() );
Go( &COMMON_TOOLS::GridPreset, ACTIONS::gridPreset.MakeEvent() );
Go( &COMMON_TOOLS::ToggleGrid, ACTIONS::toggleGrid.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursor, ACT_toggleCursor.MakeEvent() );
Go( &COMMON_TOOLS::ImperialUnits, ACTIONS::imperialUnits.MakeEvent() );
Go( &COMMON_TOOLS::MetricUnits, ACTIONS::metricUnits.MakeEvent() );
Go( &COMMON_TOOLS::ToggleUnits, ACTIONS::toggleUnits.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursor, ACTIONS::toggleCursor.MakeEvent() );
Go( &COMMON_TOOLS::ToggleCursorStyle, ACTIONS::toggleCursorStyle.MakeEvent() );
}

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 CERN
* Copyright (C) 2015-2019 KiCad Developers, see CHANGELOG.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -25,18 +26,35 @@
#include <tool/conditional_menu.h>
#include <tool/context_menu.h>
CONTEXT_MENU* CONDITIONAL_MENU::create() const
{
CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool );
clone->m_entries = m_entries;
return clone;
}
void CONDITIONAL_MENU::AddItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition,
int aOrder )
{
assert( aAction.GetId() > 0 ); // Check if action was previously registered in ACTION_MANAGER
addEntry( ENTRY( &aAction, aCondition, aOrder ) );
addEntry( ENTRY( &aAction, aCondition, aOrder, false ) );
}
void CONDITIONAL_MENU::AddMenu( CONTEXT_MENU* aMenu, bool aExpand,
const SELECTION_CONDITION& aCondition, int aOrder )
void CONDITIONAL_MENU::AddCheckItem( const TOOL_ACTION& aAction,
const SELECTION_CONDITION& aCondition, int aOrder )
{
addEntry( ENTRY( aMenu, aExpand, aCondition, aOrder ) );
assert( aAction.GetId() > 0 ); // Check if action was previously registered in ACTION_MANAGER
addEntry( ENTRY( &aAction, aCondition, aOrder, true ) );
}
void CONDITIONAL_MENU::AddMenu( CONTEXT_MENU* aMenu, const SELECTION_CONDITION& aCondition,
int aOrder )
{
addEntry( ENTRY( aMenu, aCondition, aOrder ) );
}
@ -46,50 +64,49 @@ void CONDITIONAL_MENU::AddSeparator( const SELECTION_CONDITION& aCondition, int
}
CONTEXT_MENU* CONDITIONAL_MENU::Generate( SELECTION& aSelection )
void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection )
{
CONTEXT_MENU* m_menu = new CONTEXT_MENU;
m_menu->SetTool( m_tool );
Clear();
for( std::list<ENTRY>::iterator it = m_entries.begin(); it != m_entries.end(); ++it )
for( const ENTRY& entry : m_entries )
{
const SELECTION_CONDITION& cond = it->Condition();
const SELECTION_CONDITION& cond = entry.Condition();
bool result;
wxMenuItem* menuItem = nullptr;
try
{
if( !cond( aSelection ) )
continue;
result = cond( aSelection );
}
catch( std::exception& )
{
continue;
}
switch( it->Type() )
if( m_isContextMenu && !result )
continue;
switch( entry.Type() )
{
case ENTRY::ACTION:
m_menu->Add( *it->Action() );
menuItem = Add( *entry.Action(), entry.IsCheckmarkEntry() );
break;
case ENTRY::MENU:
m_menu->Add( it->Menu(), it->Expand() );
menuItem = Add( entry.Menu() );
break;
case ENTRY::WXITEM:
m_menu->Append( it->wxItem() );
break;
case ENTRY::SEPARATOR:
m_menu->AppendSeparator();
menuItem = AppendSeparator();
break;
default:
assert( false );
break;
}
}
return m_menu;
if( entry.IsCheckmarkEntry() )
menuItem->Check( result );
else
menuItem->Enable( result );
}
}

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2017 CERN
* Copyright (C) 2013-2019 KiCad Developers, see CHANGELOG.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -23,6 +24,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <functional>
#include <tool/actions.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tool/tool_interactive.h>
@ -30,11 +33,16 @@
#include <wx/log.h>
#include <pgm_base.h>
#include <functional>
using namespace std::placeholders;
CONTEXT_MENU::CONTEXT_MENU() :
m_titleDisplayed( false ), m_selected( -1 ), m_tool( nullptr ), m_icon( nullptr )
m_Dirty( true ),
m_titleDisplayed( false ),
m_selected( -1 ),
m_tool( nullptr ),
m_icon( nullptr )
{
setupEvents();
}
@ -47,7 +55,6 @@ CONTEXT_MENU::~CONTEXT_MENU()
menu->SetParent( nullptr );
CONTEXT_MENU* parent = dynamic_cast<CONTEXT_MENU*>( GetParent() );
wxASSERT( parent || !GetParent() );
if( parent )
parent->m_submenus.remove( this );
@ -80,6 +87,7 @@ void CONTEXT_MENU::SetIcon( const BITMAP_OPAQUE* aIcon )
void CONTEXT_MENU::setupEvents()
{
Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
}
@ -148,13 +156,14 @@ wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPA
}
wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry )
{
/// ID numbers for tool actions need to have a value higher than ACTION_ID
const BITMAP_OPAQUE* icon = aAction.GetIcon();
wxMenuItem* item = new wxMenuItem( this, getMenuId( aAction ), aAction.GetMenuItem(),
aAction.GetDescription(), wxITEM_NORMAL );
aAction.GetDescription(),
aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
set_wxMenuIcon( item, icon );
@ -165,38 +174,24 @@ wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
}
std::list<wxMenuItem*> CONTEXT_MENU::Add( CONTEXT_MENU* aMenu, bool aExpand )
wxMenuItem* CONTEXT_MENU::Add( CONTEXT_MENU* aMenu )
{
std::list<wxMenuItem*> items;
CONTEXT_MENU* menuCopy = aMenu->Clone();
m_submenus.push_back( menuCopy );
if( aExpand )
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for CONTEXT_MENU using SetTitle()" );
if( aMenu->m_icon )
{
for( int i = 0; i < (int) aMenu->GetMenuItemCount(); ++i )
{
wxMenuItem* item = aMenu->FindItemByPosition( i );
items.push_back( appendCopy( item ) );
}
wxMenuItem* newItem = new wxMenuItem( this, -1, menuCopy->m_title );
set_wxMenuIcon( newItem, aMenu->m_icon );
newItem->SetSubMenu( menuCopy );
return Append( newItem );
}
else
{
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for CONTEXT_MENU using SetTitle()" );
if( aMenu->m_icon )
{
wxMenuItem* newItem = new wxMenuItem( this, -1, menuCopy->m_title );
set_wxMenuIcon( newItem, aMenu->m_icon );
newItem->SetSubMenu( menuCopy );
items.push_back( Append( newItem ) );
}
else
{
items.push_back( AppendSubMenu( menuCopy, menuCopy->m_title ) );
}
return AppendSubMenu( menuCopy, menuCopy->m_title );
}
return items;
}
@ -326,10 +321,17 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
wxEventType type = aEvent.GetEventType();
if( type == wxEVT_MENU_OPEN && m_Dirty )
{
getToolManager()->RunAction( ACTIONS::updateMenu, true, this );
aEvent.Skip();
return;
}
// When the currently chosen item in the menu is changed, an update event is issued.
// For example, the selection tool can use this to dynamically highlight the current item
// from selection clarification popup.
if( type == wxEVT_MENU_HIGHLIGHT )
else if( type == wxEVT_MENU_HIGHLIGHT )
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_UPDATE, aEvent.GetId() );
// One of menu entries was selected..

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2013-2019 KiCad Developers, see CHANGELOG.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Last changes: 2018
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -470,7 +470,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
aEvent.Skip();
#endif
updateUI( aEvent );
m_toolMgr->UpdateUI();
}
@ -483,19 +483,7 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent& aEvent )
else
aEvent.Skip();
updateUI( aEvent );
m_toolMgr->UpdateUI();
}
void TOOL_DISPATCHER::updateUI( wxEvent& aEvent )
{
// TODO I don't feel it is the right place for updating UI,
// but at the moment I cannot think of a better one..
auto frame = dynamic_cast<EDA_DRAW_FRAME*>( m_toolMgr->GetEditFrame() );
if( frame )
{
frame->UpdateStatusBar();
frame->SyncMenusAndToolbars( aEvent );
}
}

View File

@ -164,15 +164,13 @@ const std::string TOOL_EVENT_LIST::Format() const
bool TOOL_EVENT::IsClick( int aButtonMask ) const
{
return IsAction( &ACTIONS::cursorClick )
|| ( m_actions == TA_MOUSE_CLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask );
return m_actions == TA_MOUSE_CLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask;
}
bool TOOL_EVENT::IsDblClick( int aButtonMask ) const
{
return IsAction( &ACTIONS::cursorDblClick )
|| ( m_actions == TA_MOUSE_DBLCLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask );
return m_actions == TA_MOUSE_DBLCLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask;
}

View File

@ -303,6 +303,7 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
TOOL_STATE* current = m_activeState;
processEvent( event );
setActiveState( current );
UpdateUI();
}
else
{
@ -696,8 +697,6 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
// Display a copy of menu
std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );
// Run update handlers on the created copy
menu->UpdateAll();
m_menuOwner = toolId;
m_menuActive = true;
@ -860,7 +859,7 @@ TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame )
KIGFX::VIEW_CONTROLS* aViewControls, EDA_DRAW_FRAME* aFrame )
{
m_model = aModel;
m_view = aView;
@ -965,3 +964,15 @@ bool TOOL_MANAGER::IsToolActive( TOOL_ID aId ) const
auto it = m_toolIdIndex.find( aId );
return !it->second->idle;
}
void TOOL_MANAGER::UpdateUI()
{
EDA_DRAW_FRAME* frame = GetEditFrame();
if( frame )
{
frame->UpdateStatusBar();
frame->SyncMenusAndToolbars();
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see CHANGELOG.txt for contributors.
* Copyright (C) 2017-2019 KiCad Developers, see CHANGELOG.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
@ -22,12 +22,9 @@
*/
#include <draw_frame.h>
#include <tool/tool_menu.h>
#include <tool/tool_interactive.h>
#include <tool/context_menu.h>
#include <tool/actions.h>
#include <tool/zoom_menu.h>
#include <tool/grid_menu.h>
@ -35,7 +32,7 @@
TOOL_MENU::TOOL_MENU( TOOL_INTERACTIVE& aTool ) :
m_menu( &aTool ),
m_menu( true, &aTool ),
m_tool( aTool )
{
}
@ -61,26 +58,22 @@ void TOOL_MENU::AddSubMenu( std::shared_ptr<CONTEXT_MENU> aSubMenu )
void TOOL_MENU::ShowContextMenu( SELECTION& aSelection )
{
m_contextMenu = std::unique_ptr<CONTEXT_MENU>( m_menu.Generate( aSelection ) );
if( m_contextMenu->GetMenuItemCount() > 0 )
m_tool.SetContextMenu( m_contextMenu.get(), CMENU_NOW );
m_menu.Evaluate( aSelection );
m_menu.UpdateAll();
m_menu.m_Dirty = false;
m_tool.SetContextMenu( &m_menu, CMENU_NOW );
}
void TOOL_MENU::ShowContextMenu()
{
SELECTION dummySelection;
ShowContextMenu( dummySelection );
m_menu.m_Dirty = true;
m_tool.SetContextMenu( &m_menu, CMENU_NOW );
}
void TOOL_MENU::CloseContextMenu( OPT_TOOL_EVENT& evt )
{
// m_contextMenu can be null here, that's OK
if( evt->Parameter<CONTEXT_MENU*>() == m_contextMenu.get() )
m_contextMenu = nullptr;
}
@ -98,7 +91,7 @@ void TOOL_MENU::AddStandardSubMenus( EDA_DRAW_FRAME* aFrame )
if( aFrame )
{
m_menu.AddMenu( createOwnSubMenu<ZOOM_MENU>( aFrame ).get(), false, S_C::ShowAlways, 1000 );
m_menu.AddMenu( createOwnSubMenu<GRID_MENU>( aFrame ).get(), false, S_C::ShowAlways, 1000 );
m_menu.AddMenu( createOwnSubMenu<ZOOM_MENU>( aFrame ).get(), S_C::ShowAlways, 1000 );
m_menu.AddMenu( createOwnSubMenu<GRID_MENU>( aFrame ).get(), S_C::ShowAlways, 1000 );
}
}

View File

@ -121,6 +121,8 @@ static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-',
ID_KEY_ZOOM_OUT );
#endif
static EDA_HOTKEY HkSwitchUnits( _HKI( "Switch Units" ), HK_SWITCH_UNITS, 'U' + GR_KB_CTRL );
static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY HkPreferences( _HKI( "Preferences" ), HK_PREFERENCES, GR_KB_CTRL + ',',
wxID_PREFERENCES );

View File

@ -99,30 +99,7 @@ enum id_eeschema_frm
ID_SCHEMATIC_DELETE_ITEM_BUTT,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
// Schematic editor menu place IDs (equivalent to vertical toolbar IDs
// for submenus.
// On Windows we cannot use the same ID for 2 items in the same frame.
// Usually it creates issues (wxASSERTS, item not displayed, ...)
ID_SCHEMATIC_PLACE_MENU_START,
ID_MENU_PLACE_COMPONENT,
ID_MENU_PLACE_POWER_BUTT,
ID_MENU_BUS_BUTT,
ID_MENU_WIRE_BUTT,
ID_MENU_BUSTOBUS_ENTRY_BUTT,
ID_MENU_WIRETOBUS_ENTRY_BUTT,
ID_MENU_LABEL_BUTT,
ID_MENU_GLABEL_BUTT,
ID_MENU_HIERLABEL_BUTT,
ID_MENU_IMPORT_HLABEL_BUTT,
ID_MENU_SHEET_PIN_BUTT,
ID_MENU_NOCONN_BUTT,
ID_MENU_JUNCTION_BUTT,
ID_MENU_SHEET_SYMBOL_BUTT,
ID_MENU_TEXT_COMMENT_BUTT,
ID_MENU_LINE_COMMENT_BUTT,
ID_MENU_ADD_IMAGE_BUTT,
ID_MENU_DELETE_ITEM_BUTT,
ID_SCHEMATIC_PLACE_MENU_END,
// Toolbar options id:
ID_TB_OPTIONS_HIDDEN_PINS,
@ -211,17 +188,6 @@ enum id_eeschema_frm
ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT,
/* Library editor context menu IDs */
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM,
ID_POPUP_LIBEDIT_BODY_EDIT_ITEM,
ID_POPUP_LIBEDIT_DELETE_ITEM,
ID_POPUP_LIBEDIT_MODIFY_ITEM,
ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
/* Library editor toolbar options IDs */
ID_LIBEDIT_SHOW_ELECTRICAL_TYPE,
ID_LIBEDIT_SHOW_HIDE_SEARCH_TREE,

View File

@ -29,17 +29,16 @@
#include <id.h>
#include <bitmaps.h>
#include <dialog_shim.h>
#include <sch_edit_frame.h>
#include <general.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <wx/imaglist.h>
#include <wx/treectrl.h>
#include <tool/tool_manager.h>
#include <tools/ee_actions.h>
#include <netlist_object.h>
#include <tools/sch_editor_control.h>
//#include <netlist_object.h>
#include <sch_sheet_path.h>
#include <view/view.h>
@ -130,12 +129,14 @@ private:
};
void SCH_EDIT_FRAME::InstallHierarchyFrame( wxCommandEvent& event )
int SCH_EDITOR_CONTROL::NavigateHierarchy( const TOOL_EVENT& aEvent )
{
HIERARCHY_NAVIG_DLG* treeframe = new HIERARCHY_NAVIG_DLG( this );
HIERARCHY_NAVIG_DLG* treeframe = new HIERARCHY_NAVIG_DLG( m_frame );
treeframe->ShowQuasiModal();
treeframe->Destroy();
return 0;
}

View File

@ -557,6 +557,8 @@ public:
void ShowChangedLanguage() override;
void SyncMenusAndToolbars() override;
virtual void SetScreen( BASE_SCREEN* aScreen ) override;
virtual const BOX2I GetDocumentExtents() const override;

View File

@ -235,3 +235,14 @@ void LIB_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar->Realize();
}
void LIB_EDIT_FRAME::SyncMenusAndToolbars()
{
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, IsGridVisible() );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, GetUserUnits() != INCHES );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, GetUserUnits() == INCHES );
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, galOpts.m_fullscreenCursor );
}

View File

@ -23,15 +23,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/menubar.cpp
* @brief (Re)Create the main menubar for the schematic frame
*/
#include <kiface_i.h>
#include <menus_helpers.h>
#include <pgm_base.h>
#include <tool/conditional_menu.h>
#include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_actions.h>
#include "eeschema_id.h"
#include "general.h"
@ -39,10 +38,12 @@
#include "ee_hotkeys.h"
#include "sch_edit_frame.h"
class CONDITIONAL_MENU;
// helper functions that build specific submenus:
// Build the place submenu
static void preparePlaceMenu( wxMenu* aParentMenu );
static void preparePlaceMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool );
// Build the files menu. Because some commands are available only if
// Eeschemat is run outside a project (run alone), aIsOutsideProject is false
@ -62,7 +63,7 @@ static void prepareHelpMenu( wxMenu* aParentMenu );
static void prepareEditMenu( wxMenu* aParentMenu );
// Build the view menu
static void prepareViewMenu( wxMenu* aParentMenu );
static void prepareViewMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool );
// Build the preferences menu
static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
@ -70,6 +71,7 @@ static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu
void SCH_EDIT_FRAME::ReCreateMenuBar()
{
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
@ -87,12 +89,12 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
prepareEditMenu( editMenu );
// Menu View:
wxMenu* viewMenu = new wxMenu;
prepareViewMenu( viewMenu );
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
prepareViewMenu( viewMenu, selTool );
// Menu place:
wxMenu* placeMenu = new wxMenu;
preparePlaceMenu( placeMenu );
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
preparePlaceMenu( placeMenu, selTool );
// Menu Inspect:
wxMenu* inspectMenu = new wxMenu;
@ -125,102 +127,60 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
}
void prepareViewMenu( wxMenu* aParentMenu )
void prepareViewMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool )
{
wxString text;
SCH_EDIT_FRAME* frame = static_cast<SCH_EDIT_FRAME*>( selTool->GetManager()->GetEditFrame() );
AddMenuItem( aParentMenu,
ID_TO_LIBVIEW,
_( "Symbol Library &Browser" ), HELP_RUN_LIB_VIEWER,
KiBitmap( library_browse_xpm ) );
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
AddMenuItem( aParentMenu,
ID_HIERARCHY,
_( "Show &Hierarchical Navigator" ),
_( "Navigate schematic hierarchy" ),
KiBitmap( hierarchy_nav_xpm ) );
auto gridShownCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->IsGridVisible();
};
text = AddHotkeyName( _( "&Leave Sheet" ), g_Schematic_Hotkeys_Descr, HK_LEAVE_SHEET );
AddMenuItem( aParentMenu,
ID_SCH_LEAVE_SHEET, text,
_( "Return to parent schematic sheet" ),
KiBitmap( leave_sheet_xpm ) );
auto imperialUnitsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetUserUnits() == INCHES;
};
aParentMenu->AppendSeparator();
auto metricUnitsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetUserUnits() == MILLIMETRES;
};
/**
* Important Note for ZOOM IN and ZOOM OUT commands from menubar:
* we cannot add hotkey shortcut here, because the hotkey HK_ZOOM_IN and HK_ZOOM_OUT
* events(default = WXK_F1 and WXK_F2) are *NOT* equivalent to this menu command:
* zoom in and out from hotkeys are equivalent to the pop up menu zoom
* From here, zooming is made around the screen center
* From hotkeys, zooming is made around the mouse cursor position
* (obviously not possible from the toolbar or menubar command)
*
* in others words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators
* for Zoom in and Zoom out sub menus
* SO WE ADD THE NAME OF THE CORRESPONDING HOTKEY AS A COMMENT, NOT AS A SHORTCUT
* using in AddHotkeyName call the option "false" (not a shortcut)
*/
auto fullCrosshairCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetGalDisplayOptions().m_fullscreenCursor;
};
text = AddHotkeyName( _( "Zoom &In" ), g_Schematic_Hotkeys_Descr,
HK_ZOOM_IN, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
auto hiddenPinsCondition = [ frame ] ( const SELECTION& aSel ) {
return frame->GetShowAllPins();
};
text = AddHotkeyName( _( "Zoom &Out" ), g_Schematic_Hotkeys_Descr,
HK_ZOOM_OUT, IS_ACCELERATOR ); // add accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
aParentMenu->AddItem( EE_ACTIONS::showLibraryBrowser, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::navigateHierarchy, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition );
text = AddHotkeyName( _( "&Zoom to Fit" ), g_Schematic_Hotkeys_Descr, HK_ZOOM_AUTO );
aParentMenu->AddSeparator();
aParentMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways );
AddMenuItem( aParentMenu, ID_ZOOM_PAGE, text,
HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) );
text = AddHotkeyName( _( "Zoom to Selection" ), g_Eeschema_Hotkeys_Descr, HK_ZOOM_SELECTION );
AddMenuItem( aParentMenu, ID_ZOOM_SELECTION, text, KiBitmap( zoom_area_xpm ) );
text = AddHotkeyName( _( "&Redraw" ), g_Schematic_Hotkeys_Descr, HK_ZOOM_REDRAW );
AddMenuItem( aParentMenu, ID_ZOOM_REDRAW, text,
HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_TB_OPTIONS_SHOW_GRID,
_( "Show &Grid" ), wxEmptyString,
KiBitmap( grid_xpm ), wxITEM_CHECK );
AddMenuItem( aParentMenu, ID_GRID_SETTINGS,
_( "Grid Settings..." ), wxEmptyString,
KiBitmap( grid_xpm ) );
aParentMenu->AddSeparator();
aParentMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
aParentMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways );
// Units submenu
wxMenu* unitsSubMenu = new wxMenu;
AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_INCH,
_( "&Imperial" ), _( "Use imperial units" ),
KiBitmap( unit_inch_xpm ), wxITEM_RADIO );
CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool );
unitsSubMenu->SetTitle( _( "&Units" ) );
unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition );
unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition );
aParentMenu->AddMenu( unitsSubMenu );
AddMenuItem( unitsSubMenu, ID_TB_OPTIONS_SELECT_UNIT_MM,
_( "&Metric" ), _( "Use metric units" ),
KiBitmap( unit_mm_xpm ), wxITEM_RADIO );
aParentMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
AddMenuItem( aParentMenu, unitsSubMenu,
-1, _( "&Units" ),
_( "Select which units are displayed" ),
KiBitmap( unit_mm_xpm ) );
AddMenuItem( aParentMenu, ID_TB_OPTIONS_SELECT_CURSOR,
_( "Full &Window Crosshair" ),
_( "Change cursor shape" ),
KiBitmap( cursor_shape_xpm ), wxITEM_CHECK );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_TB_OPTIONS_HIDDEN_PINS,
_( "Show Hidden &Pins" ),
wxEmptyString,
KiBitmap( hidden_pin_xpm ), wxITEM_CHECK );
aParentMenu->AddSeparator();
aParentMenu->AddCheckItem( EE_ACTIONS::toggleHiddenPins, hiddenPinsCondition );
#ifdef __APPLE__
aParentMenu->AppendSeparator();
@ -228,113 +188,29 @@ void prepareViewMenu( wxMenu* aParentMenu )
}
void preparePlaceMenu( wxMenu* aParentMenu )
void preparePlaceMenu( CONDITIONAL_MENU* aParentMenu, EE_SELECTION_TOOL* selTool )
{
wxString text;
aParentMenu->AddItem( EE_ACTIONS::placeSymbol, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placePower, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawWire, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawBus, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeBusWireEntry, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeBusBusEntry, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeNoConnect, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeJunction, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeLabel, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&Symbol" ), g_Schematic_Hotkeys_Descr,
HK_ADD_NEW_COMPONENT, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_PLACE_COMPONENT, text,
HELP_PLACE_COMPONENTS,
KiBitmap( add_component_xpm ) );
aParentMenu->AddSeparator();
aParentMenu->AddItem( EE_ACTIONS::placeHierarchicalLabel, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeSheetPin, EE_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&Power Port" ), g_Schematic_Hotkeys_Descr,
HK_ADD_NEW_POWER, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_PLACE_POWER_BUTT, text,
HELP_PLACE_POWERPORT,
KiBitmap( add_power_xpm ) );
text = AddHotkeyName( _( "&Wire" ), g_Schematic_Hotkeys_Descr,
HK_BEGIN_WIRE, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_WIRE_BUTT, text,
HELP_PLACE_WIRE,
KiBitmap( add_line_xpm ) );
text = AddHotkeyName( _( "&Bus" ), g_Schematic_Hotkeys_Descr,
HK_BEGIN_BUS, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_BUS_BUTT, text,
HELP_PLACE_BUS,
KiBitmap( add_bus_xpm ) );
text = AddHotkeyName( _( "Wire to Bus &Entry" ), g_Schematic_Hotkeys_Descr,
HK_ADD_WIRE_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_WIRETOBUS_ENTRY_BUTT, text,
HELP_PLACE_WIRE2BUS_ENTRY,
KiBitmap( add_line2bus_xpm ) );
text = AddHotkeyName( _( "Bus &to Bus Entry" ), g_Schematic_Hotkeys_Descr,
HK_ADD_BUS_ENTRY, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_BUSTOBUS_ENTRY_BUTT, text,
HELP_PLACE_BUS2BUS_ENTRY,
KiBitmap( add_bus2bus_xpm ) );
text = AddHotkeyName( _( "&No Connect Flag" ), g_Schematic_Hotkeys_Descr,
HK_ADD_NOCONN_FLAG, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_NOCONN_BUTT, text, HELP_PLACE_NC_FLAG, KiBitmap( noconn_xpm ) );
text = AddHotkeyName( _( "&Junction" ), g_Schematic_Hotkeys_Descr,
HK_ADD_JUNCTION, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_JUNCTION_BUTT, text,
HELP_PLACE_JUNCTION,
KiBitmap( add_junction_xpm ) );
text = AddHotkeyName( _( "&Label" ), g_Schematic_Hotkeys_Descr,
HK_ADD_LABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_LABEL_BUTT, text,
HELP_PLACE_NETLABEL,
KiBitmap( add_line_label_xpm ) );
text = AddHotkeyName( _( "Gl&obal Label" ), g_Schematic_Hotkeys_Descr,
HK_ADD_GLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_GLABEL_BUTT, text,
HELP_PLACE_GLOBALLABEL,
KiBitmap( add_glabel_xpm ) );
aParentMenu->AppendSeparator();
text = AddHotkeyName( _( "&Hierarchical Label" ), g_Schematic_Hotkeys_Descr,
HK_ADD_HLABEL, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_HIERLABEL_BUTT,
text, HELP_PLACE_HIER_LABEL,
KiBitmap( add_hierarchical_label_xpm ) );
text = AddHotkeyName( _( "Hierar&chical Sheet" ), g_Schematic_Hotkeys_Descr,
HK_ADD_HIER_SHEET, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_SHEET_SYMBOL_BUTT, text,
HELP_PLACE_SHEET,
KiBitmap( add_hierarchical_subsheet_xpm ) );
AddMenuItem( aParentMenu,
ID_MENU_IMPORT_HLABEL_BUTT,
_( "I&mport Hierarchical Label" ),
HELP_IMPORT_SHEETPIN,
KiBitmap( import_hierarchical_label_xpm ) );
AddMenuItem( aParentMenu,
ID_MENU_SHEET_PIN_BUTT,
_( "Hierarchical Pi&n to Sheet" ),
HELP_PLACE_SHEETPIN,
KiBitmap( add_hierar_pin_xpm ) );
aParentMenu->AppendSeparator();
text = AddHotkeyName( _( "Graphic Pol&yline" ), g_Schematic_Hotkeys_Descr,
HK_ADD_GRAPHIC_POLYLINE, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_LINE_COMMENT_BUTT, text,
HELP_PLACE_GRAPHICLINES,
KiBitmap( add_dashed_line_xpm ) );
text = AddHotkeyName( _( "&Graphic Text" ), g_Schematic_Hotkeys_Descr,
HK_ADD_GRAPHIC_TEXT, IS_ACCELERATOR ); // add an accelerator, not a shortcut
AddMenuItem( aParentMenu, ID_MENU_TEXT_COMMENT_BUTT, text,
HELP_PLACE_GRAPHICTEXTS,
KiBitmap( text_xpm ) );
// Add graphic image
AddMenuItem( aParentMenu, ID_MENU_ADD_IMAGE_BUTT, _( "&Image" ),
HELP_PLACE_GRAPHICIMAGES,
KiBitmap( image_xpm ) );
aParentMenu->AddSeparator();
aParentMenu->AddItem( EE_ACTIONS::drawLines, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways );
aParentMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways );
}

View File

@ -330,7 +330,6 @@ public:
*/
virtual void OnModify() {}
protected:
/**
* Open the library viewer only to browse library contents.
* If the viewed is already opened from this, raise the viewer
@ -338,6 +337,7 @@ protected:
*/
void OnOpenLibraryViewer( wxCommandEvent& event );
protected:
/**
* Saves Symbol Library Tables to disk.
*

View File

@ -242,7 +242,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, SCH_EDIT_FRAME::OnConfigurePaths )
EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
EVT_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId )
@ -253,7 +252,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
EVT_TOOL( ID_HIERARCHY, SCH_EDIT_FRAME::InstallHierarchyFrame )
EVT_TOOL( wxID_UNDO, SCH_EDIT_FRAME::GetSchematicFromUndoList )
EVT_TOOL( wxID_REDO, SCH_EDIT_FRAME::GetSchematicFromRedoList )
EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate )
@ -287,8 +285,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
/* Handle user interface update events. */
EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_HIGHLIGHT_BUTT, SCH_EDIT_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
@ -356,6 +352,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
setupTools();
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
@ -378,7 +375,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_auimgr.Update();
setupTools();
GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
GetToolManager()->RunAction( "common.Control.zoomFitScreen", true );
@ -765,27 +761,6 @@ void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
}
void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
{
wxString tool_tip = GetForceHVLines() ?
_( "Draw wires and buses in any direction" ) :
_( "Draw horizontal and vertical wires and buses only" );
aEvent.Check( GetForceHVLines() );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
}
void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
{
wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
_( "Show hidden pins" );
aEvent.Check( m_showAllPins );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
}
void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
{
SCH_SHEET_LIST sheetList( g_RootSheet );

View File

@ -823,7 +823,6 @@ private:
/* User interface update event handlers. */
void OnUpdatePaste( wxUpdateUIEvent& event );
void OnUpdateHiddenPins( wxUpdateUIEvent& event );
void OnUpdateBusOrientation( wxUpdateUIEvent& event );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateSave( wxUpdateUIEvent& aEvent );
@ -859,9 +858,6 @@ private:
*/
void NormalizeSchematicOnFirstLoad( bool recalculateConnections );
// Hierarchical Sheet & PinSheet
void InstallHierarchyFrame( wxCommandEvent& event );
public:
/**
* Change a text type to another one.
@ -1196,6 +1192,8 @@ public:
void ShowChangedLanguage() override;
void SyncMenusAndToolbars() override;
virtual void SetScreen( BASE_SCREEN* aScreen ) override;
virtual const BOX2I GetDocumentExtents() const override;

View File

@ -37,9 +37,9 @@
#include <general.h>
#include <ee_hotkeys.h>
#include <eeschema_id.h>
#include <tool/tool_manager.h>
#include <help_common_strings.h>
#include <tools/ee_actions.h>
/* Create the main Horizontal Toolbar for the schematic editor
*/
@ -317,15 +317,7 @@ void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
switch( id )
{
case ID_TB_OPTIONS_HIDDEN_PINS:
{
m_showAllPins = !m_showAllPins;
auto painter = static_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
painter->GetSettings()->m_ShowHiddenPins = m_showAllPins;
GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
GetCanvas()->Refresh();
}
m_toolManager->RunAction( EE_ACTIONS::toggleHiddenPins, true );
break;
case ID_TB_OPTIONS_BUS_WIRES_ORIENT:
@ -337,3 +329,19 @@ void SCH_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break;
}
}
void SCH_EDIT_FRAME::SyncMenusAndToolbars()
{
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, IsGridVisible() );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, GetUserUnits() != INCHES );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, GetUserUnits() == INCHES );
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR, galOpts.m_fullscreenCursor );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, GetShowAllPins() );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT, GetForceHVLines() );
m_optionsToolBar->Refresh();
}

View File

@ -58,77 +58,66 @@ OPT<TOOL_EVENT> EE_ACTIONS::TranslateLegacyId( int aId )
case ID_ZOOM_SELECTION:
return ACTIONS::zoomTool.MakeEvent();
case ID_HIERARCHY:
return EE_ACTIONS::navigateHierarchy.MakeEvent();
case ID_TO_LIBVIEW:
return EE_ACTIONS::showLibraryBrowser.MakeEvent();
case ID_HIGHLIGHT_BUTT:
return EE_ACTIONS::highlightNetCursor.MakeEvent();
case ID_HIGHLIGHT_NET:
return EE_ACTIONS::highlightNet.MakeEvent();
case ID_MENU_PLACE_COMPONENT:
case ID_SCH_PLACE_COMPONENT:
return EE_ACTIONS::placeSymbol.MakeEvent();
case ID_MENU_PLACE_POWER_BUTT:
case ID_PLACE_POWER_BUTT:
return EE_ACTIONS::placePower.MakeEvent();
case ID_MENU_WIRE_BUTT:
case ID_WIRE_BUTT:
return EE_ACTIONS::drawWire.MakeEvent();
case ID_MENU_BUS_BUTT:
case ID_BUS_BUTT:
return EE_ACTIONS::drawBus.MakeEvent();
case ID_MENU_NOCONN_BUTT:
case ID_NOCONN_BUTT:
return EE_ACTIONS::placeNoConnect.MakeEvent();
case ID_MENU_JUNCTION_BUTT:
case ID_JUNCTION_BUTT:
return EE_ACTIONS::placeJunction.MakeEvent();
case ID_MENU_WIRETOBUS_ENTRY_BUTT:
case ID_WIRETOBUS_ENTRY_BUTT:
return EE_ACTIONS::placeBusWireEntry.MakeEvent();
case ID_MENU_BUSTOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
return EE_ACTIONS::placeBusBusEntry.MakeEvent();
case ID_MENU_LABEL_BUTT:
case ID_LABEL_BUTT:
return EE_ACTIONS::placeLabel.MakeEvent();
case ID_MENU_GLABEL_BUTT:
case ID_GLOBALLABEL_BUTT:
return EE_ACTIONS::placeGlobalLabel.MakeEvent();
case ID_MENU_HIERLABEL_BUTT:
case ID_HIERLABEL_BUTT:
return EE_ACTIONS::placeHierarchicalLabel.MakeEvent();
case ID_MENU_SHEET_PIN_BUTT:
case ID_SHEET_PIN_BUTT:
return EE_ACTIONS::placeSheetPin.MakeEvent();
case ID_MENU_IMPORT_HLABEL_BUTT:
case ID_IMPORT_HLABEL_BUTT:
return EE_ACTIONS::importSheetPin.MakeEvent();
case ID_MENU_SHEET_SYMBOL_BUTT:
case ID_SHEET_SYMBOL_BUTT:
return EE_ACTIONS::drawSheet.MakeEvent();
case ID_MENU_TEXT_COMMENT_BUTT:
case ID_TEXT_COMMENT_BUTT:
return EE_ACTIONS::placeSchematicText.MakeEvent();
case ID_MENU_LINE_COMMENT_BUTT:
case ID_LINE_COMMENT_BUTT:
return EE_ACTIONS::drawLines.MakeEvent();
case ID_MENU_ADD_IMAGE_BUTT:
case ID_ADD_IMAGE_BUTT:
return EE_ACTIONS::placeImage.MakeEvent();

View File

@ -148,6 +148,7 @@ public:
static TOOL_ACTION showDatasheet;
static TOOL_ACTION showMarkerInfo;
static TOOL_ACTION editWithSymbolEditor;
static TOOL_ACTION showLibraryBrowser;
/// Clipboard
static TOOL_ACTION cut;
@ -157,10 +158,9 @@ public:
// Miscellaneous
static TOOL_ACTION enterSheet;
static TOOL_ACTION leaveSheet;
static TOOL_ACTION navigateHierarchy;
static TOOL_ACTION cleanupSheetPins;
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION updateUnits;
static TOOL_ACTION toggleHiddenPins;
static TOOL_ACTION symbolProperties;
static TOOL_ACTION pinTable;
static TOOL_ACTION deleteItemCursor;

View File

@ -204,8 +204,8 @@ bool EE_SELECTION_TOOL::Init()
return m_isLibEdit;
};
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
auto belowRootSheetCondition = [this] ( const SELECTION& aSel ) {
return !m_isLibEdit && g_CurrentSheet->Last() != g_RootSheet;
};
auto& menu = m_menu.GetMenu();
@ -275,6 +275,21 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
}
int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
{
CONTEXT_MENU* actionMenu = aEvent.Parameter<CONTEXT_MENU*>();
CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
if( conditionalMenu )
conditionalMenu->Evaluate( m_selection );
if( actionMenu )
actionMenu->UpdateAll();
return 0;
}
int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
@ -326,7 +341,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
if( !selectionCancelled )
m_menu.ShowContextMenu( m_selection );
m_menu.ShowContextMenu();
}
// double click? Display the properties window
@ -1140,6 +1155,8 @@ bool EE_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
void EE_SELECTION_TOOL::setTransitions()
{
Go( &EE_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
Go( &EE_SELECTION_TOOL::Main, EE_ACTIONS::selectionActivate.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectNode, EE_ACTIONS::selectNode.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectConnection, EE_ACTIONS::selectConnection.MakeEvent() );

View File

@ -66,6 +66,8 @@ public:
/// @copydoc TOOL_BASE::Reset()
void Reset( RESET_REASON aReason ) override;
int UpdateMenu( const TOOL_EVENT& aEvent );
/**
* Function Main()
*

View File

@ -250,7 +250,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( item && ( evt->IsAction( &EE_ACTIONS::refreshPreview ) || evt->IsMotion() ) )
@ -384,7 +384,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
// Enable autopanning and cursor capture only when there is a shape being drawn
@ -436,9 +436,7 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
SELECTION emptySelection;
m_menu.ShowContextMenu( emptySelection );
m_menu.ShowContextMenu();
}
}

View File

@ -242,7 +242,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
//
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection );
m_menu.ShowContextMenu();
}
//------------------------------------------------------------------------
// Handle drop

View File

@ -311,7 +311,7 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE
if( !aComponent )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
{
@ -445,7 +445,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
if( !image )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( image && ( evt->IsAction( &EE_ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
@ -553,9 +553,7 @@ int SCH_DRAWING_TOOLS::doSingleClickPlace( KICAD_T aType )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
SELECTION emptySelection;
m_menu.ShowContextMenu( emptySelection );
m_menu.ShowContextMenu();
}
}
@ -705,7 +703,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( item && TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
{
@ -815,7 +813,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
if( !sheet )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
// Enable autopanning and cursor capture only when there is a sheet to be placed

View File

@ -376,7 +376,7 @@ bool SCH_EDIT_TOOL::Init()
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu->SetTool( this );
m_menu.AddSubMenu( symUnitMenu );
moveMenu.AddMenu( symUnitMenu.get(), false, EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
moveMenu.AddMenu( symUnitMenu.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
moveMenu.AddSeparator( EE_CONDITIONS::IdleSelection );
moveMenu.AddItem( EE_ACTIONS::cut, EE_CONDITIONS::IdleSelection );
@ -403,7 +403,7 @@ bool SCH_EDIT_TOOL::Init()
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu2 = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu2->SetTool( drawingTools );
drawingTools->GetToolMenu().AddSubMenu( symUnitMenu2 );
drawMenu.AddMenu( symUnitMenu2.get(), false, EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
drawMenu.AddMenu( symUnitMenu2.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
drawMenu.AddItem( EE_ACTIONS::editWithSymbolEditor,
singleComponentCondition && EE_CONDITIONS::Idle, 200 );
@ -438,7 +438,7 @@ bool SCH_EDIT_TOOL::Init()
std::shared_ptr<SYMBOL_UNIT_MENU> symUnitMenu3 = std::make_shared<SYMBOL_UNIT_MENU>();
symUnitMenu3->SetTool( m_selectionTool );
m_selectionTool->GetToolMenu().AddSubMenu( symUnitMenu3 );
selToolMenu.AddMenu( symUnitMenu3.get(), false, EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
selToolMenu.AddMenu( symUnitMenu3.get(), EE_CONDITIONS::SingleMultiUnitSymbol, 1 );
selToolMenu.AddItem( EE_ACTIONS::editWithSymbolEditor,
singleComponentCondition && EE_CONDITIONS::Idle, 200 );

View File

@ -48,6 +48,7 @@
#include <class_library.h>
#include <confirm.h>
#include <lib_edit_frame.h>
#include <sch_painter.h>
#include "sch_wire_bus_tool.h"
TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
@ -91,6 +92,11 @@ TOOL_ACTION EE_ACTIONS::editWithSymbolEditor( "eeschema.EditorControl.editWithSy
_( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ),
libedit_xpm );
TOOL_ACTION EE_ACTIONS::showLibraryBrowser( "eeschema.EditorControl.showLibraryBrowser",
AS_GLOBAL, 0,
_( "Symbol Library Browser" ), "",
library_browse_xpm );
TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet",
AS_GLOBAL, 0,
_( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ),
@ -101,11 +107,21 @@ TOOL_ACTION EE_ACTIONS::leaveSheet( "eeschema.EditorControl.leaveSheet",
_( "Leave Sheet" ), _( "Display the parent sheet in the Eeschema window" ),
leave_sheet_xpm );
TOOL_ACTION EE_ACTIONS::navigateHierarchy( "eeschema.EditorControl.navigateHierarchy",
AS_GLOBAL, 0,
_( "Show Hierarchy Navigator" ), "",
hierarchy_nav_xpm );
TOOL_ACTION EE_ACTIONS::explicitCrossProbe( "eeschema.EditorControl.explicitCrossProbe",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_ITEMS_ON_PCB ),
_( "Highlight on PCB" ), _( "Highlight corresponding items in PCBNew" ),
select_same_sheet_xpm );
TOOL_ACTION EE_ACTIONS::toggleHiddenPins( "eeschema.EditorControl.showHiddenPins",
AS_GLOBAL, 0,
_( "Show Hidden Pins" ), "",
hidden_pin_xpm );
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" )
@ -662,6 +678,15 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnOpenLibraryViewer( dummy );
return 0;
}
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
@ -689,6 +714,20 @@ int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::ToggleHiddenPins( const TOOL_EVENT& aEvent )
{
m_frame->SetShowAllPins( !m_frame->GetShowAllPins() );
auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
getView()->UpdateAllItems( KIGFX::REPAINT );
m_frame->GetCanvas()->Refresh();
return 0;
}
void SCH_EDITOR_CONTROL::setTransitions()
{
/*
@ -718,7 +757,11 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::Paste, EE_ACTIONS::paste.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, EE_ACTIONS::editWithSymbolEditor.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::EnterSheet, EE_ACTIONS::enterSheet.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::LeaveSheet, EE_ACTIONS::leaveSheet.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::NavigateHierarchy, EE_ACTIONS::navigateHierarchy.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ToggleHiddenPins, EE_ACTIONS::toggleHiddenPins.MakeEvent() );
}

View File

@ -75,9 +75,13 @@ public:
int Paste( const TOOL_EVENT& aEvent );
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
int EnterSheet( const TOOL_EVENT& aEvent );
int LeaveSheet( const TOOL_EVENT& aEvent );
int NavigateHierarchy( const TOOL_EVENT& aEvent );
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
private:
///> copy selection to clipboard

View File

@ -374,7 +374,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
//
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection );
m_menu.ShowContextMenu();
}
//------------------------------------------------------------------------
// Handle drop

View File

@ -235,7 +235,7 @@ bool SCH_WIRE_BUS_TOOL::Init()
std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
busUnfoldMenu->SetTool( this );
m_menu.AddSubMenu( busUnfoldMenu );
ctxMenu.AddMenu( busUnfoldMenu.get(), false, EE_CONDITIONS::Idle, 10 );
ctxMenu.AddMenu( busUnfoldMenu.get(), EE_CONDITIONS::Idle, 10 );
ctxMenu.AddSeparator( wireOrBusTool && EE_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( EE_ACTIONS::addJunction, wireOrBusTool && EE_CONDITIONS::Idle, 100 );
@ -257,7 +257,7 @@ bool SCH_WIRE_BUS_TOOL::Init()
std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
selBusUnfoldMenu->SetTool( m_selectionTool );
m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu );
selToolMenu.AddMenu( selBusUnfoldMenu.get(), false, busSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddMenu( selBusUnfoldMenu.get(), busSelection && EE_CONDITIONS::Idle, 100 );
return true;
}
@ -764,7 +764,7 @@ int SCH_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
if( !aSegment )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
{

View File

@ -35,8 +35,7 @@
// see also enum common_hotkey_id_command in hotkeys_basic.h
// for shared hotkeys id
enum hotkey_id_command {
HK_SWITCH_UNITS = HK_COMMON_END,
HK_GBR_LINES_DISPLAY_MODE,
HK_GBR_LINES_DISPLAY_MODE = HK_COMMON_END,
HK_GBR_FLASHED_DISPLAY_MODE,
HK_GBR_POLYGON_DISPLAY_MODE,
HK_GBR_NEGATIVE_DISPLAY_ONOFF,

View File

@ -163,7 +163,7 @@ bool GERBVIEW_SELECTION_TOOL::Init()
auto& menu = m_menu.GetMenu();
menu.AddMenu( selectMenu.get(), false );
menu.AddMenu( selectMenu.get() );
menu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
m_menu.AddStandardSubMenus( getEditFrame<GERBVIEW_FRAME>() );

View File

@ -947,7 +947,7 @@ public:
* Update the toolbars and menus (mostly settings/check buttons/checkboxes)
* with the current controller state
*/
virtual void SyncMenusAndToolbars( wxEvent& aEvent ) {};
virtual void SyncMenusAndToolbars() {};
bool GetShowAxis() const { return m_showAxis; }
bool GetShowGridAxis() const { return m_showGridAxis; }

View File

@ -277,6 +277,7 @@ enum common_hotkey_id_command {
HK_SWITCH_GRID_TO_FASTGRID2,
HK_SWITCH_GRID_TO_NEXT,
HK_SWITCH_GRID_TO_PREVIOUS,
HK_SWITCH_UNITS,
HK_HELP,
HK_ZOOM_IN,
HK_ZOOM_OUT,

View File

@ -46,6 +46,7 @@ public:
// Generic actions
static TOOL_ACTION cancelInteractive;
static TOOL_ACTION updateMenu;
// View controls
static TOOL_ACTION zoomRedraw;
@ -58,6 +59,8 @@ public:
static TOOL_ACTION zoomPreset;
static TOOL_ACTION zoomTool;
static TOOL_ACTION centerContents;
static TOOL_ACTION toggleCursor;
static TOOL_ACTION toggleCursorStyle;
/// Cursor control with keyboard
static TOOL_ACTION cursorUp;
@ -87,6 +90,13 @@ public:
static TOOL_ACTION gridSetOrigin;
static TOOL_ACTION gridResetOrigin;
static TOOL_ACTION gridPreset;
static TOOL_ACTION toggleGrid;
static TOOL_ACTION gridProperties;
// Units
static TOOL_ACTION imperialUnits;
static TOOL_ACTION metricUnits;
static TOOL_ACTION toggleUnits;
/**
* Function TranslateLegacyId()

View File

@ -59,11 +59,18 @@ public:
// Cursor control
int CursorControl( const TOOL_EVENT& aEvent );
int ToggleCursor( const TOOL_EVENT& aEvent );
int ToggleCursorStyle( const TOOL_EVENT& aEvent );
// Units control
int ImperialUnits( const TOOL_EVENT& aEvent );
int MetricUnits( const TOOL_EVENT& aEvent );
int ToggleUnits( const TOOL_EVENT& aEvent );
// Grid control
int GridNext( const TOOL_EVENT& aEvent );
int GridPrev( const TOOL_EVENT& aEvent );
int GridPreset( const TOOL_EVENT& aEvent );
int ToggleGrid( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -25,24 +25,31 @@
#ifndef CONDITIONAL_MENU_H
#define CONDITIONAL_MENU_H
#include "selection_conditions.h"
#include <tool/selection_conditions.h>
#include <tool/context_menu.h>
#include <list>
#include <wx/wx.h>
class SELECTION_TOOL;
class TOOL_ACTION;
class TOOL_INTERACTIVE;
class CONTEXT_MENU;
class CONDITIONAL_MENU
class CONDITIONAL_MENU : public CONTEXT_MENU
{
public:
///> Constant to indicate that we do not care about an ENTRY location in the menu.
static const int ANY_ORDER = -1;
CONDITIONAL_MENU( TOOL_INTERACTIVE* aTool ) :
m_tool( aTool )
{}
CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) :
m_isContextMenu( isContextMenu )
{
m_tool = aTool;
}
CONTEXT_MENU* create() const override;
/**
* Function AddItem()
@ -53,10 +60,21 @@ public:
* @param aOrder determines location of the added item, higher numbers are put on the bottom.
* You may use ANY_ORDER here if you think it does not matter.
*/
void AddItem( const TOOL_ACTION& aAction,
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
void AddItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition,
int aOrder = ANY_ORDER );
/**
* Function AddCheckItem()
*
* Adds a checked menu entry to run a TOOL_ACTION on selected items.
* @param aAction is a menu entry to be added.
* @param aCondition is a condition that has to be fulfilled to check the menu entry.
* @param aOrder determines location of the added item, higher numbers are put on the bottom.
* You may use ANY_ORDER here if you think it does not matter.
*/
void AddCheckItem( const TOOL_ACTION& aAction, const SELECTION_CONDITION& aCondition,
int aOrder = ANY_ORDER );
/**
* Function AddMenu()
*
@ -69,7 +87,7 @@ public:
* @param aOrder determines location of the added menu, higher numbers are put on the bottom.
* You may use ANY_ORDER here if you think it does not matter.
*/
void AddMenu( CONTEXT_MENU* aMenu, bool aExpand = false,
void AddMenu( CONTEXT_MENU* aMenu,
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
int aOrder = ANY_ORDER );
@ -85,55 +103,49 @@ public:
int aOrder = ANY_ORDER );
/**
* Function Generate()
* Function Evaluate()
*
* Generates a context menu that contains only entries that are satisfying assigned conditions.
* @param aSelection is selection for which the conditions are checked against.
* @return Menu filtered by the entry conditions.
* Updates the contents of the menu based on the supplied conditions.
*/
CONTEXT_MENU* Generate( SELECTION& aSelection );
void Evaluate( SELECTION& aSelection );
private:
///> Helper class to organize menu entries.
class ENTRY
{
public:
ENTRY( const TOOL_ACTION* aAction,
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
int aOrder = ANY_ORDER ) :
m_type( ACTION ), m_condition( aCondition ), m_order( aOrder ), m_expand( false )
ENTRY( const TOOL_ACTION* aAction, SELECTION_CONDITION aCondition, int aOrder,
bool aCheckmark ) :
m_type( ACTION ),
m_condition( aCondition ),
m_order( aOrder ),
m_isCheckmarkEntry( aCheckmark )
{
m_data.action = aAction;
}
ENTRY( CONTEXT_MENU* aMenu, bool aExpand = false,
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
int aOrder = ANY_ORDER ) :
m_type( MENU ), m_condition( aCondition ), m_order( aOrder ), m_expand( aExpand )
ENTRY( CONTEXT_MENU* aMenu, SELECTION_CONDITION aCondition, int aOrder ) :
m_type( MENU ),
m_condition( aCondition ),
m_order( aOrder ),
m_isCheckmarkEntry( false )
{
m_data.menu = aMenu;
}
ENTRY( wxMenuItem* aItem, const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
int aOrder = ANY_ORDER ) :
m_type( WXITEM ), m_condition( aCondition ), m_order( aOrder ), m_expand( false )
{
m_data.wxItem = aItem;
}
// Separator
ENTRY( const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
int aOrder = ANY_ORDER ) :
m_type( SEPARATOR ), m_condition( aCondition ), m_order( aOrder ), m_expand( false )
ENTRY( SELECTION_CONDITION aCondition, int aOrder ) :
m_type( SEPARATOR ),
m_condition( aCondition ),
m_order( aOrder ),
m_isCheckmarkEntry( false )
{
m_data.wxItem = NULL;
}
///> Possible entry types.
enum ENTRY_TYPE {
ACTION,
MENU,
WXITEM,
SEPARATOR
};
@ -154,16 +166,9 @@ private:
return m_data.menu;
}
inline wxMenuItem* wxItem() const
inline bool IsCheckmarkEntry() const
{
assert( m_type == WXITEM );
return m_data.wxItem;
}
inline bool Expand() const
{
assert( m_type == MENU );
return m_expand;
return m_isCheckmarkEntry;
}
inline const SELECTION_CONDITION& Condition() const
@ -187,7 +192,6 @@ private:
union {
const TOOL_ACTION* action;
CONTEXT_MENU* menu;
wxMenuItem* wxItem;
} m_data;
///> Condition to be fulfilled to show the entry in menu.
@ -196,18 +200,18 @@ private:
///> Order number, the higher the number the lower position it takes it is in the menu.
int m_order;
///> CONTEXT_MENU expand flag
bool m_expand;
bool m_isCheckmarkEntry;
};
///> Inserts the entry, preserving the requested order.
void addEntry( ENTRY aEntry );
///> Context menus include only items that resolve to true;
///> Regular menus enable only menu items that resolve to true.
bool m_isContextMenu;
///> List of all menu entries.
std::list<ENTRY> m_entries;
///> tool owning the menu
TOOL_INTERACTIVE* m_tool;
};
#endif /* CONDITIONAL_MENU_H */

View File

@ -89,17 +89,15 @@ public:
* a TOOL_EVENT command containing name of the action is sent.
* @param aAction is the action to be added to menu entry.
*/
wxMenuItem* Add( const TOOL_ACTION& aAction );
wxMenuItem* Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry = false );
/**
* Function Add()
* Adds a context menu as a submenu. The difference between this function and wxMenu::AppendSubMenu()
* is the capability to handle icons.
* @param aMenu is the submenu to be added.
* @param aExpand allows one to add all entries from the menu as individual
* entries rather than add everything as a submenu.
*/
std::list<wxMenuItem*> Add( CONTEXT_MENU* aMenu, bool aExpand = false );
wxMenuItem* Add( CONTEXT_MENU* aMenu );
/**
* Function Clear()
@ -144,6 +142,10 @@ public:
*/
CONTEXT_MENU* Clone() const;
public:
///> Menu requires updating before display.
bool m_Dirty;
protected:
///> Returns an instance of this class. It has to be overridden in inheriting classes.
virtual CONTEXT_MENU* create() const;
@ -180,7 +182,7 @@ protected:
*/
void copyFrom( const CONTEXT_MENU& aMenu );
private:
protected:
/**
* Function appendCopy
* Appends a copy of wxMenuItem.
@ -219,7 +221,7 @@ private:
TOOL_INTERACTIVE* m_tool;
///> Menu items with ID higher than that are considered TOOL_ACTIONs
static const int ACTION_ID = 2000;
static const int ACTION_ID = 10000;
///> Associates tool actions with menu item IDs. Non-owning.
std::map<int, const TOOL_ACTION*> m_toolActions;

View File

@ -87,19 +87,10 @@ public:
return m_id;
}
/**
* Function HasHotKey()
* Checks if the action has a hot key assigned.
*
* @return True if there is a hot key assigned, false otherwise.
*/
/**
* Function MakeEvent()
* Returns the event associated with the action (i.e. the event that will be sent after
* activating the action).
*
* @return The event associated with the action.
*/
TOOL_EVENT MakeEvent() const
{

View File

@ -115,9 +115,6 @@ private:
return mods;
}
///> Redraws the status bar and message panel, synchronizes menus and toolbars.
void updateUI( wxEvent& aEvent );
///> Stores all the informations regarding a mouse button state.
struct BUTTON_STATE;

View File

@ -244,7 +244,7 @@ public:
///> Returns if it this event has a valid position (true for mouse events)
bool HasPosition() const
{
return m_category == TC_MOUSE;
return m_category == TC_MOUSE || m_category == TC_COMMAND;
}
///> Returns information about difference between current mouse cursor position and the place
@ -434,7 +434,7 @@ private:
/**
* Ensure that the event is a type that has a position before returning a
* position, otherwise return a mull-constructed position.
* position, otherwise return a null-constructed position.
* Used to defend the position accessors from runtime access when the event
* does not have a valid position.
*

View File

@ -246,7 +246,7 @@ public:
* when the board is set up.
*/
void SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
KIGFX::VIEW_CONTROLS* aViewControls, wxWindow* aFrame );
KIGFX::VIEW_CONTROLS* aViewControls, EDA_DRAW_FRAME* aFrame );
/* Accessors for the environment objects (view, model, etc.) */
KIGFX::VIEW* GetView() const
@ -264,7 +264,7 @@ public:
return m_model;
}
inline wxWindow* GetEditFrame() const
inline EDA_DRAW_FRAME* GetEditFrame() const
{
return m_editFrame;
}
@ -324,6 +324,11 @@ public:
void RunMainStack( TOOL_BASE* aTool, std::function<void()> aFunc );
/**
* Synchronizes toolbars.
*/
void UpdateUI();
/**
* Pauses execution of a given tool until one or more events matching aConditions arrives.
* The pause/resume operation is done through COROUTINE object.
@ -531,7 +536,7 @@ private:
EDA_ITEM* m_model;
KIGFX::VIEW* m_view;
KIGFX::VIEW_CONTROLS* m_viewControls;
wxWindow* m_editFrame;
EDA_DRAW_FRAME* m_editFrame;
/// Queue that stores events to be processed at the end of the event processing cycle.
std::list<TOOL_EVENT> m_eventQueue;

View File

@ -150,15 +150,10 @@ private:
}
/**
* The conditional model of the menu displayed by the tool
* The conditional menu displayed by the tool
*/
CONDITIONAL_MENU m_menu;
/**
* The actual menu displayed by the tool
*/
std::unique_ptr<CONTEXT_MENU> m_contextMenu;
/**
* The tool that owns this menu
*/

View File

@ -35,8 +35,7 @@
// see also enum common_hotkey_id_command in hotkeys_basic.h
// for shared hotkeys id
enum hotkey_id_command {
HK_SWITCH_UNITS = HK_COMMON_END,
HK_MOVE_ITEM,
HK_MOVE_ITEM = HK_COMMON_END,
HK_MOVE_START_POINT,
HK_MOVE_END_POINT,
HK_PLACE_ITEM,

View File

@ -64,7 +64,6 @@ enum hotkey_id_command {
HK_ADD_MICROVIA,
HK_SWITCH_TRACK_POSTURE,
HK_DRAG_TRACK_KEEP_SLOPE,
HK_SWITCH_UNITS,
HK_SWITCH_TRACK_DISPLAY_MODE,
HK_3D_VIEWER,
HK_FIND_ITEM,

View File

@ -1733,7 +1733,7 @@ public:
*/
void CommonSettingsChanged() override;
void SyncMenusAndToolbars( wxEvent& aEvent ) override;
void SyncMenusAndToolbars() override;
DECLARE_EVENT_TABLE()
};

View File

@ -188,10 +188,10 @@ void PCB_EDIT_FRAME::OnUpdateMuWaveToolbar( wxUpdateUIEvent& aEvent )
}
void PCB_EDIT_FRAME::SyncMenusAndToolbars( wxEvent& aEvent )
void PCB_EDIT_FRAME::SyncMenusAndToolbars()
{
auto displOpts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto menuBar = GetMenuBar();
PCB_DISPLAY_OPTIONS* displOpts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions();
wxMenuBar* menuBar = GetMenuBar();
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_ZONES, false );
m_optionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, false );

View File

@ -191,7 +191,7 @@ bool PAD_TOOL::Init()
( SELECTION_CONDITIONS::HasType( PCB_PAD_T )
|| SELECTION_CONDITIONS::Count( 0 ) );
menu.AddMenu( contextMenu.get(), false, showCond, 1000 );
menu.AddMenu( contextMenu.get(), showCond, 1000 );
// we need a separator only when the selection is empty
auto separatorCond = canShowMenuCond && SELECTION_CONDITIONS::Count( 0 );

View File

@ -312,11 +312,8 @@ bool PCB_EDITOR_CONTROL::Init()
toolMenu.AddSubMenu( zoneMenu );
toolMenu.AddSubMenu( lockMenu );
menu.AddMenu( zoneMenu.get(), false,
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
menu.AddMenu( lockMenu.get(), false,
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
}
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
@ -338,7 +335,7 @@ bool PCB_EDITOR_CONTROL::Init()
};
};
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
}
m_ratsnestTimer.SetOwner( this );
@ -508,7 +505,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( module && evt->IsMotion() )
@ -664,7 +661,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selTool->GetSelection() );
m_menu.ShowContextMenu();
}
else if( evt->IsMotion() )

View File

@ -94,13 +94,9 @@ ALIGN_DISTRIBUTE_TOOL::~ALIGN_DISTRIBUTE_TOOL()
bool ALIGN_DISTRIBUTE_TOOL::Init()
{
// Find the selection tool, so they can cooperate
m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
m_selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( !m_selectionTool )
{
DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) );
return false;
}
wxASSERT_MSG( m_selectionTool, _( "pcbnew.InteractiveSelection tool is not available" ) );
m_frame = getEditFrame<PCB_BASE_FRAME>();
@ -120,8 +116,8 @@ bool ALIGN_DISTRIBUTE_TOOL::Init()
m_placementMenu->Add( PCB_ACTIONS::distributeHorizontally );
m_placementMenu->Add( PCB_ACTIONS::distributeVertically );
m_selectionTool->GetToolMenu().GetMenu().AddMenu( m_placementMenu, false,
SELECTION_CONDITIONS::MoreThan( 1 ) );
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
selToolMenu.AddMenu( m_placementMenu, SELECTION_CONDITIONS::MoreThan( 1 ) );
return true;
}

View File

@ -229,7 +229,7 @@ bool SELECTION_TOOL::Init()
auto& menu = m_menu.GetMenu();
menu.AddMenu( selectMenu.get(), false, SELECTION_CONDITIONS::NotEmpty );
menu.AddMenu( selectMenu.get(), SELECTION_CONDITIONS::NotEmpty );
menu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
if( frame )
@ -310,7 +310,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
if( !selectionCancelled )
m_menu.ShowContextMenu( m_selection );
m_menu.ShowContextMenu();
}
// double click? Display the properties window