Prevent Pin Properties Alternate Pin pane closing on subsequent dialog open

This commit is contained in:
Bevan Weiss 2022-11-04 12:04:32 +00:00 committed by jean-pierre charras
parent 9dba54190e
commit 8444339681
5 changed files with 20 additions and 3 deletions

View File

@ -171,8 +171,13 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN
m_sdbSizerButtonsCancel
};
// Default alternates turndow to whether or not alternates exist
m_alternatesTurndown->Collapse( m_pin->GetAlternates().size() == 0 );
// Default alternates turndown to whether or not alternates exist, or if we've had it open before
m_alternatesTurndown->Collapse( m_pin->GetAlternates().size() == 0 && !s_alternatesTurndownOpen);
// wxwidgets doesn't call the OnCollapseChange even at init, so we update this value if
// the alternates pane defaults to open
if ( m_pin->GetAlternates().size() > 0 )
s_alternatesTurndownOpen = true;
m_alternatesDataModel = new ALT_PIN_DATA_MODEL( GetUserUnits() );
@ -427,6 +432,11 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event )
m_panelShowPin->Refresh();
}
void DIALOG_PIN_PROPERTIES::OnCollapsiblePaneChanged( wxCollapsiblePaneEvent& event )
{
s_alternatesTurndownOpen = !event.GetCollapsed();
}
wxString DIALOG_PIN_PROPERTIES::getSyncPinsMessage()
{

View File

@ -61,6 +61,7 @@ public:
void OnPaintShowPanel( wxPaintEvent& event ) override;
void OnPropertiesChange( wxCommandEvent& event ) override;
void OnCollapsiblePaneChanged( wxCollapsiblePaneEvent& event ) override;
void OnAddAlternate( wxCommandEvent& event ) override;
void OnDeleteAlternate( wxCommandEvent& event ) override;
void OnSize( wxSizeEvent& event ) override;
@ -93,6 +94,7 @@ private:
int m_originalColWidths[ COL_COUNT ];
wxSize m_size;
bool m_initialized;
inline static bool s_alternatesTurndownOpen = false;
};
#endif // __dialog_lib_edit_pin__

View File

@ -288,6 +288,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::OnCollapsiblePaneChanged ), 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 );
}
@ -309,6 +310,7 @@ 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::OnCollapsiblePaneChanged ), 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 );

View File

@ -2218,6 +2218,7 @@
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="1">
<event name="OnCollapsiblePaneChanged">OnCollapsiblePaneChanged</event>
<property name="minimum_size"></property>
<property name="name">bAlternatesSizer</property>
<property name="orient">wxVERTICAL</property>

View File

@ -90,11 +90,12 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); }
virtual void OnCollapsiblePaneChanged( wxCollapsiblePaneEvent& event ) { event.Skip(); }
virtual void OnAddAlternate( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDeleteAlternate( wxCommandEvent& event ) { event.Skip(); }
@ -102,6 +103,7 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM
public:
DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Pin Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PIN_PROPERTIES_BASE();
};