From 0e939993bc4e9e205a04706cb5121f95bf4b05a2 Mon Sep 17 00:00:00 2001 From: Gary Kim Date: Thu, 26 Jan 2023 10:46:03 -0500 Subject: [PATCH] Only expand when opening alternate pin definitions When opening alternate pin definitions collapsible pane, only increase the window size to accommodate the pane. Fixes https://gitlab.com/kicad/code/kicad/-/issues/13596 --- eeschema/dialogs/dialog_pin_properties.cpp | 18 +++++++++++++++++- eeschema/dialogs/dialog_pin_properties.h | 3 ++- .../dialogs/dialog_pin_properties_base.cpp | 7 +++++-- .../dialogs/dialog_pin_properties_base.fbp | 3 ++- eeschema/dialogs/dialog_pin_properties_base.h | 3 ++- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index 5261b86ee9..f409f6d6a9 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -534,3 +534,19 @@ void DIALOG_PIN_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) m_delayedFocusColumn = -1; } } +void DIALOG_PIN_PROPERTIES::OnCollapsiblePaneChange( wxCollapsiblePaneEvent& event ) +{ + if( !event.GetCollapsed() ) + { + wxTopLevelWindow* tlw = dynamic_cast( wxGetTopLevelParent( this ) ); + + if( tlw ) + { + tlw->InvalidateBestSize(); + wxSize bestSize = tlw->GetBestSize(); + wxSize currentSize = tlw->GetSize(); + tlw->SetSize( wxMax( bestSize.GetWidth(), currentSize.GetWidth() ), + wxMax( bestSize.GetHeight(), currentSize.GetHeight() ) ); + } + } +} diff --git a/eeschema/dialogs/dialog_pin_properties.h b/eeschema/dialogs/dialog_pin_properties.h index f04bdebc72..a00a7db13a 100644 --- a/eeschema/dialogs/dialog_pin_properties.h +++ b/eeschema/dialogs/dialog_pin_properties.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014-2022 KiCad Developers, see AUTHOR.txt for contributors. + * Copyright (C) 2014-2023 KiCad Developers, see AUTHOR.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -65,6 +65,7 @@ public: void OnDeleteAlternate( wxCommandEvent& event ) override; void OnSize( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; + void OnCollapsiblePaneChange( wxCollapsiblePaneEvent& event ) override; protected: void adjustGridColumns(); diff --git a/eeschema/dialogs/dialog_pin_properties_base.cpp b/eeschema/dialogs/dialog_pin_properties_base.cpp index df1b19bdd6..7e00809b1b 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.cpp +++ b/eeschema/dialogs/dialog_pin_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -185,7 +185,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind wxBoxSizer* bLowerSizer; bLowerSizer = new wxBoxSizer( wxVERTICAL ); - m_alternatesTurndown = new wxCollapsiblePane( this, wxID_ANY, _("Alternate pin definitions"), wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE ); + m_alternatesTurndown = new wxCollapsiblePane( this, wxID_ANY, _("Alternate pin definitions"), wxDefaultPosition, wxDefaultSize, wxCP_DEFAULT_STYLE|wxCP_NO_TLW_RESIZE ); m_alternatesTurndown->Collapse( true ); wxBoxSizer* bAlternatesSizer; @@ -286,6 +286,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind m_checkApplyToAllConversions->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkShow->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_panelShowPin->Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this ); + m_alternatesTurndown->Connect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnCollapsiblePaneChange ), NULL, this ); m_addAlternate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnAddAlternate ), NULL, this ); m_deleteAlternate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnDeleteAlternate ), NULL, this ); } @@ -307,7 +308,9 @@ DIALOG_PIN_PROPERTIES_BASE::~DIALOG_PIN_PROPERTIES_BASE() m_checkApplyToAllConversions->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_checkShow->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_panelShowPin->Disconnect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPaintShowPanel ), NULL, this ); + m_alternatesTurndown->Disconnect( wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnCollapsiblePaneChange ), NULL, this ); m_addAlternate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnAddAlternate ), NULL, this ); m_deleteAlternate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnDeleteAlternate ), NULL, this ); } + diff --git a/eeschema/dialogs/dialog_pin_properties_base.fbp b/eeschema/dialogs/dialog_pin_properties_base.fbp index 6166e64370..d6f0228389 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.fbp +++ b/eeschema/dialogs/dialog_pin_properties_base.fbp @@ -2209,7 +2209,7 @@ Resizable 1 - wxCP_DEFAULT_STYLE + wxCP_DEFAULT_STYLE|wxCP_NO_TLW_RESIZE ; ; forward_declare 0 @@ -2220,6 +2220,7 @@ + OnCollapsiblePaneChange bAlternatesSizer diff --git a/eeschema/dialogs/dialog_pin_properties_base.h b/eeschema/dialogs/dialog_pin_properties_base.h index 1466cdfed0..3c03c11894 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.h +++ b/eeschema/dialogs/dialog_pin_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -94,6 +94,7 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); } + virtual void OnCollapsiblePaneChange( wxCollapsiblePaneEvent& event ) { event.Skip(); } virtual void OnAddAlternate( wxCommandEvent& event ) { event.Skip(); } virtual void OnDeleteAlternate( wxCommandEvent& event ) { event.Skip(); }