Move Leave Sheet to the top of the context menu.

This commit is contained in:
Jeff Young 2019-05-03 23:48:24 +01:00
parent 7e3ad4585a
commit b5fd7b9842
6 changed files with 75 additions and 74 deletions

View File

@ -286,10 +286,10 @@ void SCH_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
aToolManager->RegisterTool( new COMMON_TOOLS ); aToolManager->RegisterTool( new COMMON_TOOLS );
aToolManager->RegisterTool( new ZOOM_TOOL ); aToolManager->RegisterTool( new ZOOM_TOOL );
aToolManager->RegisterTool( new SCH_SELECTION_TOOL ); aToolManager->RegisterTool( new SCH_SELECTION_TOOL );
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
aToolManager->RegisterTool( new SCH_PICKER_TOOL ); aToolManager->RegisterTool( new SCH_PICKER_TOOL );
aToolManager->RegisterTool( new SCH_DRAWING_TOOL ); aToolManager->RegisterTool( new SCH_DRAWING_TOOL );
aToolManager->RegisterTool( new SCH_LINE_DRAWING_TOOL ); aToolManager->RegisterTool( new SCH_LINE_DRAWING_TOOL );
aToolManager->RegisterTool( new SCH_EDIT_TOOL ); aToolManager->RegisterTool( new SCH_EDIT_TOOL );
aToolManager->RegisterTool( new SCH_INSPECTION_TOOL ); aToolManager->RegisterTool( new SCH_INSPECTION_TOOL );
aToolManager->RegisterTool( new SCH_EDITOR_CONTROL );
} }

View File

