7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 15:19:38 +00:00

Immediate-action hotkeys (and context menu actions) for eeschema.

This commit is contained in:
Jeff Young 2019-06-15 01:29:42 +01:00
parent 12a4a38507
commit 5610261dce
61 changed files with 699 additions and 832 deletions

View File

@ -291,7 +291,7 @@ void EDA_BASE_FRAME::ReCreateMenuBar()
void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
{
COMMON_CONTROL* commonControl = m_toolManager->GetTool<COMMON_CONTROL>();
ACTION_MENU* helpMenu = new ACTION_MENU();
ACTION_MENU* helpMenu = new ACTION_MENU( false );
helpMenu->SetTool( commonControl );

View File

@ -39,6 +39,7 @@
#include <wx/snglinst.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/action_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/actions.h>
#include <wx/clipbrd.h>
@ -359,7 +360,6 @@ void EDA_DRAW_FRAME::AddStandardSubMenus( TOOL_MENU& aToolMenu )
void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
{
m_toolMsg = msg;
SetStatusText( msg, 5 );
}
@ -418,6 +418,55 @@ void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
}
void EDA_DRAW_FRAME::SetTool( const std::string& actionName )
{
if( !m_toolStack.empty() )
m_toolStack.pop_back();
PushTool( actionName );
}
void EDA_DRAW_FRAME::PushTool( const std::string& actionName )
{
m_toolStack.push_back( actionName );
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( actionName );
if( action )
DisplayToolMsg( action->GetLabel() );
else
DisplayToolMsg( actionName );
}
void EDA_DRAW_FRAME::PopTool()
{
m_toolStack.pop_back();
if( !m_toolStack.empty() )
{
TOOL_ACTION* action = m_toolManager->GetActionManager()->FindAction( m_toolStack.back() );
if( action )
{
TOOL_EVENT evt = action->MakeEvent();
evt.SetHasPosition( false );
GetToolManager()->PostEvent( evt );
}
}
else
DisplayToolMsg( ACTIONS::selectionTool.GetName() );
}
void EDA_DRAW_FRAME::ClearToolStack()
{
m_toolStack.clear();
DisplayToolMsg( ACTIONS::selectionTool.GetName() );
}
void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
{
// Keep default cursor in toolbars

View File

@ -38,12 +38,13 @@
using namespace std::placeholders;
ACTION_MENU::ACTION_MENU() :
ACTION_MENU::ACTION_MENU( bool isContextMenu ) :
m_dirty( true ),
m_titleDisplayed( false ),
m_isContextMenu( isContextMenu ),
m_icon( nullptr ),
m_selected( -1 ),
m_tool( nullptr ),
m_icon( nullptr )
m_tool( nullptr )
{
setupEvents();
}
@ -70,7 +71,7 @@ void ACTION_MENU::SetIcon( const BITMAP_OPAQUE* aIcon )
void ACTION_MENU::setupEvents()
{
// See wxWidgets hack in EDA_DRAW_FRAME::OnMenuOpen().
// See wxWidgets hack in EDA_BASE_FRAME::OnMenuOpen().
// Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
// Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), NULL, this );
@ -276,7 +277,7 @@ ACTION_MENU* ACTION_MENU::Clone() const
ACTION_MENU* ACTION_MENU::create() const
{
ACTION_MENU* menu = new ACTION_MENU();
ACTION_MENU* menu = new ACTION_MENU( false );
wxASSERT_MSG( typeid( *this ) == typeid( *menu ),
wxString::Format( "You need to override create() method for class %s", typeid(*this).name() ) );
@ -296,12 +297,11 @@ void ACTION_MENU::updateHotKeys()
{
TOOL_MANAGER* toolMgr = getToolManager();
for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin();
it != m_toolActions.end(); ++it )
for( auto& ii : m_toolActions )
{
int id = it->first;
const TOOL_ACTION& action = *it->second;
int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK;
int id = ii.first;
const TOOL_ACTION& action = *ii.second;
int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK;
if( key )
{
@ -328,27 +328,33 @@ void ACTION_MENU::updateHotKeys()
void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
{
// wxWidgets doesn't tell us when a menu command was generated from a hotkey or from
// a menu selection. It's important to us because a hotkey can be an immediate action
// while the menu selection can not (as it has no associated position).
//
// We get around this by storing the last highlighted menuId. If it matches the command
// id then we know this is a menu selection. (You might think we could use the menuOpen
// menuClose events, but these are actually generated for hotkeys as well.)
static int highlightId = 0;
OPT_TOOL_EVENT evt;
wxString menuText;
wxEventType type = aEvent.GetEventType();
if( type == wxEVT_MENU_OPEN && m_dirty )
if( type == wxEVT_MENU_OPEN )
{
if( m_tool )
if( m_dirty && m_tool )
getToolManager()->RunAction( ACTIONS::updateMenu, true, this );
highlightId = 0;
aEvent.Skip();
return;
}
// When the currently chosen item in the menu is changed, an update event is issued.
// For example, the selection tool can use this to dynamically highlight the current item
// from selection clarification popup.
else if( type == wxEVT_MENU_HIGHLIGHT )
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_UPDATE, aEvent.GetId() );
// One of menu entries was selected..
{
highlightId = aEvent.GetId();
evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_UPDATE, aEvent.GetId() );
}
else if( type == wxEVT_COMMAND_MENU_SELECTED )
{
// Store the selected position, so it can be checked by the tools
@ -410,7 +416,7 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
)
{
menuText = GetLabelText( aEvent.GetId() );
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, m_selected, AS_GLOBAL,
evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_CHOICE, m_selected, AS_GLOBAL,
&menuText );
}
}
@ -420,6 +426,9 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
// clients that don't supply a tool will have to check GetSelected() themselves
if( evt && m_tool )
{
if( highlightId == aEvent.GetId() && !m_isContextMenu )
evt->SetHasPosition( false );
//aEvent.StopPropagation();
if( m_tool->GetManager() )
m_tool->GetManager()->ProcessEvent( *evt );

View File

@ -109,7 +109,7 @@ void ACTION_TOOLBAR::onToolEvent( wxAuiToolBarEvent& aEvent )
// forward the action/update event to the TOOL_MANAGER
if( evt && m_toolManager )
{
//aEvent.StopPropagation();
evt->SetHasPosition( false );
m_toolManager->ProcessEvent( *evt );
}
else

View File

@ -29,7 +29,7 @@
CONDITIONAL_MENU::CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) :
m_isContextMenu( isContextMenu )
ACTION_MENU( isContextMenu )
{
m_tool = aTool;
}
@ -100,9 +100,11 @@ void CONDITIONAL_MENU::AddSeparator( const SELECTION_CONDITION& aCondition, int
SELECTION g_resolveDummySelection;
void CONDITIONAL_MENU::Resolve()
{
Evaluate( g_resolveDummySelection );
UpdateAll();
runOnSubmenus( [] ( ACTION_MENU* aMenu ) {
CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( aMenu );

View File

@ -33,7 +33,9 @@
#include <functional>
using namespace std::placeholders;
GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent )
GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) :
ACTION_MENU( true ),
m_parent( aParent )
{
BASE_SCREEN* screen = m_parent->GetScreen();

View File

@ -73,27 +73,27 @@ const std::string TOOL_EVENT::Format() const
const FlagString actions[] =
{
{ TA_MOUSE_CLICK, "click" },
{ TA_MOUSE_DBLCLICK, "double click" },
{ TA_MOUSE_UP, "button-up" },
{ TA_MOUSE_DOWN, "button-down" },
{ TA_MOUSE_DRAG, "drag" },
{ TA_MOUSE_MOTION, "motion" },
{ TA_MOUSE_WHEEL, "wheel" },
{ TA_KEY_PRESSED, "key-pressed" },
{ TA_VIEW_REFRESH, "view-refresh" },
{ TA_VIEW_ZOOM, "view-zoom" },
{ TA_VIEW_PAN, "view-pan" },
{ TA_VIEW_DIRTY, "view-dirty" },
{ TA_CHANGE_LAYER, "change-layer" },
{ TA_CANCEL_TOOL, "cancel-tool" },
{ TA_CONTEXT_MENU_UPDATE, "context-menu-update" },
{ TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
{ TA_UNDO_REDO_PRE, "undo-redo-pre" },
{ TA_UNDO_REDO_POST, "undo-redo-post" },
{ TA_ACTION, "action" },
{ TA_ACTIVATE, "activate" },
{ 0, "" }
{ TA_MOUSE_CLICK, "click" },
{ TA_MOUSE_DBLCLICK, "double click" },
{ TA_MOUSE_UP, "button-up" },
{ TA_MOUSE_DOWN, "button-down" },
{ TA_MOUSE_DRAG, "drag" },
{ TA_MOUSE_MOTION, "motion" },
{ TA_MOUSE_WHEEL, "wheel" },
{ TA_KEY_PRESSED, "key-pressed" },
{ TA_VIEW_REFRESH, "view-refresh" },
{ TA_VIEW_ZOOM, "view-zoom" },
{ TA_VIEW_PAN, "view-pan" },
{ TA_VIEW_DIRTY, "view-dirty" },
{ TA_CHANGE_LAYER, "change-layer" },
{ TA_CANCEL_TOOL, "cancel-tool" },
{ TA_CHOICE_MENU_UPDATE, "choice-menu-update" },
{ TA_CHOICE_MENU_CHOICE, "choice-menu-choice" },
{ TA_UNDO_REDO_PRE, "undo-redo-pre" },
{ TA_UNDO_REDO_POST, "undo-redo-post" },
{ TA_ACTION, "action" },
{ TA_ACTIVATE, "activate" },
{ 0, "" }
};
const FlagString buttons[] =

View File

@ -522,7 +522,7 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
TOOL_STATE* st = m_toolIdIndex[*it];
// forward context menu events to the tool that created the menu
if( aEvent.IsMenu() )
if( aEvent.IsChoiceMenu() )
{
if( *it != m_menuOwner )
continue;
@ -699,7 +699,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
// Otherwise notify the tool of a cancelled menu
else
{
TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, -1 );
TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CHOICE, -1 );
evt.SetParameter( m );
dispatchInternal( evt );
}
@ -708,7 +708,7 @@ void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent )
m_warpMouseAfterContextMenu = true;
// Notify the tools that menu has been closed
TOOL_EVENT evt( TC_COMMAND, TA_CONTEXT_MENU_CLOSED );
TOOL_EVENT evt( TC_COMMAND, TA_CHOICE_MENU_CLOSED );
evt.SetParameter( m );
dispatchInternal( evt );

View File

@ -32,7 +32,9 @@
#include <functional>
using namespace std::placeholders;
ZOOM_MENU::ZOOM_MENU( EDA_DRAW_FRAME* aParent ) : m_parent( aParent )
ZOOM_MENU::ZOOM_MENU( EDA_DRAW_FRAME* aParent ) :
ACTION_MENU( true ),
m_parent( aParent )
{
BASE_SCREEN* screen = aParent->GetScreen();

View File

@ -93,7 +93,7 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
clearSelection();
}
else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}

View File

@ -76,7 +76,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( strcmp( idcmd, "$NET:" ) == 0 )
{
if( GetToolId() == ID_HIGHLIGHT_TOOL )
if( GetCurrentToolName() == EE_ACTIONS::highlightNetCursor.GetName() )
{
m_SelectedNetName = FROM_UTF8( text );

View File

@ -58,38 +58,10 @@ enum id_eeschema_frm
/* Schematic editor main menubar IDs. */
ID_RESCUE_CACHED,
ID_EDIT_SYM_LIB_TABLE,
ID_REMAP_SYMBOLS,
/* Schematic editor horizontal toolbar IDs */
ID_BACKANNO_ITEMS,
/* Schematic editor vertical toolbar IDs */
ID_HIGHLIGHT_TOOL,
ID_PLACE_SYMBOL_TOOL,
ID_PLACE_POWER_TOOL,
ID_BUS_TOOL,
ID_WIRE_TOOL,
ID_BUSTOBUS_ENTRY_TOOL,
ID_WIRETOBUS_ENTRY_TOOL,
ID_LABEL_TOOL,
ID_GLOBALLABEL_TOOL,
ID_HIERLABEL_TOOL,
ID_IMPORT_SHEETPIN_TOOL,
ID_SHEETPIN_TOOL,
ID_NOCONNECT_TOOL,
ID_JUNCTION_TOOL,
ID_SHEET_TOOL,
ID_SCHEMATIC_TEXT_TOOL,
ID_SCHEMATIC_LINE_TOOL,
ID_PLACE_IMAGE_TOOL,
ID_DELETE_TOOL,
ID_SCH_MOVE,
ID_SCH_DRAG,
ID_SCH_UNFOLD_BUS,
ID_HOTKEY_HIGHLIGHT,
ID_ADD_PART_TO_SCHEMATIC,
/* Library editor horizontal toolbar IDs. */
@ -97,16 +69,8 @@ enum id_eeschema_frm
ID_LIBEDIT_SELECT_PART_NUMBER,
/* Library editor vertical toolbar IDs. */
ID_SYMBOL_PIN_TOOL,
ID_SYMBOL_LINE_TOOL,
ID_SYMBOL_ARC_TOOL,
ID_SYMBOL_CIRCLE_TOOL,
ID_SYMBOL_RECT_TOOL,
ID_SYMBOL_TEXT_TOOL,
ID_SYMBOL_ANCHOR_TOOL,
ID_LIBEDIT_IMPORT_BODY_BUTT,
ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT,
/* Library editor menubar IDs */
ID_LIBEDIT_GEN_PNG_FILE,

View File

@ -448,18 +448,16 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
void LIB_EDIT_FRAME::OnImportBody( wxCommandEvent& aEvent )
{
m_toolManager->DeactivateTool();
SetToolID( ID_LIBEDIT_IMPORT_BODY_BUTT, GetCanvas()->GetDefaultCursor(), _( "Import" ) );
LoadOneSymbol();
SetNoToolSelected();
m_drawToolBar->ToggleTool( ID_LIBEDIT_IMPORT_BODY_BUTT, false );
}
void LIB_EDIT_FRAME::OnExportBody( wxCommandEvent& aEvent )
{
m_toolManager->DeactivateTool();
SetToolID( ID_LIBEDIT_EXPORT_BODY_BUTT, GetCanvas()->GetDefaultCursor(), _( "Export" ) );
SaveOneSymbol();
SetNoToolSelected();
m_drawToolBar->ToggleTool( ID_LIBEDIT_EXPORT_BODY_BUTT, false );
}

View File

@ -72,7 +72,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddItem( EE_ACTIONS::importSymbol, EE_CONDITIONS::ShowAlways );
// Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU();
ACTION_MENU* submenuExport = new ACTION_MENU( false );
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm );

View File

@ -187,13 +187,15 @@ void LIB_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolPin, GetToolId() == ID_SYMBOL_PIN_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolText, GetToolId() == ID_SYMBOL_TEXT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolRectangle, GetToolId() == ID_SYMBOL_RECT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolCircle, GetToolId() == ID_SYMBOL_CIRCLE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolArc, GetToolId() == ID_SYMBOL_ARC_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSymbolLines, GetToolId() == ID_SYMBOL_LINE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbolAnchor, GetToolId() == ID_SYMBOL_ANCHOR_TOOL );
#define TOGGLE_TOOL( tool ) m_drawToolBar->Toggle( tool, GetCurrentToolName() == tool.GetName() )
TOGGLE_TOOL( EE_ACTIONS::selectionTool );
TOGGLE_TOOL( EE_ACTIONS::placeSymbolPin );
TOGGLE_TOOL( EE_ACTIONS::placeSymbolText );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolRectangle );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolCircle );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolArc );
TOGGLE_TOOL( EE_ACTIONS::drawSymbolLines );
TOGGLE_TOOL( EE_ACTIONS::deleteItemCursor );
m_drawToolBar->Refresh();
}

