Lazy loading of stackup UI widgets.
(cherry picked from commit 9481a218c7
)
This commit is contained in:
parent
f35ed59868
commit
00a82905ec
|
@ -717,20 +717,26 @@ void PANEL_SETUP_BOARD_STACKUP::showOnlyActiveLayers()
|
||||||
|
|
||||||
ui_row_item.m_isEnabled = show_item;
|
ui_row_item.m_isEnabled = show_item;
|
||||||
|
|
||||||
// Show or not items of this row:
|
if( show_item && !ui_row_item.m_Icon )
|
||||||
ui_row_item.m_Icon->Show( show_item );
|
lazyBuildRowUI( ui_row_item );
|
||||||
ui_row_item.m_LayerName->Show( show_item );
|
|
||||||
ui_row_item.m_LayerTypeCtrl->Show( show_item );
|
|
||||||
ui_row_item.m_MaterialCtrl->Show( show_item );
|
|
||||||
|
|
||||||
if( ui_row_item.m_MaterialButt )
|
if( ui_row_item.m_Icon )
|
||||||
ui_row_item.m_MaterialButt->Show( show_item );
|
{
|
||||||
|
// Show or not items of this row:
|
||||||
|
ui_row_item.m_Icon->Show( show_item );
|
||||||
|
ui_row_item.m_LayerName->Show( show_item );
|
||||||
|
ui_row_item.m_LayerTypeCtrl->Show( show_item );
|
||||||
|
ui_row_item.m_MaterialCtrl->Show( show_item );
|
||||||
|
|
||||||
ui_row_item.m_ThicknessCtrl->Show( show_item );
|
if( ui_row_item.m_MaterialButt )
|
||||||
ui_row_item.m_ThicknessLockCtrl->Show( show_item );
|
ui_row_item.m_MaterialButt->Show( show_item );
|
||||||
ui_row_item.m_ColorCtrl->Show( show_item );
|
|
||||||
ui_row_item.m_EpsilonCtrl->Show( show_item );
|
ui_row_item.m_ThicknessCtrl->Show( show_item );
|
||||||
ui_row_item.m_LossTgCtrl->Show( show_item );
|
ui_row_item.m_ThicknessLockCtrl->Show( show_item );
|
||||||
|
ui_row_item.m_ColorCtrl->Show( show_item );
|
||||||
|
ui_row_item.m_EpsilonCtrl->Show( show_item );
|
||||||
|
ui_row_item.m_LossTgCtrl->Show( show_item );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,16 +781,11 @@ wxControl* PANEL_SETUP_BOARD_STACKUP::addSpacer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
void PANEL_SETUP_BOARD_STACKUP::lazyBuildRowUI( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item )
|
||||||
BOARD_STACKUP_ITEM* aStackupItem,
|
|
||||||
int aSublayerIdx )
|
|
||||||
{
|
{
|
||||||
wxASSERT( aStackupItem );
|
BOARD_STACKUP_ITEM* item = ui_row_item.m_Item;
|
||||||
wxASSERT( aSublayerIdx >= 0 && aSublayerIdx < aStackupItem->GetSublayersCount() );
|
int sublayerIdx = ui_row_item.m_SubItem;
|
||||||
|
int row = ui_row_item.m_Row;
|
||||||
BOARD_STACKUP_ROW_UI_ITEM ui_row_item( aStackupItem, aSublayerIdx );
|
|
||||||
BOARD_STACKUP_ITEM* item = aStackupItem;
|
|
||||||
int row = aRow;
|
|
||||||
|
|
||||||
// Add color swatch icon. The color will be updated later,
|
// Add color swatch icon. The color will be updated later,
|
||||||
// when all widgets are initialized
|
// when all widgets are initialized
|
||||||
|
@ -792,15 +793,13 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
m_fgGridSizer->Add( bitmap, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 4 );
|
m_fgGridSizer->Add( bitmap, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 4 );
|
||||||
ui_row_item.m_Icon = bitmap;
|
ui_row_item.m_Icon = bitmap;
|
||||||
|
|
||||||
ui_row_item.m_isEnabled = true;
|
|
||||||
|
|
||||||
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
||||||
{
|
{
|
||||||
wxString lname = item->FormatDielectricLayerName();
|
wxString lname = item->FormatDielectricLayerName();
|
||||||
|
|
||||||
if( item->GetSublayersCount() > 1 )
|
if( item->GetSublayersCount() > 1 )
|
||||||
{
|
{
|
||||||
lname << wxT( " (" ) << aSublayerIdx+1 << wxT( "/" )
|
lname << wxT( " (" ) << sublayerIdx +1 << wxT( "/" )
|
||||||
<< item->GetSublayersCount() << wxT( ")" );
|
<< item->GetSublayersCount() << wxT( ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,8 +808,8 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
ui_row_item.m_LayerName = st_text;
|
ui_row_item.m_LayerName = st_text;
|
||||||
|
|
||||||
// For a dielectric layer, the layer type choice is not for each sublayer,
|
// For a dielectric layer, the layer type choice is not for each sublayer,
|
||||||
// only for the first (aSublayerIdx = 0), and is common to all sublayers
|
// only for the first (sublayerIdx = 0), and is common to all sublayers
|
||||||
if( aSublayerIdx == 0 )
|
if( sublayerIdx == 0 )
|
||||||
{
|
{
|
||||||
wxChoice* choice = new wxChoice( m_scGridWin, wxID_ANY, wxDefaultPosition,
|
wxChoice* choice = new wxChoice( m_scGridWin, wxID_ANY, wxDefaultPosition,
|
||||||
wxDefaultSize, m_core_prepreg_choice );
|
wxDefaultSize, m_core_prepreg_choice );
|
||||||
|
@ -846,7 +845,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
|
|
||||||
if( item->IsMaterialEditable() )
|
if( item->IsMaterialEditable() )
|
||||||
{
|
{
|
||||||
wxString matName = item->GetMaterial( aSublayerIdx );
|
wxString matName = item->GetMaterial( sublayerIdx );
|
||||||
addMaterialChooser( ID_ITEM_MATERIAL+row, &matName, ui_row_item );
|
addMaterialChooser( ID_ITEM_MATERIAL+row, &matName, ui_row_item );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -858,7 +857,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
{
|
{
|
||||||
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row );
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row );
|
||||||
textCtrl->SetMinSize( m_numericTextCtrlSize );
|
textCtrl->SetMinSize( m_numericTextCtrlSize );
|
||||||
textCtrl->ChangeValue( m_frame->StringFromValue( item->GetThickness( aSublayerIdx ), true ) );
|
textCtrl->ChangeValue( m_frame->StringFromValue( item->GetThickness( sublayerIdx ), true ) );
|
||||||
m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 );
|
||||||
m_controlItemsList.push_back( textCtrl );
|
m_controlItemsList.push_back( textCtrl );
|
||||||
textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
|
textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED,
|
||||||
|
@ -870,7 +869,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
{
|
{
|
||||||
wxCheckBox* cb_box = new wxCheckBox( m_scGridWin, ID_ITEM_THICKNESS_LOCKED+row,
|
wxCheckBox* cb_box = new wxCheckBox( m_scGridWin, ID_ITEM_THICKNESS_LOCKED+row,
|
||||||
wxEmptyString );
|
wxEmptyString );
|
||||||
cb_box->SetValue( item->IsThicknessLocked( aSublayerIdx ) );
|
cb_box->SetValue( item->IsThicknessLocked( sublayerIdx ) );
|
||||||
m_fgGridSizer->Add( cb_box, 0, wxALIGN_CENTER_VERTICAL, 2 );
|
m_fgGridSizer->Add( cb_box, 0, wxALIGN_CENTER_VERTICAL, 2 );
|
||||||
ui_row_item.m_ThicknessLockCtrl = cb_box;
|
ui_row_item.m_ThicknessLockCtrl = cb_box;
|
||||||
}
|
}
|
||||||
|
@ -887,9 +886,9 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
|
|
||||||
if( item->IsColorEditable() )
|
if( item->IsColorEditable() )
|
||||||
{
|
{
|
||||||
if( item->GetColor( aSublayerIdx ).StartsWith( wxT( "#" ) ) ) // User defined color
|
if( item->GetColor( sublayerIdx ).StartsWith( wxT( "#" ) ) ) // User defined color
|
||||||
{
|
{
|
||||||
ui_row_item.m_UserColor = COLOR4D( item->GetColor( aSublayerIdx ) ).ToColour();
|
ui_row_item.m_UserColor = COLOR4D( item->GetColor( sublayerIdx ) ).ToColour();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ui_row_item.m_UserColor = GetDefaultUserColor( item->GetType() );
|
ui_row_item.m_UserColor = GetDefaultUserColor( item->GetType() );
|
||||||
|
@ -899,17 +898,17 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
|
|
||||||
m_fgGridSizer->Add( bm_combo, 1, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 2 );
|
m_fgGridSizer->Add( bm_combo, 1, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 2 );
|
||||||
|
|
||||||
if( item->GetColor( aSublayerIdx ).StartsWith( wxT( "#" ) ) )
|
if( item->GetColor( sublayerIdx ).StartsWith( wxT( "#" ) ) )
|
||||||
{
|
{
|
||||||
selected = GetColorUserDefinedListIdx( item->GetType() );
|
selected = GetColorUserDefinedListIdx( item->GetType() );
|
||||||
bm_combo->SetString( selected, item->GetColor( aSublayerIdx ) );
|
bm_combo->SetString( selected, item->GetColor( sublayerIdx ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Note: don't use bm_combo->FindString() because the combo strings are translated.
|
// Note: don't use bm_combo->FindString() because the combo strings are translated.
|
||||||
for( size_t ii = 0; ii < GetStandardColors( item->GetType() ).size(); ii++ )
|
for( size_t ii = 0; ii < GetStandardColors( item->GetType() ).size(); ii++ )
|
||||||
{
|
{
|
||||||
if( GetStandardColorName( item->GetType(), ii ) == item->GetColor( aSublayerIdx ) )
|
if( GetStandardColorName( item->GetType(), ii ) == item->GetColor( sublayerIdx ) )
|
||||||
{
|
{
|
||||||
selected = ii;
|
selected = ii;
|
||||||
break;
|
break;
|
||||||
|
@ -927,7 +926,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
|
|
||||||
if( item->HasEpsilonRValue() )
|
if( item->HasEpsilonRValue() )
|
||||||
{
|
{
|
||||||
wxString txt = UIDouble2Str( item->GetEpsilonR( aSublayerIdx ) );
|
wxString txt = UIDouble2Str( item->GetEpsilonR( sublayerIdx ) );
|
||||||
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
||||||
wxDefaultPosition, m_numericFieldsSize );
|
wxDefaultPosition, m_numericFieldsSize );
|
||||||
textCtrl->ChangeValue( txt );
|
textCtrl->ChangeValue( txt );
|
||||||
|
@ -941,7 +940,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
|
|
||||||
if( item->HasLossTangentValue() )
|
if( item->HasLossTangentValue() )
|
||||||
{
|
{
|
||||||
wxString txt = UIDouble2Str( item->GetLossTangent( aSublayerIdx ) );;
|
wxString txt = UIDouble2Str( item->GetLossTangent( sublayerIdx ) );;
|
||||||
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, wxID_ANY, wxEmptyString,
|
||||||
wxDefaultPosition, m_numericFieldsSize );
|
wxDefaultPosition, m_numericFieldsSize );
|
||||||
textCtrl->ChangeValue( txt );
|
textCtrl->ChangeValue( txt );
|
||||||
|
@ -952,8 +951,6 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
|
||||||
{
|
{
|
||||||
ui_row_item.m_LossTgCtrl = addSpacer();
|
ui_row_item.m_LossTgCtrl = addSpacer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ui_row_item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -973,7 +970,8 @@ void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel( bool aRelinkItems )
|
||||||
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item: m_rowUiItemsList )
|
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item: m_rowUiItemsList )
|
||||||
{
|
{
|
||||||
// This remove and delete the current ui_item.m_MaterialCtrl sizer
|
// This remove and delete the current ui_item.m_MaterialCtrl sizer
|
||||||
ui_item.m_MaterialCtrl->SetSizer( nullptr );
|
if( ui_item.m_MaterialCtrl )
|
||||||
|
ui_item.m_MaterialCtrl->SetSizer( nullptr );
|
||||||
|
|
||||||
// Delete other widgets
|
// Delete other widgets
|
||||||
delete ui_item.m_Icon; // Color icon in first column (column 1)
|
delete ui_item.m_Icon; // Color icon in first column (column 1)
|
||||||
|
@ -1020,6 +1018,8 @@ void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel( bool aRelinkItems )
|
||||||
// Now enable/disable stackup items, according to the m_enabledLayers config
|
// Now enable/disable stackup items, according to the m_enabledLayers config
|
||||||
showOnlyActiveLayers();
|
showOnlyActiveLayers();
|
||||||
|
|
||||||
|
updateIconColor();
|
||||||
|
|
||||||
m_scGridWin->Layout();
|
m_scGridWin->Layout();
|
||||||
m_scGridWin->Show();
|
m_scGridWin->Show();
|
||||||
}
|
}
|
||||||
|
@ -1079,14 +1079,10 @@ void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreateInitialStackup
|
||||||
{
|
{
|
||||||
for( int sub_idx = 0; sub_idx < item->GetSublayersCount(); sub_idx++ )
|
for( int sub_idx = 0; sub_idx < item->GetSublayersCount(); sub_idx++ )
|
||||||
{
|
{
|
||||||
BOARD_STACKUP_ROW_UI_ITEM ui_row_item = createRowData( row, item, sub_idx );
|
m_rowUiItemsList.emplace_back( item, sub_idx, row );
|
||||||
m_rowUiItemsList.emplace_back( ui_row_item );
|
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateIconColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1578,9 +1574,12 @@ void PANEL_SETUP_BOARD_STACKUP::updateIconColor( int aRow )
|
||||||
|
|
||||||
for( unsigned row = 0; row < m_rowUiItemsList.size(); row++ )
|
for( unsigned row = 0; row < m_rowUiItemsList.size(); row++ )
|
||||||
{
|
{
|
||||||
wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, bitmap_depth );
|
if( m_rowUiItemsList[row].m_Icon )
|
||||||
drawBitmap( bmp, getColorIconItem( row ) );
|
{
|
||||||
m_rowUiItemsList[row].m_Icon->SetBitmap( bmp );
|
wxBitmap bmp( m_colorIconsSize.x, m_colorIconsSize.y / 2, bitmap_depth );
|
||||||
|
drawBitmap( bmp, getColorIconItem( row ) );
|
||||||
|
m_rowUiItemsList[row].m_Icon->SetBitmap( bmp );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct BOARD_STACKUP_ROW_UI_ITEM
|
||||||
int m_SubItem; // For multilayer dielectric, the index in sublayer list.
|
int m_SubItem; // For multilayer dielectric, the index in sublayer list.
|
||||||
// Must be >= 0 and < m_Item sublayer count. Used only for dielectic
|
// Must be >= 0 and < m_Item sublayer count. Used only for dielectic
|
||||||
// 0 is the base list of parameters (always existing)
|
// 0 is the base list of parameters (always existing)
|
||||||
|
int m_Row; // The row number in the parent grid
|
||||||
bool m_isEnabled; // True if the row is in board
|
bool m_isEnabled; // True if the row is in board
|
||||||
// false if not (this row is not shown on the panel)
|
// false if not (this row is not shown on the panel)
|
||||||
wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
|
wxStaticBitmap* m_Icon; // Color icon in first column (column 1)
|
||||||
|
@ -66,10 +67,11 @@ struct BOARD_STACKUP_ROW_UI_ITEM
|
||||||
|
|
||||||
COLOR4D m_UserColor; // User-specified color (if any)
|
COLOR4D m_UserColor; // User-specified color (if any)
|
||||||
|
|
||||||
BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem = 1 ) :
|
BOARD_STACKUP_ROW_UI_ITEM( BOARD_STACKUP_ITEM* aItem, int aSubItem, int aRow ) :
|
||||||
m_Item( aItem ),
|
m_Item( aItem ),
|
||||||
m_SubItem( aSubItem ),
|
m_SubItem( aSubItem ),
|
||||||
m_isEnabled( true ),
|
m_Row( aRow ),
|
||||||
|
m_isEnabled( false ),
|
||||||
m_Icon( nullptr ),
|
m_Icon( nullptr ),
|
||||||
m_LayerName( nullptr ),
|
m_LayerName( nullptr ),
|
||||||
m_LayerTypeCtrl( nullptr ),
|
m_LayerTypeCtrl( nullptr ),
|
||||||
|
@ -116,7 +118,7 @@ public:
|
||||||
bool TransferDataFromWindow() override;
|
bool TransferDataFromWindow() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Creates a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.
|
/** Creates the controls in a BOARD_STACKUP_ROW_UI_ITEM relative to the aStackupItem.
|
||||||
* @return a BOARD_STACKUP_ROW_UI_ITEM filled with corresponding widgets
|
* @return a BOARD_STACKUP_ROW_UI_ITEM filled with corresponding widgets
|
||||||
* @param aRow is the row index in the row list
|
* @param aRow is the row index in the row list
|
||||||
* @param aStackupItem is the stackup item controlled by the created
|
* @param aStackupItem is the stackup item controlled by the created
|
||||||
|
@ -125,8 +127,7 @@ private:
|
||||||
* this is the index of the sublayer to used inside aStackupItem
|
* this is the index of the sublayer to used inside aStackupItem
|
||||||
* (from 0 to sub layer count - 1)
|
* (from 0 to sub layer count - 1)
|
||||||
*/
|
*/
|
||||||
BOARD_STACKUP_ROW_UI_ITEM createRowData( int aRow, BOARD_STACKUP_ITEM* aStackupItem,
|
void lazyBuildRowUI( BOARD_STACKUP_ROW_UI_ITEM& ui_row_item );
|
||||||
int aSublayerIdx );
|
|
||||||
|
|
||||||
/** add a Spacer in m_fgGridSizer when a empty cell is needed
|
/** add a Spacer in m_fgGridSizer when a empty cell is needed
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue