Fix change footprints dialog to use correct selection state.

This commit is contained in:
Jeff Young 2023-09-11 21:16:47 +01:00
parent a2b7bf97b9
commit 899fe8be17
6 changed files with 33 additions and 19 deletions

View File

@ -25,8 +25,6 @@
*/
#include <bitmaps.h>
#include <board_commit.h>
#include <board.h>
#include <footprint.h>
#include <pad.h>
#include <dialog_exchange_footprints.h>
@ -35,8 +33,8 @@
#include <macros.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <project.h>
#include <widgets/wx_html_report_panel.h>
#include <widgets/std_bitmap_button.h>
#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 );

View File

@ -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 );

View File

@ -634,7 +634,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">2</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
@ -693,7 +693,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="subclass">STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
@ -911,7 +911,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">2</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
@ -970,7 +970,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="subclass">STD_BITMAP_BUTTON; widgets/std_bitmap_button.h; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>

View File

@ -10,6 +10,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
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;

View File

@ -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 )

View File

@ -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
{