View File

@ -61,7 +61,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
if( openRecentMenu )
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new ACTION_MENU();
openRecentMenu = new ACTION_MENU( false );
openRecentMenu->SetTool( selTool );
openRecentMenu->SetTitle( _( "Open Recent" ) );
openRecentMenu->SetIcon( recent_xpm );
@ -92,7 +92,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddSeparator();
// Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU();
ACTION_MENU* submenuImport = new ACTION_MENU( false );
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( import_xpm );
@ -105,7 +105,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU();
ACTION_MENU* submenuExport = new ACTION_MENU( false );
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm );
@ -234,7 +234,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( EE_ACTIONS::placeHierarchicalLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeHierLabel, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways );
placeMenu->AddItem( EE_ACTIONS::placeSheetPin, EE_CONDITIONS::ShowAlways );

View File

@ -36,6 +36,7 @@
#include <viewlib_frame.h>
#include <sch_base_frame.h>
#include <symbol_lib_table.h>
#include <tool/action_toolbar.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/ee_actions.h>
@ -438,3 +439,14 @@ void SCH_BASE_FRAME::SyncView()
GetCanvas()->GetGAL()->SetGridSize( VECTOR2D( gs.x, gs.y ));
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
}
std::string SCH_BASE_FRAME::GetCurrentToolName()
{
if( m_toolStack.empty() )
return EE_ACTIONS::selectionTool.GetName();
else
return m_toolStack.back();
}

