Browse Source

Auto-update flyout icons when changed

Provides an update action to refresh the icon display when the user
changes the angle mode using a hotkey.  Also unifies the angle modes
between schematic, pcb and library editors
master
Seth Hillbrand 2 months ago
parent
commit
0785e7525b
  1. 22
      common/tool/action_toolbar.cpp
  2. 7
      cvpcb/display_footprints_frame.cpp
  3. 7
      cvpcb/toolbars_display_footprints.cpp
  4. 14
      eeschema/sch_edit_frame.cpp
  5. 6
      eeschema/symbol_editor/symbol_edit_frame.cpp
  6. 7
      eeschema/symbol_editor/toolbars_symbol_editor.cpp
  7. 5
      eeschema/tools/sch_actions.cpp
  8. 2
      eeschema/tools/sch_actions.h
  9. 25
      eeschema/tools/sch_editor_control.cpp
  10. 1
      eeschema/tools/sch_editor_control.h
  11. 4
      gerbview/gerbview_frame.cpp
  12. 7
      gerbview/toolbars_gerber.cpp
  13. 10
      include/eda_base_frame.h
  14. 6
      include/tool/action_toolbar.h
  15. 6
      pagelayout_editor/pl_editor_frame.cpp
  16. 7
      pagelayout_editor/toolbars_pl_editor.cpp
  17. 6
      pcbnew/footprint_edit_frame.cpp
  18. 6
      pcbnew/pcb_edit_frame.cpp
  19. 12
      pcbnew/toolbars_footprint_editor.cpp
  20. 8
      pcbnew/toolbars_footprint_viewer.cpp
  21. 12
      pcbnew/toolbars_pcb_editor.cpp
  22. 56
      pcbnew/tools/board_editor_control.cpp
  23. 5
      pcbnew/tools/board_editor_control.h
  24. 57
      pcbnew/tools/footprint_editor_control.cpp
  25. 5
      pcbnew/tools/footprint_editor_control.h
  26. 43
      pcbnew/tools/pcb_actions.cpp
  27. 7
      pcbnew/tools/pcb_actions.h
  28. 4
      pcbnew/tools/pcb_viewer_tools.cpp

22
common/tool/action_toolbar.cpp

@ -484,6 +484,28 @@ void ACTION_TOOLBAR::SelectAction( ACTION_GROUP* aGroup, const TOOL_ACTION& aAct
}
void ACTION_TOOLBAR::SelectAction( const TOOL_ACTION& aAction )
{
// Find the group that contains this action and select it
for( auto& [id, groupPtr] : m_actionGroups )
{
ACTION_GROUP* group = groupPtr.get();
bool inGroup = std::any_of( group->m_actions.begin(), group->m_actions.end(),
[&]( const TOOL_ACTION* action2 )
{
return aAction.GetId() == action2->GetId();
} );
if( inGroup )
{
doSelectAction( group, aAction );
break;
}
}
}
void ACTION_TOOLBAR::doSelectAction( ACTION_GROUP* aGroup, const TOOL_ACTION& aAction )
{
wxASSERT( GetParent() );

7
cvpcb/display_footprints_frame.cpp

@ -198,13 +198,6 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::measureTool, CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
mgr->SetConditions( PCB_ACTIONS::padDisplayMode, CHECK( !cond.PadFillDisplay() ) );

7
cvpcb/toolbars_display_footprints.cpp

@ -43,9 +43,10 @@ std::optional<TOOLBAR_CONFIGURATION> DISPLAY_FOOTPRINTS_TOOLBAR_SETTINGS::Defaul
config.AppendSeparator()
.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::togglePolarCoords )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )

14
eeschema/sch_edit_frame.cpp

