7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 15:01:41 +00:00

TOOL_INTERACTIVE: only create the context menu when we are running in GUI mode

TOOL_MENU::m_menu was unconditionally created by the TOOL_INTERACTIVE constructor, resulting in crashes if
we wanted to run the TOOLs in headless  mode, e.g. in unit tests. This commits makes
the creation of the menu object dependent on Pgm::IsGui().
This commit is contained in:
Tomasz Wlostowski 2024-07-30 17:57:33 +02:00
parent 145f26dd1e
commit 9963b9dd9f
31 changed files with 113 additions and 99 deletions

View File

@ -37,7 +37,7 @@
bool EDA_3D_CONTROLLER::Init()
{
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
ctxMenu.AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
@ -133,7 +133,7 @@ int EDA_3D_CONTROLLER::Main( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu();
m_menu->ShowContextMenu();
}
else
{

View File

@ -60,14 +60,14 @@ bool PICKER_TOOL::Init()
{
m_frame = getEditFrame<EDA_DRAW_FRAME>();
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddSeparator( 1 );
// Finally, add the standard zoom/grid items
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -180,7 +180,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu();
m_menu->ShowContextMenu();
}
else

View File

@ -31,19 +31,28 @@
#include <tool/tool_interactive.h>
#include <tool/action_menu.h>
#include <pgm_base.h>
#include <wx/log.h>
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
TOOL_BASE( INTERACTIVE, aId, aName ),
m_menu( *this )
TOOL_BASE( INTERACTIVE, aId, aName )
{
if( Pgm().IsGUI() )
{
m_menu.reset( new TOOL_MENU( *this ) );
}
}
TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) :
TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName ),
m_menu( *this )
TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName )
{
if( Pgm().IsGUI() )
{
m_menu.reset( new TOOL_MENU( *this ) );
}
}
@ -97,3 +106,8 @@ void TOOL_INTERACTIVE::RunMainStack( std::function<void()> aFunc )
m_toolMgr->RunMainStack( this, std::move( aFunc ) );
}
TOOL_MENU& TOOL_INTERACTIVE::GetToolMenu()
{
return *m_menu.get();
}

View File

@ -41,14 +41,14 @@ ZOOM_TOOL::~ZOOM_TOOL() {}
bool ZOOM_TOOL::Init()
{
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddSeparator( 1 );
// Finally, add the standard zoom/grid items
getEditFrame<EDA_DRAW_FRAME>()->AddStandardSubMenus( m_menu );
getEditFrame<EDA_DRAW_FRAME>()->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -89,7 +89,7 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) )
{
SELECTION dummy;
m_menu.ShowContextMenu( dummy );
m_menu->ShowContextMenu( dummy );
}
else
{

View File

@ -35,7 +35,7 @@ CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL() :
bool CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init()
{
getEditFrame<DISPLAY_FOOTPRINTS_FRAME>()->AddStandardSubMenus( m_menu );
getEditFrame<DISPLAY_FOOTPRINTS_FRAME>()->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -60,7 +60,7 @@ int CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selection );
m_menu->ShowContextMenu( m_selection );
}
else if( evt->IsDblClick( BUT_MIDDLE ) )
{

View File

@ -294,7 +294,7 @@ bool EE_SELECTION_TOOL::Init()
&& !symbEditorFrame->IsSymbolAlias();
};
auto& menu = m_menu.GetMenu();
auto& menu = m_menu->GetMenu();
menu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
menu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
@ -336,7 +336,7 @@ bool EE_SELECTION_TOOL::Init()
haveSymbol && symbolDisplayNameIsEditable && EE_CONDITIONS::Empty, 400 );
menu.AddSeparator( 1000 );
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
m_disambiguateTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( EE_SELECTION_TOOL::onDisambiguationExpire ),
@ -558,7 +558,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
if( !selCancelled )
m_menu.ShowContextMenu( m_selection );
m_menu->ShowContextMenu( m_selection );
}
else if( evt->IsDblClick( BUT_LEFT ) )
{

View File

@ -68,14 +68,14 @@ public:
m_isSymbolEditor = m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR );
// A basic context menu. Many (but not all) tools will choose to override this.
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddSeparator( 1 );
// Finally, add the standard zoom/grid items
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
return true;
}