View File

@ -302,6 +302,8 @@ public:
void HardRedraw() override;
std::string GetCurrentToolName();
/**
* Add an item to the screen (and view)
* aScreen is the screen the item is located on, if not the current screen

View File

@ -130,7 +130,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->Add( EE_ACTIONS::placeJunction, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeLabel, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeGlobalLabel, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeHierarchicalLabel, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeHierLabel, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::drawSheet, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::importSheetPin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( EE_ACTIONS::placeSheetPin, ACTION_TOOLBAR::TOGGLE );
@ -168,7 +168,7 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
void SCH_EDIT_FRAME::SyncToolbars()
{
{
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
SCH_SHEET_LIST sheetList( g_RootSheet );
@ -186,25 +186,27 @@ void SCH_EDIT_FRAME::SyncToolbars()
m_optionsToolBar->Toggle( EE_ACTIONS::toggleForceHV, GetForceHVLines() );
m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( EE_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( EE_ACTIONS::highlightNetCursor, GetToolId() == ID_HIGHLIGHT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSymbol, GetToolId() == ID_COMPONENT_BUTT );
m_drawToolBar->Toggle( EE_ACTIONS::placePower, GetToolId() == ID_PLACE_POWER_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawWire, GetToolId() == ID_WIRE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawBus, GetToolId() == ID_BUS_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeBusWireEntry, GetToolId() == ID_WIRETOBUS_ENTRY_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeBusBusEntry, GetToolId() == ID_BUSTOBUS_ENTRY_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeNoConnect, GetToolId() == ID_NOCONNECT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeJunction, GetToolId() == ID_JUNCTION_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeLabel, GetToolId() == ID_LABEL_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeGlobalLabel, GetToolId() == ID_GLOBALLABEL_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeHierarchicalLabel, GetToolId() == ID_HIERLABEL_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawSheet, GetToolId() == ID_SHEET_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::importSheetPin, GetToolId() == ID_IMPORT_SHEETPIN_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSheetPin, GetToolId() == ID_SHEETPIN_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::drawLines, GetToolId() == ID_SCHEMATIC_LINE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeSchematicText, GetToolId() == ID_SCHEMATIC_TEXT_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::placeImage, GetToolId() == ID_PLACE_IMAGE_TOOL );
m_drawToolBar->Toggle( EE_ACTIONS::deleteItemCursor, GetToolId() == ID_DELETE_TOOL );
#define TOGGLE_TOOL( tool ) m_drawToolBar->Toggle( tool, GetCurrentToolName() == tool.GetName() )
TOGGLE_TOOL( ACTIONS::selectionTool );
TOGGLE_TOOL( EE_ACTIONS::highlightNetCursor );
TOGGLE_TOOL( EE_ACTIONS::placeSymbol );
TOGGLE_TOOL( EE_ACTIONS::placePower );
TOGGLE_TOOL( EE_ACTIONS::drawWire );
TOGGLE_TOOL( EE_ACTIONS::drawBus );
TOGGLE_TOOL( EE_ACTIONS::placeBusWireEntry );
TOGGLE_TOOL( EE_ACTIONS::placeBusBusEntry );
TOGGLE_TOOL( EE_ACTIONS::placeNoConnect );
TOGGLE_TOOL( EE_ACTIONS::placeJunction );
TOGGLE_TOOL( EE_ACTIONS::placeLabel );
TOGGLE_TOOL( EE_ACTIONS::placeGlobalLabel );
TOGGLE_TOOL( EE_ACTIONS::placeHierLabel );
TOGGLE_TOOL( EE_ACTIONS::drawSheet );
TOGGLE_TOOL( EE_ACTIONS::importSheetPin );
TOGGLE_TOOL( EE_ACTIONS::placeSheetPin );
TOGGLE_TOOL( EE_ACTIONS::drawLines );
TOGGLE_TOOL( EE_ACTIONS::placeSchematicText );
TOGGLE_TOOL( EE_ACTIONS::placeImage );
TOGGLE_TOOL( EE_ACTIONS::deleteItemCursor );
m_drawToolBar->Refresh();
}

View File

@ -76,9 +76,7 @@ public:
static TOOL_ACTION pickerTool;
static TOOL_ACTION placeSymbol;
static TOOL_ACTION placePower;
static TOOL_ACTION startWire;
static TOOL_ACTION drawWire;
static TOOL_ACTION startBus;
static TOOL_ACTION drawBus;
static TOOL_ACTION unfoldBus;
static TOOL_ACTION placeNoConnect;
@ -87,12 +85,11 @@ public:
static TOOL_ACTION placeBusBusEntry;
static TOOL_ACTION placeLabel;
static TOOL_ACTION placeGlobalLabel;
static TOOL_ACTION placeHierarchicalLabel;
static TOOL_ACTION placeHierLabel;
static TOOL_ACTION drawSheet;
static TOOL_ACTION placeSheetPin;
static TOOL_ACTION importSheetPin;
static TOOL_ACTION placeSchematicText;
static TOOL_ACTION startLines;
static TOOL_ACTION drawLines;
static TOOL_ACTION placeImage;
static TOOL_ACTION finishLineWireOrBus;
@ -129,12 +126,6 @@ public:
static TOOL_ACTION showDeMorganStandard;
static TOOL_ACTION showDeMorganAlternate;
static TOOL_ACTION editSymbolUnit;
static TOOL_ACTION addJunction;
static TOOL_ACTION addLabel;
static TOOL_ACTION addGlobalLabel;
static TOOL_ACTION addHierLabel;
static TOOL_ACTION addSheetPin;
static TOOL_ACTION addImportedSheetPin;
static TOOL_ACTION toShapeSlash;
static TOOL_ACTION toShapeBackslash;
static TOOL_ACTION toLabel;

View File

@ -170,8 +170,7 @@ void EE_INSPECTION_TOOL::checkPart( LIB_PART* aPart )
dup_error++;
/* TODO I dare someone to find a way to make happy translators on
this thing! Lorenzo */
/* TODO I dare someone to find a way to make happy translators on this thing! Lorenzo */
msg = wxString::Format( _( "<b>Duplicate pin %s</b> \"%s\" at location <b>(%.3f, %.3f)</b>"
" conflicts with pin %s \"%s\" at location <b>(%.3f, %.3f)</b>" ),
@ -271,7 +270,7 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
if( part->GetAliasCount() > 1 )
{
ACTION_MENU popup;
ACTION_MENU popup( true );
wxString msg;
int id = 0;

View File

@ -125,7 +125,6 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
resetPicker();
controls->ForceCursorPosition( false );
getEditFrame<SCH_BASE_FRAME>()->SetNoToolSelected();
return 0;
}

View File

@ -267,8 +267,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
KIGFX::VIEW_CONTROLS* controls = getViewControls();
KIGFX::VIEW* view = getView();
int savedToolID = m_frame->GetToolId();
wxString savedToolMsg = m_frame->GetToolMsg();
EDA_ITEM* item = (EDA_ITEM*) selection.Front();
controls->ShowCursor( true );
@ -286,21 +284,14 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
if( !m_editPoints
|| evt->Matches( EVENTS::ClearedEvent )
|| evt->Matches( EVENTS::UnselectedEvent )
|| evt->Matches( EVENTS::SelectedEvent ) )
{
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
break;
}
if ( !inDrag )
updateEditedPoint( *evt );
if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
{
m_frame->SetToolID( ID_DRAG_POINT, -1, _( "Drag Point" ) );
if( !inDrag )
{
saveItemsToUndo();
@ -318,8 +309,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
else if( evt->IsMouseUp( BUT_LEFT ) )
{
controls->SetAutoPan( false );
m_frame->SetToolID( savedToolID, -1, savedToolMsg );
inDrag = false;
m_toolMgr->PassEvent();
@ -333,7 +322,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
modified = false;
}
m_frame->SetToolID( savedToolID, -1, savedToolMsg );
break;
}
@ -348,7 +336,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
controls->SetAutoPan( false );
controls->CaptureCursor( false );
m_frame->SetToolID( savedToolID, -1, savedToolMsg );
if( m_editPoints )
{

View File

@ -214,8 +214,8 @@ bool EE_SELECTION_TOOL::Init()
menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
menu.AddSeparator( EE_CONDITIONS::Empty, 100 );
menu.AddItem( EE_ACTIONS::startWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
menu.AddItem( EE_ACTIONS::startBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
menu.AddSeparator( SCH_WIRE_BUS_TOOL::IsDrawingWire, 100 );
menu.AddItem( EE_ACTIONS::finishWire, SCH_WIRE_BUS_TOOL::IsDrawingWire, 100 );
@ -225,14 +225,14 @@ bool EE_SELECTION_TOOL::Init()
menu.AddSeparator( EE_CONDITIONS::NotEmpty, 200 );
menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::addImportedSheetPin,sheetSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::placeSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
menu.AddItem( EE_ACTIONS::importSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
menu.AddSeparator( havePartCondition && EE_CONDITIONS::Empty, 400 );
menu.AddItem( EE_ACTIONS::symbolProperties, havePartCondition && EE_CONDITIONS::Empty, 400 );
@ -293,6 +293,15 @@ int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
}
int EE_SELECTION_TOOL::SelectionTool( const TOOL_EVENT& aEvent )
{
// Since the selection tool is always running underneath the toolStack, all we need to
// do is clear the stack.
m_frame->ClearToolStack();
return 0;
}
int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
const KICAD_T movableItems[] =
@ -335,7 +344,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// JEY TODO: this is a hack, but I can't figure out why it's needed to
// keep from getting the first click when running the Place Symbol tool.
if( m_frame->GetToolId() != ID_NO_TOOL_SELECTED )
if( m_frame->GetCurrentToolName() != EE_ACTIONS::selectionTool.GetName() )
continue;
if( evt->Modifier( MD_CTRL ) && dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
@ -415,7 +424,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
// context sub-menu selection? Handle unit selection or bus unfolding
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
{
if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
&& evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
@ -446,7 +455,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
ClearSelection();
}
else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
@ -995,7 +1004,7 @@ int EE_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
{
EDA_ITEM* current = nullptr;
ACTION_MENU menu;
ACTION_MENU menu( true );
int limit = std::min( MAX_SELECT_ITEM_IDS, aCollector->GetCount() );
@ -1018,7 +1027,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
if( evt->Action() == TA_CHOICE_MENU_UPDATE )
{
if( current )
unhighlight( current, BRIGHTENED );
@ -1036,7 +1045,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
current = NULL;
}
}
else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
{
if( current )
unhighlight( current, BRIGHTENED );
@ -1315,6 +1324,7 @@ void EE_SELECTION_TOOL::setTransitions()
Go( &EE_SELECTION_TOOL::UpdateMenu, ACTIONS::updateMenu.MakeEvent() );
Go( &EE_SELECTION_TOOL::Main, EE_ACTIONS::selectionActivate.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectionTool, ACTIONS::selectionTool.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectNode, EE_ACTIONS::selectNode.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectConnection, EE_ACTIONS::selectConnection.MakeEvent() );
Go( &EE_SELECTION_TOOL::ClearSelection, EE_ACTIONS::clearSelection.MakeEvent() );

View File

@ -74,6 +74,11 @@ public:
*/
int Main( const TOOL_EVENT& aEvent );
/*
* Main() is always running, so this just clears the frame's tool stack.
*/
int SelectionTool( const TOOL_EVENT& aEvent );
/**
* Function GetSelection()
*

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