From f30eab422e0c272f3f4bf28ced51a18996dd9b6b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 23 Feb 2021 17:24:26 +0000 Subject: [PATCH] Don't allow footprint text item columns to be resized. We auto-size them in the code and doing both produces nothing but a mess. Also improves the auto-sizing for the layers drop-down (particularly needed for the new, somewhat longer, layer names. Fixes https://gitlab.com/kicad/code/kicad/issues/7671 --- .../dialog_edit_footprint_for_fp_editor.cpp | 15 ++++++++++++--- pcbnew/dialogs/dialog_footprint_properties.cpp | 13 ++++++++++--- pcbnew/dialogs/dialog_footprint_properties.h | 2 +- .../dialogs/dialog_footprint_properties_base.cpp | 4 ++-- .../dialogs/dialog_footprint_properties_base.fbp | 4 ++-- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index c97ed1a232..a61b96f0f6 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -319,12 +319,21 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow() for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ ) { // Adjust min size to the column label size - m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false, false ) ); - // Adjust the column size. The column 6 has a small bitmap, so its width must be taken in account + m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false, + false ) ); + // Adjust the column size. int col_size = m_itemsGrid->GetVisibleWidth( col, true, true, false ); - if( col == 6 ) + if( col == FPT_LAYER ) // This one's a drop-down. Check all possible values. + { + BOARD* board = m_footprint->GetBoard(); + + for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() ) + col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x ); + + // And the swatch: col_size += 20; + } if( m_itemsGrid->IsColShown( col ) ) m_itemsGrid->SetColSize( col, col_size ); diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index a2519e8a5f..1ffde91b70 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -408,12 +408,19 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow() { m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false, false ) ); - // Adjust the column size. The column 6 has a small bitmap, so its width must be - // taken in account + // Adjust the column size. int col_size = m_itemsGrid->GetVisibleWidth( col, true, true, false ); - if( col == 6 ) + if( col == FPT_LAYER ) // This one's a drop-down. Check all possible values. + { + BOARD* board = m_footprint->GetBoard(); + + for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() ) + col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x ); + + // And the swatch: col_size += 20; + } if( m_itemsGrid->IsColShown( col ) ) m_itemsGrid->SetColSize( col, col_size ); diff --git a/pcbnew/dialogs/dialog_footprint_properties.h b/pcbnew/dialogs/dialog_footprint_properties.h index 8c9eea4012..7a59249f97 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.h +++ b/pcbnew/dialogs/dialog_footprint_properties.h @@ -58,7 +58,7 @@ private: static int m_page; // remember the last open page during session - FP_TEXT_GRID_TABLE* m_texts; + FP_TEXT_GRID_TABLE* m_texts; UNIT_BINDER m_posX; UNIT_BINDER m_posY; wxFloatingPointValidator m_OrientValidator; diff --git a/pcbnew/dialogs/dialog_footprint_properties_base.cpp b/pcbnew/dialogs/dialog_footprint_properties_base.cpp index 80f53886c3..a18bd062f8 100644 --- a/pcbnew/dialogs/dialog_footprint_properties_base.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties_base.cpp @@ -42,13 +42,13 @@ DIALOG_FOOTPRINT_PROPERTIES_BASE::DIALOG_FOOTPRINT_PROPERTIES_BASE( wxWindow* pa m_itemsGrid->SetColSize( 3, 110 ); m_itemsGrid->SetColSize( 4, 110 ); m_itemsGrid->SetColSize( 5, 60 ); - m_itemsGrid->SetColSize( 6, 110 ); + m_itemsGrid->SetColSize( 6, 140 ); m_itemsGrid->SetColSize( 7, 110 ); m_itemsGrid->SetColSize( 8, 110 ); m_itemsGrid->SetColSize( 9, 110 ); m_itemsGrid->SetColSize( 10, 110 ); m_itemsGrid->EnableDragColMove( false ); - m_itemsGrid->EnableDragColSize( true ); + m_itemsGrid->EnableDragColSize( false ); m_itemsGrid->SetColLabelSize( 24 ); m_itemsGrid->SetColLabelValue( 0, _("Text Items") ); m_itemsGrid->SetColLabelValue( 1, _("Show") ); diff --git a/pcbnew/dialogs/dialog_footprint_properties_base.fbp b/pcbnew/dialogs/dialog_footprint_properties_base.fbp index 03dd0aca9f..4e29bf2216 100644 --- a/pcbnew/dialogs/dialog_footprint_properties_base.fbp +++ b/pcbnew/dialogs/dialog_footprint_properties_base.fbp @@ -221,7 +221,7 @@ "Text Items" "Show" "Width" "Height" "Thickness" "Italic" "Layer" "Orientation" "Keep Upright" "X Offset" "Y Offset" wxALIGN_CENTER 11 - 124,60,110,110,110,60,110,110,110,110,110 + 124,60,110,110,110,60,140,110,110,110,110 1 0 @@ -229,7 +229,7 @@ 0 Left 0 - 1 + 0 0 0 1