CONTEXT_MENU -> ACTION_MENU. (Now used for menu-bar menus too.)
This commit is contained in:
parent
eb3a201d39
commit
f9e4ee1fc9
|
@ -398,7 +398,7 @@ set( COMMON_SRCS
|
||||||
tool/actions.cpp
|
tool/actions.cpp
|
||||||
tool/common_tools.cpp
|
tool/common_tools.cpp
|
||||||
tool/conditional_menu.cpp
|
tool/conditional_menu.cpp
|
||||||
tool/context_menu.cpp
|
tool/action_menu.cpp
|
||||||
tool/edit_constraints.cpp
|
tool/edit_constraints.cpp
|
||||||
tool/edit_points.cpp
|
tool/edit_points.cpp
|
||||||
tool/grid_menu.cpp
|
tool/grid_menu.cpp
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <tool/tool_event.h>
|
#include <tool/tool_event.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
#include <pgm_base.h>
|
#include <pgm_base.h>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MENU::CONTEXT_MENU() :
|
ACTION_MENU::ACTION_MENU() :
|
||||||
m_Dirty( true ),
|
m_Dirty( true ),
|
||||||
m_titleDisplayed( false ),
|
m_titleDisplayed( false ),
|
||||||
m_selected( -1 ),
|
m_selected( -1 ),
|
||||||
|
@ -48,13 +48,13 @@ CONTEXT_MENU::CONTEXT_MENU() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MENU::~CONTEXT_MENU()
|
ACTION_MENU::~ACTION_MENU()
|
||||||
{
|
{
|
||||||
// Set parent to NULL to prevent submenus from unregistering from a notexisting object
|
// Set parent to NULL to prevent submenus from unregistering from a notexisting object
|
||||||
for( auto menu : m_submenus )
|
for( auto menu : m_submenus )
|
||||||
menu->SetParent( nullptr );
|
menu->SetParent( nullptr );
|
||||||
|
|
||||||
CONTEXT_MENU* parent = dynamic_cast<CONTEXT_MENU*>( GetParent() );
|
ACTION_MENU* parent = dynamic_cast<ACTION_MENU*>( GetParent() );
|
||||||
|
|
||||||
if( parent )
|
if( parent )
|
||||||
parent->m_submenus.remove( this );
|
parent->m_submenus.remove( this );
|
||||||
|
@ -79,21 +79,21 @@ static void set_wxMenuIcon( wxMenuItem* aMenu, const BITMAP_OPAQUE* aIcon )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::SetIcon( const BITMAP_OPAQUE* aIcon )
|
void ACTION_MENU::SetIcon( const BITMAP_OPAQUE* aIcon )
|
||||||
{
|
{
|
||||||
m_icon = aIcon;
|
m_icon = aIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::setupEvents()
|
void ACTION_MENU::setupEvents()
|
||||||
{
|
{
|
||||||
Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
|
Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this );
|
||||||
Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
|
Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this );
|
||||||
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
|
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::SetTitle( const wxString& aTitle )
|
void ACTION_MENU::SetTitle( const wxString& aTitle )
|
||||||
{
|
{
|
||||||
// Unfortunately wxMenu::SetTitle() does not work very well, so this is an alternative version
|
// Unfortunately wxMenu::SetTitle() does not work very well, so this is an alternative version
|
||||||
m_title = aTitle;
|
m_title = aTitle;
|
||||||
|
@ -104,7 +104,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::DisplayTitle( bool aDisplay )
|
void ACTION_MENU::DisplayTitle( bool aDisplay )
|
||||||
{
|
{
|
||||||
if( ( !aDisplay || m_title.IsEmpty() ) && m_titleDisplayed )
|
if( ( !aDisplay || m_title.IsEmpty() ) && m_titleDisplayed )
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ void CONTEXT_MENU::DisplayTitle( bool aDisplay )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPAQUE* aIcon )
|
wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPAQUE* aIcon )
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if( FindItem( aId ) != NULL )
|
if( FindItem( aId ) != NULL )
|
||||||
|
@ -156,7 +156,7 @@ wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry )
|
wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry )
|
||||||
{
|
{
|
||||||
/// ID numbers for tool actions need to have a value higher than ACTION_ID
|
/// ID numbers for tool actions need to have a value higher than ACTION_ID
|
||||||
const BITMAP_OPAQUE* icon = aAction.GetIcon();
|
const BITMAP_OPAQUE* icon = aAction.GetIcon();
|
||||||
|
@ -174,12 +174,12 @@ wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxMenuItem* CONTEXT_MENU::Add( CONTEXT_MENU* aMenu )
|
wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu )
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* menuCopy = aMenu->Clone();
|
ACTION_MENU* menuCopy = aMenu->Clone();
|
||||||
m_submenus.push_back( menuCopy );
|
m_submenus.push_back( menuCopy );
|
||||||
|
|
||||||
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for CONTEXT_MENU using SetTitle()" );
|
wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );
|
||||||
|
|
||||||
if( aMenu->m_icon )
|
if( aMenu->m_icon )
|
||||||
{
|
{
|
||||||
|
@ -195,7 +195,7 @@ wxMenuItem* CONTEXT_MENU::Add( CONTEXT_MENU* aMenu )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::Clear()
|
void ACTION_MENU::Clear()
|
||||||
{
|
{
|
||||||
m_titleDisplayed = false;
|
m_titleDisplayed = false;
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ void CONTEXT_MENU::Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CONTEXT_MENU::HasEnabledItems() const
|
bool ACTION_MENU::HasEnabledItems() const
|
||||||
{
|
{
|
||||||
bool hasEnabled = false;
|
bool hasEnabled = false;
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ bool CONTEXT_MENU::HasEnabledItems() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::UpdateAll()
|
void ACTION_MENU::UpdateAll()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -236,35 +236,35 @@ void CONTEXT_MENU::UpdateAll()
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxString::Format( "CONTEXT_MENU update handler exception: %s", e.what() ) );
|
wxLogDebug( wxString::Format( "ACTION_MENU update handler exception: %s", e.what() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_tool )
|
if( m_tool )
|
||||||
updateHotKeys();
|
updateHotKeys();
|
||||||
|
|
||||||
runOnSubmenus( std::bind( &CONTEXT_MENU::UpdateAll, _1 ) );
|
runOnSubmenus( std::bind( &ACTION_MENU::UpdateAll, _1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::SetTool( TOOL_INTERACTIVE* aTool )
|
void ACTION_MENU::SetTool( TOOL_INTERACTIVE* aTool )
|
||||||
{
|
{
|
||||||
m_tool = aTool;
|
m_tool = aTool;
|
||||||
runOnSubmenus( std::bind( &CONTEXT_MENU::SetTool, _1, aTool ) );
|
runOnSubmenus( std::bind( &ACTION_MENU::SetTool, _1, aTool ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MENU* CONTEXT_MENU::Clone() const
|
ACTION_MENU* ACTION_MENU::Clone() const
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* clone = create();
|
ACTION_MENU* clone = create();
|
||||||
clone->Clear();
|
clone->Clear();
|
||||||
clone->copyFrom( *this );
|
clone->copyFrom( *this );
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MENU* CONTEXT_MENU::create() const
|
ACTION_MENU* ACTION_MENU::create() const
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* menu = new CONTEXT_MENU();
|
ACTION_MENU* menu = new ACTION_MENU();
|
||||||
|
|
||||||
wxASSERT_MSG( typeid( *this ) == typeid( *menu ),
|
wxASSERT_MSG( typeid( *this ) == typeid( *menu ),
|
||||||
wxString::Format( "You need to override create() method for class %s", typeid(*this).name() ) );
|
wxString::Format( "You need to override create() method for class %s", typeid(*this).name() ) );
|
||||||
|
@ -273,14 +273,14 @@ CONTEXT_MENU* CONTEXT_MENU::create() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TOOL_MANAGER* CONTEXT_MENU::getToolManager() const
|
TOOL_MANAGER* ACTION_MENU::getToolManager() const
|
||||||
{
|
{
|
||||||
wxASSERT( m_tool );
|
wxASSERT( m_tool );
|
||||||
return m_tool ? m_tool->GetManager() : nullptr;
|
return m_tool ? m_tool->GetManager() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::updateHotKeys()
|
void ACTION_MENU::updateHotKeys()
|
||||||
{
|
{
|
||||||
TOOL_MANAGER* toolMgr = getToolManager();
|
TOOL_MANAGER* toolMgr = getToolManager();
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ void CONTEXT_MENU::updateHotKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
void ACTION_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
{
|
{
|
||||||
OPT_TOOL_EVENT evt;
|
OPT_TOOL_EVENT evt;
|
||||||
wxString menuText;
|
wxString menuText;
|
||||||
|
@ -340,12 +340,12 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
// Store the selected position, so it can be checked by the tools
|
// Store the selected position, so it can be checked by the tools
|
||||||
m_selected = aEvent.GetId();
|
m_selected = aEvent.GetId();
|
||||||
|
|
||||||
CONTEXT_MENU* parent = dynamic_cast<CONTEXT_MENU*>( GetParent() );
|
ACTION_MENU* parent = dynamic_cast<ACTION_MENU*>( GetParent() );
|
||||||
|
|
||||||
while( parent )
|
while( parent )
|
||||||
{
|
{
|
||||||
parent->m_selected = m_selected;
|
parent->m_selected = m_selected;
|
||||||
parent = dynamic_cast<CONTEXT_MENU*>( parent->GetParent() );
|
parent = dynamic_cast<ACTION_MENU*>( parent->GetParent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is a TOOL_ACTION for the given ID
|
// Check if there is a TOOL_ACTION for the given ID
|
||||||
|
@ -373,7 +373,7 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
if( menu && menu != this )
|
if( menu && menu != this )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* cxmenu = static_cast<CONTEXT_MENU*>( menu );
|
ACTION_MENU* cxmenu = static_cast<ACTION_MENU*>( menu );
|
||||||
evt = cxmenu->eventHandler( aEvent );
|
evt = cxmenu->eventHandler( aEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,36 +402,36 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent )
|
void ACTION_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent )
|
||||||
{
|
{
|
||||||
aToolEvent = eventHandler( aMenuEvent );
|
aToolEvent = eventHandler( aMenuEvent );
|
||||||
|
|
||||||
if( !aToolEvent )
|
if( !aToolEvent )
|
||||||
runOnSubmenus( std::bind( &CONTEXT_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) );
|
runOnSubmenus( std::bind( &ACTION_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::runOnSubmenus( std::function<void(CONTEXT_MENU*)> aFunction )
|
void ACTION_MENU::runOnSubmenus( std::function<void(ACTION_MENU*)> aFunction )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::for_each( m_submenus.begin(), m_submenus.end(), [&]( CONTEXT_MENU* m ) {
|
std::for_each( m_submenus.begin(), m_submenus.end(), [&]( ACTION_MENU* m ) {
|
||||||
aFunction( m );
|
aFunction( m );
|
||||||
m->runOnSubmenus( aFunction );
|
m->runOnSubmenus( aFunction );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
catch( std::exception& e )
|
catch( std::exception& e )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxString::Format( "CONTEXT_MENU runOnSubmenus exception: %s", e.what() ) );
|
wxLogDebug( wxString::Format( "ACTION_MENU runOnSubmenus exception: %s", e.what() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OPT_TOOL_EVENT CONTEXT_MENU::findToolAction( int aId )
|
OPT_TOOL_EVENT ACTION_MENU::findToolAction( int aId )
|
||||||
{
|
{
|
||||||
OPT_TOOL_EVENT evt;
|
OPT_TOOL_EVENT evt;
|
||||||
|
|
||||||
auto findFunc = [&]( CONTEXT_MENU* m ) {
|
auto findFunc = [&]( ACTION_MENU* m ) {
|
||||||
if( evt )
|
if( evt )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ OPT_TOOL_EVENT CONTEXT_MENU::findToolAction( int aId )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONTEXT_MENU::copyFrom( const CONTEXT_MENU& aMenu )
|
void ACTION_MENU::copyFrom( const ACTION_MENU& aMenu )
|
||||||
{
|
{
|
||||||
m_icon = aMenu.m_icon;
|
m_icon = aMenu.m_icon;
|
||||||
m_title = aMenu.m_title;
|
m_title = aMenu.m_title;
|
||||||
|
@ -468,7 +468,7 @@ void CONTEXT_MENU::copyFrom( const CONTEXT_MENU& aMenu )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxMenuItem* CONTEXT_MENU::appendCopy( const wxMenuItem* aSource )
|
wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource )
|
||||||
{
|
{
|
||||||
wxMenuItem* newItem = new wxMenuItem( this, aSource->GetId(), aSource->GetItemLabel(),
|
wxMenuItem* newItem = new wxMenuItem( this, aSource->GetId(), aSource->GetItemLabel(),
|
||||||
aSource->GetHelp(), aSource->GetKind() );
|
aSource->GetHelp(), aSource->GetKind() );
|
||||||
|
@ -481,12 +481,12 @@ wxMenuItem* CONTEXT_MENU::appendCopy( const wxMenuItem* aSource )
|
||||||
|
|
||||||
if( aSource->IsSubMenu() )
|
if( aSource->IsSubMenu() )
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* menu = dynamic_cast<CONTEXT_MENU*>( aSource->GetSubMenu() );
|
ACTION_MENU* menu = dynamic_cast<ACTION_MENU*>( aSource->GetSubMenu() );
|
||||||
wxASSERT_MSG( menu, "Submenus are expected to be a CONTEXT_MENU" );
|
wxASSERT_MSG( menu, "Submenus are expected to be a ACTION_MENU" );
|
||||||
|
|
||||||
if( menu )
|
if( menu )
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* menuCopy = menu->Clone();
|
ACTION_MENU* menuCopy = menu->Clone();
|
||||||
newItem->SetSubMenu( menuCopy );
|
newItem->SetSubMenu( menuCopy );
|
||||||
m_submenus.push_back( menuCopy );
|
m_submenus.push_back( menuCopy );
|
||||||
}
|
}
|
|
@ -24,10 +24,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tool/conditional_menu.h>
|
#include <tool/conditional_menu.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
|
|
||||||
|
|
||||||
CONTEXT_MENU* CONDITIONAL_MENU::create() const
|
ACTION_MENU* CONDITIONAL_MENU::create() const
|
||||||
{
|
{
|
||||||
CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool );
|
CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool );
|
||||||
clone->m_entries = m_entries;
|
clone->m_entries = m_entries;
|
||||||
|
@ -51,7 +51,7 @@ void CONDITIONAL_MENU::AddCheckItem( const TOOL_ACTION& aAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CONDITIONAL_MENU::AddMenu( CONTEXT_MENU* aMenu, const SELECTION_CONDITION& aCondition,
|
void CONDITIONAL_MENU::AddMenu( ACTION_MENU* aMenu, const SELECTION_CONDITION& aCondition,
|
||||||
int aOrder )
|
int aOrder )
|
||||||
{
|
{
|
||||||
addEntry( ENTRY( aMenu, aCondition, aOrder ) );
|
addEntry( ENTRY( aMenu, aCondition, aOrder ) );
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <tool/tool_event.h>
|
#include <tool/tool_event.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
|
|
||||||
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
|
TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) :
|
||||||
TOOL_BASE( INTERACTIVE, aId, aName )
|
TOOL_BASE( INTERACTIVE, aId, aName )
|
||||||
|
@ -71,7 +71,7 @@ void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_INTERACTIVE::SetContextMenu( CONTEXT_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger )
|
void TOOL_INTERACTIVE::SetContextMenu( ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger )
|
||||||
{
|
{
|
||||||
if( aMenu )
|
if( aMenu )
|
||||||
aMenu->SetTool( this );
|
aMenu->SetTool( this );
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <tool/tool_base.h>
|
#include <tool/tool_base.h>
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/coroutine.h>
|
#include <tool/coroutine.h>
|
||||||
#include <tool/action_manager.h>
|
#include <tool/action_manager.h>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ struct TOOL_MANAGER::TOOL_STATE
|
||||||
bool pendingContextMenu;
|
bool pendingContextMenu;
|
||||||
|
|
||||||
/// Context menu currently used by the tool
|
/// Context menu currently used by the tool
|
||||||
CONTEXT_MENU* contextMenu;
|
ACTION_MENU* contextMenu;
|
||||||
|
|
||||||
/// Defines when the context menu is opened
|
/// Defines when the context menu is opened
|
||||||
CONTEXT_MENU_TRIGGER contextMenuTrigger;
|
CONTEXT_MENU_TRIGGER contextMenuTrigger;
|
||||||
|
@ -671,7 +671,7 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||||
st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
|
st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
|
||||||
|
|
||||||
// Store the menu pointer in case it is changed by the TOOL when handling menu events
|
// Store the menu pointer in case it is changed by the TOOL when handling menu events
|
||||||
CONTEXT_MENU* m = st->contextMenu;
|
ACTION_MENU* m = st->contextMenu;
|
||||||
|
|
||||||
if( st->contextMenuTrigger == CMENU_NOW )
|
if( st->contextMenuTrigger == CMENU_NOW )
|
||||||
st->contextMenuTrigger = CMENU_OFF;
|
st->contextMenuTrigger = CMENU_OFF;
|
||||||
|
@ -695,7 +695,7 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent )
|
||||||
m_viewControls->ForceCursorPosition( true, m_menuCursor );
|
m_viewControls->ForceCursorPosition( true, m_menuCursor );
|
||||||
|
|
||||||
// Display a copy of menu
|
// Display a copy of menu
|
||||||
std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );
|
std::unique_ptr<ACTION_MENU> menu( m->Clone() );
|
||||||
|
|
||||||
m_menuOwner = toolId;
|
m_menuOwner = toolId;
|
||||||
m_menuActive = true;
|
m_menuActive = true;
|
||||||
|
@ -796,7 +796,7 @@ bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
|
void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu,
|
||||||
CONTEXT_MENU_TRIGGER aTrigger )
|
CONTEXT_MENU_TRIGGER aTrigger )
|
||||||
{
|
{
|
||||||
TOOL_STATE* st = m_toolState[aTool];
|
TOOL_STATE* st = m_toolState[aTool];
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <draw_frame.h>
|
#include <draw_frame.h>
|
||||||
#include <tool/tool_menu.h>
|
#include <tool/tool_menu.h>
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/actions.h>
|
#include <tool/actions.h>
|
||||||
#include <tool/zoom_menu.h>
|
#include <tool/zoom_menu.h>
|
||||||
#include <tool/grid_menu.h>
|
#include <tool/grid_menu.h>
|
||||||
|
@ -49,7 +49,7 @@ CONDITIONAL_MENU& TOOL_MENU::GetMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_MENU::AddSubMenu( std::shared_ptr<CONTEXT_MENU> aSubMenu )
|
void TOOL_MENU::AddSubMenu( std::shared_ptr<ACTION_MENU> aSubMenu )
|
||||||
{
|
{
|
||||||
// store a copy of the menu (keeps a reference)
|
// store a copy of the menu (keeps a reference)
|
||||||
m_subMenus.push_back( std::move( aSubMenu ) );
|
m_subMenus.push_back( std::move( aSubMenu ) );
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/selection.h>
|
#include <tool/selection.h>
|
||||||
#include <tool/selection_conditions.h>
|
#include <tool/selection_conditions.h>
|
||||||
#include <tool/tool_menu.h>
|
#include <tool/tool_menu.h>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
#include <wx/progdlg.h>
|
#include <wx/progdlg.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_dispatcher.h>
|
#include <tool/tool_dispatcher.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/common_tools.h>
|
#include <tool/common_tools.h>
|
||||||
#include <tool/zoom_tool.h>
|
#include <tool/zoom_tool.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
|
@ -586,7 +586,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event )
|
||||||
|
|
||||||
if( part->GetAliasCount() > 1 )
|
if( part->GetAliasCount() > 1 )
|
||||||
{
|
{
|
||||||
CONTEXT_MENU popup;
|
ACTION_MENU popup;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
||||||
|
|
||||||
int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
|
int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
CONTEXT_MENU* actionMenu = aEvent.Parameter<CONTEXT_MENU*>();
|
ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
|
||||||
CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
|
CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
|
||||||
|
|
||||||
if( conditionalMenu )
|
if( conditionalMenu )
|
||||||
|
@ -841,8 +841,8 @@ int EE_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
|
bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
|
||||||
{
|
{
|
||||||
EDA_ITEM* current = nullptr;
|
EDA_ITEM* current = nullptr;
|
||||||
CONTEXT_MENU menu;
|
ACTION_MENU menu;
|
||||||
|
|
||||||
int limit = std::min( MAX_SELECT_ITEM_IDS, aCollector->GetCount() );
|
int limit = std::min( MAX_SELECT_ITEM_IDS, aCollector->GetCount() );
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define KICAD_SCH_SELECTION_TOOL_H
|
#define KICAD_SCH_SELECTION_TOOL_H
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/selection.h>
|
#include <tool/selection.h>
|
||||||
#include <tool/tool_menu.h>
|
#include <tool/tool_menu.h>
|
||||||
#include <ee_collectors.h>
|
#include <ee_collectors.h>
|
||||||
|
|
|
@ -175,7 +175,7 @@ TOOL_ACTION EE_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus",
|
||||||
break_line_xpm );
|
break_line_xpm );
|
||||||
|
|
||||||
|
|
||||||
class SYMBOL_UNIT_MENU : public CONTEXT_MENU
|
class SYMBOL_UNIT_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SYMBOL_UNIT_MENU()
|
SYMBOL_UNIT_MENU()
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new SYMBOL_UNIT_MENU();
|
return new SYMBOL_UNIT_MENU();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ TOOL_ACTION EE_ACTIONS::finishLine( "eeschema.WireBusDrawing.finishLine",
|
||||||
checked_ok_xpm, AF_NONE );
|
checked_ok_xpm, AF_NONE );
|
||||||
|
|
||||||
|
|
||||||
class BUS_UNFOLD_MENU : public CONTEXT_MENU
|
class BUS_UNFOLD_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BUS_UNFOLD_MENU() :
|
BUS_UNFOLD_MENU() :
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new BUS_UNFOLD_MENU();
|
return new BUS_UNFOLD_MENU();
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ private:
|
||||||
|
|
||||||
if( member->Type() == CONNECTION_BUS )
|
if( member->Type() == CONNECTION_BUS )
|
||||||
{
|
{
|
||||||
wxMenu* submenu = new CONTEXT_MENU;
|
wxMenu* submenu = new ACTION_MENU;
|
||||||
AppendSubMenu( submenu, name );
|
AppendSubMenu( submenu, name );
|
||||||
|
|
||||||
for( const auto& sub_member : member->Members() )
|
for( const auto& sub_member : member->Members() )
|
||||||
|
|
|
@ -75,7 +75,7 @@ TOOL_ACTION GERBVIEW_ACTIONS::measureTool( "gerbview.InteractiveSelection.measur
|
||||||
nullptr, AF_ACTIVATE );
|
nullptr, AF_ACTIVATE );
|
||||||
|
|
||||||
|
|
||||||
class HIGHLIGHT_MENU: public CONTEXT_MENU
|
class HIGHLIGHT_MENU: public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HIGHLIGHT_MENU()
|
HIGHLIGHT_MENU()
|
||||||
|
@ -131,7 +131,7 @@ private:
|
||||||
Add( GERBVIEW_ACTIONS::highlightClear );
|
Add( GERBVIEW_ACTIONS::highlightClear );
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new HIGHLIGHT_MENU();
|
return new HIGHLIGHT_MENU();
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
|
||||||
{
|
{
|
||||||
EDA_ITEM* current = NULL;
|
EDA_ITEM* current = NULL;
|
||||||
KIGFX::VIEW_GROUP highlightGroup;
|
KIGFX::VIEW_GROUP highlightGroup;
|
||||||
CONTEXT_MENU menu;
|
ACTION_MENU menu;
|
||||||
|
|
||||||
highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
|
highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
|
||||||
getView()->Add( &highlightGroup );
|
getView()->Add( &highlightGroup );
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
|
|
||||||
#include <tool/tool_interactive.h>
|
#include <tool/tool_interactive.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/selection.h>
|
#include <tool/selection.h>
|
||||||
#include <tool/selection_conditions.h>
|
#include <tool/selection_conditions.h>
|
||||||
#include <tool/tool_menu.h>
|
#include <tool/tool_menu.h>
|
||||||
|
|
|
@ -36,25 +36,24 @@
|
||||||
class TOOL_INTERACTIVE;
|
class TOOL_INTERACTIVE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CONTEXT_MENU
|
* Class ACTION_MENU
|
||||||
*
|
*
|
||||||
* Defines the structure of a context (usually right-click) popup menu
|
* Defines the structure of a menu based on ACTIONs.
|
||||||
* for a given tool.
|
|
||||||
*/
|
*/
|
||||||
class CONTEXT_MENU : public wxMenu
|
class ACTION_MENU : public wxMenu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///> Default constructor
|
///> Default constructor
|
||||||
CONTEXT_MENU();
|
ACTION_MENU();
|
||||||
|
|
||||||
virtual ~CONTEXT_MENU();
|
virtual ~ACTION_MENU();
|
||||||
|
|
||||||
CONTEXT_MENU( const CONTEXT_MENU& aMenu ) = delete;
|
ACTION_MENU( const ACTION_MENU& aMenu ) = delete;
|
||||||
CONTEXT_MENU& operator=( const CONTEXT_MENU& aMenu ) = delete;
|
ACTION_MENU& operator=( const ACTION_MENU& aMenu ) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetTitle()
|
* Function SetTitle()
|
||||||
* Sets title for the context menu. The title is shown as a text label shown on the top of
|
* Sets title for the menu. The title is shown as a text label shown on the top of
|
||||||
* the menu.
|
* the menu.
|
||||||
* @param aTitle is the new title.
|
* @param aTitle is the new title.
|
||||||
*/
|
*/
|
||||||
|
@ -93,11 +92,11 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Add()
|
* Function Add()
|
||||||
* Adds a context menu as a submenu. The difference between this function and wxMenu::AppendSubMenu()
|
* Adds an action menu as a submenu. The difference between this function and
|
||||||
* is the capability to handle icons.
|
* wxMenu::AppendSubMenu() is the capability to handle icons.
|
||||||
* @param aMenu is the submenu to be added.
|
* @param aMenu is the submenu to be added.
|
||||||
*/
|
*/
|
||||||
wxMenuItem* Add( CONTEXT_MENU* aMenu );
|
wxMenuItem* Add( ACTION_MENU* aMenu );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Clear()
|
* Function Clear()
|
||||||
|
@ -117,7 +116,7 @@ public:
|
||||||
* Function GetSelected()
|
* Function GetSelected()
|
||||||
* Returns the position of selected item. If the returned value is negative, that means that
|
* Returns the position of selected item. If the returned value is negative, that means that
|
||||||
* menu was dismissed.
|
* menu was dismissed.
|
||||||
* @return The position of selected item in the context menu.
|
* @return The position of selected item in the action menu.
|
||||||
*/
|
*/
|
||||||
inline int GetSelected() const
|
inline int GetSelected() const
|
||||||
{
|
{
|
||||||
|
@ -138,9 +137,9 @@ public:
|
||||||
void SetTool( TOOL_INTERACTIVE* aTool );
|
void SetTool( TOOL_INTERACTIVE* aTool );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a deep, recursive copy of this CONTEXT_MENU.
|
* Creates a deep, recursive copy of this ACTION_MENU.
|
||||||
*/
|
*/
|
||||||
CONTEXT_MENU* Clone() const;
|
ACTION_MENU* Clone() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///> Menu requires updating before display.
|
///> Menu requires updating before display.
|
||||||
|
@ -148,7 +147,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///> Returns an instance of this class. It has to be overridden in inheriting classes.
|
///> Returns an instance of this class. It has to be overridden in inheriting classes.
|
||||||
virtual CONTEXT_MENU* create() const;
|
virtual ACTION_MENU* create() const;
|
||||||
|
|
||||||
///> Returns an instance of TOOL_MANAGER class.
|
///> Returns an instance of TOOL_MANAGER class.
|
||||||
TOOL_MANAGER* getToolManager() const;
|
TOOL_MANAGER* getToolManager() const;
|
||||||
|
@ -180,7 +179,7 @@ protected:
|
||||||
* Copies another menus data to this instance. Old entries are preserved, and ones form aMenu
|
* Copies another menus data to this instance. Old entries are preserved, and ones form aMenu
|
||||||
* are copied.
|
* are copied.
|
||||||
*/
|
*/
|
||||||
void copyFrom( const CONTEXT_MENU& aMenu );
|
void copyFrom( const ACTION_MENU& aMenu );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +202,7 @@ protected:
|
||||||
void runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent );
|
void runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent );
|
||||||
|
|
||||||
///> Runs a function on the menu and all its submenus.
|
///> Runs a function on the menu and all its submenus.
|
||||||
void runOnSubmenus( std::function<void(CONTEXT_MENU*)> aFunction );
|
void runOnSubmenus( std::function<void(ACTION_MENU*)> aFunction );
|
||||||
|
|
||||||
///> Checks if any of submenus contains a TOOL_ACTION with a specific ID.
|
///> Checks if any of submenus contains a TOOL_ACTION with a specific ID.
|
||||||
OPT_TOOL_EVENT findToolAction( int aId );
|
OPT_TOOL_EVENT findToolAction( int aId );
|
||||||
|
@ -227,7 +226,7 @@ protected:
|
||||||
std::map<int, const TOOL_ACTION*> m_toolActions;
|
std::map<int, const TOOL_ACTION*> m_toolActions;
|
||||||
|
|
||||||
///> List of submenus.
|
///> List of submenus.
|
||||||
std::list<CONTEXT_MENU*> m_submenus;
|
std::list<ACTION_MENU*> m_submenus;
|
||||||
|
|
||||||
///> Optional icon
|
///> Optional icon
|
||||||
const BITMAP_OPAQUE* m_icon;
|
const BITMAP_OPAQUE* m_icon;
|
|
@ -26,7 +26,7 @@
|
||||||
#define CONDITIONAL_MENU_H
|
#define CONDITIONAL_MENU_H
|
||||||
|
|
||||||
#include <tool/selection_conditions.h>
|
#include <tool/selection_conditions.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class TOOL_ACTION;
|
||||||
class TOOL_INTERACTIVE;
|
class TOOL_INTERACTIVE;
|
||||||
|
|
||||||
|
|
||||||
class CONDITIONAL_MENU : public CONTEXT_MENU
|
class CONDITIONAL_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///> Constant to indicate that we do not care about an ENTRY location in the menu.
|
///> Constant to indicate that we do not care about an ENTRY location in the menu.
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
m_tool = aTool;
|
m_tool = aTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTEXT_MENU* create() const override;
|
ACTION_MENU* create() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function AddItem()
|
* Function AddItem()
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
* @param aOrder determines location of the added menu, higher numbers are put on the bottom.
|
* @param aOrder determines location of the added menu, higher numbers are put on the bottom.
|
||||||
* You may use ANY_ORDER here if you think it does not matter.
|
* You may use ANY_ORDER here if you think it does not matter.
|
||||||
*/
|
*/
|
||||||
void AddMenu( CONTEXT_MENU* aMenu,
|
void AddMenu( ACTION_MENU* aMenu,
|
||||||
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
|
const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways,
|
||||||
int aOrder = ANY_ORDER );
|
int aOrder = ANY_ORDER );
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
m_data.action = aAction;
|
m_data.action = aAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENTRY( CONTEXT_MENU* aMenu, SELECTION_CONDITION aCondition, int aOrder ) :
|
ENTRY( ACTION_MENU* aMenu, SELECTION_CONDITION aCondition, int aOrder ) :
|
||||||
m_type( MENU ),
|
m_type( MENU ),
|
||||||
m_condition( aCondition ),
|
m_condition( aCondition ),
|
||||||
m_order( aOrder ),
|
m_order( aOrder ),
|
||||||
|
@ -160,7 +160,7 @@ private:
|
||||||
return m_data.action;
|
return m_data.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CONTEXT_MENU* Menu() const
|
inline ACTION_MENU* Menu() const
|
||||||
{
|
{
|
||||||
assert( m_type == MENU );
|
assert( m_type == MENU );
|
||||||
return m_data.menu;
|
return m_data.menu;
|
||||||
|
@ -191,7 +191,7 @@ private:
|
||||||
|
|
||||||
union {
|
union {
|
||||||
const TOOL_ACTION* action;
|
const TOOL_ACTION* action;
|
||||||
CONTEXT_MENU* menu;
|
ACTION_MENU* menu;
|
||||||
} m_data;
|
} m_data;
|
||||||
|
|
||||||
///> Condition to be fulfilled to show the entry in menu.
|
///> Condition to be fulfilled to show the entry in menu.
|
||||||
|
|
|
@ -25,17 +25,17 @@
|
||||||
#ifndef GRID_MENU_H
|
#ifndef GRID_MENU_H
|
||||||
#define GRID_MENU_H
|
#define GRID_MENU_H
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
|
|
||||||
class EDA_DRAW_FRAME;
|
class EDA_DRAW_FRAME;
|
||||||
|
|
||||||
class GRID_MENU : public CONTEXT_MENU
|
class GRID_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GRID_MENU( EDA_DRAW_FRAME* aParent );
|
GRID_MENU( EDA_DRAW_FRAME* aParent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new GRID_MENU( m_parent );
|
return new GRID_MENU( m_parent );
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <tool/tool_event.h>
|
#include <tool/tool_event.h>
|
||||||
#include <tool/tool_base.h>
|
#include <tool/tool_base.h>
|
||||||
|
|
||||||
class CONTEXT_MENU;
|
class ACTION_MENU;
|
||||||
|
|
||||||
class TOOL_INTERACTIVE : public TOOL_BASE
|
class TOOL_INTERACTIVE : public TOOL_BASE
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
* @param aMenu is the menu to be assigned.
|
* @param aMenu is the menu to be assigned.
|
||||||
* @param aTrigger determines conditions upon which the context menu is activated.
|
* @param aTrigger determines conditions upon which the context menu is activated.
|
||||||
*/
|
*/
|
||||||
void SetContextMenu( CONTEXT_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger = CMENU_BUTTON );
|
void SetContextMenu( ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger = CMENU_BUTTON );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RunMainStack()
|
* Function RunMainStack()
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
class TOOL_BASE;
|
class TOOL_BASE;
|
||||||
class ACTION_MANAGER;
|
class ACTION_MANAGER;
|
||||||
class CONTEXT_MENU;
|
class ACTION_MENU;
|
||||||
class wxWindow;
|
class wxWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
* CMENU_OFF: menu is disabled.
|
* CMENU_OFF: menu is disabled.
|
||||||
* May be called from a coroutine context.
|
* May be called from a coroutine context.
|
||||||
*/
|
*/
|
||||||
void ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
|
void ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu,
|
||||||
CONTEXT_MENU_TRIGGER aTrigger );
|
CONTEXT_MENU_TRIGGER aTrigger );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class CONTEXT_MENU;
|
class ACTION_MENU;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TOOL_MENU
|
* Class TOOL_MENU
|
||||||
|
@ -87,14 +87,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param aSubMenu: a sub menu to add
|
* @param aSubMenu: a sub menu to add
|
||||||
*/
|
*/
|
||||||
void AddSubMenu( std::shared_ptr<CONTEXT_MENU> aSubMenu );
|
void AddSubMenu( std::shared_ptr<ACTION_MENU> aSubMenu );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ShowContextMenu
|
* Function ShowContextMenu
|
||||||
*
|
*
|
||||||
* Helper function to set and immediately show a CONTEXT_MENU
|
* Helper function to set and immediately show a CONDITIONAL_MENU
|
||||||
* based on the internal CONDITIONAL_MENU in concert with
|
* in concert with the given SELECTION
|
||||||
* the given SELECTION
|
|
||||||
*
|
*
|
||||||
* You don't have to use this function, if the caller has a
|
* You don't have to use this function, if the caller has a
|
||||||
* different way to show the menu, it can create one from
|
* different way to show the menu, it can create one from
|
||||||
|
@ -162,7 +161,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Lifetime-managing container of submenus
|
* Lifetime-managing container of submenus
|
||||||
*/
|
*/
|
||||||
std::vector<std::shared_ptr<CONTEXT_MENU> > m_subMenus;
|
std::vector<std::shared_ptr<ACTION_MENU> > m_subMenus;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOOLS_TOOL_MENU__H_
|
#endif // TOOLS_TOOL_MENU__H_
|
||||||
|
|
|
@ -25,17 +25,17 @@
|
||||||
#ifndef ZOOM_MENU_H
|
#ifndef ZOOM_MENU_H
|
||||||
#define ZOOM_MENU_H
|
#define ZOOM_MENU_H
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
|
|
||||||
class EDA_DRAW_FRAME;
|
class EDA_DRAW_FRAME;
|
||||||
|
|
||||||
class ZOOM_MENU : public CONTEXT_MENU
|
class ZOOM_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZOOM_MENU( EDA_DRAW_FRAME* aParent );
|
ZOOM_MENU( EDA_DRAW_FRAME* aParent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new ZOOM_MENU( m_parent );
|
return new ZOOM_MENU( m_parent );
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <dialogs/dialog_pns_settings.h>
|
#include <dialogs/dialog_pns_settings.h>
|
||||||
#include <dialogs/dialog_pns_length_tuning_settings.h>
|
#include <dialogs/dialog_pns_length_tuning_settings.h>
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
|
@ -86,7 +86,7 @@ LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TUNER_TOOL_MENU : public CONTEXT_MENU
|
class TUNER_TOOL_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TUNER_TOOL_MENU()
|
TUNER_TOOL_MENU()
|
||||||
|
@ -107,7 +107,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new TUNER_TOOL_MENU();
|
return new TUNER_TOOL_MENU();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ using namespace std::placeholders;
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tools/pcb_actions.h>
|
#include <tools/pcb_actions.h>
|
||||||
#include <tools/grid_helper.h>
|
#include <tools/grid_helper.h>
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ using namespace std::placeholders;
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <collectors.h>
|
#include <collectors.h>
|
||||||
|
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tool/tool_settings.h>
|
#include <tool/tool_settings.h>
|
||||||
#include <tool/grid_menu.h>
|
#include <tool/grid_menu.h>
|
||||||
|
@ -205,7 +205,7 @@ ROUTER_TOOL::ROUTER_TOOL() :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TRACK_WIDTH_MENU: public CONTEXT_MENU
|
class TRACK_WIDTH_MENU: public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TRACK_WIDTH_MENU( PCB_EDIT_FRAME& aFrame ) :
|
TRACK_WIDTH_MENU( PCB_EDIT_FRAME& aFrame ) :
|
||||||
|
@ -216,7 +216,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new TRACK_WIDTH_MENU( m_frame );
|
return new TRACK_WIDTH_MENU( m_frame );
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DIFF_PAIR_MENU: public CONTEXT_MENU
|
class DIFF_PAIR_MENU: public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DIFF_PAIR_MENU( PCB_EDIT_FRAME& aFrame ) :
|
DIFF_PAIR_MENU( PCB_EDIT_FRAME& aFrame ) :
|
||||||
|
@ -344,7 +344,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new DIFF_PAIR_MENU( m_frame );
|
return new DIFF_PAIR_MENU( m_frame );
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ROUTER_TOOL_MENU : public CONTEXT_MENU
|
class ROUTER_TOOL_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ROUTER_TOOL_MENU( PCB_EDIT_FRAME& aFrame, PNS::ROUTER_MODE aMode ) :
|
ROUTER_TOOL_MENU( PCB_EDIT_FRAME& aFrame, PNS::ROUTER_MODE aMode ) :
|
||||||
|
@ -467,7 +467,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new ROUTER_TOOL_MENU( m_frame, m_mode );
|
return new ROUTER_TOOL_MENU( m_frame, m_mode );
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ TOOL_ACTION PCB_ACTIONS::pushPadSettings(
|
||||||
push_pad_settings_xpm );
|
push_pad_settings_xpm );
|
||||||
|
|
||||||
|
|
||||||
class PAD_CONTEXT_MENU : public CONTEXT_MENU
|
class PAD_CONTEXT_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new PAD_CONTEXT_MENU( m_editingFootprint, m_haveGlobalPadSettings );
|
return new PAD_CONTEXT_MENU( m_editingFootprint, m_haveGlobalPadSettings );
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include <tools/pcb_tool_base.h>
|
#include <tools/pcb_tool_base.h>
|
||||||
|
|
||||||
class CONTEXT_MENU;
|
class ACTION_MENU;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PAD_TOOL
|
* Class PAD_TOOL
|
||||||
|
|
|
@ -153,7 +153,7 @@ TOOL_ACTION PCB_ACTIONS::updateLocalRatsnest( "pcbnew.Control.updateLocalRatsnes
|
||||||
AS_GLOBAL, 0,
|
AS_GLOBAL, 0,
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
class ZONE_CONTEXT_MENU : public CONTEXT_MENU
|
class ZONE_CONTEXT_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZONE_CONTEXT_MENU()
|
ZONE_CONTEXT_MENU()
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new ZONE_CONTEXT_MENU();
|
return new ZONE_CONTEXT_MENU();
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LOCK_CONTEXT_MENU : public CONTEXT_MENU
|
class LOCK_CONTEXT_MENU : public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LOCK_CONTEXT_MENU()
|
LOCK_CONTEXT_MENU()
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
Add( PCB_ACTIONS::toggleLock );
|
Add( PCB_ACTIONS::toggleLock );
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new LOCK_CONTEXT_MENU();
|
return new LOCK_CONTEXT_MENU();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool ALIGN_DISTRIBUTE_TOOL::Init()
|
||||||
m_frame = getEditFrame<PCB_BASE_FRAME>();
|
m_frame = getEditFrame<PCB_BASE_FRAME>();
|
||||||
|
|
||||||
// Create a context menu and make it available through selection tool
|
// Create a context menu and make it available through selection tool
|
||||||
m_placementMenu = new CONTEXT_MENU;
|
m_placementMenu = new ACTION_MENU;
|
||||||
m_placementMenu->SetIcon( align_items_xpm );
|
m_placementMenu->SetIcon( align_items_xpm );
|
||||||
m_placementMenu->SetTitle( _( "Align/Distribute" ) );
|
m_placementMenu->SetTitle( _( "Align/Distribute" ) );
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ private:
|
||||||
|
|
||||||
SELECTION_TOOL* m_selectionTool;
|
SELECTION_TOOL* m_selectionTool;
|
||||||
|
|
||||||
CONTEXT_MENU* m_placementMenu;
|
ACTION_MENU* m_placementMenu;
|
||||||
|
|
||||||
PCB_BASE_FRAME* m_frame;
|
PCB_BASE_FRAME* m_frame;
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSel
|
||||||
_( "Filter Selection..." ), _( "Filter the types of items in the selection" ),
|
_( "Filter Selection..." ), _( "Filter the types of items in the selection" ),
|
||||||
options_generic_xpm );
|
options_generic_xpm );
|
||||||
|
|
||||||
class SELECT_MENU: public CONTEXT_MENU
|
class SELECT_MENU: public ACTION_MENU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SELECT_MENU()
|
SELECT_MENU()
|
||||||
|
@ -175,7 +175,7 @@ private:
|
||||||
Enable( getMenuId( PCB_ACTIONS::selectSameSheet ), sheetSelEnabled );
|
Enable( getMenuId( PCB_ACTIONS::selectSameSheet ), sheetSelEnabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTEXT_MENU* create() const override
|
ACTION_MENU* create() const override
|
||||||
{
|
{
|
||||||
return new SELECT_MENU();
|
return new SELECT_MENU();
|
||||||
}
|
}
|
||||||
|
@ -1441,7 +1441,7 @@ bool SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, const wxStr
|
||||||
{
|
{
|
||||||
BOARD_ITEM* current = nullptr;
|
BOARD_ITEM* current = nullptr;
|
||||||
SELECTION highlightGroup;
|
SELECTION highlightGroup;
|
||||||
CONTEXT_MENU menu;
|
ACTION_MENU menu;
|
||||||
|
|
||||||
highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
|
highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
|
||||||
getView()->Add( &highlightGroup );
|
getView()->Add( &highlightGroup );
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <tools/pcb_tool_base.h>
|
#include <tools/pcb_tool_base.h>
|
||||||
#include <tool/context_menu.h>
|
#include <tool/action_menu.h>
|
||||||
#include <tool/selection.h>
|
#include <tool/selection.h>
|
||||||
|
|
||||||
#include <tools/pcb_selection_conditions.h>
|
#include <tools/pcb_selection_conditions.h>
|
||||||
|
|
Loading…
Reference in New Issue