Fix library tree column widths when tree is refreshed
GTK only calculates new widths once the tree is displayed, so calling Refresh after updating the tree but before display will return a column width of 0. Instead, use saved column widths if an invalid width was returned. Fixes https://gitlab.com/kicad/code/kicad/issues/4837
This commit is contained in:
parent
53bbf69466
commit
4cd0ec8808
|
@ -403,8 +403,22 @@ void LIB_TREE_MODEL_ADAPTER::RefreshTree()
|
|||
// user's scroll position (which re-attaching or deleting/re-inserting columns does).
|
||||
static int walk = 1;
|
||||
|
||||
m_col_part->SetWidth( m_col_part->GetWidth() + walk );
|
||||
m_col_desc->SetWidth( m_col_desc->GetWidth() - walk );
|
||||
int partWidth = m_col_part->GetWidth();
|
||||
int descWidth = m_col_desc->GetWidth();
|
||||
|
||||
// Only use the widths read back if they are non-zero.
|
||||
// GTK returns the displayed width of the column, which is not calculated immediately
|
||||
if( descWidth > 0 )
|
||||
{
|
||||
m_colWidths[PART_COL] = partWidth;
|
||||
m_colWidths[DESC_COL] = descWidth;
|
||||
}
|
||||
|
||||
m_colWidths[PART_COL] += walk;
|
||||
m_colWidths[DESC_COL] -= walk;
|
||||
|
||||
m_col_part->SetWidth( m_colWidths[PART_COL] );
|
||||
m_col_desc->SetWidth( m_colWidths[DESC_COL] );
|
||||
walk = -walk;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue