Prevent auto-column sizing when editor opens

On GTK, some configurations will trigger a column resize, which will
close the current editor.  This blocks the column resize while the
editor is open, unless the resize continues, which indicates dragging of
the window edge

Fixes https://gitlab.com/kicad/code/kicad/issues/5690
This commit is contained in:
Seth Hillbrand 2022-01-25 17:57:42 -08:00
parent 744bc0bd18
commit 2dc031ee34
5 changed files with 23 additions and 10 deletions

View File

@ -295,6 +295,8 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent,
m_delayedFocusRow = REFERENCE_FIELD;
m_delayedFocusColumn = FDC_VALUE;
m_delayedSelection = true;
m_editorShown = false;
m_lastRequestedSize = wxSize( 0, 0 );
#ifndef KICAD_SPICE
m_spiceFieldsButton->Hide();
@ -795,14 +797,13 @@ void DIALOG_SYMBOL_PROPERTIES::OnGridEditorShown( wxGridEvent& aEvent )
if( aEvent.GetRow() == REFERENCE_FIELD && aEvent.GetCol() == FDC_VALUE )
m_delayedSelection= true;
/// Queue up an event to ensure the widget gets resized if the editor needs it
wxSizeEvent *evt = new wxSizeEvent();
evt->SetSize( m_fieldsSize + wxSize( 1, 1 ) );
wxQueueEvent( m_fieldsGrid, evt );
m_editorShown = true;
}
wxSizeEvent *frmEvt = new wxSizeEvent();
evt->SetSize( wxSize( -1, -1 ) );
wxQueueEvent( this, frmEvt );
void DIALOG_SYMBOL_PROPERTIES::OnGridEditorHidden( wxGridEvent& aEvent )
{
m_editorShown = false;
}
@ -1079,13 +1080,18 @@ void DIALOG_SYMBOL_PROPERTIES::OnSizeFieldsGrid( wxSizeEvent& event )
{
wxSize new_size = event.GetSize();
if( m_fieldsSize != new_size )
if( ( !m_editorShown || m_lastRequestedSize != new_size ) && m_fieldsSize != new_size )
{
m_fieldsSize = new_size;
AdjustFieldsGridColumns();
}
// We store this value to check whether the dialog is changing size. This might indicate
// that the user is scaling the dialog with an editor shown. Some editors do not close
// (at least on GTK) when the user drags a dialog corner
m_lastRequestedSize = new_size;
// Always propagate for a grid repaint (needed if the height changes, as well as width)
event.Skip();
}

View File

@ -81,6 +81,7 @@ private:
void OnCancelButtonClick( wxCommandEvent& event ) override;
void OnInitDlg( wxInitDialogEvent& event ) override;
void OnGridEditorShown( wxGridEvent& event ) override;
void OnGridEditorHidden( wxGridEvent& event ) override;
void OnChoice( wxCommandEvent& event ) override;
void OnCheckBox( wxCommandEvent& event ) override;
@ -97,10 +98,12 @@ private:
LIB_SYMBOL* m_part;
wxSize m_fieldsSize;
wxSize m_lastRequestedSize;
wxSize m_pinsSize;
int m_delayedFocusRow;
int m_delayedFocusColumn;
bool m_delayedSelection;
bool m_editorShown;
wxString m_shownColumns;
FIELDS_GRID_TABLE<SCH_FIELD>* m_fields;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -336,6 +336,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::DIALOG_SYMBOL_PROPERTIES_BASE( wxWindow* parent,
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnInitDlg ) );
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUpdateUI ) );
m_fieldsGrid->Connect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnGridEditorHidden ), NULL, this );
m_fieldsGrid->Connect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnGridEditorShown ), NULL, this );
m_fieldsGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnSizeFieldsGrid ), NULL, this );
m_bpAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnAddField ), NULL, this );
@ -365,6 +366,7 @@ DIALOG_SYMBOL_PROPERTIES_BASE::~DIALOG_SYMBOL_PROPERTIES_BASE()
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnInitDlg ) );
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnUpdateUI ) );
m_fieldsGrid->Disconnect( wxEVT_GRID_EDITOR_HIDDEN, wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnGridEditorHidden ), NULL, this );
m_fieldsGrid->Disconnect( wxEVT_GRID_EDITOR_SHOWN, wxGridEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnGridEditorShown ), NULL, this );
m_fieldsGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnSizeFieldsGrid ), NULL, this );
m_bpAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_PROPERTIES_BASE::OnAddField ), NULL, this );

View File

@ -278,6 +278,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnGridEditorHidden">OnGridEditorHidden</event>
<event name="OnGridEditorShown">OnGridEditorShown</event>
<event name="OnSize">OnSizeFieldsGrid</event>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -80,6 +80,7 @@ class DIALOG_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnGridEditorHidden( wxGridEvent& event ) { event.Skip(); }
virtual void OnGridEditorShown( wxGridEvent& event ) { event.Skip(); }
virtual void OnSizeFieldsGrid( wxSizeEvent& event ) { event.Skip(); }
virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); }