Fix a minor issue in PANEL_SETUP_NETCLASSES, when resizing it. Second attempt.

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 17:03:48 +01:00
parent 2f3f4c209e
commit 696fc7e46e
5 changed files with 30 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 );
}
@ -528,6 +532,24 @@ void PANEL_SETUP_NETCLASSES::AdjustMembershipGridColumns( int aWidth )
}
void PANEL_SETUP_NETCLASSES::onmembershipPanelSize( wxSizeEvent& event )
{
// When a class name choice widget is selected (activated), in
// wxGrid m_membershipGrid, resizing its wxGrid parent is not taken in account
// by the widget until it is deselected and stay in the old position.
// So we deselect it if this is the case
// Note also this is made here, not in OnSizeMembershipGrid because on Linux
// there are a lot of wxSizeEvent send to m_membershipGrid when opening a choice widget
int c_row = m_membershipGrid->GetGridCursorRow();
int c_col = m_membershipGrid->GetGridCursorCol();
if( c_row >= 0 && c_col == 1 ) // this means the class name choice widget is selected (opened)
m_membershipGrid->SetGridCursor( c_row, 0 ); // Close it
event.Skip();
}
void PANEL_SETUP_NETCLASSES::OnSizeMembershipGrid( wxSizeEvent& event )
{
AdjustMembershipGridColumns( event.GetSize().GetX() );

View File

@ -47,7 +47,8 @@ private:
void OnAddNetclassClick( wxCommandEvent& event ) override;
void OnRemoveNetclassClick( wxCommandEvent& event ) override;
void OnSizeNetclassGrid( wxSizeEvent& event ) override;
void OnSizeMembershipGrid( wxSizeEvent& event ) override;
void OnSizeMembershipGrid( wxSizeEvent& event ) override;
void onmembershipPanelSize( wxSizeEvent& event ) override;
void OnUpdateUI( wxUpdateUIEvent &event ) override;
void OnNetclassGridCellChanging( wxGridEvent& event );
void OnShowAll( wxCommandEvent& event ) override { doApplyFilters( true ); }

View File

@ -241,6 +241,7 @@ PANEL_SETUP_NETCLASSES_BASE::PANEL_SETUP_NETCLASSES_BASE( wxWindow* parent, wxWi
m_netclassGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeNetclassGrid ), NULL, this );
m_addButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddNetclassClick ), NULL, this );
m_removeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveNetclassClick ), NULL, this );
m_membershipPane->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::onmembershipPanelSize ), NULL, this );
m_showAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnShowAll ), NULL, this );
m_filterNetsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_assignAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );
@ -255,6 +256,7 @@ PANEL_SETUP_NETCLASSES_BASE::~PANEL_SETUP_NETCLASSES_BASE()
m_netclassGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnSizeNetclassGrid ), NULL, this );
m_addButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAddNetclassClick ), NULL, this );
m_removeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnRemoveNetclassClick ), NULL, this );
m_membershipPane->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_SETUP_NETCLASSES_BASE::onmembershipPanelSize ), NULL, this );
m_showAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnShowAll ), NULL, this );
m_filterNetsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnApplyFilters ), NULL, this );
m_assignAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_NETCLASSES_BASE::OnAssignAll ), NULL, this );

View File

@ -441,6 +441,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnSize">onmembershipPanelSize</event>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Net Class Memberships</property>

View File

@ -62,6 +62,7 @@ class PANEL_SETUP_NETCLASSES_BASE : public wxPanel
virtual void OnSizeNetclassGrid( wxSizeEvent& event ) { event.Skip(); }
virtual void OnAddNetclassClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveNetclassClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onmembershipPanelSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnShowAll( wxCommandEvent& event ) { event.Skip(); }
virtual void OnApplyFilters( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAssignAll( wxCommandEvent& event ) { event.Skip(); }