diff --git a/eeschema/dialogs/dialog_pin_properties.cpp b/eeschema/dialogs/dialog_pin_properties.cpp index c622ae6e2c..1dc32f84e1 100644 --- a/eeschema/dialogs/dialog_pin_properties.cpp +++ b/eeschema/dialogs/dialog_pin_properties.cpp @@ -33,6 +33,7 @@ #include #include #include +#include class ALT_PIN_DATA_MODEL : public wxGridTableBase, public std::vector { @@ -141,24 +142,6 @@ DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_PIN m_dummyParent->SetShowPinNames( true ); m_dummyParent->SetShowPinNumbers( true ); - 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() ); @@ -272,27 +255,45 @@ bool DIALOG_PIN_PROPERTIES::TransferDataToWindow() m_textPinNumber->SetValue( m_pin->GetNumber() ); m_numberSize.SetValue( m_pin->GetNumberTextSize() ); m_pinLength.SetValue( m_pin->GetLength() ); + m_checkApplyToAllParts->Enable( m_pin->GetParent()->IsMulti() ); m_checkApplyToAllParts->SetValue( m_pin->GetUnit() == 0 ); m_checkApplyToAllConversions->SetValue( m_pin->GetConvert() == 0 ); m_checkShow->SetValue( m_pin->IsVisible() ); m_dummyPin->SetVisible( m_pin->IsVisible() ); - bool hasMultiUnit = m_pin->GetParent()->GetUnitCount() > 1; + wxString commonUnitsToolTip; - m_checkApplyToAllParts->Enable( hasMultiUnit ); + if( m_frame->m_SyncPinEdit ) + { + wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY, + _( "Exit sync pins mode" ), + wxEmptyString ); - wxString toolTip; + button->Bind( wxEVT_COMMAND_HYPERLINK, + std::function( + [&]( wxHyperlinkEvent& aEvent ) + { + m_frame->m_SyncPinEdit = false; + m_infoBar->Dismiss(); + } ) ); - 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.\n" - "Similar pins will be edited, regardless this option." ); + m_infoBar->RemoveAllButtons(); + m_infoBar->AddButton( button ); + m_infoBar->ShowMessage( getSyncPinsMessage() ); + + commonUnitsToolTip = _( "Synchronized pins mode is enabled.\n" + "Similar pins will be edited regardless of this option." ); + } else - toolTip = _( "If checked, this pin will exist in all units." ); + { + commonUnitsToolTip = _( "If checked, this pin will exist in all units." ); + } - m_checkApplyToAllParts->SetToolTip( toolTip ); + if( !m_pin->GetParent()->IsMulti() ) + commonUnitsToolTip = _( "This symbol only has one unit. This control has no effect." ); + + m_checkApplyToAllParts->SetToolTip( commonUnitsToolTip ); for( const std::pair& alt : m_pin->GetAlternates() ) m_alternatesDataModel->AppendRow( alt.second ); @@ -416,10 +417,24 @@ void DIALOG_PIN_PROPERTIES::OnPropertiesChange( wxCommandEvent& event ) m_dummyPin->SetShape( m_choiceStyle->GetPinShapeSelection() ); m_dummyPin->SetVisible( m_checkShow->GetValue() ); + if( event.GetEventObject() == m_checkApplyToAllParts && m_frame->m_SyncPinEdit ) + m_infoBar->ShowMessage( getSyncPinsMessage() ); + m_panelShowPin->Refresh(); } +wxString DIALOG_PIN_PROPERTIES::getSyncPinsMessage() +{ + if( m_checkApplyToAllParts->GetValue() ) + return _( "Synchronized Pins Mode." ); + else if( m_pin->IsNew() ) + return _( "Synchronized Pins Mode. New pin will be added to all units." ); + else + return _( "Synchronized Pins Mode. Matching pins in other units will be updated." ); +} + + void DIALOG_PIN_PROPERTIES::OnAddAlternate( wxCommandEvent& event ) { if( !m_alternatesGrid->CommitPendingChanges() ) @@ -510,10 +525,3 @@ void DIALOG_PIN_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) m_delayedFocusColumn = -1; } } - - -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 74987669cc..d4f363b768 100644 --- a/eeschema/dialogs/dialog_pin_properties.h +++ b/eeschema/dialogs/dialog_pin_properties.h @@ -65,10 +65,10 @@ public: void OnDeleteAlternate( wxCommandEvent& event ) override; void OnSize( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; - void onUpdateUIInfo( wxUpdateUIEvent& event ) override; protected: void adjustGridColumns(); + wxString getSyncPinsMessage(); private: SYMBOL_EDIT_FRAME* m_frame; diff --git a/eeschema/dialogs/dialog_pin_properties_base.cpp b/eeschema/dialogs/dialog_pin_properties_base.cpp index 35cb222989..8e99f94686 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.cpp +++ b/eeschema/dialogs/dialog_pin_properties_base.cpp @@ -7,6 +7,7 @@ #include "pin_shape_combobox.h" #include "pin_type_combobox.h" +#include "widgets/infobar.h" #include "widgets/wx_grid.h" #include "wx/bmpcbox.h" @@ -21,27 +22,12 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind wxBoxSizer* mainSizer; mainSizer = new wxBoxSizer( wxVERTICAL ); - m_bSizerInfo = new wxBoxSizer( wxHORIZONTAL ); + m_infoBar = new WX_INFOBAR( this ); + m_infoBar->SetShowHideEffects( wxSHOW_EFFECT_NONE, wxSHOW_EFFECT_NONE ); + m_infoBar->SetEffectDuration( 500 ); + m_infoBar->Hide(); - 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 ); + mainSizer->Add( m_infoBar, 0, wxEXPAND, 5 ); wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -156,7 +142,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind bLeftSizer->Add( gbSizer1, 1, wxEXPAND, 5 ); - bUpperSizer->Add( bLeftSizer, 1, wxEXPAND|wxALL, 10 ); + bUpperSizer->Add( bLeftSizer, 1, wxEXPAND|wxALL, 15 ); wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); @@ -190,10 +176,10 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind bRightSizer->Add( m_panelShowPin, 1, wxEXPAND|wxLEFT, 5 ); - bUpperSizer->Add( bRightSizer, 1, wxEXPAND|wxALL, 10 ); + bUpperSizer->Add( bRightSizer, 1, wxEXPAND|wxALL, 15 ); - mainSizer->Add( bUpperSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + mainSizer->Add( bUpperSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bLowerSizer; bLowerSizer = new wxBoxSizer( wxVERTICAL ); @@ -266,7 +252,7 @@ DIALOG_PIN_PROPERTIES_BASE::DIALOG_PIN_PROPERTIES_BASE( wxWindow* parent, wxWind bLowerSizer->Add( m_alternatesTurndown, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - mainSizer->Add( bLowerSizer, 1, wxEXPAND|wxLEFT, 5 ); + mainSizer->Add( bLowerSizer, 1, wxEXPAND|wxLEFT, 10 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -290,9 +276,6 @@ 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 ); @@ -314,9 +297,6 @@ 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 9e1fa58a3e..80ea8f9bf6 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.fbp +++ b/eeschema/dialogs/dialog_pin_properties_base.fbp @@ -64,210 +64,65 @@ 5 wxEXPAND 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 500 + 1 + + 1 + + 0 + 1 + wxSHOW_EFFECT_NONE + wxID_ANY + + 0 + + + 0 - m_bSizerInfo - wxHORIZONTAL + 1 + m_infoBar + 1 + + 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 - - - - + 1 + + Resizable + 1 + wxSHOW_EFFECT_NONE + + WX_INFOBAR; widgets/infobar.h; forward_declare + 0 + + + + 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + wxEXPAND|wxRIGHT|wxLEFT 0 @@ -275,7 +130,7 @@ wxHORIZONTAL none - 10 + 15 wxEXPAND|wxALL 1 @@ -1944,7 +1799,7 @@ - 10 + 15 wxEXPAND|wxALL 1 @@ -2292,7 +2147,7 @@ - 5 + 10 wxEXPAND|wxLEFT 1 diff --git a/eeschema/dialogs/dialog_pin_properties_base.h b/eeschema/dialogs/dialog_pin_properties_base.h index 04c0feb745..82587c7f52 100644 --- a/eeschema/dialogs/dialog_pin_properties_base.h +++ b/eeschema/dialogs/dialog_pin_properties_base.h @@ -13,27 +13,28 @@ class PinShapeComboBox; class PinTypeComboBox; class WX_GRID; +class WX_INFOBAR; 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 @@ -49,10 +50,7 @@ class DIALOG_PIN_PROPERTIES_BASE : public DIALOG_SHIM private: protected: - wxBoxSizer* m_bSizerInfo; - wxStaticBitmap* m_bitmapInfo; - wxStaticText* m_textInfoUpper; - wxStaticText* m_textInfoLower; + WX_INFOBAR* m_infoBar; wxStaticText* m_pinNameLabel; wxTextCtrl* m_textPinName; wxStaticText* m_pinNumberLabel; @@ -95,7 +93,6 @@ 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(); } diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 27757e4a77..7623daa792 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -205,8 +205,8 @@ TOOL_ACTION EE_ACTIONS::exportSymbolAsSVG( "eeschema.SymbolLibraryControl.export TOOL_ACTION EE_ACTIONS::toggleSyncedPinsMode( "eeschema.SymbolLibraryControl.toggleSyncedPinsMode", AS_GLOBAL, 0, "", - _( "Synchronized Pins Edit Mode" ), - _( "Synchronized Pins Edit Mode\n" + _( "Synchronized Pins Mode" ), + _( "Synchronized Pins Mode\n" "When enabled propagates all changes (except pin numbers) to other units.\n" "Enabled by default for multiunit parts with interchangeable units." ), BITMAPS::pin2pin );