From e7300ffb5c0f80df632911abead42b2d5852aafb Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 28 Dec 2022 16:27:03 +0000 Subject: [PATCH] Improved column sizing in library setup dialogs. --- eeschema/dialogs/panel_sym_lib_table.cpp | 23 ++++++----- eeschema/dialogs/panel_sym_lib_table_base.cpp | 38 ++++++++++++++++--- eeschema/dialogs/panel_sym_lib_table_base.fbp | 22 +++++------ pcbnew/dialogs/panel_fp_lib_table.cpp | 21 ++++++---- pcbnew/dialogs/panel_fp_lib_table_base.cpp | 36 +++++++++++++++--- pcbnew/dialogs/panel_fp_lib_table_base.fbp | 28 +++++++------- pcbnew/dialogs/panel_fp_lib_table_base.h | 2 +- 7 files changed, 116 insertions(+), 54 deletions(-) diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index ee90886565..c34bb47d11 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -224,6 +224,15 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, P m_lastProjectLibDir = m_project->GetProjectPath(); + auto autoSizeCol = + [&]( WX_GRID* aGrid, int aCol ) + { + int prevWidth = aGrid->GetColSize( aCol ); + + aGrid->AutoSizeColumn( aCol, false ); + aGrid->SetColSize( aCol, std::max( prevWidth, aGrid->GetColSize( aCol ) ) ); + }; + auto setupGrid = [&]( WX_GRID* aGrid ) { @@ -234,7 +243,6 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, P aGrid->PushEventHandler( new SYMBOL_GRID_TRICKS( m_parent, aGrid ) ); aGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); - aGrid->AutoSizeColumns( false ); // Set special attributes wxGridCellAttr* attr; @@ -264,14 +272,11 @@ PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, P aGrid->SetColAttr( COL_VISIBLE, attr ); // all but COL_OPTIONS, which is edited with Option Editor anyways. - aGrid->AutoSizeColumn( COL_NICKNAME, false ); - aGrid->AutoSizeColumn( COL_TYPE, false ); - aGrid->AutoSizeColumn( COL_URI, false ); - aGrid->AutoSizeColumn( COL_DESCR, false ); - aGrid->AutoSizeColumn( COL_ENABLED, false ); - - // would set this to width of title, if it was easily known. - aGrid->SetColSize( COL_OPTIONS, 80 ); + autoSizeCol( aGrid, COL_NICKNAME ); + autoSizeCol( aGrid, COL_TYPE ); + autoSizeCol( aGrid, COL_URI ); + autoSizeCol( aGrid, COL_DESCR ); + autoSizeCol( aGrid, COL_ENABLED ); // Gives a selection to each grid, mainly for delete button. wxGrid's wake up with // a currentCell which is sometimes not highlighted. diff --git a/eeschema/dialogs/panel_sym_lib_table_base.cpp b/eeschema/dialogs/panel_sym_lib_table_base.cpp index af2b73b520..42c424654d 100644 --- a/eeschema/dialogs/panel_sym_lib_table_base.cpp +++ b/eeschema/dialogs/panel_sym_lib_table_base.cpp @@ -21,8 +21,6 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_top_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Libraries by Scope") ), wxVERTICAL ); m_notebook = new wxNotebook( m_top_sizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - m_notebook->SetMinSize( wxSize( 400,-1 ) ); - m_global_panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* m_global_sizer; m_global_sizer = new wxBoxSizer( wxVERTICAL ); @@ -30,16 +28,29 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_global_grid = new WX_GRID( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_global_grid->CreateGrid( 1, 5 ); + m_global_grid->CreateGrid( 1, 7 ); m_global_grid->EnableEditing( true ); m_global_grid->EnableGridLines( true ); m_global_grid->EnableDragGridSize( false ); m_global_grid->SetMargins( 0, 0 ); // Columns - m_global_grid->AutoSizeColumns(); + m_global_grid->SetColSize( 0, 48 ); + m_global_grid->SetColSize( 1, 48 ); + m_global_grid->SetColSize( 2, 100 ); + m_global_grid->SetColSize( 3, 240 ); + m_global_grid->SetColSize( 4, 100 ); + m_global_grid->SetColSize( 5, 80 ); + m_global_grid->SetColSize( 6, 240 ); m_global_grid->EnableDragColMove( false ); m_global_grid->EnableDragColSize( true ); + m_global_grid->SetColLabelValue( 0, _("Active") ); + m_global_grid->SetColLabelValue( 1, _("Visible") ); + m_global_grid->SetColLabelValue( 2, _("Nickname") ); + m_global_grid->SetColLabelValue( 3, _("Library Path") ); + m_global_grid->SetColLabelValue( 4, _("LIbrary Format") ); + m_global_grid->SetColLabelValue( 5, _("Options") ); + m_global_grid->SetColLabelValue( 6, _("Description") ); m_global_grid->SetColLabelSize( 22 ); m_global_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); @@ -67,16 +78,29 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID m_project_grid = new WX_GRID( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_project_grid->CreateGrid( 1, 5 ); + m_project_grid->CreateGrid( 1, 7 ); m_project_grid->EnableEditing( true ); m_project_grid->EnableGridLines( true ); m_project_grid->EnableDragGridSize( false ); m_project_grid->SetMargins( 0, 0 ); // Columns - m_project_grid->AutoSizeColumns(); + m_project_grid->SetColSize( 0, 48 ); + m_project_grid->SetColSize( 1, 48 ); + m_project_grid->SetColSize( 2, 100 ); + m_project_grid->SetColSize( 3, 240 ); + m_project_grid->SetColSize( 4, 100 ); + m_project_grid->SetColSize( 5, 80 ); + m_project_grid->SetColSize( 6, 240 ); m_project_grid->EnableDragColMove( false ); m_project_grid->EnableDragColSize( true ); + m_project_grid->SetColLabelValue( 0, _("Active") ); + m_project_grid->SetColLabelValue( 1, _("Visible") ); + m_project_grid->SetColLabelValue( 2, _("Nickname") ); + m_project_grid->SetColLabelValue( 3, _("Library Path") ); + m_project_grid->SetColLabelValue( 4, _("LIbrary Format") ); + m_project_grid->SetColLabelValue( 5, _("Options") ); + m_project_grid->SetColLabelValue( 6, _("Description") ); m_project_grid->SetColLabelSize( 22 ); m_project_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); @@ -89,6 +113,8 @@ PANEL_SYM_LIB_TABLE_BASE::PANEL_SYM_LIB_TABLE_BASE( wxWindow* parent, wxWindowID // Cell Defaults m_project_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_project_grid->SetMinSize( wxSize( 600,-1 ) ); + m_project_sizer->Add( m_project_grid, 2, wxALL|wxEXPAND, 5 ); diff --git a/eeschema/dialogs/panel_sym_lib_table_base.fbp b/eeschema/dialogs/panel_sym_lib_table_base.fbp index 767269bda7..4f40c3ef08 100644 --- a/eeschema/dialogs/panel_sym_lib_table_base.fbp +++ b/eeschema/dialogs/panel_sym_lib_table_base.fbp @@ -42,7 +42,7 @@ 0 wxID_ANY - + -1,-1 PANEL_SYM_LIB_TABLE_BASE -1,-1 @@ -108,7 +108,7 @@ 0 - 400,-1 + -1,-1 1 m_notebook 1 @@ -200,7 +200,7 @@ - 1 + 0 1 @@ -215,10 +215,10 @@ 1 wxALIGN_CENTER 22 - + "Active" "Visible" "Nickname" "Library Path" "LIbrary Format" "Options" "Description" wxALIGN_CENTER - 5 - + 7 + 48,48,100,240,100,80,240 1 0 @@ -351,7 +351,7 @@ - 1 + 0 0 @@ -366,10 +366,10 @@ 1 wxALIGN_CENTER 22 - + "Active" "Visible" "Nickname" "Library Path" "LIbrary Format" "Options" "Description" wxALIGN_CENTER - 5 - + 7 + 48,48,100,240,100,80,240 1 0 @@ -400,7 +400,7 @@ 0 - + 600,-1 0 m_project_grid 1 diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index eb8548cc8e..151418eb11 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -391,6 +391,15 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, m_lastProjectLibDir = m_projectBasePath; + auto autoSizeCol = + [&]( WX_GRID* aGrid, int aCol ) + { + int prevWidth = aGrid->GetColSize( aCol ); + + aGrid->AutoSizeColumn( aCol, false ); + aGrid->SetColSize( aCol, std::max( prevWidth, aGrid->GetColSize( aCol ) ) ); + }; + auto setupGrid = [&]( WX_GRID* aGrid ) { @@ -401,7 +410,6 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, aGrid->PushEventHandler( new FP_GRID_TRICKS( m_parent, aGrid ) ); aGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); - aGrid->AutoSizeColumns( false ); wxGridCellAttr* attr; @@ -427,13 +435,10 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, aGrid->HideCol( COL_VISIBLE ); // all but COL_OPTIONS, which is edited with Option Editor anyways. - aGrid->AutoSizeColumn( COL_NICKNAME, false ); - aGrid->AutoSizeColumn( COL_TYPE, false ); - aGrid->AutoSizeColumn( COL_URI, false ); - aGrid->AutoSizeColumn( COL_DESCR, false ); - - // would set this to width of title, if it was easily known. - aGrid->SetColSize( COL_OPTIONS, 80 ); + autoSizeCol( aGrid, COL_NICKNAME ); + autoSizeCol( aGrid, COL_TYPE ); + autoSizeCol( aGrid, COL_URI ); + autoSizeCol( aGrid, COL_DESCR ); // Gives a selection to each grid, mainly for delete button. wxGrid's wake up with // a currentCell which is sometimes not highlighted. diff --git a/pcbnew/dialogs/panel_fp_lib_table_base.cpp b/pcbnew/dialogs/panel_fp_lib_table_base.cpp index 079f2df2e4..a381d23c48 100644 --- a/pcbnew/dialogs/panel_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -28,16 +28,29 @@ PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID i m_global_grid = new WX_GRID( m_global_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_global_grid->CreateGrid( 1, 5 ); + m_global_grid->CreateGrid( 1, 7 ); m_global_grid->EnableEditing( true ); m_global_grid->EnableGridLines( true ); m_global_grid->EnableDragGridSize( false ); m_global_grid->SetMargins( 0, 0 ); // Columns - m_global_grid->AutoSizeColumns(); + m_global_grid->SetColSize( 0, 48 ); + m_global_grid->SetColSize( 1, 48 ); + m_global_grid->SetColSize( 2, 100 ); + m_global_grid->SetColSize( 3, 240 ); + m_global_grid->SetColSize( 4, 100 ); + m_global_grid->SetColSize( 5, 80 ); + m_global_grid->SetColSize( 6, 240 ); m_global_grid->EnableDragColMove( false ); m_global_grid->EnableDragColSize( true ); + m_global_grid->SetColLabelValue( 0, _("Active") ); + m_global_grid->SetColLabelValue( 1, _("Visible") ); + m_global_grid->SetColLabelValue( 2, _("Nickname") ); + m_global_grid->SetColLabelValue( 3, _("Library Path") ); + m_global_grid->SetColLabelValue( 4, _("LIbrary Format") ); + m_global_grid->SetColLabelValue( 5, _("Options") ); + m_global_grid->SetColLabelValue( 6, _("Description") ); m_global_grid->SetColLabelSize( 22 ); m_global_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); @@ -64,16 +77,29 @@ PANEL_FP_LIB_TABLE_BASE::PANEL_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID i m_project_grid = new WX_GRID( m_project_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_project_grid->CreateGrid( 1, 5 ); + m_project_grid->CreateGrid( 1, 7 ); m_project_grid->EnableEditing( true ); m_project_grid->EnableGridLines( true ); m_project_grid->EnableDragGridSize( false ); m_project_grid->SetMargins( 0, 0 ); // Columns - m_project_grid->AutoSizeColumns(); + m_project_grid->SetColSize( 0, 48 ); + m_project_grid->SetColSize( 1, 48 ); + m_project_grid->SetColSize( 2, 100 ); + m_project_grid->SetColSize( 3, 240 ); + m_project_grid->SetColSize( 4, 100 ); + m_project_grid->SetColSize( 5, 80 ); + m_project_grid->SetColSize( 6, 240 ); m_project_grid->EnableDragColMove( false ); m_project_grid->EnableDragColSize( true ); + m_project_grid->SetColLabelValue( 0, _("Active") ); + m_project_grid->SetColLabelValue( 1, _("Visible") ); + m_project_grid->SetColLabelValue( 2, _("Nickname") ); + m_project_grid->SetColLabelValue( 3, _("Library Path") ); + m_project_grid->SetColLabelValue( 4, _("LIbrary Format") ); + m_project_grid->SetColLabelValue( 5, _("Options") ); + m_project_grid->SetColLabelValue( 6, _("Description") ); m_project_grid->SetColLabelSize( 22 ); m_project_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); diff --git a/pcbnew/dialogs/panel_fp_lib_table_base.fbp b/pcbnew/dialogs/panel_fp_lib_table_base.fbp index 39cb19fa5a..c7018bfc38 100644 --- a/pcbnew/dialogs/panel_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/panel_fp_lib_table_base.fbp @@ -127,11 +127,11 @@ - + Global Libraries 1 - + 1 1 1 @@ -182,7 +182,7 @@ wxTAB_TRAVERSAL - + m_global_sizer wxVERTICAL @@ -200,7 +200,7 @@ - 1 + 0 0 @@ -215,10 +215,10 @@ 1 wxALIGN_CENTER 22 - + "Active" "Visible" "Nickname" "Library Path" "LIbrary Format" "Options" "Description" wxALIGN_CENTER - 5 - + 7 + 48,48,100,240,100,80,240 1 0 @@ -278,11 +278,11 @@ - + Project Specific Libraries 0 - + 1 1 1 @@ -333,7 +333,7 @@ wxTAB_TRAVERSAL - + m_project_sizer wxVERTICAL @@ -351,7 +351,7 @@ - 1 + 0 0 @@ -366,10 +366,10 @@ 1 wxALIGN_CENTER 22 - + "Active" "Visible" "Nickname" "Library Path" "LIbrary Format" "Options" "Description" wxALIGN_CENTER - 5 - + 7 + 48,48,100,240,100,80,240 1 0 diff --git a/pcbnew/dialogs/panel_fp_lib_table_base.h b/pcbnew/dialogs/panel_fp_lib_table_base.h index c363643529..019e17bb70 100644 --- a/pcbnew/dialogs/panel_fp_lib_table_base.h +++ b/pcbnew/dialogs/panel_fp_lib_table_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE!