From 179f31d377a376dd7c6d95f8e71686ef3b05a5cf Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 10 Dec 2019 23:24:56 +0000 Subject: [PATCH] Add a minimum size to the part column in the lib trees When the column has 0 width, it becomes hidden and users don't know where it went or how to get it back. Fixes https://gitlab.com/kicad/code/kicad/issues/3656 --- common/lib_tree_model_adapter.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index f0dca46c09..d378775f4b 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -216,6 +216,10 @@ void LIB_TREE_MODEL_ADAPTER::AttachTo( wxDataViewCtrl* aDataViewCtrl ) wxString partHead = _( "Item" ); wxString descHead = _( "Description" ); + // The extent of the text doesn't take into account the space on either side + // in the header, so artificially pad it by M + wxSize partHeadMinWidth = GetTextSize( partHead + "M", aDataViewCtrl ); + if( aDataViewCtrl->GetColumnCount() > 0 ) { int partWidth = aDataViewCtrl->GetColumn( PART_COL )->GetWidth(); @@ -240,6 +244,15 @@ void LIB_TREE_MODEL_ADAPTER::AttachTo( wxDataViewCtrl* aDataViewCtrl ) m_colWidths[PART_COL] ); m_col_desc = aDataViewCtrl->AppendTextColumn( descHead, DESC_COL, wxDATAVIEW_CELL_INERT, m_colWidths[DESC_COL] ); + + // Ensure the part column is wider than the smallest allowable width + if( m_colWidths[PART_COL] < partHeadMinWidth.x ) + { + m_colWidths[PART_COL] = partHeadMinWidth.x; + m_col_part->SetWidth( partHeadMinWidth.x ); + } + + m_col_part->SetMinWidth( partHeadMinWidth.x ); }