@ -193,6 +193,10 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
configureToolbars();
RecreateToolbars();
// Ensure the "Line modes" toolbar group shows the current angle mode on startup
if( GetToolManager() )
GetToolManager()->RunAction( SCH_ACTIONS::angleSnapModeChanged );
#ifdef KICAD_IPC_API
wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, &SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
#endif
@ -735,16 +739,6 @@ void SCH_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( SCH_ACTIONS::showDesignBlockPanel, CHECK( designBlockCond ) );
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( SCH_ACTIONS::lineModeFree, CHECK( cond.LineMode( LINE_MODE::LINE_MODE_FREE ) ) );
mgr->SetConditions( SCH_ACTIONS::lineMode90, CHECK( cond.LineMode( LINE_MODE::LINE_MODE_90 ) ) );
mgr->SetConditions( SCH_ACTIONS::lineMode45, CHECK( cond.LineMode( LINE_MODE::LINE_MODE_45 ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );

6
eeschema/symbol_editor/symbol_edit_frame.cpp

@ -490,12 +490,6 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );

7
eeschema/symbol_editor/toolbars_symbol_editor.cpp

@ -59,9 +59,10 @@ std::optional<TOOLBAR_CONFIGURATION> SYMBOL_EDIT_TOOLBAR_SETTINGS::DefaultToolba
case TOOLBAR_LOC::LEFT:
config.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::toggleGridOverrides )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )

5
eeschema/tools/sch_actions.cpp

@ -1315,6 +1315,11 @@ TOOL_ACTION SCH_ACTIONS::lineModeNext( TOOL_ACTION_ARGS()
.FriendlyName( _( "Line Mode for Wires and Buses" ) )
.Tooltip( _( "Switch to next line mode" ) ) );
TOOL_ACTION SCH_ACTIONS::angleSnapModeChanged( TOOL_ACTION_ARGS()
.Name( "eeschema.EditorControl.angleSnapModeChanged" )
.Scope( AS_GLOBAL )
.Flags( AF_NOTIFY ) );
TOOL_ACTION SCH_ACTIONS::toggleAnnotateAuto( TOOL_ACTION_ARGS()
.Name( "eeschema.EditorControl.annotateAutomatically" )
.Scope( AS_GLOBAL )

2
eeschema/tools/sch_actions.h

@ -267,6 +267,8 @@ public:
static TOOL_ACTION lineMode90;
static TOOL_ACTION lineMode45;
static TOOL_ACTION lineModeNext;
// Notify listeners when angle snap/line mode changes
static TOOL_ACTION angleSnapModeChanged;
// Annotation
static TOOL_ACTION toggleAnnotateAuto;

25
eeschema/tools/sch_editor_control.cpp

@ -2751,6 +2751,8 @@ int SCH_EDITOR_CONTROL::ChangeLineMode( const TOOL_EVENT& aEvent )
{
m_frame->eeconfig()->m_Drawing.line_mode = aEvent.Parameter<LINE_MODE>();
m_toolMgr->PostAction( ACTIONS::refreshPreview );
// Notify toolbar to update selection
m_toolMgr->RunAction( SCH_ACTIONS::angleSnapModeChanged );
return 0;
}
@ -2760,6 +2762,8 @@ int SCH_EDITOR_CONTROL::NextLineMode( const TOOL_EVENT& aEvent )
m_frame->eeconfig()->m_Drawing.line_mode++;
m_frame->eeconfig()->m_Drawing.line_mode %= LINE_MODE::LINE_MODE_COUNT;
m_toolMgr->PostAction( ACTIONS::refreshPreview );
// Notify toolbar to update selection
m_toolMgr->RunAction( SCH_ACTIONS::angleSnapModeChanged );
return 0;
}
@ -2789,6 +2793,26 @@ int SCH_EDITOR_CONTROL::ReloadPlugins( const TOOL_EVENT& aEvent )
return 0;
}
int SCH_EDITOR_CONTROL::OnAngleSnapModeChanged( const TOOL_EVENT& aEvent )
{
// Update the left toolbar Line modes group icon to match current mode
switch( static_cast<LINE_MODE>( m_frame->eeconfig()->m_Drawing.line_mode ) )
{
case LINE_MODE::LINE_MODE_FREE:
m_frame->SelectLeftToolbarAction( SCH_ACTIONS::lineModeFree );
break;
case LINE_MODE::LINE_MODE_90:
m_frame->SelectLeftToolbarAction( SCH_ACTIONS::lineMode90 );
break;
case LINE_MODE::LINE_MODE_45:
default:
m_frame->SelectLeftToolbarAction( SCH_ACTIONS::lineMode45 );
break;
}
return 0;
}
int SCH_EDITOR_CONTROL::RepairSchematic( const TOOL_EVENT& aEvent )
{
@ -3079,6 +3103,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::ChangeLineMode, SCH_ACTIONS::lineMode90.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ChangeLineMode, SCH_ACTIONS::lineMode45.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::NextLineMode, SCH_ACTIONS::lineModeNext.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::OnAngleSnapModeChanged, SCH_ACTIONS::angleSnapModeChanged.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ToggleAnnotateAuto, SCH_ACTIONS::toggleAnnotateAuto.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ReloadPlugins, ACTIONS::pluginsReload.MakeEvent() );

