Rework GERBVIEW_FRAME::ReCreateAuxiliaryToolbar to fix layout issues

Fixes: lp:1745203
* https://bugs.launchpad.net/kicad/+bug/1745203
This commit is contained in:
Jon Evans 2018-01-28 20:30:43 -05:00 committed by jean-pierre charras
parent 1bc3dfef10
commit 14abe8723d
2 changed files with 66 additions and 62 deletions

View File

@ -86,6 +86,9 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_hotkeysDescrList = GerbviewHokeysDescr; m_hotkeysDescrList = GerbviewHokeysDescr;
m_SelLayerBox = NULL; m_SelLayerBox = NULL;
m_DCodeSelector = NULL; m_DCodeSelector = NULL;
m_SelComponentBox = nullptr;
m_SelNetnameBox = nullptr;
m_SelAperAttributesBox = nullptr;
m_displayMode = 0; m_displayMode = 0;
m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 ); m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 );
m_zipFileHistory.SetBaseId( ID_GERBVIEW_ZIP_FILE1 ); m_zipFileHistory.SetBaseId( ID_GERBVIEW_ZIP_FILE1 );
@ -137,13 +140,13 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
m_auimgr.SetManagedWindow( this );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateOptToolbar(); ReCreateOptToolbar();
ReCreateAuxiliaryToolbar(); ReCreateAuxiliaryToolbar();
m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz; EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane(); horiz.HorizontalToolbarPane();

View File

@ -108,80 +108,81 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
{ {
wxWindowUpdateLocker dummy( this ); wxWindowUpdateLocker dummy( this );
wxStaticText* text;
#if 0 if( !m_auxiliaryToolBar )
if( m_auxiliaryToolBar ) m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
// Creates box to display and choose components:
if( !m_SelComponentBox )
{ {
m_SelComponentBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
m_SelComponentBox->SetToolTip( _("Select a component and highlight items belonging to this component") );
}
// Creates choice box to display net names and highlight selected:
if( !m_SelNetnameBox )
{
m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
m_SelNetnameBox->SetToolTip( _("Select a net name and highlight graphic items belonging to this net") );
}
// Creates choice box to display aperture attributes and highlight selected:
if( !m_SelAperAttributesBox )
{
m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
m_SelAperAttributesBox->SetToolTip( _("Select an aperture attribute and highlight graphic items having this attribute") );
}
if( !m_DCodeSelector )
{
m_DCodeSelector = new DCODE_SELECTION_BOX( m_auxiliaryToolBar,
ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
wxDefaultPosition, wxSize( 150, -1 ) );
}
updateComponentListSelectBox(); updateComponentListSelectBox();
updateNetnameListSelectBox(); updateNetnameListSelectBox();
updateAperAttributesSelectBox(); updateAperAttributesSelectBox();
updateDCodeSelectBox(); updateDCodeSelectBox();
// combobox sizes can have changed: apply new best sizes // combobox sizes can have changed: apply new best sizes
wxSize size; m_SelComponentBox->SetMinSize( m_SelComponentBox->GetBestSize() );
size = m_SelComponentBox->GetBestSize(); m_SelNetnameBox->SetMinSize( m_SelNetnameBox->GetBestSize() );
size.x = std::max( size.x, 100 ); m_SelAperAttributesBox->SetMinSize( m_SelAperAttributesBox->GetBestSize() );
m_SelComponentBox->SetMinSize( size );
size = m_SelNetnameBox->GetBestSize(); // Because wxAuiToolBar doesn't actually clear things properly...
size.x = std::max( size.x, 100 ); for( unsigned i = 0; i < m_auxiliaryToolBar->GetToolCount(); ++i )
m_SelNetnameBox->SetMinSize( size ); {
auto item = m_auxiliaryToolBar->FindToolByIndex( i );
auto control = dynamic_cast<wxStaticText*>( item->GetWindow() );
size = m_SelAperAttributesBox->GetBestSize(); if( control )
size.x = std::max( size.x, 100 ); {
m_SelAperAttributesBox->SetMinSize( size ); delete control;
}
size = m_DCodeSelector->GetBestSize();
size.x = std::max( size.x, 100 );
m_DCodeSelector->SetMinSize( size );
m_auimgr.Update();
return;
} }
#endif
if( m_auxiliaryToolBar )
m_auxiliaryToolBar->Clear(); m_auxiliaryToolBar->Clear();
else
m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
// Creates box to display and choose components: text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Cmp:") );
wxStaticText* text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Cmp:") );
m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( text );
m_SelComponentBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE );
m_SelComponentBox->SetToolTip( _("Select a component and highlight items belonging to this component") );
updateComponentListSelectBox();
m_auxiliaryToolBar->AddControl( m_SelComponentBox ); m_auxiliaryToolBar->AddControl( m_SelComponentBox );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_auxiliaryToolBar, this );
// Creates choice box to display net names and highlight selected:
text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Net:") ); text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Net:") );
m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( text );
m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE );
m_SelNetnameBox->SetToolTip( _("Select a net name and highlight graphic items belonging to this net") );
m_auxiliaryToolBar->AddControl( m_SelNetnameBox ); m_auxiliaryToolBar->AddControl( m_SelNetnameBox );
updateNetnameListSelectBox(); KiScaledSeparator( m_auxiliaryToolBar, this );
KiScaledSeparator( m_mainToolBar, this );
// Creates choice box to display aperture attributes and highlight selected:
text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Attr:") ); text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("Attr:") );
m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( text );
m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar,
ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
m_SelAperAttributesBox->SetToolTip( _("Select an aperture attribute and highlight graphic items having this attribute") );
m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox ); m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox );
updateAperAttributesSelectBox(); KiScaledSeparator( m_auxiliaryToolBar, this );
KiScaledSeparator( m_mainToolBar, this );
text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("DCode:") ); text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _("DCode:") );
m_auxiliaryToolBar->AddControl( text ); m_auxiliaryToolBar->AddControl( text );
m_DCodeSelector = new DCODE_SELECTION_BOX( m_auxiliaryToolBar,
ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE,
wxDefaultPosition, wxSize( 150, -1 ) );
updateDCodeSelectBox();
m_auxiliaryToolBar->AddControl( m_DCodeSelector ); m_auxiliaryToolBar->AddControl( m_DCodeSelector );
// after adding the buttons to the toolbar, must call Realize() // after adding the buttons to the toolbar, must call Realize()