Move Leave Sheet to the top of the context menu.
This commit is contained in:
parent
7e3ad4585a
commit
b5fd7b9842
|
@ -286,10 +286,10 @@ void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
|
|||
aToolManager->RegisterTool( new COMMON_TOOLS );
|
||||
aToolManager->RegisterTool( new ZOOM_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_SELECTION_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||
aToolManager->RegisterTool( new SCH_PICKER_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_DRAWING_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_LINE_DRAWING_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDIT_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_INSPECTION_TOOL );
|
||||
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
|
||||
}
|
||||
|
|
|
@ -165,8 +165,8 @@ bool SCH_DRAWING_TOOL::Init()
|
|||
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
||||
};
|
||||
|
||||
auto sheetTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() == ID_SHEET_SYMBOL_BUTT );
|
||||
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
|
||||
return g_CurrentSheet->Last() != g_RootSheet;
|
||||
};
|
||||
|
||||
auto& ctxMenu = m_menu.GetMenu();
|
||||
|
@ -175,8 +175,7 @@ bool SCH_DRAWING_TOOL::Init()
|
|||
// Build the drawing tool menu
|
||||
//
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
|
||||
|
||||
ctxMenu.AddItem( SCH_ACTIONS::resizeSheet, sheetTool && SCH_CONDITIONS::Idle, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
|
||||
|
||||
ctxMenu.AddSeparator( activeTool, 1000 );
|
||||
m_menu.AddStandardSubMenus( m_frame );
|
||||
|
|
|
@ -264,10 +264,21 @@ bool SCH_EDIT_TOOL::Init()
|
|||
wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" );
|
||||
wxASSERT_MSG( drawingTool, "eeshema.InteractiveDrawing tool is not available" );
|
||||
|
||||
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
|
||||
auto activeTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
||||
};
|
||||
|
||||
auto sheetTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() == ID_SHEET_SYMBOL_BUTT );
|
||||
};
|
||||
|
||||
auto anyTextTool = [ this ] ( const SELECTION& aSel ) {
|
||||
return ( m_frame->GetToolId() == ID_LABEL_BUTT
|
||||
|| m_frame->GetToolId() == ID_GLOBALLABEL_BUTT
|
||||
|| m_frame->GetToolId() == ID_HIERLABEL_BUTT
|
||||
|| m_frame->GetToolId() == ID_TEXT_COMMENT_BUTT );
|
||||
};
|
||||
|
||||
auto moveCondition = [] ( const SELECTION& aSel ) {
|
||||
if( aSel.Empty() )
|
||||
return false;
|
||||
|
@ -363,7 +374,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
//
|
||||
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
|
||||
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
|
||||
|
||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::rotateCCW, orientCondition );
|
||||
|
@ -415,10 +426,12 @@ bool SCH_EDIT_TOOL::Init()
|
|||
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toHLabel, toHLabelCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toHLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toGLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::toText, anyTextTool && SCH_CONDITIONS::Idle, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::cleanupSheetPins, sheetTool && SCH_CONDITIONS::Idle, 200 );
|
||||
drawingMenu.AddItem( SCH_ACTIONS::resizeSheet, sheetTool && SCH_CONDITIONS::Idle, 200 );
|
||||
|
||||
//
|
||||
// Add editing actions to the selection tool menu
|
||||
|
@ -453,6 +466,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
selToolMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::cleanupSheetPins, singleSheetCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition, 200 );
|
||||
|
||||
selToolMenu.AddSeparator( SCH_CONDITIONS::Idle, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::cut, SCH_CONDITIONS::IdleSelection, 200 );
|
||||
|
@ -1644,17 +1658,18 @@ int SCH_EDIT_TOOL::ChangeShape( const TOOL_EVENT& aEvent )
|
|||
|
||||
int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION selection = m_selectionTool->GetSelection();
|
||||
KICAD_T type;
|
||||
KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
|
||||
SELECTION selection = m_selectionTool->RequestSelection( allTextTypes );
|
||||
KICAD_T convertTo;
|
||||
|
||||
if( aEvent.IsAction( &SCH_ACTIONS::toLabel ) )
|
||||
type = SCH_LABEL_T;
|
||||
convertTo = SCH_LABEL_T;
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::toHLabel ) )
|
||||
type = SCH_HIER_LABEL_T;
|
||||
convertTo = SCH_HIER_LABEL_T;
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::toGLabel ) )
|
||||
type = SCH_GLOBAL_LABEL_T;
|
||||
convertTo = SCH_GLOBAL_LABEL_T;
|
||||
else if( aEvent.IsAction( &SCH_ACTIONS::toText ) )
|
||||
type = SCH_TEXT_T;
|
||||
convertTo = SCH_TEXT_T;
|
||||
else
|
||||
return 0;
|
||||
|
||||
|
@ -1663,7 +1678,7 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
|
|||
SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
|
||||
|
||||
if( text )
|
||||
m_frame->ConvertTextType( text, type );
|
||||
m_frame->ConvertTextType( text, convertTo );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <class_library.h>
|
||||
#include <confirm.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include "sch_line_drawing_tool.h"
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
|
||||
AS_GLOBAL, 0, "", "" );
|
||||
|
@ -133,15 +134,6 @@ bool SCH_EDITOR_CONTROL::Init()
|
|||
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
|
||||
};
|
||||
|
||||
auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& 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();
|
||||
|
||||
// "Cancel" goes at the top of the context menu when a tool is active
|
||||
|
@ -151,29 +143,6 @@ bool SCH_EDITOR_CONTROL::Init()
|
|||
// Finally, add the standard zoom & grid items
|
||||
m_menu.AddStandardSubMenus( m_frame );
|
||||
|
||||
// Add the SCH control menus to relevant other tools
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
|
||||
if( selTool )
|
||||
{
|
||||
CONDITIONAL_MENU& selToolMenu = selTool->GetToolMenu().GetMenu();
|
||||
|
||||
selToolMenu.AddSeparator( anySheetCondition, 600 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::enterSheet, singleSheetCondition, 600 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 600 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::explicitCrossProbe, singleSheetCondition, 600 );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,24 +205,30 @@ bool SCH_LINE_DRAWING_TOOL::Init()
|
|||
return ( m_frame->GetToolId() == ID_LINE_COMMENT_BUTT );
|
||||
};
|
||||
|
||||
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
|
||||
return g_CurrentSheet->Last() != g_RootSheet;
|
||||
};
|
||||
|
||||
auto& ctxMenu = m_menu.GetMenu();
|
||||
|
||||
//
|
||||
// Build the tool menu
|
||||
//
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
|
||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, SCH_CONDITIONS::ShowAlways, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
|
||||
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startWire, wireOrBusTool && SCH_CONDITIONS::Idle, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startBus, wireOrBusTool && SCH_CONDITIONS::Idle, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startLines, lineTool && SCH_CONDITIONS::Idle, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishWire, IsDrawingWire, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishBus, IsDrawingBus, 1 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishLine, IsDrawingLine, 1 );
|
||||
ctxMenu.AddSeparator( SCH_CONDITIONS::ShowAlways, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startWire, wireOrBusTool && SCH_CONDITIONS::Idle, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startBus, wireOrBusTool && SCH_CONDITIONS::Idle, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::startLines, lineTool && SCH_CONDITIONS::Idle, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishWire, IsDrawingWire, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishBus, IsDrawingBus, 10 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::finishLine, IsDrawingLine, 10 );
|
||||
|
||||
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, SCH_CONDITIONS::Idle, 1 );
|
||||
ctxMenu.AddMenu( busUnfoldMenu.get(), false, SCH_CONDITIONS::Idle, 10 );
|
||||
|
||||
ctxMenu.AddSeparator( wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
||||
ctxMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
|
||||
|
|
|
@ -178,19 +178,31 @@ bool SCH_SELECTION_TOOL::Init()
|
|||
auto wireOrBusSelection = SCH_CONDITIONS::MoreThan( 0 )
|
||||
&& SCH_CONDITIONS::OnlyTypes( wireOrBusTypes );
|
||||
|
||||
auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
auto sheetSelection = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T );
|
||||
|
||||
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
|
||||
return g_CurrentSheet->Last() != g_RootSheet;
|
||||
};
|
||||
|
||||
auto& menu = m_menu.GetMenu();
|
||||
|
||||
// TODO(JE): add menu access to unfold bus on busSelectionCondition...
|
||||
|
||||
menu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition && SCH_CONDITIONS::Idle, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::enterSheet, sheetSelection && SCH_CONDITIONS::Idle, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::explicitCrossProbe, sheetSelection && SCH_CONDITIONS::Idle, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::resizeSheet, sheetSelection && SCH_CONDITIONS::Idle, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
|
||||
|
||||
menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::startBus, SCH_CONDITIONS::Empty, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::finishWire, SCH_LINE_DRAWING_TOOL::IsDrawingWire, 1 );
|
||||
menu.AddItem( SCH_ACTIONS::finishBus, SCH_LINE_DRAWING_TOOL::IsDrawingBus, 1 );
|
||||
menu.AddSeparator( SCH_CONDITIONS::Empty, 100 );
|
||||
menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 100 );
|
||||
menu.AddItem( SCH_ACTIONS::startBus, SCH_CONDITIONS::Empty, 100 );
|
||||
|
||||
menu.AddSeparator( SCH_LINE_DRAWING_TOOL::IsDrawingWire, 100 );
|
||||
menu.AddItem( SCH_ACTIONS::finishWire, SCH_LINE_DRAWING_TOOL::IsDrawingWire, 100 );
|
||||
|
||||
menu.AddSeparator( SCH_LINE_DRAWING_TOOL::IsDrawingBus, 100 );
|
||||
menu.AddItem( SCH_ACTIONS::finishBus, SCH_LINE_DRAWING_TOOL::IsDrawingBus, 100 );
|
||||
|
||||
menu.AddSeparator( SCH_CONDITIONS::NotEmpty, 200 );
|
||||
menu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusSelection && SCH_CONDITIONS::Idle, 200 );
|
||||
|
@ -200,7 +212,7 @@ bool SCH_SELECTION_TOOL::Init()
|
|||
menu.AddItem( SCH_ACTIONS::addHierLabel, wireOrBusSelection && SCH_CONDITIONS::Idle, 200 );
|
||||
menu.AddItem( SCH_ACTIONS::breakWire, wireSelection && SCH_CONDITIONS::Idle, 200 );
|
||||
menu.AddItem( SCH_ACTIONS::breakBus, busSelection && SCH_CONDITIONS::Idle, 200 );
|
||||
menu.AddItem( SCH_ACTIONS::importSheetPin, singleSheetCondition && SCH_CONDITIONS::Idle, 200 );
|
||||
menu.AddItem( SCH_ACTIONS::importSheetPin, sheetSelection && SCH_CONDITIONS::Idle, 200 );
|
||||
|
||||
menu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
|
||||
m_menu.AddStandardSubMenus( m_frame );
|
||||
|
|
Loading…
Reference in New Issue