PCM: remove redundant calculations on resize

This commit is contained in:
canwail 2022-05-17 01:39:27 +02:00 committed by Seth Hillbrand
parent 03152b6e18
commit c44b15e9f5
1 changed files with 10 additions and 14 deletions

View File

@ -49,6 +49,15 @@ PANEL_PACKAGE::PANEL_PACKAGE( wxWindow* parent, const ActionCallback& aCallback,
m_minHeight = GetMinHeight();
double descLineHeight = m_desc->GetTextExtent( "X" ).GetHeight() * 1.2 /* leading */;
m_desc->SetLabel( m_data.package.description );
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 );
@ -59,19 +68,6 @@ PANEL_PACKAGE::PANEL_PACKAGE( wxWindow* parent, const ActionCallback& aCallback,
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;
wxSize minSize = GetMinSize();
minSize.y = std::max( nameLineHeight + KiROUND( descLineHeight ) + 15, m_minHeight );
SetMinSize( minSize );
Layout();
}