View File

@ -116,7 +116,7 @@ bool SCH_DRAWING_TOOLS::Init()
return m_drawingRuleArea;
};
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 150 );
ctxMenu.AddItem( EE_ACTIONS::closeOutline, inDrawingRuleArea, 200 );
ctxMenu.AddItem( EE_ACTIONS::deleteLastPoint, inDrawingRuleArea, 200 );
@ -466,7 +466,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
if( !symbol )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
{
@ -750,7 +750,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
if( !image )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->IsAction( &ACTIONS::duplicate )
|| evt->IsAction( &EE_ACTIONS::repeatDrawItem ) )
@ -925,7 +925,7 @@ int SCH_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{
@ -1114,7 +1114,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
{
@ -1726,7 +1726,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && evt->IsSelectionEvent() )
{
@ -2030,7 +2030,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && evt->IsAction( &ACTIONS::redo ) )
{
@ -2159,7 +2159,7 @@ int SCH_DRAWING_TOOLS::DrawRuleArea( const TOOL_EVENT& aEvent )
if( !started )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
// events that lock in nodes
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT )
@ -2427,7 +2427,7 @@ int SCH_DRAWING_TOOLS::DrawTable( const TOOL_EVENT& aEvent )
if( !table )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( table && evt->IsAction( &ACTIONS::redo ) )
{
@ -2649,7 +2649,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
if( !sheet )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( sheet && evt->IsAction( &ACTIONS::redo ) )
{

View File

@ -194,7 +194,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
std::shared_ptr<BUS_UNFOLD_MENU>
busUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>( busGetter );
busUnfoldMenu->SetTool( this );
m_menu.RegisterSubMenu( busUnfoldMenu );
m_menu->RegisterSubMenu( busUnfoldMenu );
std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>( busGetter );
selBusUnfoldMenu->SetTool( m_selectionTool );
@ -230,7 +230,7 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init()
return editFrame && !editFrame->GetHighlightedConnection().IsEmpty();
};
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// Build the tool menu
//
@ -1019,7 +1019,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const TOOL_EVENT& aTool, int aType,
m_toolMgr->VetoContextMenuMouseWarp();
contextMenuPos = cursorPos;
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
{

View File

@ -893,7 +893,7 @@ bool SCH_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COMMIT* aComm
//
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
//------------------------------------------------------------------------
// Handle drop

View File

@ -51,7 +51,7 @@ bool SYMBOL_EDITOR_CONTROL::Init()
if( m_isSymbolEditor )
{
LIBRARY_EDITOR_CONTROL* libraryTreeTool = m_toolMgr->GetTool<LIBRARY_EDITOR_CONTROL>();
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
wxCHECK( editFrame, false );

View File

@ -73,7 +73,7 @@ bool SYMBOL_EDITOR_DRAWING_TOOLS::Init()
return item && item->IsNew();
};
m_menu.GetMenu().AddItem( ACTIONS::finishInteractive, isDrawingCondition, 2 );
m_menu->GetMenu().AddItem( ACTIONS::finishInteractive, isDrawingCondition, 2 );
return true;
}
@ -309,7 +309,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
@ -575,7 +575,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::opt
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else
{
@ -643,7 +643,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else
{
@ -787,7 +787,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::ImportGraphics( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{

View File

@ -311,7 +311,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
//
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
//------------------------------------------------------------------------
// Handle drop

View File

@ -306,7 +306,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_frame->GetCurrentSelection() );
m_menu->ShowContextMenu( m_frame->GetCurrentSelection() );
}
else
{

View File

@ -127,12 +127,12 @@ bool GERBVIEW_SELECTION_TOOL::Init()
{
std::shared_ptr<HIGHLIGHT_MENU> highlightSubMenu = std::make_shared<HIGHLIGHT_MENU>();
highlightSubMenu->SetTool( this );
m_menu.RegisterSubMenu( highlightSubMenu );
m_menu->RegisterSubMenu( highlightSubMenu );
m_menu.GetMenu().AddMenu( highlightSubMenu.get() );
m_menu.GetMenu().AddSeparator( 1000 );
m_menu->GetMenu().AddMenu( highlightSubMenu.get() );
m_menu->GetMenu().AddSeparator( 1000 );
getEditFrame<GERBVIEW_FRAME>()->AddStandardSubMenus( m_menu );
getEditFrame<GERBVIEW_FRAME>()->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -191,7 +191,7 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
// Show selection before opening menu
m_frame->GetCanvas()->ForceRefresh();
m_menu.ShowContextMenu( m_selection );
m_menu->ShowContextMenu( m_selection );
}
else if( evt->IsDblClick( BUT_MIDDLE ) )
{

View File

@ -74,7 +74,7 @@ public:
*/
void Activate();
TOOL_MENU& GetToolMenu() { return m_menu; }
TOOL_MENU& GetToolMenu();
/**
* Assign a context menu and tells when it should be activated.
@ -122,7 +122,7 @@ public:
void Yield( const T& returnValue );*/
protected:
TOOL_MENU m_menu;
std::unique_ptr<TOOL_MENU> m_menu;
private:
/**

View File

@ -49,14 +49,14 @@ bool PL_DRAWING_TOOLS::Init()
m_frame = getEditFrame<PL_EDITOR_FRAME>();
m_selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
ctxMenu.AddSeparator( 1 );
// Finally, add the standard zoom/grid items
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -196,7 +196,7 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
@ -336,7 +336,7 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( !item )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
else
{

View File

@ -66,7 +66,7 @@ bool PL_EDIT_TOOL::Init()
wxASSERT_MSG( m_selectionTool, "plEditor.InteractiveSelection tool is not available" );
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
@ -75,7 +75,7 @@ bool PL_EDIT_TOOL::Init()
ctxMenu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty, 200 );
// Finally, add the standard zoom/grid items
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
//
// Add editing actions to the selection tool menu
@ -277,7 +277,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
//
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
}
//------------------------------------------------------------------------
// Handle drop

View File

@ -55,7 +55,7 @@ bool PL_SELECTION_TOOL::Init()
{
m_frame = getEditFrame<PL_EDITOR_FRAME>();
auto& menu = m_menu.GetMenu();
auto& menu = m_menu->GetMenu();
menu.AddSeparator( 200 );
menu.AddItem( PL_ACTIONS::drawLine, SELECTION_CONDITIONS::Empty, 200 );
@ -64,7 +64,7 @@ bool PL_SELECTION_TOOL::Init()
menu.AddItem( PL_ACTIONS::placeImage, SELECTION_CONDITIONS::Empty, 200 );
menu.AddSeparator( 1000 );
m_frame->AddStandardSubMenus( m_menu );
m_frame->AddStandardSubMenus( *m_menu.get() );
m_disambiguateTimer.SetOwner( this );
Connect( wxEVT_TIMER, wxTimerEventHandler( PL_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
@ -131,7 +131,7 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
m_frame->GetCanvas()->ForceRefresh();
if( !selectionCancelled )
m_menu.ShowContextMenu( m_selection );
m_menu->ShowContextMenu( m_selection );
}
// double click? Display the properties window

View File

@ -2386,7 +2386,7 @@ int DRAWING_TOOL::PlaceTuningPattern( const TOOL_EVENT& aEvent )
else if( evt->IsClick( BUT_RIGHT ) )
{
PCB_SELECTION dummy;
m_menu.ShowContextMenu( dummy );
m_menu->ShowContextMenu( dummy );
}
else if( evt->IsAction( &PCB_ACTIONS::spacingIncrease )
|| evt->IsAction( &PCB_ACTIONS::spacingDecrease ) )

View File

@ -217,7 +217,7 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else
{

View File

@ -472,16 +472,16 @@ bool ROUTER_TOOL::Init()
wxASSERT( frame );
auto& menu = m_menu.GetMenu();
auto& menu = m_menu->GetMenu();
menu.SetTitle( _( "Interactive Router" ) );
m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
m_trackViaMenu->SetTool( this );
m_menu.RegisterSubMenu( m_trackViaMenu );
m_menu->RegisterSubMenu( m_trackViaMenu );
m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
m_diffPairMenu->SetTool( this );
m_menu.RegisterSubMenu( m_diffPairMenu );
m_menu->RegisterSubMenu( m_diffPairMenu );
auto haveHighlight =
[&]( const SELECTION& sel )
@ -555,7 +555,7 @@ bool ROUTER_TOOL::Init()
menu.AddSeparator();
frame->AddStandardSubMenus( m_menu );
frame->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -1475,7 +1475,7 @@ void ROUTER_TOOL::performRouting()
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
// TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
// but we don't at present have that, so we just knock out some of the egregious ones.
@ -1834,7 +1834,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else
{
@ -1949,7 +1949,7 @@ void ROUTER_TOOL::performDragging( int aMode )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsCancelInteractive() || evt->IsActivate() )
{

View File

@ -180,7 +180,7 @@ bool BOARD_EDITOR_CONTROL::Init()
return m_frame->IsCurrentTool( PCB_ACTIONS::placeFootprint ) && aSel.GetSize() == 0;
};
auto& ctxMenu = m_menu.GetMenu();
auto& ctxMenu = m_menu->GetMenu();
// "Cancel" goes at the top of the context menu when a tool is active
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
@ -191,7 +191,7 @@ bool BOARD_EDITOR_CONTROL::Init()
ctxMenu.AddSeparator( 1000 );
// Finally, add the standard zoom & grid items
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
std::shared_ptr<ZONE_CONTEXT_MENU> zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
zoneMenu->SetTool( this );
@ -1175,7 +1175,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
{

View File

@ -617,7 +617,7 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) )
{

View File

@ -243,7 +243,7 @@ bool DRAWING_TOOL::Init()
return m_mode == MODE::TUNING;
};
CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
// cancel current tool goes in main context menu at the top if present
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 );
@ -267,7 +267,7 @@ bool DRAWING_TOOL::Init()
std::shared_ptr<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
viaSizeMenu->SetTool( this );
m_menu.RegisterSubMenu( viaSizeMenu );
m_menu->RegisterSubMenu( viaSizeMenu );
ctxMenu.AddMenu( viaSizeMenu.get(), viaToolActive, 500 );
ctxMenu.AddSeparator( 500 );
@ -276,7 +276,7 @@ bool DRAWING_TOOL::Init()
// For example, zone fill/unfill is provided by the PCB control tool
// Finally, add the standard zoom/grid items
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( *m_menu.get() );
return true;
}
@ -751,7 +751,7 @@ int DRAWING_TOOL::PlaceReferenceImage( const TOOL_EVENT& aEvent )
if( !image )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selectionTool->GetSelection() );
m_menu->ShowContextMenu( selectionTool->GetSelection() );
}
else if( image && ( evt->IsAction( &ACTIONS::refreshPreview )
|| evt->IsMotion() ) )
@ -895,7 +895,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
if( !text )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) )
{
@ -1133,7 +1133,7 @@ int DRAWING_TOOL::DrawTable( const TOOL_EVENT& aEvent )
if( !table )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) )
{
@ -1415,7 +1415,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
if( !dimension )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{
@ -1890,7 +1890,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{
@ -1992,7 +1992,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsCancelInteractive() || evt->IsActivate() )
{
@ -2221,7 +2221,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
if( !graphic )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
{
@ -2661,7 +2661,7 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
if( !graphic )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
{
@ -2916,7 +2916,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
if( !started )
m_toolMgr->VetoContextMenuMouseWarp();
m_menu.ShowContextMenu( selection() );
m_menu->ShowContextMenu( selection() );
}
// events that lock in nodes
else if( evt->IsClick( BUT_LEFT )

Some files were not shown because too many files have changed in this diff Show More