Add enter/leave sheet to modern toolset.
This commit is contained in:
parent
423d430b58
commit
35e8a340ca
|
@ -256,6 +256,9 @@ void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event )
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||||
{
|
{
|
||||||
|
m_toolManager->RunAction( ACTIONS::cancelInteractive, true );
|
||||||
|
m_toolManager->RunAction( SCH_ACTIONS::clearSelection, true );
|
||||||
|
|
||||||
SetRepeatItem( NULL );
|
SetRepeatItem( NULL );
|
||||||
ClearMsgPanel();
|
ClearMsgPanel();
|
||||||
|
|
||||||
|
|
|
@ -77,23 +77,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( item == NULL )
|
|
||||||
{
|
|
||||||
if( g_CurrentSheet->Last() != g_RootSheet )
|
|
||||||
{
|
|
||||||
msg = AddHotkeyName( _( "Leave Sheet" ), g_Schematic_Hotkeys_Descr, HK_LEAVE_SHEET );
|
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, msg, KiBitmap( leave_sheet_xpm ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch( item->Type() )
|
switch( item->Type() )
|
||||||
{
|
{
|
||||||
case SCH_JUNCTION_T:
|
|
||||||
addJunctionMenuEntries( PopMenu, (SCH_JUNCTION*) item );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCH_COMPONENT_T:
|
case SCH_COMPONENT_T:
|
||||||
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item, Prj().SchSymbolLibTable() );
|
AddMenusForComponent( PopMenu, (SCH_COMPONENT*) item, Prj().SchSymbolLibTable() );
|
||||||
break;
|
break;
|
||||||
|
@ -170,20 +155,6 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunction )
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
SCH_SCREEN* screen = GetScreen();
|
|
||||||
|
|
||||||
if( !aJunction->IsNew() )
|
|
||||||
{
|
|
||||||
if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) )
|
|
||||||
AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ),
|
|
||||||
KiBitmap( break_line_xpm ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
|
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
|
||||||
{
|
{
|
||||||
wxPoint pos = frame->GetCrossHairPosition();
|
wxPoint pos = frame->GetCrossHairPosition();
|
||||||
|
@ -244,8 +215,6 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
||||||
|
|
||||||
if( !Sheet->GetEditFlags() )
|
if( !Sheet->GetEditFlags() )
|
||||||
{
|
{
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ),
|
|
||||||
KiBitmap( enter_sheet_xpm ) );
|
|
||||||
PopMenu->AppendSeparator();
|
PopMenu->AppendSeparator();
|
||||||
msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr,
|
msg = AddHotkeyName( _( "Select Items On PCB" ), g_Schematic_Hotkeys_Descr,
|
||||||
HK_SELECT_ITEMS_ON_PCB );
|
HK_SELECT_ITEMS_ON_PCB );
|
||||||
|
@ -263,10 +232,6 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
||||||
if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
|
if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
|
AddMenuItem( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
|
||||||
KiBitmap( options_pinsheet_xpm ) );
|
KiBitmap( options_pinsheet_xpm ) );
|
||||||
|
|
||||||
PopMenu->AppendSeparator();
|
|
||||||
msg = AddHotkeyName( _( "Delete" ), g_Schematic_Hotkeys_Descr, HK_DELETE );
|
|
||||||
AddMenuItem( PopMenu, ID_SCH_DELETE, msg, KiBitmap( delete_sheet_xpm ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,6 @@
|
||||||
case ID_POPUP_SCH_RESIZE_SHEET:
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
||||||
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
||||||
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
||||||
case ID_POPUP_SCH_ENTER_SHEET:
|
|
||||||
case ID_POPUP_SCH_LEAVE_SHEET:
|
|
||||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||||
case ID_POPUP_SCH_ADD_LABEL:
|
case ID_POPUP_SCH_ADD_LABEL:
|
||||||
/* At this point: Do nothing. these commands do not need to stop the
|
/* At this point: Do nothing. these commands do not need to stop the
|
||||||
|
@ -136,23 +134,6 @@
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_ENTER_SHEET:
|
|
||||||
|
|
||||||
if( item && (item->Type() == SCH_SHEET_T) )
|
|
||||||
{
|
|
||||||
g_CurrentSheet->push_back( (SCH_SHEET*) item );
|
|
||||||
DisplayCurrentSheet();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_LEAVE_SHEET:
|
|
||||||
if( g_CurrentSheet->Last() != g_RootSheet )
|
|
||||||
{
|
|
||||||
g_CurrentSheet->pop_back();
|
|
||||||
DisplayCurrentSheet();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: // Log error:
|
default: // Log error:
|
||||||
wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
|
wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -256,6 +256,12 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
|
|
||||||
case ID_HOTKEY_SELECT_CONNECTION:
|
case ID_HOTKEY_SELECT_CONNECTION:
|
||||||
return SCH_ACTIONS::selectConnection.MakeEvent();
|
return SCH_ACTIONS::selectConnection.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_ENTER_SHEET:
|
||||||
|
return SCH_ACTIONS::enterSheet.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
||||||
|
return SCH_ACTIONS::leaveSheet.MakeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPT<TOOL_EVENT>();
|
return OPT<TOOL_EVENT>();
|
||||||
|
|
|
@ -67,25 +67,6 @@ public:
|
||||||
/// Runs a selection menu to select from a list of items
|
/// Runs a selection menu to select from a list of items
|
||||||
static TOOL_ACTION selectionMenu;
|
static TOOL_ACTION selectionMenu;
|
||||||
|
|
||||||
/* Can we share these with PCBNew?
|
|
||||||
// Layer control
|
|
||||||
static TOOL_ACTION layerTop;
|
|
||||||
static TOOL_ACTION layerInner1;
|
|
||||||
static TOOL_ACTION layerInner2;
|
|
||||||
static TOOL_ACTION layerInner3;
|
|
||||||
static TOOL_ACTION layerInner4;
|
|
||||||
static TOOL_ACTION layerInner5;
|
|
||||||
static TOOL_ACTION layerInner6;
|
|
||||||
static TOOL_ACTION layerBottom;
|
|
||||||
static TOOL_ACTION layerNext;
|
|
||||||
static TOOL_ACTION layerPrev;
|
|
||||||
static TOOL_ACTION layerAlphaInc;
|
|
||||||
static TOOL_ACTION layerAlphaDec;
|
|
||||||
static TOOL_ACTION layerToggle;
|
|
||||||
|
|
||||||
static TOOL_ACTION layerChanged; // notification
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Locking
|
// Locking
|
||||||
static TOOL_ACTION toggleLock;
|
static TOOL_ACTION toggleLock;
|
||||||
static TOOL_ACTION lock;
|
static TOOL_ACTION lock;
|
||||||
|
@ -160,6 +141,8 @@ public:
|
||||||
static TOOL_ACTION paste;
|
static TOOL_ACTION paste;
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
|
static TOOL_ACTION enterSheet;
|
||||||
|
static TOOL_ACTION leaveSheet;
|
||||||
static TOOL_ACTION switchCursor;
|
static TOOL_ACTION switchCursor;
|
||||||
static TOOL_ACTION switchUnits;
|
static TOOL_ACTION switchUnits;
|
||||||
static TOOL_ACTION updateUnits;
|
static TOOL_ACTION updateUnits;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <tools/sch_picker_tool.h>
|
#include <tools/sch_picker_tool.h>
|
||||||
#include <tools/sch_editor_control.h>
|
#include <tools/sch_editor_control.h>
|
||||||
#include <tools/sch_selection_tool.h>
|
#include <tools/sch_selection_tool.h>
|
||||||
|
#include <tools/sch_drawing_tool.h>
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
|
@ -89,6 +90,16 @@ TOOL_ACTION SCH_ACTIONS::editWithSymbolEditor( "eeschema.EditorControl.editWithS
|
||||||
_( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ),
|
_( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ),
|
||||||
libedit_xpm );
|
libedit_xpm );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
_( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ),
|
||||||
|
enter_sheet_xpm );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::leaveSheet( "eeschema.EditorControl.leaveSheet",
|
||||||
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEAVE_SHEET ),
|
||||||
|
_( "Leave Sheet" ), _( "Display the parent sheet in the Eeschema window" ),
|
||||||
|
leave_sheet_xpm );
|
||||||
|
|
||||||
|
|
||||||
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
|
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
|
||||||
TOOL_INTERACTIVE( "eeschema.EditorControl" ),
|
TOOL_INTERACTIVE( "eeschema.EditorControl" ),
|
||||||
|
@ -117,10 +128,15 @@ bool SCH_EDITOR_CONTROL::Init()
|
||||||
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
||||||
};
|
};
|
||||||
|
|
||||||
auto inactiveStateCondition = [ this ] ( const SELECTION& aSel ) {
|
auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||||
return ( m_frame->GetToolId() == ID_NO_TOOL_SELECTED && aSel.Size() == 0 );
|
&& SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T );
|
||||||
|
|
||||||
|
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
|
||||||
|
return g_CurrentSheet->Last() != g_RootSheet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto anySheetCondition = singleSheetCondition || belowRootSheetCondition;
|
||||||
|
|
||||||
auto& ctxMenu = m_menu.GetMenu();
|
auto& ctxMenu = m_menu.GetMenu();
|
||||||
|
|
||||||
// "Cancel" goes at the top of the context menu when a tool is active
|
// "Cancel" goes at the top of the context menu when a tool is active
|
||||||
|
@ -130,25 +146,27 @@ bool SCH_EDITOR_CONTROL::Init()
|
||||||
// Finally, add the standard zoom & grid items
|
// Finally, add the standard zoom & grid items
|
||||||
m_menu.AddStandardSubMenus( m_frame );
|
m_menu.AddStandardSubMenus( m_frame );
|
||||||
|
|
||||||
/*
|
|
||||||
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
|
|
||||||
lockMenu->SetTool( this );
|
|
||||||
|
|
||||||
// Add the SCH control menus to relevant other tools
|
// Add the SCH control menus to relevant other tools
|
||||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||||
|
|
||||||
if( selTool )
|
if( selTool )
|
||||||
{
|
{
|
||||||
auto& toolMenu = selTool->GetToolMenu();
|
CONDITIONAL_MENU& selToolMenu = selTool->GetToolMenu().GetMenu();
|
||||||
auto& menu = toolMenu.GetMenu();
|
|
||||||
|
|
||||||
menu.AddSeparator( inactiveStateCondition );
|
selToolMenu.AddSeparator( anySheetCondition, 600 );
|
||||||
toolMenu.AddSubMenu( lockMenu );
|
selToolMenu.AddItem( SCH_ACTIONS::enterSheet, singleSheetCondition, 600 );
|
||||||
|
selToolMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 600 );
|
||||||
menu.AddMenu( lockMenu.get(), false,
|
}
|
||||||
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
|
|
||||||
|
SCH_DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<SCH_DRAWING_TOOL>();
|
||||||
|
|
||||||
|
if( drawingTool )
|
||||||
|
{
|
||||||
|
CONDITIONAL_MENU& drawingToolMenu = drawingTool->GetToolMenu().GetMenu();
|
||||||
|
|
||||||
|
drawingToolMenu.AddSeparator( belowRootSheetCondition, 600 );
|
||||||
|
drawingToolMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 600 );
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -680,6 +698,33 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||||
|
const SELECTION& selection = selTool->RequestSelection( (KICAD_T[]) { SCH_SHEET_T, EOT } );
|
||||||
|
|
||||||
|
if( selection.GetSize() == 1 )
|
||||||
|
{
|
||||||
|
g_CurrentSheet->push_back( (SCH_SHEET*) selection.GetItem( 0 ) );
|
||||||
|
m_frame->DisplayCurrentSheet();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_EDITOR_CONTROL::LeaveSheet( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
if( g_CurrentSheet->Last() != g_RootSheet )
|
||||||
|
{
|
||||||
|
g_CurrentSheet->pop_back();
|
||||||
|
m_frame->DisplayCurrentSheet();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDITOR_CONTROL::setTransitions()
|
void SCH_EDITOR_CONTROL::setTransitions()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -714,4 +759,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
||||||
Go( &SCH_EDITOR_CONTROL::Paste, SCH_ACTIONS::paste.MakeEvent() );
|
Go( &SCH_EDITOR_CONTROL::Paste, SCH_ACTIONS::paste.MakeEvent() );
|
||||||
|
|
||||||
Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, SCH_ACTIONS::editWithSymbolEditor.MakeEvent() );
|
Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, SCH_ACTIONS::editWithSymbolEditor.MakeEvent() );
|
||||||
|
|
||||||
|
Go( &SCH_EDITOR_CONTROL::EnterSheet, SCH_ACTIONS::enterSheet.MakeEvent() );
|
||||||
|
Go( &SCH_EDITOR_CONTROL::LeaveSheet, SCH_ACTIONS::leaveSheet.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,9 @@ public:
|
||||||
|
|
||||||
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
|
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
|
int EnterSheet( const TOOL_EVENT& aEvent );
|
||||||
|
int LeaveSheet( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///> copy selection to clipboard
|
///> copy selection to clipboard
|
||||||
bool doCopy();
|
bool doCopy();
|
||||||
|
|
|
@ -97,7 +97,7 @@ bool SCH_SELECTION_TOOL::Init()
|
||||||
{
|
{
|
||||||
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
||||||
|
|
||||||
m_menu.GetMenu().AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
|
m_menu.GetMenu().AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
|
||||||
m_menu.AddStandardSubMenus( m_frame );
|
m_menu.AddStandardSubMenus( m_frame );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue