Browse Source

PCM: remove redundant calculations on resize

7.0
canwail 3 years ago
committed by Seth Hillbrand
parent
commit
c44b15e9f5
  1. 24
      kicad/pcm/dialogs/panel_package.cpp

24
kicad/pcm/dialogs/panel_package.cpp

@ -49,28 +49,24 @@ PANEL_PACKAGE::PANEL_PACKAGE( wxWindow* parent, const ActionCallback& aCallback,
m_minHeight = GetMinHeight();
wxSizeEvent dummy;
OnSize( dummy );
SetState( m_data.state );
}
void PANEL_PACKAGE::OnSize( wxSizeEvent& event )
{
Layout();
int nameLineHeight = m_name->GetTextExtent( "X" ).GetHeight();
double descLineHeight = m_desc->GetTextExtent( "X" ).GetHeight() * 1.2 /* leading */;
m_desc->SetLabel( m_data.package.description );
m_desc->Wrap( m_desc->GetClientSize().GetWidth() - 10 );
descLineHeight = wxSplit( m_desc->GetLabel(), '\n' ).size() * descLineHeight;
int nameLineHeight = m_name->GetTextExtent( "X" ).GetHeight();
wxSize minSize = GetMinSize();
minSize.y = std::max( nameLineHeight + KiROUND( descLineHeight ) + 15, m_minHeight );
SetMinSize( minSize );
wxSizeEvent dummy;
OnSize( dummy );
SetState( m_data.state );
}
void PANEL_PACKAGE::OnSize( wxSizeEvent& event )
{
Layout();
}

Loading…
Cancel
Save