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
This commit is contained in:
jean-pierre charras 2020-11-24 11:29:37 +01:00
parent f64360e915
commit 52d8b70d3a
1 changed files with 17 additions and 3 deletions

View File

@ -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 ) );
}