From 52d8b70d3a0539459d3c603ddb20e8527f3870d0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 24 Nov 2020 11:29:37 +0100 Subject: [PATCH] Fix a minor issue in PANEL_SETUP_NETCLASSES, when resizing it. If a class name choice widget is selected, resizing the panel does not move the opened widgets, until it is closed. Fixes #6474 https://gitlab.com/kicad/code/kicad/issues/6474 --- common/dialogs/panel_setup_netclasses.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index 02c9a50b6c..87e35d3b12 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -174,7 +174,9 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSE m_removeButton->SetBitmap( KiBitmap( trash_xpm ) ); // wxFormBuilder doesn't include this event... - m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this ); + m_netclassGrid->Connect( wxEVT_GRID_CELL_CHANGING, + wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), + NULL, this ); m_netclassGrid->EndBatch(); m_membershipGrid->EndBatch(); @@ -190,7 +192,9 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES() m_netclassGrid->PopEventHandler( true ); m_membershipGrid->PopEventHandler( true ); - m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this ); + m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, + wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), + NULL, this ); } @@ -518,12 +522,22 @@ void PANEL_SETUP_NETCLASSES::OnSizeNetclassGrid( wxSizeEvent& event ) void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns( int aWidth ) { + // When a class name choice widget is selected (activated), resizing + // the wxGrid parent is not taken in account by the widget until it is + // dselected. So we deselect it if this is the case + int c_row = m_membershipGrid->GetGridCursorRow(); + int c_col = m_membershipGrid->GetGridCursorCol(); + + if( c_col == 1 ) // this means the class name choice widget is selected (opened) + m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it + // Account for scroll bars aWidth -= ( m_membershipGrid->GetSize().x - m_membershipGrid->GetClientSize().x ); - // Set className column width to original className width from netclasses grid int classNameWidth = m_originalColWidths[ 0 ]; + // Set className column width to original className width from netclasses grid m_membershipGrid->SetColSize( 1, m_originalColWidths[ 0 ] ); + m_membershipGrid->SetColSize( 0, std::max( aWidth - classNameWidth, classNameWidth ) ); }