1
eeschema/tools/sch_editor_control.h

@ -145,6 +145,7 @@ public:
int TogglePinAltIcons( const TOOL_EVENT& aEvent );
int ChangeLineMode( const TOOL_EVENT& aEvent );
int NextLineMode( const TOOL_EVENT& aEvent );
int OnAngleSnapModeChanged( const TOOL_EVENT& aEvent );
int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
int TogglePythonConsole( const TOOL_EVENT& aEvent );
int ReloadPlugins( const TOOL_EVENT& aEvent );

4
gerbview/gerbview_frame.cpp

@ -1107,10 +1107,6 @@ void GERBVIEW_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
auto flashedDisplayOutlinesCond =
[this] ( const SELECTION& )
{

7
gerbview/toolbars_gerber.cpp

@ -55,9 +55,10 @@ std::optional<TOOLBAR_CONFIGURATION> GERBVIEW_TOOLBAR_SETTINGS::DefaultToolbarCo
config.AppendSeparator()
.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::togglePolarCoords )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )

10
include/eda_base_frame.h

@ -198,6 +198,16 @@ public:
virtual void OnSize( wxSizeEvent& aEvent );
/**
* Select the given action in the left toolbar group which contains it, if any.
* This updates the displayed icon/tooltip and UI conditions for that group.
*/
void SelectLeftToolbarAction( const TOOL_ACTION& aAction )
{
if( m_tbLeft )
m_tbLeft->SelectAction( aAction );
}
void OnMaximize( wxMaximizeEvent& aEvent );
int GetAutoSaveInterval() const;

6
include/tool/action_toolbar.h

