diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index 3928fe4fcc..22731a2b76 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -98,22 +98,6 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) switch( id ) { - case ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH: - { - if( GetDesignSettings().UseCustomTrackViaSize() ) - { - GetDesignSettings().UseCustomTrackViaSize( false ); - GetDesignSettings().m_UseConnectedTrackWidth = true; - } - else - { - GetDesignSettings().m_UseConnectedTrackWidth = - not GetDesignSettings().m_UseConnectedTrackWidth; - } - - break; - } - case ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES: GetDesignSettings().m_UseConnectedTrackWidth = false; GetDesignSettings().SetTrackWidthIndex( 0 ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 4054bcae91..9532064246 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -174,7 +174,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard ) // Horizontal toolbar - EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) EVT_CHOICE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event ) @@ -185,7 +184,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) // User interface update event handlers. EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize ) - EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectAutoWidth ) EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH8, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth ) EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8, @@ -972,6 +970,14 @@ void PCB_EDIT_FRAME::setupUIConditions() mgr->SetConditions( PCB_ACTIONS::routerShoveMode, CHECK( isShoveMode ) ); mgr->SetConditions( PCB_ACTIONS::routerWalkaroundMode, CHECK( isWalkaroundMode ) ); + auto isAutoTrackWidth = + [this]( const SELECTION& ) + { + return GetDesignSettings().m_UseConnectedTrackWidth; + }; + + mgr->SetConditions( PCB_ACTIONS::autoTrackWidth, CHECK( isAutoTrackWidth ) ); + auto haveNetCond = [] ( const SELECTION& aSel ) { diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 4c976593ed..21a0942d80 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -164,7 +164,6 @@ public: void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent ); - void OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent ); void RunEeschema(); diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index bf61563a54..e458b0cd2b 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -21,7 +21,6 @@ enum pcbnew_ids // Tracks and vias sizes general options ID_AUX_TOOLBAR_PCB_VIA_SIZE, ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, - ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, ID_POPUP_PCB_SELECT_WIDTH_START_RANGE, ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, ID_POPUP_PCB_SELECT_AUTO_WIDTH, diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 40d7a740d6..c60ace7006 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -346,15 +346,9 @@ std::optional<TOOLBAR_CONFIGURATION> PCB_EDIT_FRAME::DefaultTopAuxToolbarConfig( TOOLBAR_CONFIGURATION config; // clang-format off - config.AppendControl( "control.PCBTrackWidth" ); + config.AppendControl( "control.PCBTrackWidth" ) + .AppendAction( PCB_ACTIONS::autoTrackWidth ); - /* TODO (ISM): Turn this into an action - m_tbTopAux->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, wxEmptyString, - KiBitmapBundle( BITMAPS::auto_track_width ), - _( "When routing from an existing track use its width instead " - "of the current width setting" ), - wxITEM_CHECK ); -*/ config.AppendSeparator() .AppendControl( "control.PCBViaDia" ); @@ -736,11 +730,3 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent ) m_SelViaSizeBox->SetSelection( sel ); } } - - -void PCB_EDIT_FRAME::OnUpdateSelectAutoWidth( wxUpdateUIEvent& aEvent ) -{ - BOARD_DESIGN_SETTINGS& bds = GetDesignSettings(); - - aEvent.Check( bds.m_UseConnectedTrackWidth ); -} diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 22d87d8552..201039edd3 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -1006,6 +1006,24 @@ int BOARD_EDITOR_CONTROL::ViaSizeDec( const TOOL_EVENT& aEvent ) } +int BOARD_EDITOR_CONTROL::AutoTrackWidth( const TOOL_EVENT& aEvent ) +{ + BOARD_DESIGN_SETTINGS& bds = getModel<BOARD>()->GetDesignSettings(); + + if( bds.UseCustomTrackViaSize() ) + { + bds.UseCustomTrackViaSize( false ); + bds.m_UseConnectedTrackWidth = true; + } + else + { + bds.m_UseConnectedTrackWidth = !bds.m_UseConnectedTrackWidth; + } + + return 0; +} + + int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent ) { if( m_inPlaceFootprint ) @@ -1718,6 +1736,7 @@ void BOARD_EDITOR_CONTROL::setTransitions() Go( &BOARD_EDITOR_CONTROL::TrackWidthDec, PCB_ACTIONS::trackWidthDec.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::ViaSizeInc, PCB_ACTIONS::viaSizeInc.MakeEvent() ); Go( &BOARD_EDITOR_CONTROL::ViaSizeDec, PCB_ACTIONS::viaSizeDec.MakeEvent() ); + Go( &BOARD_EDITOR_CONTROL::AutoTrackWidth, PCB_ACTIONS::autoTrackWidth.MakeEvent() ); // Zone actions Go( &BOARD_EDITOR_CONTROL::ZoneMerge, PCB_ACTIONS::zoneMerge.MakeEvent() ); diff --git a/pcbnew/tools/board_editor_control.h b/pcbnew/tools/board_editor_control.h index 6318a4fca2..bc3e7d1e68 100644 --- a/pcbnew/tools/board_editor_control.h +++ b/pcbnew/tools/board_editor_control.h @@ -88,6 +88,7 @@ public: int TrackWidthDec( const TOOL_EVENT& aEvent ); int ViaSizeInc( const TOOL_EVENT& aEvent ); int ViaSizeDec( const TOOL_EVENT& aEvent ); + int AutoTrackWidth( const TOOL_EVENT& aEvent ); // Zone actions int ZoneMerge( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index 29a51d8a3b..3abed6c451 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1129,6 +1129,15 @@ TOOL_ACTION PCB_ACTIONS::viaSizeDec( TOOL_ACTION_ARGS() .FriendlyName( _( "Decrease Via Size" ) ) .Tooltip( _( "Change via size to previous pre-defined size" ) ) ); +TOOL_ACTION PCB_ACTIONS::autoTrackWidth( TOOL_ACTION_ARGS() + .Name( "pcbnew.EditorControl.autoTrackWidth" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Automatically select track width" ) ) + .Tooltip( _( "When routing from an existing track use its width instead " + "of the current width setting" ) ) + .Icon( BITMAPS::auto_track_width ) + .ToolbarState( TOOLBAR_STATE::TOGGLE ) ); + TOOL_ACTION PCB_ACTIONS::trackViaSizeChanged( TOOL_ACTION_ARGS() .Name( "pcbnew.EditorControl.trackViaSizeChanged" ) .Scope( AS_GLOBAL ) diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 16d39c29c9..6766130364 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -399,6 +399,8 @@ public: static TOOL_ACTION viaSizeInc; static TOOL_ACTION viaSizeDec; + static TOOL_ACTION autoTrackWidth; + static TOOL_ACTION trackViaSizeChanged; // notification static TOOL_ACTION assignNetClass;