@ -165,8 +165,8 @@ bool SCH_DRAWING_TOOL::Init()
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED ); return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED );
}; };
auto sheetTool = [ this ] ( const SELECTION& aSel ) { auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return ( m_frame->GetToolId() == ID_SHEET_SYMBOL_BUTT ); return g_CurrentSheet->Last() != g_RootSheet;
}; };
auto& ctxMenu = m_menu.GetMenu(); auto& ctxMenu = m_menu.GetMenu();
@ -175,8 +175,7 @@ bool SCH_DRAWING_TOOL::Init()
// Build the drawing tool menu // Build the drawing tool menu
// //
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 ); ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
ctxMenu.AddItem( SCH_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
ctxMenu.AddItem( SCH_ACTIONS::resizeSheet, sheetTool && SCH_CONDITIONS::Idle, 1 );
ctxMenu.AddSeparator( activeTool, 1000 ); ctxMenu.AddSeparator( activeTool, 1000 );
m_menu.AddStandardSubMenus( m_frame ); m_menu.AddStandardSubMenus( m_frame );

View File

@ -264,10 +264,21 @@ bool SCH_EDIT_TOOL::Init()
wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" ); wxASSERT_MSG( m_selectionTool, "eeshema.InteractiveSelection tool is not available" );
wxASSERT_MSG( drawingTool, "eeshema.InteractiveDrawing 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 ); 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 ) { auto moveCondition = [] ( const SELECTION& aSel ) {
if( aSel.Empty() ) if( aSel.Empty() )
return false; return false;
@ -363,7 +374,7 @@ bool SCH_EDIT_TOOL::Init()
// //
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 ); ctxMenu.AddItem( ACTIONS::cancelInteractive, activeTool, 1 );
ctxMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty ); ctxMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty );
ctxMenu.AddItem( SCH_ACTIONS::rotateCCW, orientCondition ); ctxMenu.AddItem( SCH_ACTIONS::rotateCCW, orientCondition );
@ -415,24 +426,26 @@ bool SCH_EDIT_TOOL::Init()
drawingMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 ); drawingMenu.AddItem( SCH_ACTIONS::toShapeSlash, entryCondition, 200 );
drawingMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 ); drawingMenu.AddItem( SCH_ACTIONS::toShapeBackslash, entryCondition, 200 );
drawingMenu.AddItem( SCH_ACTIONS::toLabel, toLabelCondition, 200 ); drawingMenu.AddItem( SCH_ACTIONS::toLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
drawingMenu.AddItem( SCH_ACTIONS::toHLabel, toHLabelCondition, 200 ); drawingMenu.AddItem( SCH_ACTIONS::toHLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
drawingMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 ); drawingMenu.AddItem( SCH_ACTIONS::toGLabel, anyTextTool && SCH_CONDITIONS::Idle, 200 );
drawingMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 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 // Add editing actions to the selection tool menu
// //
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
selToolMenu.AddItem( SCH_ACTIONS::move, moveCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::move, moveCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::drag, moveCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::drag, moveCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::rotateCCW, orientCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::rotateCCW, orientCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::rotateCW, orientCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::rotateCW, orientCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::mirrorX, orientCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::mirrorX, orientCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::mirrorY, orientCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::mirrorY, orientCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::duplicate, moveCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::duplicate, moveCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::doDelete, SCH_CONDITIONS::NotEmpty, 200 ); selToolMenu.AddItem( SCH_ACTIONS::doDelete, SCH_CONDITIONS::NotEmpty, 200 );
selToolMenu.AddItem( SCH_ACTIONS::properties, propertiesCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::properties, propertiesCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::editReference, SCH_CONDITIONS::SingleSymbol, 200 ); selToolMenu.AddItem( SCH_ACTIONS::editReference, SCH_CONDITIONS::SingleSymbol, 200 );
@ -453,6 +466,7 @@ bool SCH_EDIT_TOOL::Init()
selToolMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::toGLabel, toGLabelCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::cleanupSheetPins, singleSheetCondition, 200 ); selToolMenu.AddItem( SCH_ACTIONS::cleanupSheetPins, singleSheetCondition, 200 );
selToolMenu.AddItem( SCH_ACTIONS::resizeSheet, singleSheetCondition, 200 );
selToolMenu.AddSeparator( SCH_CONDITIONS::Idle, 200 ); selToolMenu.AddSeparator( SCH_CONDITIONS::Idle, 200 );
selToolMenu.AddItem( SCH_ACTIONS::cut, SCH_CONDITIONS::IdleSelection, 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 ) int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
{ {
SELECTION selection = m_selectionTool->GetSelection(); KICAD_T allTextTypes[] = { SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_TEXT_T, EOT };
KICAD_T type; SELECTION selection = m_selectionTool->RequestSelection( allTextTypes );
KICAD_T convertTo;
if( aEvent.IsAction( &SCH_ACTIONS::toLabel ) ) if( aEvent.IsAction( &SCH_ACTIONS::toLabel ) )
type = SCH_LABEL_T; convertTo = SCH_LABEL_T;
else if( aEvent.IsAction( &SCH_ACTIONS::toHLabel ) ) else if( aEvent.IsAction( &SCH_ACTIONS::toHLabel ) )
type = SCH_HIER_LABEL_T; convertTo = SCH_HIER_LABEL_T;
else if( aEvent.IsAction( &SCH_ACTIONS::toGLabel ) ) else if( aEvent.IsAction( &SCH_ACTIONS::toGLabel ) )
type = SCH_GLOBAL_LABEL_T; convertTo = SCH_GLOBAL_LABEL_T;
else if( aEvent.IsAction( &SCH_ACTIONS::toText ) ) else if( aEvent.IsAction( &SCH_ACTIONS::toText ) )
type = SCH_TEXT_T; convertTo = SCH_TEXT_T;
else else
return 0; 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 ) ); SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( selection.GetItem( i ) );
if( text ) if( text )
m_frame->ConvertTextType( text, type ); m_frame->ConvertTextType( text, convertTo );
} }
return 0; return 0;

View File

@ -48,6 +48,7 @@
#include <class_library.h> #include <class_library.h>
#include <confirm.h> #include <confirm.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include "sch_line_drawing_tool.h"
TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview", TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" ); AS_GLOBAL, 0, "", "" );
@ -133,15 +134,6 @@ bool SCH_EDITOR_CONTROL::Init()
return ( m_frame->GetToolId() != ID_NO_TOOL_SELECTED ); 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(); 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
@ -151,29 +143,6 @@ 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 );
// 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; return true;
} }

View File

@ -205,24 +205,30 @@ bool SCH_LINE_DRAWING_TOOL::Init()
return ( m_frame->GetToolId() == ID_LINE_COMMENT_BUTT ); return ( m_frame->GetToolId() == ID_LINE_COMMENT_BUTT );
}; };
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
auto& ctxMenu = m_menu.GetMenu(); auto& ctxMenu = m_menu.GetMenu();
// //
// Build the tool menu // 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.AddSeparator( SCH_CONDITIONS::ShowAlways, 10 );
ctxMenu.AddItem( SCH_ACTIONS::startBus, wireOrBusTool && SCH_CONDITIONS::Idle, 1 ); ctxMenu.AddItem( SCH_ACTIONS::startWire, wireOrBusTool && SCH_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( SCH_ACTIONS::startLines, lineTool && SCH_CONDITIONS::Idle, 1 ); ctxMenu.AddItem( SCH_ACTIONS::startBus, wireOrBusTool && SCH_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( SCH_ACTIONS::finishWire, IsDrawingWire, 1 ); ctxMenu.AddItem( SCH_ACTIONS::startLines, lineTool && SCH_CONDITIONS::Idle, 10 );
ctxMenu.AddItem( SCH_ACTIONS::finishBus, IsDrawingBus, 1 ); ctxMenu.AddItem( SCH_ACTIONS::finishWire, IsDrawingWire, 10 );
ctxMenu.AddItem( SCH_ACTIONS::finishLine, IsDrawingLine, 1 ); 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>(); std::shared_ptr<BUS_UNFOLD_MENU> busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
busUnfoldMenu->SetTool( this ); busUnfoldMenu->SetTool( this );
m_menu.AddSubMenu( busUnfoldMenu ); 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.AddSeparator( wireOrBusTool && SCH_CONDITIONS::Idle, 100 );
ctxMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusTool && SCH_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( SCH_ACTIONS::addJunction, wireOrBusTool && SCH_CONDITIONS::Idle, 100 );

View File

@ -178,19 +178,31 @@ bool SCH_SELECTION_TOOL::Init()
auto wireOrBusSelection = SCH_CONDITIONS::MoreThan( 0 ) auto wireOrBusSelection = SCH_CONDITIONS::MoreThan( 0 )
&& SCH_CONDITIONS::OnlyTypes( wireOrBusTypes ); && SCH_CONDITIONS::OnlyTypes( wireOrBusTypes );
auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 ) auto sheetSelection = SELECTION_CONDITIONS::Count( 1 )
&& SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T ); && SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T );
auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
return g_CurrentSheet->Last() != g_RootSheet;
};
auto& menu = m_menu.GetMenu(); auto& menu = m_menu.GetMenu();
// TODO(JE): add menu access to unfold bus on busSelectionCondition... // 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.AddSeparator( SCH_CONDITIONS::Empty, 100 );
menu.AddItem( SCH_ACTIONS::startBus, SCH_CONDITIONS::Empty, 1 ); menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 100 );
menu.AddItem( SCH_ACTIONS::finishWire, SCH_LINE_DRAWING_TOOL::IsDrawingWire, 1 ); menu.AddItem( SCH_ACTIONS::startBus, SCH_CONDITIONS::Empty, 100 );
menu.AddItem( SCH_ACTIONS::finishBus, SCH_LINE_DRAWING_TOOL::IsDrawingBus, 1 );
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.AddSeparator( SCH_CONDITIONS::NotEmpty, 200 );
menu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusSelection && SCH_CONDITIONS::Idle, 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::addHierLabel, wireOrBusSelection && SCH_CONDITIONS::Idle, 200 );
menu.AddItem( SCH_ACTIONS::breakWire, wireSelection && 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::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 ); menu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
m_menu.AddStandardSubMenus( m_frame ); m_menu.AddStandardSubMenus( m_frame );