Use a list dialog that can be parented by the Board Setup dialog.

(The current one keeps pulling the Kicad Manager window to the front
on OSX.)

I also removed the UpdateUI stuff which was probably causing:

Fixes https://gitlab.com/kicad/code/kicad/issues/5049
This commit is contained in:
Jeff Young 2021-06-27 00:33:12 +01:00
parent 0dfb5fcaf9
commit 0f27618125
13 changed files with 149 additions and 114 deletions

View File

@ -32,21 +32,22 @@
// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or // wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
// not, in repeatedly creating/destroying a wxDC to do the measurement in). // not, in repeatedly creating/destroying a wxDC to do the measurement in).
// Use default column widths instead. // Use default column widths instead.
static int DEFAULT_SINGLE_COL_WIDTH = 260;
static int DEFAULT_COL_WIDTHS[] = { 200, 600 }; static int DEFAULT_COL_WIDTHS[] = { 200, 600 };
EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
const wxArrayString& aItemHeaders, const wxArrayString& aItemHeaders,
const std::vector<wxArrayString>& aItemList, const std::vector<wxArrayString>& aItemList,
const wxString& aSelection ) : const wxString& aPreselectText ) :
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
{ {
m_itemsList = &aItemList; m_itemsList = &aItemList;
m_filterBox->SetHint( _( "Filter" ) ); m_filterBox->SetHint( _( "Filter" ) );
initDialog( aItemHeaders, aSelection ); initDialog( aItemHeaders, aPreselectText );
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient // DIALOG_SHIM needs a unique hash_key because classname is not sufficient
// because so many dialogs share this same class, with different numbers of // because so many dialogs share this same class, with different numbers of
@ -65,10 +66,18 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection ) void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection )
{ {
if( aItemHeaders.Count() == 1 )
{
m_listBox->InsertColumn( 0, aItemHeaders.Item( 0 ), wxLIST_FORMAT_LEFT,
DEFAULT_SINGLE_COL_WIDTH );
}
else
{
for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) for( unsigned i = 0; i < aItemHeaders.Count(); i++ )
{ {
m_listBox->InsertColumn( i, aItemHeaders.Item( i ), m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT,
wxLIST_FORMAT_LEFT, DEFAULT_COL_WIDTHS[ i ] ); DEFAULT_COL_WIDTHS[ i ] );
}
} }
InsertItems( *m_itemsList, 0 ); InsertItems( *m_itemsList, 0 );
@ -103,6 +112,12 @@ void EDA_LIST_DIALOG::SetOKLabel( const wxString& aLabel )
} }
void EDA_LIST_DIALOG::HideFilter()
{
m_filterBox->Hide();
}
void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
{ {
wxString filter; wxString filter;
@ -124,6 +139,12 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
} }
long EDA_LIST_DIALOG::GetSelection()
{
return m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
}
wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn ) wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
{ {
wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString, wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString,

View File

@ -23,8 +23,8 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
m_listLabel->Wrap( -1 ); m_listLabel->Wrap( -1 );
bMargins->Add( m_listLabel, 0, wxALL, 5 ); bMargins->Add( m_listLabel, 0, wxALL, 5 );
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL ); m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxBORDER_SIMPLE|wxVSCROLL );
m_listBox->SetMinSize( wxSize( -1,200 ) ); m_listBox->SetMinSize( wxSize( 280,150 ) );
bMargins->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bMargins->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
@ -32,7 +32,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
bMargins->Add( m_filterBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bMargins->Add( m_filterBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( bMargins, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizerOK = new wxButton( this, wxID_OK );
@ -41,7 +41,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize(); m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );

View File

@ -60,7 +60,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property> <property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -165,7 +165,7 @@
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">-1,200</property> <property name="minimum_size">280,150</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_listBox</property> <property name="name">m_listBox</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -187,7 +187,7 @@
<property name="validator_variable"></property> <property name="validator_variable"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style">wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL</property> <property name="window_style">wxBORDER_SIMPLE|wxVSCROLL</property>
<event name="OnListItemActivated">onListItemActivated</event> <event name="OnListItemActivated">onListItemActivated</event>
</object> </object>
</object> </object>
@ -260,7 +260,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxEXPAND|wxALL</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>

View File

@ -55,15 +55,15 @@ public:
* @param aTitle The title shown on top. * @param aTitle The title shown on top.
* @param aItemHeaders an optional array containing the column header names for the dialog. * @param aItemHeaders an optional array containing the column header names for the dialog.
* @param aItemList A wxArrayString of the list of elements. * @param aItemList A wxArrayString of the list of elements.
* @param aRefText An item name if an item must be preselected. * @param aPreselectText An item name if an item must be preselected.
*/ */
EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders,
const wxArrayString& aItemHeaders,
const std::vector<wxArrayString>& aItemList, const std::vector<wxArrayString>& aItemList,
const wxString& aRefText ); const wxString& aPreselectText = wxEmptyString );
void SetListLabel( const wxString& aLabel ); void SetListLabel( const wxString& aLabel );
void SetOKLabel( const wxString& aLabel ); void SetOKLabel( const wxString& aLabel );
void HideFilter();
void Append( const wxArrayString& aItemStr ); void Append( const wxArrayString& aItemStr );
void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 ); void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
@ -76,6 +76,8 @@ public:
*/ */
wxString GetTextSelection( int aColumn = 0 ); wxString GetTextSelection( int aColumn = 0 );
long GetSelection();
private: private:
void onListItemActivated( wxListEvent& event ) override; void onListItemActivated( wxListEvent& event ) override;
void textChangeInFilterBox(wxCommandEvent& event) override; void textChangeInFilterBox(wxCommandEvent& event) override;