@ -286,6 +286,12 @@ public:
*/
void SelectAction( ACTION_GROUP* aGroup, const TOOL_ACTION& aAction );
/**
* Select the given action in whatever group contains it and update that group's icon.
* If the action is not part of any group on this toolbar, this is a no-op.
*/
void SelectAction( const TOOL_ACTION& aAction );
/**
* Replace the contents of this toolbar with the configuration given in
* @c aConfig.

6
pagelayout_editor/pl_editor_frame.cpp

@ -313,12 +313,6 @@ void PL_EDITOR_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );

7
pagelayout_editor/toolbars_pl_editor.cpp

@ -44,9 +44,10 @@ std::optional<TOOLBAR_CONFIGURATION> PL_EDITOR_TOOLBAR_SETTINGS::DefaultToolbarC
case TOOLBAR_LOC::LEFT:
config.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits );
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) );
/* TODO: Implement context menus
PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>();

6
pcbnew/footprint_edit_frame.cpp

@ -1340,12 +1340,6 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );

6
pcbnew/pcb_edit_frame.cpp

@ -930,13 +930,7 @@ void PCB_EDIT_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
mgr->SetConditions( ACTIONS::toggleGridOverrides, CHECK( cond.GridOverrides() ) );
mgr->SetConditions( ACTIONS::cursorSmallCrosshairs, CHECK( cond.CursorSmallCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursorFullCrosshairs, CHECK( cond.CursorFullCrosshairs() ) );
mgr->SetConditions( ACTIONS::cursor45Crosshairs, CHECK( cond.Cursor45Crosshairs() ) );
mgr->SetConditions( ACTIONS::togglePolarCoords, CHECK( cond.PolarCoordinates() ) );
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
mgr->SetConditions( ACTIONS::cut, ENABLE( cond.HasItems() ) );
mgr->SetConditions( ACTIONS::copy, ENABLE( cond.HasItems() ) );

12
pcbnew/toolbars_footprint_editor.cpp

@ -51,16 +51,20 @@ std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_EDIT_TOOLBAR_SETTINGS::DefaultToo
config.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::toggleGridOverrides )
.AppendAction( PCB_ACTIONS::togglePolarCoords )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )
.AddAction( ACTIONS::cursor45Crosshairs ) );
config.AppendSeparator()
.AppendAction( PCB_ACTIONS::toggleHV45Mode );
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
.AddAction( PCB_ACTIONS::lineModeFree )
.AddAction( PCB_ACTIONS::lineMode90 )
.AddAction( PCB_ACTIONS::lineMode45 ) );
config.AppendSeparator()
.AppendAction( PCB_ACTIONS::padDisplayMode )

8
pcbnew/toolbars_footprint_viewer.cpp

@ -77,9 +77,11 @@ std::optional<TOOLBAR_CONFIGURATION> FOOTPRINT_VIEWER_TOOLBAR_SETTINGS::DefaultT
config.AppendSeparator()
.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::togglePolarCoords )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendSeparator()
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )

12
pcbnew/toolbars_pcb_editor.cpp

@ -137,16 +137,20 @@ std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_TOOLBAR_SETTINGS::DefaultToolbarCo
config.AppendAction( ACTIONS::toggleGrid )
.AppendAction( ACTIONS::toggleGridOverrides )
.AppendAction( PCB_ACTIONS::togglePolarCoords )
.AppendAction( ACTIONS::inchesUnits )
.AppendAction( ACTIONS::milsUnits )
.AppendAction( ACTIONS::millimetersUnits )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Units" ) )
.AddAction( ACTIONS::millimetersUnits )
.AddAction( ACTIONS::inchesUnits )
.AddAction( ACTIONS::milsUnits ) )
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Crosshair modes" ) )
.AddAction( ACTIONS::cursorSmallCrosshairs )
.AddAction( ACTIONS::cursorFullCrosshairs )
.AddAction( ACTIONS::cursor45Crosshairs ) );
config.AppendSeparator()
.AppendAction( PCB_ACTIONS::toggleHV45Mode );
.AppendGroup( TOOLBAR_GROUP_CONFIG( _( "Line modes" ) )
.AddAction( PCB_ACTIONS::lineModeFree )
.AddAction( PCB_ACTIONS::lineMode90 )
.AddAction( PCB_ACTIONS::lineMode45 ) );
config.AppendSeparator()
.AppendAction( PCB_ACTIONS::showRatsnest )

56
pcbnew/tools/board_editor_control.cpp

@ -57,6 +57,8 @@
#include <pcbnew_id.h>
#include <project.h>
#include <project/project_file.h> // LAST_PATH_TYPE
#include <settings/settings_manager.h>
#include <pcbnew_settings.h>
#include <tool/tool_manager.h>
#include <tool/tool_event.h>
#include <tools/drawing_tool.h>
@ -167,6 +169,50 @@ void BOARD_EDITOR_CONTROL::Reset( RESET_REASON aReason )
}
}
// Update left-toolbar Line modes group icon based on current settings
int BOARD_EDITOR_CONTROL::OnAngleSnapModeChanged( const TOOL_EVENT& aEvent )
{
PCB_EDIT_FRAME* f = getEditFrame<PCB_EDIT_FRAME>();
if( !f )
return 0;
LEADER_MODE mode = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode;
switch( mode )
{
case LEADER_MODE::DIRECT:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineModeFree );
break;
case LEADER_MODE::DEG90:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineMode90 );
break;
case LEADER_MODE::DEG45:
default:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineMode45 );
break;
}
return 0;
}
int BOARD_EDITOR_CONTROL::ChangeLineMode( const TOOL_EVENT& aEvent )
{
LEADER_MODE mode = aEvent.Parameter<LEADER_MODE>();
GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" )->m_AngleSnapMode = mode;
m_toolMgr->PostAction( ACTIONS::refreshPreview );
m_toolMgr->RunAction( PCB_ACTIONS::angleSnapModeChanged );
return 0;
}
int BOARD_EDITOR_CONTROL::NextLineMode( const TOOL_EVENT& aEvent )
{
// Reuse existing toggle behavior
OPT_TOOL_EVENT evt = PCB_ACTIONS::toggleHV45Mode.MakeEvent();
m_toolMgr->ProcessEvent( *evt );
return 0;
}
bool BOARD_EDITOR_CONTROL::Init()
{
@ -250,6 +296,10 @@ bool BOARD_EDITOR_CONTROL::Init()
menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 );
}
// Ensure the left toolbar's Line modes group reflects the current setting at startup
if( m_toolMgr )
m_toolMgr->RunAction( PCB_ACTIONS::angleSnapModeChanged );
return true;
}
@ -1857,4 +1907,10 @@ void BOARD_EDITOR_CONTROL::setTransitions()
Go( &BOARD_EDITOR_CONTROL::ToggleSearch, PCB_ACTIONS::showSearch.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
// Line modes: explicit, next, and notification
Go( &BOARD_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineModeFree.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineMode90.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineMode45.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::NextLineMode, PCB_ACTIONS::lineModeNext.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::OnAngleSnapModeChanged,PCB_ACTIONS::angleSnapModeChanged.MakeEvent() );
}

5
pcbnew/tools/board_editor_control.h

@ -148,6 +148,11 @@ public:
static void DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
EDA_ITEM* aItem, const VECTOR2D& aPoint );
// Line-mode handlers
int ChangeLineMode( const TOOL_EVENT& aEvent );
int NextLineMode( const TOOL_EVENT& aEvent );
int OnAngleSnapModeChanged( const TOOL_EVENT& aEvent );
private:
///< How to modify a property for selected items.
enum MODIFY_MODE { ON, OFF, TOGGLE };

57
pcbnew/tools/footprint_editor_control.cpp

@ -26,12 +26,15 @@
#include <advanced_config.h>
#include <string_utils.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include <tool/library_editor_control.h>
#include <tools/pcb_actions.h>
#include <footprint_editor_settings.h>
#include <eda_doc.h>
#include <footprint_edit_frame.h>
#include <generate_footprint_info.h>
#include <pcbnew_settings.h>
#include <pcbnew_id.h>
#include <confirm.h>
#include <kidialog.h>
@ -158,6 +161,10 @@ bool FOOTPRINT_EDITOR_CONTROL::Init()
libraryTreeTool->AddContextMenuItems( &ctxMenu );
// Ensure the left toolbar's Line modes group reflects the current setting at startup
if( m_toolMgr )
m_toolMgr->RunAction( PCB_ACTIONS::angleSnapModeChanged );
return true;
}
@ -948,4 +955,54 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() );
// clang-format on
// Line modes for the footprint editor: explicit modes, next-mode, and toolbar sync
Go( &FOOTPRINT_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineModeFree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineMode90.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ChangeLineMode, PCB_ACTIONS::lineMode45.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::NextLineMode, PCB_ACTIONS::lineModeNext.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::OnAngleSnapModeChanged,
PCB_ACTIONS::angleSnapModeChanged.MakeEvent() );
}
int FOOTPRINT_EDITOR_CONTROL::ChangeLineMode( const TOOL_EVENT& aEvent )
{
LEADER_MODE mode = aEvent.Parameter<LEADER_MODE>();
GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_AngleSnapMode = mode;
m_toolMgr->PostAction( ACTIONS::refreshPreview );
m_toolMgr->RunAction( PCB_ACTIONS::angleSnapModeChanged );
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::NextLineMode( const TOOL_EVENT& aEvent )
{
OPT_TOOL_EVENT evt = PCB_ACTIONS::toggleHV45Mode.MakeEvent();
m_toolMgr->ProcessEvent( *evt );
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::OnAngleSnapModeChanged( const TOOL_EVENT& aEvent )
{
FOOTPRINT_EDIT_FRAME* f = getEditFrame<FOOTPRINT_EDIT_FRAME>();
if( !f )
return 0;
LEADER_MODE mode = GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>( "fpedit" )->m_AngleSnapMode;
switch( mode )
{
case LEADER_MODE::DIRECT:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineModeFree );
break;
case LEADER_MODE::DEG90:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineMode90 );
break;
case LEADER_MODE::DEG45:
default:
f->SelectLeftToolbarAction( PCB_ACTIONS::lineMode45 );
break;
}
return 0;
}

5
pcbnew/tools/footprint_editor_control.h

@ -94,6 +94,11 @@ private:
*/
void tryToSaveFootprintInLibrary( FOOTPRINT& aFootprint, const LIB_ID& aLibId );
// Line-mode handlers
int ChangeLineMode( const TOOL_EVENT& aEvent );
int NextLineMode( const TOOL_EVENT& aEvent );
int OnAngleSnapModeChanged( const TOOL_EVENT& aEvent );
FOOTPRINT_EDIT_FRAME* m_frame;
DIALOG_FOOTPRINT_CHECKER* m_checkerDialog;

