mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 16:59:18 +00:00
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:
parent
d290154dd3
commit
ef5c69167a
common
legacy_gal
tool
eeschema
ee_hotkeys.cppeeschema_id.hhierarch.cpp
libedit
menubar.cppsch_base_frame.hsch_edit_frame.cppsch_edit_frame.htoolbars_sch_editor.cpptools
gerbview
include
pagelayout_editor
pcbnew
@ -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()
|
||||
{
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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..
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -557,6 +557,8 @@ public:
|
||||
|
||||
void ShowChangedLanguage() override;
|
||||
|
||||
void SyncMenusAndToolbars() override;
|
||||
|
||||
virtual void SetScreen( BASE_SCREEN* aScreen ) override;
|
||||
|
||||
virtual const BOX2I GetDocumentExtents() const override;
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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() );
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
/// @copydoc TOOL_BASE::Reset()
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
int UpdateMenu( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function Main()
|
||||
*
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user