Move some dupicated tools to common tools.

This commit is contained in:
Jeff Young 2019-06-03 02:46:08 +01:00
parent e517199794
commit 9f1e2e34b7
23 changed files with 36 additions and 134 deletions

View File

@ -344,6 +344,15 @@ TOOL_ACTION ACTIONS::highContrastDec( "common.Control.highContrastDec",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HIGHCONTRAST_DEC ),
"", "" );
TOOL_ACTION ACTIONS::selectionTool( "common.InteractiveSelection.selectionTool",
AS_GLOBAL, 0, _( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::measureTool( "common.InteractiveEdit.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
measurement_xpm, AF_ACTIVATE );
TOOL_ACTION ACTIONS::show3DViewer( "common.Control.show3DViewer",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_3D_VIEWER ),
_( "3D Viewer" ), _( "Show 3D viewer window" ),

View File

@ -50,8 +50,8 @@
#include <tool/tool_dispatcher.h>
#include <tool/common_tools.h>
#include <tool/zoom_tool.h>
#include <tools/cvpcb_selection_tool.h>
#include <tools/cvpcb_actions.h>
#include <tools/cvpcb_selection_tool.h>
#include <tools/cvpcb_control.h>
// Colors for layers and items
@ -63,14 +63,6 @@ BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
EVT_TOOL( ID_OPTIONS_SETUP, DISPLAY_FOOTPRINTS_FRAME::InstallOptionsDisplay )
EVT_CHOICE( ID_ON_ZOOM_SELECT, DISPLAY_FOOTPRINTS_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, DISPLAY_FOOTPRINTS_FRAME::OnSelectGrid )
/*
EVT_TOOL and EVT_UPDATE_UI for:
ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
ID_TB_OPTIONS_SHOW_PADS_SKETCH
are managed in PCB_BASE_FRAME
*/
END_EVENT_TABLE()
@ -209,8 +201,8 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar()
// TODO: these can be moved to the 'proper' right vertical toolbar if and when there are
// actual tools to put there. That, or I'll get around to implementing configurable
// toolbars.
m_optionsToolBar->Add( CVPCB_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( CVPCB_ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
@ -460,11 +452,11 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
void DISPLAY_FOOTPRINTS_FRAME::SyncMenusAndToolbars()
{
m_mainToolBar->Toggle( CVPCB_ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );
m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( CVPCB_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_optionsToolBar->Toggle( CVPCB_ACTIONS::measureTool, GetToolId() == ID_TB_MEASUREMENT_TOOL );
m_optionsToolBar->Toggle( ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_optionsToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_TB_MEASUREMENT_TOOL );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Refresh();

View File

@ -46,11 +46,6 @@ public:
/// Activation of the selection tool
static TOOL_ACTION selectionActivate;
/// Tool selection
static TOOL_ACTION selectionTool;
static TOOL_ACTION measureTool;
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
};

View File

@ -24,9 +24,9 @@
*/
#include <cstdint>
#include "cvpcb_actions.h"
#include "cvpcb_control.h"
#include <functional>
#include <tool/actions.h>
#include <tools/cvpcb_control.h>
using namespace std::placeholders;

View File

@ -18,7 +18,6 @@
*/
#include <limits>
#include <functional>
using namespace std::placeholders;
@ -29,28 +28,15 @@ using namespace std::placeholders;
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tools/cvpcb_actions.h>
#include <tools/cvpcb_selection_tool.h>
#include <preview_items/ruler_item.h>
#include <cvpcb_id.h>
#include <tools/cvpcb_selection_tool.h>
// JEY TODO: move all these actions to tool/actions.cpp
// Selection tool actions
TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection",
AS_GLOBAL, 0,
"", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
// Selection tool actions
TOOL_ACTION CVPCB_ACTIONS::selectionTool( "cvpcb.InteractiveSelection.selectionTool",
AS_GLOBAL, 0,
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION CVPCB_ACTIONS::measureTool( "cvpcb.InteractiveSelection.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
measurement_xpm, AF_ACTIVATE );
CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() :
TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ),
@ -235,6 +221,6 @@ const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
void CVPCB_SELECTION_TOOL::setTransitions()
{
Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() );
Go( &CVPCB_SELECTION_TOOL::MeasureTool, CVPCB_ACTIONS::measureTool.MakeEvent() );
Go( &CVPCB_SELECTION_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() );
}

View File

@ -362,7 +362,7 @@ void SCH_EDIT_FRAME::setupTools()
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
m_toolManager->RunAction( EE_ACTIONS::selectionActivate );
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
}

View File

@ -73,7 +73,6 @@ public:
static TOOL_ACTION unlock;
// Schematic Tools
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
static TOOL_ACTION placeSymbol;
static TOOL_ACTION placePower;

View File

@ -51,10 +51,6 @@ TOOL_ACTION EE_ACTIONS::selectionActivate( "eeschema.InteractiveSelection",
AS_GLOBAL, 0, "", "", // No description, not shown anywhere
nullptr, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::selectionTool( "eeschema.InteractiveSelection.selectionTool",
AS_GLOBAL, 0, _( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::selectNode( "eeschema.InteractiveSelection.SelectNode",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SELECT_NODE ),
_( "Select Node" ), _( "Select a connection item under the cursor" ) );

View File

@ -232,7 +232,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
toolsMenu->Add( _( "&Show Source..." ), _( "Show source file for the current layer" ),
ID_GERBVIEW_SHOW_SOURCE, tools_xpm );
toolsMenu->Add( GERBVIEW_ACTIONS::measureTool );
toolsMenu->Add( ACTIONS::measureTool );
toolsMenu->AppendSeparator();
toolsMenu->Add( _( "Clear Current Layer..." ), _( "Clear the selected graphic layer" ),

View File

@ -220,8 +220,8 @@ void GERBVIEW_FRAME::ReCreateOptToolbar()
// TODO: these can be moved to the 'proper' vertical toolbar if and when there are
// actual tools to put there. That, or I'll get around to implementing configurable
// toolbars.
m_optionsToolBar->Add( GERBVIEW_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( GERBVIEW_ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );

View File

@ -38,7 +38,6 @@ OPT<TOOL_EVENT> GERBVIEW_ACTIONS::TranslateLegacyId( int aId )
case ID_HIGHLIGHT_APER_ATTRIBUTE_ITEMS:
return GERBVIEW_ACTIONS::highlightAttribute.MakeEvent();
break;
}
return OPT<TOOL_EVENT>();

View File

@ -56,8 +56,6 @@ public:
/// Activation of the edit tool
static TOOL_ACTION properties;
static TOOL_ACTION measureTool;
// Display modes
static TOOL_ACTION linesDisplayOutlines;
static TOOL_ACTION flashedDisplayOutlines;
@ -69,15 +67,10 @@ public:
// Layer control
static TOOL_ACTION layerPrev;
static TOOL_ACTION layerNext;
static TOOL_ACTION layerAlphaInc;
static TOOL_ACTION layerAlphaDec;
static TOOL_ACTION layerToggle;
static TOOL_ACTION layerChanged; // notification
// Miscellaneous
static TOOL_ACTION selectionTool;
static TOOL_ACTION zoomTool;
static TOOL_ACTION showHelp;
// Highlighting

View File

@ -29,11 +29,6 @@
#include "gerbview_control.h"
#include "gerbview_selection_tool.h"
TOOL_ACTION GERBVIEW_ACTIONS::selectionTool( "gerbview.Control.selectionTool",
AS_GLOBAL, 0,
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION GERBVIEW_ACTIONS::layerChanged( "gerbview.Control.layerChanged",
AS_GLOBAL, 0,
"", "",
@ -240,13 +235,6 @@ int GERBVIEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent )
}
int GERBVIEW_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
return 0;
}
int GERBVIEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
{
DisplayHotkeyList( m_frame, m_frame->GetHotkeyConfig() );

View File

@ -69,11 +69,6 @@ TOOL_ACTION GERBVIEW_ACTIONS::selectionClear( "gerbview.InteractiveSelection.Cle
AS_GLOBAL, 0,
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION GERBVIEW_ACTIONS::measureTool( "gerbview.InteractiveSelection.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
measurement_xpm, AF_ACTIVATE );
class HIGHLIGHT_MENU: public ACTION_MENU
{
@ -477,7 +472,7 @@ void GERBVIEW_SELECTION_TOOL::setTransitions()
Go( &GERBVIEW_SELECTION_TOOL::ClearSelection, GERBVIEW_ACTIONS::selectionClear.MakeEvent() );
Go( &GERBVIEW_SELECTION_TOOL::SelectItem, GERBVIEW_ACTIONS::selectItem.MakeEvent() );
Go( &GERBVIEW_SELECTION_TOOL::UnselectItem, GERBVIEW_ACTIONS::unselectItem.MakeEvent() );
Go( &GERBVIEW_SELECTION_TOOL::MeasureTool, GERBVIEW_ACTIONS::measureTool.MakeEvent() );
Go( &GERBVIEW_SELECTION_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() );
}

View File

@ -135,6 +135,10 @@ public:
static TOOL_ACTION togglePolarCoords;
static TOOL_ACTION resetLocalCoords;
// Common Tools
static TOOL_ACTION selectionTool;
static TOOL_ACTION measureTool;
// Misc
static TOOL_ACTION show3DViewer;
static TOOL_ACTION configurePaths;

View File

@ -28,7 +28,6 @@ set( PL_EDITOR_SRCS
menubar.cpp
toolbars_pl_editor.cpp
tools/pl_actions.cpp
tools/pl_selection_tool.cpp
tools/pl_drawing_tools.cpp
tools/pl_edit_tool.cpp

View File

@ -1,43 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <common.h>
#include <id.h>
#include <bitmaps.h>
#include <hotkeys_basic.h>
#include "pl_actions.h"
OPT<TOOL_EVENT> PL_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_MOUSE_CLICK:
return ACTIONS::cursorClick.MakeEvent();
case ID_MOUSE_DOUBLECLICK:
return ACTIONS::cursorDblClick.MakeEvent();
}
return OPT<TOOL_EVENT>();
}

View File

@ -59,7 +59,6 @@ public:
static TOOL_ACTION selectionMenu;
// Tools
static TOOL_ACTION selectionTool;
static TOOL_ACTION pickerTool;
static TOOL_ACTION placeText;
static TOOL_ACTION placeImage;
@ -80,7 +79,7 @@ public:
static TOOL_ACTION toggleBackground;
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
};

View File

@ -49,10 +49,6 @@ TOOL_ACTION PL_ACTIONS::selectionActivate( "plEditor.InteractiveSelection",
AS_GLOBAL, 0, "", "", // No description, not shown anywhere
nullptr, AF_ACTIVATE );
TOOL_ACTION PL_ACTIONS::selectionTool( "plEditor.InteractiveSelection.selectionTool",
AS_GLOBAL, 0, _( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION PL_ACTIONS::selectionMenu( "plEditor.InteractiveSelection.SelectionMenu",
AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere

View File

@ -159,7 +159,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( PCB_ACTIONS::setAnchor, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Realize();
}
@ -211,7 +211,7 @@ void FOOTPRINT_EDIT_FRAME::SyncMenusAndToolbars()
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( PCB_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_drawToolBar->Toggle( PCB_ACTIONS::placePad, GetToolId() == ID_MODEDIT_PAD_TOOL );
m_drawToolBar->Toggle( PCB_ACTIONS::drawLine, GetToolId() == ID_MODEDIT_LINE_TOOL );
m_drawToolBar->Toggle( PCB_ACTIONS::drawCircle, GetToolId() == ID_MODEDIT_CIRCLE_TOOL );
@ -221,6 +221,6 @@ void FOOTPRINT_EDIT_FRAME::SyncMenusAndToolbars()
m_drawToolBar->Toggle( PCB_ACTIONS::deleteTool, GetToolId() == ID_MODEDIT_DELETE_TOOL );
m_drawToolBar->Toggle( PCB_ACTIONS::setAnchor, GetToolId() == ID_MODEDIT_ANCHOR_TOOL );
m_drawToolBar->Toggle( PCB_ACTIONS::gridSetOrigin, GetToolId() == ID_MODEDIT_PLACE_GRID_COORD );
m_drawToolBar->Toggle( PCB_ACTIONS::measureTool, GetToolId() == ID_MODEDIT_MEASUREMENT_TOOL );
m_drawToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_MODEDIT_MEASUREMENT_TOOL );
m_drawToolBar->Refresh();
}

View File

@ -419,7 +419,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
KiScaledSeparator( m_drawToolBar, this );
m_drawToolBar->Add( PCB_ACTIONS::drillOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Realize();
}
@ -817,6 +817,6 @@ void PCB_EDIT_FRAME::SyncMenusAndToolbars()
m_drawToolBar->Toggle( PCB_ACTIONS::deleteTool, GetToolId() == ID_PCB_DELETE_ITEM_BUTT );
m_drawToolBar->Toggle( PCB_ACTIONS::drillOrigin, GetToolId() == ID_PCB_PLACE_OFFSET_COORD_BUTT );
m_drawToolBar->Toggle( PCB_ACTIONS::gridSetOrigin, GetToolId() == ID_PCB_PLACE_GRID_COORD_BUTT );
m_drawToolBar->Toggle( PCB_ACTIONS::measureTool, GetToolId() == ID_PCB_MEASUREMENT_TOOL );
m_drawToolBar->Toggle( ACTIONS::measureTool, GetToolId() == ID_PCB_MEASUREMENT_TOOL );
m_drawToolBar->Refresh();
}

View File

@ -149,11 +149,6 @@ TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
_( "Properties..." ), _( "Displays item properties dialog" ),
config_xpm );
TOOL_ACTION PCB_ACTIONS::measureTool( "pcbnew.InteractiveEdit.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
_( "Measuring Tool" ), _( "Interactively measure distance between points" ),
measurement_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::updateUnits( "pcbnew.InteractiveEdit.updateUnits",
AS_GLOBAL, 0,
"", "" );
@ -1490,7 +1485,7 @@ void EDIT_TOOL::setTransitions()
Go( &EDIT_TOOL::editFootprintInFpEditor, PCB_ACTIONS::editFootprintInFpEditor.MakeEvent() );
Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::updateFootprints.MakeEvent() );
Go( &EDIT_TOOL::ExchangeFootprints, PCB_ACTIONS::exchangeFootprints.MakeEvent() );
Go( &EDIT_TOOL::MeasureTool, PCB_ACTIONS::measureTool.MakeEvent() );
Go( &EDIT_TOOL::MeasureTool, ACTIONS::measureTool.MakeEvent() );
Go( &EDIT_TOOL::copyToClipboard, ACTIONS::copy.MakeEvent() );
Go( &EDIT_TOOL::cutToClipboard, ACTIONS::cut.MakeEvent() );

View File

@ -212,7 +212,7 @@ PCB_TEST_FRAME::PCB_TEST_FRAME( wxFrame* frame, const wxString& title, const wxP
m_toolManager->InitTools();
m_galPanel->SetEventDispatcher( m_toolDispatcher.get() );
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
m_toolManager->InvokeTool( "common.InteractiveSelection" );
#endif
SetBoard( new BOARD );