43
pcbnew/tools/pcb_actions.cpp

@ -37,6 +37,7 @@
#include <tools/pcb_selection_tool.h>
#include <router/pns_router.h>
#include <router/pns_routing_settings.h>
#include <geometry/geometry_utils.h>
// Actions, being statically-defined, require specialized I18N handling. We continue to
// use the _() macro so that string harvesting by the I18N framework doesn't have to be
@ -1444,6 +1445,48 @@ TOOL_ACTION PCB_ACTIONS::toggleHV45Mode( TOOL_ACTION_ARGS()
.ToolbarState( TOOLBAR_STATE::TOGGLE )
.Icon( BITMAPS::hv45mode ) );
// Line mode grouping and events (for PCB and Footprint editors)
TOOL_ACTION PCB_ACTIONS::lineModeFree( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.lineModeFree" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Line Modes" ) )
.Tooltip( _( "Draw and drag at any angle" ) )
.ToolbarState( TOOLBAR_STATE::TOGGLE )
.Icon( BITMAPS::lines_any )
.Flags( AF_NONE )
.Parameter( LEADER_MODE::DIRECT ) );
TOOL_ACTION PCB_ACTIONS::lineMode90( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.lineModeOrthonal" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Line Modes" ) )
.Tooltip( _( "Constrain drawing and dragging to horizontal or vertical motions" ) )
.ToolbarState( TOOLBAR_STATE::TOGGLE )
.Icon( BITMAPS::lines90 )
.Flags( AF_NONE )
.Parameter( LEADER_MODE::DEG90 ) );
TOOL_ACTION PCB_ACTIONS::lineMode45( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.lineMode45" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Line Modes" ) )
.Tooltip( _( "Constrain drawing and dragging to horizontal, vertical, or 45-degree angle motions" ) )
.ToolbarState( TOOLBAR_STATE::TOGGLE )
.Icon( BITMAPS::hv45mode )
.Flags( AF_NONE )
.Parameter( LEADER_MODE::DEG45 ) );
TOOL_ACTION PCB_ACTIONS::lineModeNext( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.lineModeNext" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Line Modes" ) )
.Tooltip( _( "Switch to next line mode" ) ) );
TOOL_ACTION PCB_ACTIONS::angleSnapModeChanged( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.angleSnapModeChanged" )
.Scope( AS_GLOBAL )
.Flags( AF_NOTIFY ) );
TOOL_ACTION PCB_ACTIONS::lock( TOOL_ACTION_ARGS()
.Name( "pcbnew.EditorControl.lock" )
.Scope( AS_GLOBAL )

7
pcbnew/tools/pcb_actions.h

@ -222,6 +222,13 @@ public:
static TOOL_ACTION placeImportedGraphics;
static TOOL_ACTION setAnchor;
static TOOL_ACTION deleteLastPoint;
// Line mode grouping and events
static TOOL_ACTION lineModeFree; ///< Unconstrained angle mode (icon lines_any)
static TOOL_ACTION lineMode90; ///< 90-degree-only mode (icon lines90)
static TOOL_ACTION lineMode45; ///< 45-degree-or-orthogonal mode (icon hv45mode)
static TOOL_ACTION lineModeNext; ///< Cycle through angle modes
static TOOL_ACTION angleSnapModeChanged; ///< Notification event when angle mode changes
static TOOL_ACTION closeOutline;
/// Increase width of currently drawn line

4
pcbnew/tools/pcb_viewer_tools.cpp

@ -35,6 +35,7 @@
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <tool/actions.h>
#include <tool/tool_manager.h>
#include <tools/pcb_grid_helper.h>
#include <tools/pcb_actions.h>
@ -144,6 +145,9 @@ int PCB_VIEWER_TOOLS::ToggleHV45Mode( const TOOL_EVENT& toolEvent )
frame()->UpdateStatusBar();
// Notify other tools/UI (toolbars) that the angle snap mode has changed
m_toolMgr->RunAction( PCB_ACTIONS::angleSnapModeChanged );
return 0;
}

Loading…
Cancel
Save