View File

@ -22,7 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <convert_to_biu.h>
#include <macros.h> // arrayDim definition #include <macros.h> // arrayDim definition
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
#include <board.h> #include <board.h>
@ -43,11 +42,11 @@
#include "dialog_dielectric_list_manager.h" #include "dialog_dielectric_list_manager.h"
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
#include <wx/richmsgdlg.h> #include <wx/richmsgdlg.h>
#include <wx/choicdlg.h>
#include <wx/dcclient.h> #include <wx/dcclient.h>
#include <wx/treebook.h> #include <wx/treebook.h>
#include <locale_io.h> #include <locale_io.h>
#include <dialog_helpers.h>
// Some wx widget ID to know what widget has fired a event: // Some wx widget ID to know what widget has fired a event:
#define ID_INCREMENT 256 // space between 2 ID type. Bigger than the layer count max #define ID_INCREMENT 256 // space between 2 ID type. Bigger than the layer count max
@ -96,12 +95,12 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
// Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan // Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan
// ("0.000000" + margins) // ("0.000000" + margins)
m_numericFieldsSize = dc.GetTextExtent( "X.XXXXXXX" ); m_numericFieldsSize = dc.GetTextExtent( "X.XXXXXX" );
m_numericFieldsSize.y = -1; // Use default for the vertical size m_numericFieldsSize.y = -1; // Use default for the vertical size
// Calculates a minimal size for wxTextCtrl to enter a dim with units // Calculates a minimal size for wxTextCtrl to enter a dim with units
// ("000.0000000 mils" + margins) // ("000.0000000 mils" + margins)
m_numericTextCtrlSize = dc.GetTextExtent( "XXX.XXXXXXX mils" ); m_numericTextCtrlSize = dc.GetTextExtent( "XXX.XXXXXX mils" );
m_numericTextCtrlSize.y = -1; // Use default for the vertical size m_numericTextCtrlSize.y = -1; // Use default for the vertical size
// The grid column containing the lock checkbox is kept to a minimal // The grid column containing the lock checkbox is kept to a minimal
@ -143,31 +142,40 @@ void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
wxBitmapComboBox* cb = dynamic_cast<wxBitmapComboBox*>( item ); wxBitmapComboBox* cb = dynamic_cast<wxBitmapComboBox*>( item );
if( cb ) if( cb )
{
cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, cb->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onColorSelected ),
NULL, this ); NULL, this );
}
wxButton* matButt = dynamic_cast<wxButton*>( item ); wxButton* matButt = dynamic_cast<wxButton*>( item );
if( matButt ) if( matButt )
{
matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, matButt->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onMaterialChange ),
NULL, this ); NULL, this );
}
wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item ); wxTextCtrl* textCtrl = dynamic_cast<wxTextCtrl*>( item );
if( textCtrl ) if( textCtrl )
{
textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, textCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED,
wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ), wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP::onThicknessChange ),
NULL, this ); NULL, this );
} }
}
} }
void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event ) void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
{ {
wxArrayString headers;
headers.Add( _( "Layers" ) );
// Build Dielectric layers list: // Build Dielectric layers list:
wxArrayString d_list; std::vector<wxArrayString> d_list;
std::vector<int> rows; // indexes of row values for each selectable item std::vector<int> rows; // indexes of row values for each selectable item
int row = -1; int row = -1;
@ -182,28 +190,32 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
if( brd_stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC ) if( brd_stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
{ {
wxArrayString d_item;
if( brd_stackup_item->GetSublayersCount() > 1 ) if( brd_stackup_item->GetSublayersCount() > 1 )
{ {
d_list.Add( wxString::Format( _( "Layer \"%s\" (sublayer %d/%d)" ), d_item.Add( wxString::Format( _( "Layer '%s' (sublayer %d/%d)" ),
brd_stackup_item->FormatDielectricLayerName(), brd_stackup_item->FormatDielectricLayerName(),
item.m_SubItem+1, brd_stackup_item->GetSublayersCount() ) ); item.m_SubItem+1,
brd_stackup_item->GetSublayersCount() ) );
} }
else else
d_list.Add( brd_stackup_item->FormatDielectricLayerName() ); {
d_item.Add( brd_stackup_item->FormatDielectricLayerName() );
}
d_list.emplace_back( d_item );
rows.push_back( row ); rows.push_back( row );
} }
} }
// Show list EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add Dielectric Layer" ), headers, d_list );
int index = wxGetSingleChoiceIndex( _( "Select dielectric layer to add to board stack up." ), dlg.SetListLabel( _( "Select layer to add:" ) );
_("Dielectric Layers List"), dlg.HideFilter();
d_list);
if( index < 0 ) if( dlg.ShowModal() == wxID_OK && dlg.GetSelection() >= 0 )
return; {
row = rows[ dlg.GetSelection() ];
row = rows[index];
BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[row].m_Item; BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[row].m_Item;
int new_sublayer = m_rowUiItemsList[row].m_SubItem; int new_sublayer = m_rowUiItemsList[row].m_SubItem;
@ -213,18 +225,21 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
rebuildLayerStackPanel(); rebuildLayerStackPanel();
computeBoardThickness(); computeBoardThickness();
}
} }
void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event ) void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event )
{ {
wxArrayString headers;
headers.Add( _( "Layers" ) );
// Build deletable Dielectric layers list. // Build deletable Dielectric layers list.
// A layer can be deleted if there are 2 (or more) dielectric sub-layers // A layer can be deleted if there are 2 (or more) dielectric sub-layers
// between 2 copper layers // between 2 copper layers
wxArrayString d_list; std::vector<wxArrayString> d_list;
std::vector<int> rows; // indexes of row values for each selectable item std::vector<int> rows; // indexes of row values for each selectable item
int row = 0; // row index in m_rowUiItemsList of items in choice list
int ui_row = 0; // The row index in m_rowUiItemsList of items in choice list
// Build the list of dielectric layers: // Build the list of dielectric layers:
for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() ) for( BOARD_STACKUP_ITEM* item : m_stackup.GetList() )
@ -232,38 +247,40 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event )
if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC || if( !item->IsEnabled() || item->GetType() != BS_ITEM_TYPE_DIELECTRIC ||
item->GetSublayersCount() <= 1 ) item->GetSublayersCount() <= 1 )
{ {
ui_row++; row++;
continue; continue;
} }
for( int ii = 0; ii < item->GetSublayersCount(); ii++ ) for( int ii = 0; ii < item->GetSublayersCount(); ii++ )
{ {
d_list.Add( wxString::Format( "Layer \"%s\" sublayer %d/%d", wxArrayString d_item;
item->FormatDielectricLayerName(), ii+1,
d_item.Add( wxString::Format( _( "Layer '%s' sublayer %d/%d" ),
item->FormatDielectricLayerName(),
ii+1,
item->GetSublayersCount() ) ); item->GetSublayersCount() ) );
rows.push_back( ui_row++ ); d_list.emplace_back( d_item );
rows.push_back( row++ );
} }
} }
// Show choice list EDA_LIST_DIALOG dlg( m_parentDialog, _( "Remove Dielectric Layer" ), headers, d_list );
int index = wxGetSingleChoiceIndex( _( "Select dielectric layer to remove from board stack up." ), dlg.SetListLabel( _( "Select layer to remove:" ) );
_( "Dielectric Layers" ), dlg.HideFilter();
d_list );
if( index < 0 ) if( dlg.ShowModal() == wxID_OK && dlg.GetSelection() >= 0 )
return; {
row = rows[ dlg.GetSelection() ];
ui_row = rows[index]; BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[ row ].m_Item;
int sublayer = m_rowUiItemsList[ row ].m_SubItem;
BOARD_STACKUP_ITEM* brd_stackup_item = m_rowUiItemsList[ui_row].m_Item;
int sublayer = m_rowUiItemsList[ui_row].m_SubItem;
// Remove the selected sub item for the selected dielectric layer // Remove the selected sub item for the selected dielectric layer
brd_stackup_item->RemoveDielectricPrms( sublayer ); brd_stackup_item->RemoveDielectricPrms( sublayer );
rebuildLayerStackPanel(); rebuildLayerStackPanel();
computeBoardThickness(); computeBoardThickness();
}
} }

View File

@ -42,10 +42,10 @@ PANEL_SETUP_BOARD_STACKUP_BASE::PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent
bTopSizer->Add( 40, 0, 1, wxEXPAND, 5 ); bTopSizer->Add( 40, 0, 1, wxEXPAND, 5 );
m_buttonAddDielectricLayer = new wxButton( this, wxID_ANY, _("Add Dielectric Layer"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonAddDielectricLayer = new wxButton( this, wxID_ANY, _("Add Dielectric Layer..."), wxDefaultPosition, wxDefaultSize, 0 );
bTopSizer->Add( m_buttonAddDielectricLayer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); bTopSizer->Add( m_buttonAddDielectricLayer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
m_buttonRemoveDielectricLayer = new wxButton( this, wxID_ANY, _("Remove Dielectric Layer"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonRemoveDielectricLayer = new wxButton( this, wxID_ANY, _("Remove Dielectric Layer..."), wxDefaultPosition, wxDefaultSize, 0 );
bTopSizer->Add( m_buttonRemoveDielectricLayer, 0, wxEXPAND|wxALL, 5 ); bTopSizer->Add( m_buttonRemoveDielectricLayer, 0, wxEXPAND|wxALL, 5 );

View File

@ -309,7 +309,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Add Dielectric Layer</property> <property name="label">Add Dielectric Layer...</property>
<property name="margins"></property> <property name="margins"></property>
<property name="markup">0</property> <property name="markup">0</property>
<property name="max_size"></property> <property name="max_size"></property>
@ -382,7 +382,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Remove Dielectric Layer</property> <property name="label">Remove Dielectric Layer...</property>
<property name="margins"></property> <property name="margins"></property>
<property name="markup">0</property> <property name="markup">0</property>
<property name="max_size"></property> <property name="max_size"></property>

View File

@ -36,6 +36,7 @@
#include <wx/choicdlg.h> #include <wx/choicdlg.h>
#include <wx/treebook.h> #include <wx/treebook.h>
#include <dialog_helpers.h>
// some define to choose how copper layers widgets are shown // some define to choose how copper layers widgets are shown
@ -790,20 +791,44 @@ bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aIm
void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent )
{ {
LSEQ seq; wxArrayString headers;
wxArrayString availableUserDefinedLayers = getAvailableUserDefinedLayers(); headers.Add( _( "Layers" ) );
wxCHECK( !availableUserDefinedLayers.IsEmpty(), /* void */ ); // Build the available user-defined layers list:
std::vector<wxArrayString> list;
wxSingleChoiceDialog dlg( this, _( "Select user defined layer to add to board layer set" ), for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
_( "Select Layer" ), availableUserDefinedLayers ); {
wxCheckBox* checkBox = getCheckBox( *seq );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() ) if( checkBox && checkBox->IsShown() )
continue;
wxArrayString available_user_layer;
available_user_layer.Add( LayerName( *seq ) );
list.emplace_back( available_user_layer );
}
if( list.empty() )
{
DisplayErrorMessage( m_parentDialog,
_( "All user-defined layers have already been added." ) );
return; return;
}
EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add User-defined Layer" ), headers, list );
dlg.SetListLabel( _( "Select layer to add:" ) );
dlg.HideFilter();
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetTextSelection().IsEmpty() )
return;
LSEQ seq;
for( seq = LSET::UserDefinedLayers().Seq(); seq; ++seq ) for( seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
{ {
if( LayerName( *seq ) == dlg.GetStringSelection() ) if( LayerName( *seq ) == dlg.GetTextSelection() )
break; break;
} }
@ -830,27 +855,3 @@ void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent )
} }
void PANEL_SETUP_LAYERS::onUpdateAddUserDefinedLayer( wxUpdateUIEvent& event )
{
wxArrayString availableUserDefinedLayers = getAvailableUserDefinedLayers();
event.Enable( !availableUserDefinedLayers.IsEmpty() );
}
wxArrayString PANEL_SETUP_LAYERS::getAvailableUserDefinedLayers()
{
wxArrayString availableUserDefinedLayers;
for( LSEQ seq = LSET::UserDefinedLayers().Seq(); seq; ++seq )
{
wxCheckBox* checkBox = getCheckBox( *seq );
if( checkBox && checkBox->IsShown() )
continue;
availableUserDefinedLayers.Add( LayerName( *seq ) );
}
return availableUserDefinedLayers;
}

View File

@ -110,8 +110,6 @@ private:
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
virtual void addUserDefinedLayer( wxCommandEvent& aEvent ) override; virtual void addUserDefinedLayer( wxCommandEvent& aEvent ) override;
virtual void onUpdateAddUserDefinedLayer( wxUpdateUIEvent& event ) override;
bool testLayerNames(); bool testLayerNames();
/** /**
@ -124,8 +122,6 @@ private:
*/ */
LSEQ getNonRemovableLayers(); LSEQ getNonRemovableLayers();
wxArrayString getAvailableUserDefinedLayers();
PANEL_SETUP_LAYERS_CTLs getCTLs( LAYER_NUM aLayerNumber ); PANEL_SETUP_LAYERS_CTLs getCTLs( LAYER_NUM aLayerNumber );
wxControl* getName( LAYER_NUM aLayer ); wxControl* getName( LAYER_NUM aLayer );
wxCheckBox* getCheckBox( LAYER_NUM aLayer ); wxCheckBox* getCheckBox( LAYER_NUM aLayer );

View File

@ -23,7 +23,7 @@ PANEL_SETUP_LAYERS_BASE::PANEL_SETUP_LAYERS_BASE( wxWindow* parent, wxWindowID i
bSizerLayerCnt->Add( 0, 0, 1, wxEXPAND, 5 ); bSizerLayerCnt->Add( 0, 0, 1, wxEXPAND, 5 );
m_addUserDefinedLayerButton = new wxButton( this, wxID_ANY, _("Add User Defined Layer"), wxDefaultPosition, wxDefaultSize, 0 ); m_addUserDefinedLayerButton = new wxButton( this, wxID_ANY, _("Add User Defined Layer..."), wxDefaultPosition, wxDefaultSize, 0 );
bSizerLayerCnt->Add( m_addUserDefinedLayerButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); bSizerLayerCnt->Add( m_addUserDefinedLayerButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
@ -46,6 +46,8 @@ PANEL_SETUP_LAYERS_BASE::PANEL_SETUP_LAYERS_BASE( wxWindow* parent, wxWindowID i
m_LayerListFlexGridSizer->Add( m_CrtYdFrontCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5 ); m_LayerListFlexGridSizer->Add( m_CrtYdFrontCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5 );
m_CrtYdFrontName = new wxTextCtrl( m_LayersListPanel, wxID_ANY, _("CrtYd_Front"), wxDefaultPosition, wxDefaultSize, 0 ); m_CrtYdFrontName = new wxTextCtrl( m_LayersListPanel, wxID_ANY, _("CrtYd_Front"), wxDefaultPosition, wxDefaultSize, 0 );
m_CrtYdFrontName->SetMinSize( wxSize( 160,-1 ) );
m_LayerListFlexGridSizer->Add( m_CrtYdFrontName, 0, wxEXPAND|wxRIGHT, 5 ); m_LayerListFlexGridSizer->Add( m_CrtYdFrontName, 0, wxEXPAND|wxRIGHT, 5 );
m_CrtYdFrontStaticText = new wxStaticText( m_LayersListPanel, ID_CRTYDFRONTCHOICE, _("Off-board, testing"), wxDefaultPosition, wxDefaultSize, 0 ); m_CrtYdFrontStaticText = new wxStaticText( m_LayersListPanel, ID_CRTYDFRONTCHOICE, _("Off-board, testing"), wxDefaultPosition, wxDefaultSize, 0 );
@ -814,7 +816,6 @@ PANEL_SETUP_LAYERS_BASE::PANEL_SETUP_LAYERS_BASE( wxWindow* parent, wxWindowID i
// Connect Events // Connect Events
m_addUserDefinedLayerButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::addUserDefinedLayer ), NULL, this ); m_addUserDefinedLayerButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::addUserDefinedLayer ), NULL, this );
m_addUserDefinedLayerButton->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_LAYERS_BASE::onUpdateAddUserDefinedLayer ), NULL, this );
m_CrtYdFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::DenyChangeCheckBox ), NULL, this ); m_CrtYdFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::DenyChangeCheckBox ), NULL, this );
m_FabFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_FabFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this );
m_AdhesFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_AdhesFrontCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this );
@ -880,7 +881,6 @@ PANEL_SETUP_LAYERS_BASE::~PANEL_SETUP_LAYERS_BASE()
{ {
// Disconnect Events // Disconnect Events
m_addUserDefinedLayerButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::addUserDefinedLayer ), NULL, this ); m_addUserDefinedLayerButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::addUserDefinedLayer ), NULL, this );
m_addUserDefinedLayerButton->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_LAYERS_BASE::onUpdateAddUserDefinedLayer ), NULL, this );
m_CrtYdFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::DenyChangeCheckBox ), NULL, this ); m_CrtYdFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::DenyChangeCheckBox ), NULL, this );
m_FabFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_FabFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this );
m_AdhesFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this ); m_AdhesFrontCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_SETUP_LAYERS_BASE::OnCheckBox ), NULL, this );

View File

@ -119,7 +119,7 @@
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Add User Defined Layer</property> <property name="label">Add User Defined Layer...</property>
<property name="margins"></property> <property name="margins"></property>
<property name="markup">0</property> <property name="markup">0</property>
<property name="max_size"></property> <property name="max_size"></property>
@ -153,7 +153,6 @@
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnButtonClick">addUserDefinedLayer</event> <event name="OnButtonClick">addUserDefinedLayer</event>
<event name="OnUpdateUI">onUpdateAddUserDefinedLayer</event>
</object> </object>
</object> </object>
</object> </object>
@ -388,7 +387,7 @@
<property name="maxlength"></property> <property name="maxlength"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size">160,-1</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_CrtYdFrontName</property> <property name="name">m_CrtYdFrontName</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>

View File

@ -353,7 +353,6 @@ class PANEL_SETUP_LAYERS_BASE : public wxPanel
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void addUserDefinedLayer( wxCommandEvent& event ) { event.Skip(); } virtual void addUserDefinedLayer( wxCommandEvent& event ) { event.Skip(); }
virtual void onUpdateAddUserDefinedLayer( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void DenyChangeCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void DenyChangeCheckBox( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); }

View File

@ -2359,7 +2359,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
} }
} }
EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items, wxEmptyString ); EDA_LIST_DIALOG dlg( m_frame, _( "Delete Preset" ), headers, items );
dlg.SetListLabel( _( "Select preset:" ) ); dlg.SetListLabel( _( "Select preset:" ) );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )