From 899fe8be17dc1c80bad18f715eb37152e718c6ee Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 11 Sep 2023 21:16:47 +0100 Subject: [PATCH] Fix change footprints dialog to use correct selection state. --- pcbnew/dialogs/dialog_exchange_footprints.cpp | 6 +----- .../dialog_exchange_footprints_base.cpp | 9 +++++---- .../dialog_exchange_footprints_base.fbp | 8 ++++---- .../dialogs/dialog_exchange_footprints_base.h | 5 +++-- pcbnew/tools/edit_tool.cpp | 20 +++++++++++++++++-- pcbnew/tools/global_edit_tool.cpp | 4 ++-- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index b524981c27..400e2c0c33 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -25,8 +25,6 @@ */ #include -#include -#include #include #include #include @@ -35,8 +33,8 @@ #include #include #include -#include #include +#include #define ID_MATCH_FP_ALL 4200 @@ -100,9 +98,7 @@ DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS( PCB_EDIT_FRAME* aParent, } if( m_currentFootprint ) - { m_newID->AppendText( From_UTF8( m_currentFootprint->GetFPID().Format().c_str() ) ); - } else m_upperSizer->FindItem( m_matchSelected )->Show( false ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints_base.cpp b/pcbnew/dialogs/dialog_exchange_footprints_base.cpp index b1b59b88b5..09f188363e 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints_base.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints_base.cpp @@ -5,6 +5,7 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// +#include "widgets/std_bitmap_button.h" #include "widgets/wx_html_report_panel.h" #include "dialog_exchange_footprints_base.h" @@ -57,8 +58,8 @@ DIALOG_EXCHANGE_FOOTPRINTS_BASE::DIALOG_EXCHANGE_FOOTPRINTS_BASE( wxWindow* pare bSizer4->Add( m_specifiedID, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_specifiedIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bSizer4->Add( m_specifiedIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 2 ); + m_specifiedIDBrowseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bSizer4->Add( m_specifiedIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2 ); m_mainSizer->Add( bSizer4, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); @@ -82,8 +83,8 @@ DIALOG_EXCHANGE_FOOTPRINTS_BASE::DIALOG_EXCHANGE_FOOTPRINTS_BASE( wxWindow* pare bSizer3->Add( m_newID, 1, wxALIGN_CENTER_VERTICAL, 5 ); - m_newIDBrowseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bSizer3->Add( m_newIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 2 ); + m_newIDBrowseButton = new STD_BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bSizer3->Add( m_newIDBrowseButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2 ); m_changeSizer->Add( bSizer3, 1, wxEXPAND|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/dialog_exchange_footprints_base.fbp b/pcbnew/dialogs/dialog_exchange_footprints_base.fbp index 3640d50319..7ae982440c 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints_base.fbp +++ b/pcbnew/dialogs/dialog_exchange_footprints_base.fbp @@ -634,7 +634,7 @@ 2 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -693,7 +693,7 @@ 1 - ; forward_declare + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 @@ -911,7 +911,7 @@ 2 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -970,7 +970,7 @@ 1 - ; forward_declare + STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare 0 diff --git a/pcbnew/dialogs/dialog_exchange_footprints_base.h b/pcbnew/dialogs/dialog_exchange_footprints_base.h index 7bd7fa696f..acc5b3aca6 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints_base.h +++ b/pcbnew/dialogs/dialog_exchange_footprints_base.h @@ -10,6 +10,7 @@ #include #include #include +class STD_BITMAP_BUTTON; class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" @@ -55,10 +56,10 @@ class DIALOG_EXCHANGE_FOOTPRINTS_BASE : public DIALOG_SHIM wxTextCtrl* m_specifiedValue; wxRadioButton* m_matchSpecifiedID; wxTextCtrl* m_specifiedID; - wxBitmapButton* m_specifiedIDBrowseButton; + STD_BITMAP_BUTTON* m_specifiedIDBrowseButton; wxBoxSizer* m_changeSizer; wxTextCtrl* m_newID; - wxBitmapButton* m_newIDBrowseButton; + STD_BITMAP_BUTTON* m_newIDBrowseButton; wxStaticBoxSizer* m_updateOptionsSizer; wxCheckBox* m_removeExtraBox; wxCheckBox* m_resetTextItemLayers; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 496d2254c2..878e45c2e0 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -210,8 +210,24 @@ bool EDIT_TOOL::Init() auto singleFootprintCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) && SELECTION_CONDITIONS::Count( 1 ); - auto multipleFootprintsCondition = SELECTION_CONDITIONS::OnlyTypes( { PCB_FOOTPRINT_T } ) - && SELECTION_CONDITIONS::MoreThan( 1 ); + auto multipleFootprintsCondition = + []( const SELECTION& aSelection ) + { + bool foundFirst = false; + + for( EDA_ITEM* item : aSelection ) + { + if( item->Type() == PCB_FOOTPRINT_T ) + { + if( foundFirst ) + return true; + else + foundFirst = true; + } + } + + return false; + }; auto noActiveToolCondition = [ this ]( const SELECTION& aSelection ) diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 34f8e97fdf..ca79049b83 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -79,7 +79,7 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) else if( aEvent.IsAction( &PCB_ACTIONS::updateFootprints ) ) { updateMode = true; - currentMode = false; + currentMode = selection.CountType( PCB_FOOTPRINT_T ) > 0; } else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprint ) ) { @@ -89,7 +89,7 @@ int GLOBAL_EDIT_TOOL::ExchangeFootprints( const TOOL_EVENT& aEvent ) else if( aEvent.IsAction( &PCB_ACTIONS::changeFootprints ) ) { updateMode = false; - currentMode = false; + currentMode = selection.CountType( PCB_FOOTPRINT_T ) > 0; } else {