From 08d7899f7ea1437d0fd789ed7974ec815d963a5c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 14 Aug 2021 10:15:18 +0200 Subject: [PATCH] Rework on hint to user when pin scope control has no effect or unexpected result. A info banner is now shown (in synchronized mode) to inform an user when extra pins are added to other units when a new pin is added. A good info about the synchronized mode is not easy to create. --- eeschema/dialogs/dialog_pin_properties.cpp | 33 ++- eeschema/dialogs/dialog_pin_properties.h | 1 + .../dialogs/dialog_pin_properties_base.cpp | 28 +++ .../dialogs/dialog_pin_properties_base.fbp | 205 ++++++++++++++++++ eeschema/dialogs/dialog_pin_properties_base.h | 18 +- 5 files changed, 274 insertions(+), 11 deletions(-) diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index 576bf10fe4..03388e1ada 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -136,6 +136,24 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN // Creates a dummy pin to show on a panel, inside this dialog: m_dummyPin = new LIB_PIN( *m_pin ); + m_bSizerInfo->Show( m_frame->m_SyncPinEdit ); + + if( m_frame->m_SyncPinEdit ) + { + if( aPin->IsNew() ) + { + m_textInfoUpper->SetLabel( _( "Synchronized pins edit mode, and this pin is new" ) ); + m_textInfoLower->SetLabel( _( "Similar pins will be automatically added to other units, " + "if this pin is not common to all units" ) ); + } + else + { + m_textInfoUpper->SetLabel( _( "Synchronized pins edit mode" ) ); + m_textInfoLower->SetLabel( _( "Similar pins at the same location will be edited. " + "Pin number of other pins will be not modified" ) ); + } + } + COLOR4D bgColor = parent->GetRenderSettings()->GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); m_panelShowPin->SetBackgroundColour( bgColor.ToColour() ); @@ -255,18 +273,18 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() m_dummyPin->SetVisible( m_pin->IsVisible() ); bool hasMultiUnit = m_pin->GetParent()->GetUnitCount() > 1; - bool enableUnitScope = m_pin->GetParent()->UnitsLocked(); - m_checkApplyToAllParts->Enable( !m_frame->m_SyncPinEdit && enableUnitScope && hasMultiUnit ); + m_checkApplyToAllParts->Enable( hasMultiUnit ); wxString toolTip; if( !hasMultiUnit ) toolTip = _( "This symbol only has one unit. This control has no effect." ); else if( m_frame->m_SyncPinEdit ) - toolTip = _( "Synchronized pin edit mode is enabled. This control has no effect." ); - else if( !enableUnitScope ) - toolTip = _( "All units in this symbol are interchangeable. This control has no effect." ); + toolTip = _( "Synchronized pin edit mode is enabled.\n" + "Similar pins will be edited, regardless this option." ); + else + toolTip = _( "If checked, this pin will exist in all units." ); m_checkApplyToAllParts->SetToolTip( toolTip ); @@ -485,3 +503,8 @@ void DIALOG_PIN_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) } +void DIALOG_PIN_PROPERTIES::onUpdateUIInfo( wxUpdateUIEvent& event ) +{ + // Disable Info texts for pins common to all units + event.Enable( m_checkApplyToAllParts->GetValue() == 0 ); +} diff --git a/eeschema/dialogs/dialog_pin_properties.h b/eeschema/dialogs/dialog_pin_properties.h index 09fe82d30b..d804efdaf4 100644 --- a/eeschema/dialogs/dialog_pin_properties.h +++ b/eeschema/dialogs/dialog_pin_properties.h @@ -65,6 +65,7 @@ public: void OnDeleteAlternate( wxCommandEvent& event ) override; void OnSize( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; + void onUpdateUIInfo( wxUpdateUIEvent& event ) override; protected: void adjustGridColumns( int aWidth ); diff --git a/eeschema/dialogs/dialog_pin_properties_base.cpp b/eeschema/dialogs/dialog_pin_properties_base.cpp index 942a6fd624..bc4eb5ba64 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.cpp +++ b/eeschema/dialogs/dialog_pin_properties_base.cpp @@ -21,6 +21,28 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind wxBoxSizer* mainSizer; mainSizer = new wxBoxSizer( wxVERTICAL ); + m_bSizerInfo = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmapInfo = new wxStaticBitmap( this, wxID_ANY, wxArtProvider::GetBitmap( wxART_INFORMATION, wxART_CMN_DIALOG ), wxDefaultPosition, wxDefaultSize, 0 ); + m_bSizerInfo->Add( m_bitmapInfo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + wxBoxSizer* bSizerTexts; + bSizerTexts = new wxBoxSizer( wxVERTICAL ); + + m_textInfoUpper = new wxStaticText( this, wxID_ANY, _("info"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textInfoUpper->Wrap( -1 ); + bSizerTexts->Add( m_textInfoUpper, 0, wxRIGHT|wxLEFT, 5 ); + + m_textInfoLower = new wxStaticText( this, wxID_ANY, _("info"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textInfoLower->Wrap( -1 ); + bSizerTexts->Add( m_textInfoLower, 0, wxRIGHT|wxLEFT, 5 ); + + + m_bSizerInfo->Add( bSizerTexts, 1, wxALIGN_CENTER_VERTICAL, 5 ); + + + mainSizer->Add( m_bSizerInfo, 0, wxEXPAND, 5 ); + wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -262,6 +284,9 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind // Connect Events this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnSize ) ); this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnUpdateUI ) ); + m_bitmapInfo->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); + m_textInfoUpper->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); + m_textInfoLower->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); m_textPinName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinNumber->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_pinLengthCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); @@ -283,6 +308,9 @@ DIALOG_PIN_PROPERTIES_BASE::~DIALOG_PIN_PROPERTIES_BASE() // Disconnect Events this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnSize ) ); this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnUpdateUI ) ); + m_bitmapInfo->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); + m_textInfoUpper->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); + m_textInfoLower->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_PIN_PROPERTIES_BASE::onUpdateUIInfo ), NULL, this ); m_textPinName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_textPinNumber->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); m_pinLengthCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PIN_PROPERTIES_BASE::OnPropertiesChange ), NULL, this ); diff --git a/eeschema/dialogs/dialog_pin_properties_base.fbp b/eeschema/dialogs/dialog_pin_properties_base.fbp index 232084b6b0..1d51f8bf6a 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.fbp +++ b/eeschema/dialogs/dialog_pin_properties_base.fbp @@ -60,6 +60,211 @@ mainSizer wxVERTICAL none + + 5 + wxEXPAND + 0 + + + m_bSizerInfo + wxHORIZONTAL + protected + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + Load From Art Provider; wxART_INFORMATION; wxART_CMN_DIALOG + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_bitmapInfo + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + onUpdateUIInfo + + + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + bSizerTexts + wxVERTICAL + none + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + info + 0 + + 0 + + + 0 + + 1 + m_textInfoUpper + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + onUpdateUIInfo + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + info + 0 + + 0 + + + 0 + + 1 + m_textInfoLower + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + onUpdateUIInfo + + + + + + 5 wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT diff --git a/eeschema/dialogs/dialog_pin_properties_base.h b/eeschema/dialogs/dialog_pin_properties_base.h index d3f020a262..04c0feb745 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.h +++ b/eeschema/dialogs/dialog_pin_properties_base.h @@ -16,23 +16,24 @@ class WX_GRID; class wxBitmapComboBox; #include "dialog_shim.h" -#include -#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include #include #include #include -#include #include #include #include #include -#include -#include -#include #include #include #include @@ -48,6 +49,10 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM private: protected: + wxBoxSizer* m_bSizerInfo; + wxStaticBitmap* m_bitmapInfo; + wxStaticText* m_textInfoUpper; + wxStaticText* m_textInfoLower; wxStaticText* m_pinNameLabel; wxTextCtrl* m_textPinName; wxStaticText* m_pinNumberLabel; @@ -90,6 +95,7 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnSize( wxSizeEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void onUpdateUIInfo( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnPropertiesChange( wxCommandEvent& event ) { event.Skip(); } virtual void OnPaintShowPanel( wxPaintEvent& event ) { event.Skip(); } virtual void OnAddAlternate( wxCommandEvent& event ) { event.Skip(); }