From 13b73ed6b464901a53568833846731cf85ca4e30 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 24 Dec 2022 22:18:05 +0000 Subject: [PATCH] Remember dialog sizes for dialogs that might have lots of fields. This is mainly for simulation testing where the dialog has to be grown every time you restart the app, but it might as well be applied to the similar dialogs. Fixes https://gitlab.com/kicad/code/kicad/issues/12887 --- eeschema/dialogs/dialog_label_properties.cpp | 9 ++++++++- eeschema/dialogs/dialog_sheet_properties.cpp | 18 ++++++++++++------ eeschema/dialogs/dialog_symbol_properties.cpp | 9 +++++++++ eeschema/eeschema_settings.cpp | 18 ++++++++++++++++++ eeschema/eeschema_settings.h | 6 ++++++ 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index 9887944ee3..56a7fd4805 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -215,6 +215,9 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_L // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); + + if( cfg && cfg->m_Appearance.edit_label_width > 0 && cfg->m_Appearance.edit_label_height > 0 ) + SetSize( cfg->m_Appearance.edit_label_width, cfg->m_Appearance.edit_label_height ); } @@ -224,7 +227,11 @@ DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES() wxASSERT( cfg ); if( cfg ) - cfg->m_Appearance.edit_sheet_visible_columns = m_grid->GetShownColumns(); + { + cfg->m_Appearance.edit_label_visible_columns = m_grid->GetShownColumns(); + cfg->m_Appearance.edit_label_width = GetSize().x; + cfg->m_Appearance.edit_label_height = GetSize().y; + } // Prevents crash bug in wxGrid's d'tor m_grid->DestroyTable( m_fields ); diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 760b0785f7..99b7def317 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -65,7 +65,7 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S m_grid->SetSelectionMode( wxGrid::wxGridSelectRows ); // Show/hide columns according to user's preference - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxASSERT( cfg ); if( cfg ) @@ -99,18 +99,20 @@ DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_S m_grid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( DIALOG_SHEET_PROPERTIES::OnGridCellChanging ), nullptr, this ); - - finishDialogSettings(); } DIALOG_SHEET_PROPERTIES::~DIALOG_SHEET_PROPERTIES() { - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxASSERT( cfg ); if( cfg ) + { cfg->m_Appearance.edit_sheet_visible_columns = m_grid->GetShownColumns(); + cfg->m_Appearance.edit_sheet_width = GetSize().x; + cfg->m_Appearance.edit_sheet_height = GetSize().y; + } // Prevents crash bug in wxGrid's d'tor m_grid->DestroyTable( m_fields ); @@ -181,8 +183,6 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataToWindow() m_pageNumberTextCtrl->ChangeValue( nextPageNumber ); - Layout(); - return true; } @@ -914,4 +914,10 @@ void DIALOG_SHEET_PROPERTIES::OnInitDlg( wxInitDialogEvent& event ) // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); + + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); + + if( cfg && cfg->m_Appearance.edit_sheet_width > 0 && cfg->m_Appearance.edit_sheet_height > 0 ) + SetSize( cfg->m_Appearance.edit_sheet_width, cfg->m_Appearance.edit_sheet_height ); + } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index ec5566109b..524ded950f 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -401,7 +401,11 @@ DIALOG_SYMBOL_PROPERTIES::~DIALOG_SYMBOL_PROPERTIES() EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); if( cfg ) + { cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumns(); + cfg->m_Appearance.edit_symbol_width = GetSize().x; + cfg->m_Appearance.edit_symbol_height = GetSize().y; + } // Prevents crash bug in wxGrid's d'tor m_fieldsGrid->DestroyTable( m_fields ); @@ -1209,6 +1213,11 @@ void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event ) // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); + + EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); + + if( cfg && cfg->m_Appearance.edit_symbol_width > 0 && cfg->m_Appearance.edit_symbol_height > 0 ) + SetSize( cfg->m_Appearance.edit_symbol_width, cfg->m_Appearance.edit_symbol_height ); } diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 8d0680b511..60e02bcd57 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -82,12 +82,30 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_params.emplace_back( new PARAM( "appearance.edit_symbol_visible_columns", &m_Appearance.edit_symbol_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.edit_symbol_width", + &m_Appearance.edit_symbol_width, -1 ) ); + + m_params.emplace_back( new PARAM( "appearance.edit_symbol_height", + &m_Appearance.edit_symbol_height, -1 ) ); + m_params.emplace_back( new PARAM( "appearance.edit_sheet_visible_columns", &m_Appearance.edit_sheet_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.edit_sheet_width", + &m_Appearance.edit_sheet_width, -1 ) ); + + m_params.emplace_back( new PARAM( "appearance.edit_sheet_height", + &m_Appearance.edit_sheet_height, -1 ) ); + m_params.emplace_back( new PARAM( "appearance.edit_label_visible_columns", &m_Appearance.edit_label_visible_columns, "0 1 2 3 4 5 6 7" ) ); + m_params.emplace_back( new PARAM( "appearance.edit_label_width", + &m_Appearance.edit_label_width, -1 ) ); + + m_params.emplace_back( new PARAM( "appearance.edit_label_height", + &m_Appearance.edit_label_height, -1 ) ); + m_params.emplace_back( new PARAM( "appearance.erc_severities", &m_Appearance.erc_severities, RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ) ); diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 6afd9d66e4..cbf5c14fde 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -46,8 +46,14 @@ public: struct APPEARANCE { wxString edit_symbol_visible_columns; + int edit_symbol_width; + int edit_symbol_height; wxString edit_sheet_visible_columns; + int edit_sheet_width; + int edit_sheet_height; wxString edit_label_visible_columns; + int edit_label_width; + int edit_label_height; int erc_severities; bool footprint_preview; bool print_sheet_reference;