diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index 98ece8d560..b8753271fc 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -42,7 +42,8 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, - SCH_LABEL_BASE* aLabel ) : + SCH_LABEL_BASE* aLabel, + bool aNew ) : DIALOG_LABEL_PROPERTIES_BASE( aParent ), m_Parent( aParent ), m_currentLabel( aLabel ), @@ -54,6 +55,12 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, { COLOR_SETTINGS* colorSettings = m_Parent->GetColorSettings(); COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); + bool multiLine = false; + + if( EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ) ) + multiLine = cfg->m_Appearance.edit_label_multiple; + + m_cbMultiLine->SetValue( multiLine ); m_fields = new FIELDS_GRID_TABLE( this, aParent, m_grid, m_currentLabel ); m_width = 100; // Will be later set to a better value @@ -68,7 +75,19 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false ); - m_valueCombo->SetValidator( m_netNameValidator ); + if( multiLine && aNew ) + { + m_activeTextEntry = m_valueMultiLine; + SetInitialFocus( m_valueMultiLine ); + m_labelCombo->Show( false ); + m_valueCombo->Show( false ); + } + else + { + m_labelMultiLine->Show( false ); + m_valueMultiLine->Show( false ); + m_valueCombo->SetValidator( m_netNameValidator ); + } } else if( m_currentLabel->Type() == SCH_HIER_LABEL_T ) { @@ -78,7 +97,19 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, m_labelCombo->Show( false ); m_valueCombo->Show( false ); - m_valueSingleLine->SetValidator( m_netNameValidator ); + if( multiLine && aNew ) + { + m_activeTextEntry = m_valueMultiLine; + SetInitialFocus( m_valueMultiLine ); + m_labelSingleLine->Show( false ); + m_valueSingleLine->Show( false ); + } + else + { + m_labelMultiLine->Show( false ); + m_valueMultiLine->Show( false ); + m_valueSingleLine->SetValidator( m_netNameValidator ); + } } else if( m_currentLabel->Type() == SCH_DIRECTIVE_LABEL_T ) { @@ -91,10 +122,16 @@ DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, m_valueCombo->Show( false ); m_syntaxHelp->Show( false ); m_textEntrySizer->Show( false ); + m_labelCombo->Show( false ); + m_valueCombo->Show( false ); + m_cbMultiLine->Show( false ); m_textSizeLabel->SetLabel( _( "Pin length:" ) ); } + if( !aNew ) + m_cbMultiLine->Show( false ); + switch( m_currentLabel->Type() ) { case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break; @@ -237,6 +274,7 @@ DIALOG_LABEL_PROPERTIES::~DIALOG_LABEL_PROPERTIES() cfg->m_Appearance.edit_label_visible_columns = m_grid->GetShownColumnsAsString(); cfg->m_Appearance.edit_label_width = GetSize().x; cfg->m_Appearance.edit_label_height = GetSize().y; + cfg->m_Appearance.edit_label_multiple = m_cbMultiLine->IsChecked(); } // Prevents crash bug in wxGrid's d'tor @@ -612,6 +650,60 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow() if( !commit.Empty() ) commit.Push( _( "Edit Label Properties" ) ); + else if( m_activeTextEntry && m_labelList ) + { + text = m_activeTextEntry->GetValue(); + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( wxS( "\r" ), wxS( "\n" ) ); + wxArrayString lines = wxSplit( text, '\n' ); + + for( const wxString& line : lines ) + { + text = EscapeString( line, CTX_NETNAME ); + text.Trim( false ).Trim( true ); + + if( text.empty() ) + continue; + + // convert any text variable cross-references to their UUIDs + text = m_currentLabel->Schematic()->ConvertRefsToKIIDs( text ); + + switch ( m_currentLabel->Type() ) + { + case SCH_GLOBAL_LABEL_T: + { + SCH_GLOBALLABEL* label = new SCH_GLOBALLABEL( *static_cast( m_currentLabel ) ); + label->SetText( text ); + m_labelList->push_back( std::unique_ptr( label ) ); + break; + } + case SCH_HIER_LABEL_T: + { + SCH_HIERLABEL* label = new SCH_HIERLABEL( *static_cast( m_currentLabel ) ); + label->SetText( text ); + m_labelList->push_back( std::unique_ptr( label ) ); + break; + } + case SCH_LABEL_T: + { + SCH_LABEL* label = new SCH_LABEL( *static_cast( m_currentLabel ) ); + label->SetText( text ); + m_labelList->push_back( std::unique_ptr( label ) ); + break; + } + case SCH_DIRECTIVE_LABEL_T: + { + SCH_DIRECTIVE_LABEL* label = new SCH_DIRECTIVE_LABEL( *static_cast( m_currentLabel ) ); + label->SetText( text ); + m_labelList->push_back( std::unique_ptr( label ) ); + break; + } + default: + break; + } + } + } + return true; } @@ -830,20 +922,20 @@ void DIALOG_LABEL_PROPERTIES::OnSizeGrid( wxSizeEvent& event ) /** * Handles the filtering of items in the wxComboBox based on user input. - * - * This function is triggered by the wxEVT_TEXT event whenever the user types - * or modifies the text in the combo box. It filters the dropdown list + * + * This function is triggered by the wxEVT_TEXT event whenever the user types + * or modifies the text in the combo box. It filters the dropdown list * to show only those items that match the user's input. - * + * * Key Steps: - * - Prevents re-entry using a static flag `isFiltering` to avoid recursion + * - Prevents re-entry using a static flag `isFiltering` to avoid recursion * caused by wxComboBox events triggered during item updates. * - Compares the current input with the previously entered text to avoid * unnecessary filtering if the text hasn't changed. * - Filters the items from `m_existingLabelArray` to match the user's input. - * - Updates the combo box with the filtered items while preserving the user's + * - Updates the combo box with the filtered items while preserving the user's * input and cursor position. - * + * * @param event The wxCommandEvent associated with the wxEVT_TEXT event. */ void DIALOG_LABEL_PROPERTIES::OnLabelFilter( wxCommandEvent& event ) @@ -900,21 +992,6 @@ void DIALOG_LABEL_PROPERTIES::OnLabelFilter( wxCommandEvent& event ) } -/** - * Handles the selection of an item from the wxComboBox dropdown. - * - * This function is triggered by the wxEVT_COMBOBOX event when the user selects - * an item from the dropdown list. It ensures that the selected item's value - * is preserved and that filtering logic does not interfere with the selection process. - * - * Key Steps: - * - Updates the `m_previousText` to match the selected value to prevent - * re-filtering based on the selection. - * - Uses a static flag `isHandlingSelection` to ensure filtering is not - * unnecessarily triggered by the selection. - * - * @param event The wxCommandEvent associated with the wxEVT_COMBOBOX event. - */ void DIALOG_LABEL_PROPERTIES::OnLabelItemSelected( wxCommandEvent& event ) { static bool isHandlingSelection = true; // Prevent OnFilter from firing @@ -924,4 +1001,53 @@ void DIALOG_LABEL_PROPERTIES::OnLabelItemSelected( wxCommandEvent& event ) m_previousLabelText = selectedValue; // Update the previous text to match the selected value isHandlingSelection = false; // Reset the flag +} + + +void DIALOG_LABEL_PROPERTIES::onMultiLabelCheck( wxCommandEvent& event ) +{ + if( m_currentLabel->Type() == SCH_GLOBAL_LABEL_T || m_currentLabel->Type() == SCH_LABEL_T ) + { + m_labelCombo->Show( !m_cbMultiLine->IsChecked() ); + m_valueCombo->Show( !m_cbMultiLine->IsChecked() ); + m_labelMultiLine->Show( m_cbMultiLine->IsChecked() ); + m_valueMultiLine->Show( m_cbMultiLine->IsChecked() ); + + if( m_cbMultiLine->IsChecked() ) + { + m_valueMultiLine->SetValue( m_valueCombo->GetValue() ); + m_activeTextEntry = m_valueMultiLine; + SetInitialFocus( m_valueMultiLine ); + } + else + { + wxString multiText = m_valueMultiLine->GetValue(); + m_valueCombo->SetValue( multiText.BeforeFirst( '\n' ) ); + m_activeTextEntry = m_valueCombo; + SetInitialFocus( m_valueCombo ); + } + } + else if( m_currentLabel->Type() == SCH_HIER_LABEL_T ) + { + m_labelSingleLine->Show( !m_cbMultiLine->IsChecked() ); + m_valueSingleLine->Show( !m_cbMultiLine->IsChecked() ); + m_labelMultiLine->Show( m_cbMultiLine->IsChecked() ); + m_valueMultiLine->Show( m_cbMultiLine->IsChecked() ); + + if( m_cbMultiLine->IsChecked() ) + { + m_valueMultiLine->SetValue( m_valueSingleLine->GetValue() ); + m_activeTextEntry = m_valueMultiLine; + SetInitialFocus( m_valueMultiLine ); + } + else + { + wxString multiText = m_valueMultiLine->GetValue(); + m_valueSingleLine->SetValue( multiText.BeforeFirst( '\n' ) ); + m_activeTextEntry = m_valueSingleLine; + SetInitialFocus( m_valueSingleLine ); + } + } + + Layout(); } \ No newline at end of file diff --git a/eeschema/dialogs/dialog_label_properties.h b/eeschema/dialogs/dialog_label_properties.h index a5a59c8367..5370962bc5 100644 --- a/eeschema/dialogs/dialog_label_properties.h +++ b/eeschema/dialogs/dialog_label_properties.h @@ -37,11 +37,16 @@ class HTML_MESSAGE_BOX; class DIALOG_LABEL_PROPERTIES : public DIALOG_LABEL_PROPERTIES_BASE { public: - DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_LABEL_BASE* aLabel ); + DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_LABEL_BASE* aLabel, bool aNew ); ~DIALOG_LABEL_PROPERTIES(); FIELDS_GRID_TABLE* GetFieldsGridTable() { return m_fields; } + void SetLabelList( std::list>* aLabelList ) + { + m_labelList = aLabelList; + } + private: /** * wxEVT_COMMAND_ENTER event handler for single-line control. @@ -57,14 +62,15 @@ private: void OnDeleteField( wxCommandEvent& event ) override; void OnMoveUp( wxCommandEvent& event ) override; void OnMoveDown( wxCommandEvent& event ) override; + void onMultiLabelCheck( wxCommandEvent& aEvent ) override; void OnSizeGrid( wxSizeEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event ) override; /** * Handles the filtering of items in the wxComboBox based on user input. * - * This function is triggered by the wxEVT_TEXT event when the user modifies - * the text in the combo box. It filters the dropdown list to display only + * This function is triggered by the wxEVT_TEXT event when the user modifies + * the text in the combo box. It filters the dropdown list to display only * the items that match the input text. * * @param event The wxCommandEvent associated with the wxEVT_TEXT event. @@ -74,14 +80,14 @@ private: /** * Handles the selection of an item from the wxComboBox dropdown. * - * This function is triggered by the wxEVT_COMBOBOX event when the user selects - * an item. It ensures that the selected value is correctly processed and + * This function is triggered by the wxEVT_COMBOBOX event when the user selects + * an item. It ensures that the selected value is correctly processed and * prevents unnecessary re-filtering based on the selection. * * @param event The wxCommandEvent associated with the wxEVT_COMBOBOX event. */ void OnLabelItemSelected( wxCommandEvent& event ); - + void AdjustGridColumns( int aWidth ); bool TransferDataToWindow() override; @@ -105,7 +111,9 @@ private: HTML_MESSAGE_BOX* m_helpWindow; wxArrayString m_existingLabelArray; // To store the previous value of the text typed in label combo - wxString m_previousLabelText; + wxString m_previousLabelText; + + std::list>* m_labelList; }; diff --git a/eeschema/dialogs/dialog_label_properties_base.cpp b/eeschema/dialogs/dialog_label_properties_base.cpp index 06352c8b93..c7ec7b4c9d 100644 --- a/eeschema/dialogs/dialog_label_properties_base.cpp +++ b/eeschema/dialogs/dialog_label_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -44,13 +44,34 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx m_valueCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); m_textEntrySizer->Add( m_valueCombo, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + m_labelMultiLine = new wxStaticText( this, wxID_ANY, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_labelMultiLine->Wrap( -1 ); + m_labelMultiLine->SetToolTip( _("Enter the text to be used within the schematic") ); + + m_textEntrySizer->Add( m_labelMultiLine, 0, wxALIGN_CENTER_VERTICAL, 2 ); + + m_valueMultiLine = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + m_textEntrySizer->Add( m_valueMultiLine, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 2 ); + m_textEntrySizer->Add( 0, 0, 1, wxEXPAND, 5 ); - m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + wxBoxSizer* bSizer7; + bSizer7 = new wxBoxSizer( wxHORIZONTAL ); + + m_cbMultiLine = new wxCheckBox( this, wxID_ANY, _("Multiple label input"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer7->Add( m_cbMultiLine, 0, 0, 5 ); + + + bSizer7->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_ALIGN_RIGHT|wxHL_CONTEXTMENU ); m_syntaxHelp->SetToolTip( _("Show syntax help window") ); - m_textEntrySizer->Add( m_syntaxHelp, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT|wxLEFT, 5 ); + bSizer7->Add( m_syntaxHelp, 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + + + m_textEntrySizer->Add( bSizer7, 1, wxEXPAND, 5 ); bMainSizer->Add( m_textEntrySizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); @@ -269,7 +290,7 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx bSizer22 = new wxBoxSizer( wxVERTICAL ); m_textColorSwatch = new COLOR_SWATCH( m_panelBorderColor1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer22->Add( m_textColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer22->Add( m_textColorSwatch, 0, 0, 5 ); m_panelBorderColor1->SetSizer( bSizer22 ); @@ -309,6 +330,8 @@ DIALOG_LABEL_PROPERTIES_BASE::DIALOG_LABEL_PROPERTIES_BASE( wxWindow* parent, wx m_valueSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); m_valueCombo->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnValueCharHook ), NULL, this ); m_valueCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_valueMultiLine->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnValueCharHook ), NULL, this ); + m_cbMultiLine->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::onMultiLabelCheck ), NULL, this ); m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnSizeGrid ), NULL, this ); m_bpAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnAddField ), NULL, this ); @@ -325,6 +348,8 @@ DIALOG_LABEL_PROPERTIES_BASE::~DIALOG_LABEL_PROPERTIES_BASE() m_valueSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); m_valueCombo->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnValueCharHook ), NULL, this ); m_valueCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this ); + m_valueMultiLine->Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnValueCharHook ), NULL, this ); + m_cbMultiLine->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::onMultiLabelCheck ), NULL, this ); m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnSizeGrid ), NULL, this ); m_bpAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_PROPERTIES_BASE::OnAddField ), NULL, this ); diff --git a/eeschema/dialogs/dialog_label_properties_base.fbp b/eeschema/dialogs/dialog_label_properties_base.fbp index 7249b4d3a1..cad9cf1cfa 100644 --- a/eeschema/dialogs/dialog_label_properties_base.fbp +++ b/eeschema/dialogs/dialog_label_properties_base.fbp @@ -1,34 +1,36 @@ - + - C++ - 1 - source_name - 0 - 0 + + 1 + connect + none + + + 0 + 1 res UTF-8 - connect dialog_label_properties_base - 1000 - none - - + 6000 1 + 1 + UI dialog_label_properties_base - . - + 0 + source_name + 1 + 0 + source_name + + + 1 1 - 1 - 1 - 1 - UI - 0 - 1 0 + 0 0 wxAUI_MGR_DEFAULT @@ -88,10 +90,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -150,10 +152,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -177,7 +179,7 @@ 0 - + 0 0 -1,-1 @@ -217,10 +219,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -279,10 +281,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -339,28 +341,18 @@ - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT|wxLEFT - 1 - + 2 + wxALIGN_CENTER_VERTICAL + 0 + 1 1 1 1 - + 0 - - + 0 + 0 @@ -380,9 +372,9 @@ 0 0 - wxID_ANY - Syntax help + Label: + 0 0 @@ -390,8 +382,7 @@ 0 1 - m_syntaxHelp - + m_labelMultiLine 1 @@ -399,18 +390,244 @@ 1 Resizable - 1 + 0 - wxHL_DEFAULT_STYLE - ; ; forward_declare + + 0 - Show syntax help window - - + Enter the text to be used within the schematic - OnFormattingHelp + -1 + + + + 2 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + -1,-1 + 1 + m_valueMultiLine + 1 + + + protected + 1 + + Resizable + 0 + + wxTE_MULTILINE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnValueCharHook + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + + bSizer7 + wxHORIZONTAL + none + + 5 + + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Multiple label input + + 0 + + + 0 + + 1 + m_cbMultiLine + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onMultiLabelCheck + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + + wxID_ANY + Syntax help + + 0 + + + 0 + + 1 + m_syntaxHelp + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_ALIGN_RIGHT|wxHL_CONTEXTMENU + ; ; forward_declare + 0 + Show syntax help window + + + + + + OnFormattingHelp + + @@ -436,10 +653,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 0 @@ -535,10 +752,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -610,10 +827,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -685,10 +902,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -770,10 +987,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -870,10 +1087,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -935,10 +1152,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1000,10 +1217,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1065,10 +1282,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1130,10 +1347,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1195,10 +1412,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1260,10 +1477,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1325,10 +1542,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1390,10 +1607,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1487,10 +1704,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1552,10 +1769,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -1615,7 +1832,7 @@ wxEXPAND|wxRIGHT|wxLEFT 0 1 - + m_iconBar wxHORIZONTAL @@ -1629,10 +1846,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -1703,10 +1920,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -1777,10 +1994,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -1851,10 +2068,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -1925,10 +2142,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -1999,10 +2216,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -2073,10 +2290,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -2147,10 +2364,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -2221,10 +2438,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2286,10 +2503,10 @@ 1 1 1 - + 0 - - + 0 + 0 0 @@ -2365,10 +2582,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2439,10 +2656,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2504,10 +2721,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2566,10 +2783,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2638,10 +2855,10 @@ 1 1 1 - + 0 - - + 0 + 0 @@ -2692,17 +2909,17 @@ none 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 1 1 1 1 - + 0 - - + 0 + 0 diff --git a/eeschema/dialogs/dialog_label_properties_base.h b/eeschema/dialogs/dialog_label_properties_base.h index ca2801cb57..48d38a2228 100644 --- a/eeschema/dialogs/dialog_label_properties_base.h +++ b/eeschema/dialogs/dialog_label_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -25,6 +25,7 @@ class WX_GRID; #include #include #include +#include #include #include #include @@ -36,7 +37,6 @@ class WX_GRID; #include #include #include -#include #include #include #include @@ -53,7 +53,7 @@ class DIALOG_LABEL_PROPERTIES_BASE : public DIALOG_SHIM protected: enum { - wxID_VALUESINGLE = 1000 + wxID_VALUESINGLE = 6000, }; wxFlexGridSizer* m_textEntrySizer; @@ -61,6 +61,9 @@ class DIALOG_LABEL_PROPERTIES_BASE : public DIALOG_SHIM wxTextCtrl* m_valueSingleLine; wxStaticText* m_labelCombo; wxComboBox* m_valueCombo; + wxStaticText* m_labelMultiLine; + wxTextCtrl* m_valueMultiLine; + wxCheckBox* m_cbMultiLine; wxHyperlinkCtrl* m_syntaxHelp; WX_GRID* m_grid; STD_BITMAP_BUTTON* m_bpAdd; @@ -105,6 +108,7 @@ class DIALOG_LABEL_PROPERTIES_BASE : public DIALOG_SHIM virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnValueCharHook( wxKeyEvent& event ) { event.Skip(); } virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } + virtual void onMultiLabelCheck( wxCommandEvent& event ) { event.Skip(); } virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } virtual void OnSizeGrid( wxSizeEvent& event ) { event.Skip(); } virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 601d42b077..5d06c28dc7 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -63,6 +63,7 @@ public: wxString edit_label_visible_columns; int edit_label_width; int edit_label_height; + bool edit_label_multiple; int erc_severities; bool footprint_preview; bool print_sheet_reference; diff --git a/eeschema/sch_validators.h b/eeschema/sch_validators.h index 7ffe0fc1df..07ade034f7 100644 --- a/eeschema/sch_validators.h +++ b/eeschema/sch_validators.h @@ -53,7 +53,6 @@ public: virtual wxObject* Clone() const override { return new SCH_NETNAME_VALIDATOR( *this ); } -protected: /// @return the error message if the contents of \a aVal are invalid. wxString IsValid( const wxString& aVal ) const override; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 704fb2b1c6..903f2a8874 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -1588,24 +1588,19 @@ wxString SCH_DRAWING_TOOLS::findWireLabelDriverName( SCH_LINE* aWire ) } -SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType ) +bool SCH_DRAWING_TOOLS::createNewLabel( const VECTOR2I& aPosition, int aType, + std::list>& aLabelList ) { SCHEMATIC* schematic = getModel(); SCHEMATIC_SETTINGS& settings = schematic->Settings(); - SCH_TEXT* textItem = nullptr; SCH_LABEL_BASE* labelItem = nullptr; SCH_GLOBALLABEL* globalLabel = nullptr; wxString netName; switch( aType ) { - case LAYER_NOTES: - textItem = new SCH_TEXT( aPosition ); - break; - case LAYER_LOCLABEL: labelItem = new SCH_LABEL( aPosition ); - textItem = labelItem; if( SCH_LINE* wire = findWire( aPosition ) ) netName = findWireLabelDriverName( wire ); @@ -1619,14 +1614,12 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType labelItem->GetFields().emplace_back( VECTOR2I(), FIELD_T::USER, labelItem, wxT( "Component Class" ) ); labelItem->GetFields().back().SetItalic( true ); labelItem->GetFields().back().SetVisible( true ); - textItem = labelItem; break; case LAYER_HIERLABEL: labelItem = new SCH_HIERLABEL( aPosition ); labelItem->SetShape( m_lastGlobalLabelShape ); labelItem->SetAutoRotateOnPlacement( m_lastAutoLabelRotateOnPlacement ); - textItem = labelItem; break; case LAYER_GLOBLABEL: @@ -1635,7 +1628,6 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType globalLabel->GetField( FIELD_T::INTERSHEET_REFS )->SetVisible( settings.m_IntersheetRefsShow ); globalLabel->SetAutoRotateOnPlacement( m_lastAutoLabelRotateOnPlacement ); labelItem = globalLabel; - textItem = globalLabel; if( SCH_LINE* wire = findWire( aPosition ) ) netName = findWireLabelDriverName( wire ); @@ -1644,86 +1636,50 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType default: wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" ); - return nullptr; + return false; } - textItem->SetParent( schematic ); + labelItem->SetParent( schematic ); - textItem->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); + labelItem->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); if( aType != LAYER_NETCLASS_REFS ) { // Must be after SetTextSize() - textItem->SetBold( m_lastTextBold ); - textItem->SetItalic( m_lastTextItalic ); + labelItem->SetBold( m_lastTextBold ); + labelItem->SetItalic( m_lastTextItalic ); } - if( labelItem ) - { - labelItem->SetSpinStyle( m_lastTextOrientation ); - } - else - { - textItem->SetHorizJustify( m_lastTextHJustify ); - textItem->SetVertJustify( m_lastTextVJustify ); - textItem->SetTextAngle( m_lastTextAngle ); - } + labelItem->SetSpinStyle( m_lastTextOrientation ); + labelItem->SetFlags( IS_NEW | IS_MOVING ); - textItem->SetFlags( IS_NEW | IS_MOVING ); - - if( !labelItem ) - { - DIALOG_TEXT_PROPERTIES dlg( m_frame, textItem ); - - // QuasiModal required for syntax help and Scintilla auto-complete - if( dlg.ShowQuasiModal() != wxID_OK ) - { - delete textItem; - return nullptr; - } - } - else if( !netName.IsEmpty() ) + if( !netName.IsEmpty() ) { // Auto-create from attached wire - textItem->SetText( netName ); + labelItem->SetText( netName ); } else { - DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast( textItem ) ); + DIALOG_LABEL_PROPERTIES dlg( m_frame, labelItem, true ); + + dlg.SetLabelList( &aLabelList ); // QuasiModal required for syntax help and Scintilla auto-complete if( dlg.ShowQuasiModal() != wxID_OK ) { dlg.GetFieldsGridTable()->DetachFields(); delete labelItem; - return nullptr; + return false; } } - wxString text = textItem->GetText(); - - if( textItem->Type() != SCH_DIRECTIVE_LABEL_T && NoPrintableChars( text ) ) - { - delete textItem; - return nullptr; - } - if( aType != LAYER_NETCLASS_REFS ) { - m_lastTextBold = textItem->IsBold(); - m_lastTextItalic = textItem->IsItalic(); + m_lastTextBold = labelItem->IsBold(); + m_lastTextItalic = labelItem->IsItalic(); } - if( labelItem ) - { - m_lastTextOrientation = labelItem->GetSpinStyle(); - } - else - { - m_lastTextHJustify = textItem->GetHorizJustify(); - m_lastTextVJustify = textItem->GetVertJustify(); - m_lastTextAngle = textItem->GetTextAngle(); - } + m_lastTextOrientation = labelItem->GetSpinStyle(); if( aType == LAYER_GLOBLABEL || aType == LAYER_HIERLABEL ) { @@ -1735,6 +1691,43 @@ SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType m_lastNetClassFlagShape = labelItem->GetShape(); } + // Return elements are kept in aLabelList + delete labelItem; + return true; +} + + +SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition ) +{ + SCHEMATIC* schematic = getModel(); + SCHEMATIC_SETTINGS& settings = schematic->Settings(); + SCH_TEXT* textItem = nullptr; + + textItem = new SCH_TEXT( aPosition ); + textItem->SetParent( schematic ); + textItem->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); + // Must be after SetTextSize() + textItem->SetBold( m_lastTextBold ); + textItem->SetItalic( m_lastTextItalic ); + textItem->SetHorizJustify( m_lastTextHJustify ); + textItem->SetVertJustify( m_lastTextVJustify ); + textItem->SetTextAngle( m_lastTextAngle ); + textItem->SetFlags( IS_NEW | IS_MOVING ); + + DIALOG_TEXT_PROPERTIES dlg( m_frame, textItem ); + + // QuasiModal required for syntax help and Scintilla auto-complete + if( dlg.ShowQuasiModal() != wxID_OK ) + { + delete textItem; + return nullptr; + } + + m_lastTextBold = textItem->IsBold(); + m_lastTextItalic = textItem->IsItalic(); + m_lastTextHJustify = textItem->GetHorizJustify(); + m_lastTextVJustify = textItem->GetVertJustify(); + m_lastTextAngle = textItem->GetTextAngle(); return textItem; } @@ -1839,6 +1832,25 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) item = nullptr; }; + auto prepItemForPlacement = + [&]( SCH_ITEM* aItem, const VECTOR2I& cursorPos ) + { + item->SetPosition( cursorPos ); + + item->SetFlags( IS_NEW | IS_MOVING ); + + // Not placed yet, so pass a nullptr screen reference + item->AutoplaceFields( nullptr, AUTOPLACE_AUTO ); + + updatePreview(); + m_selectionTool->AddItemToSel( item ); + m_toolMgr->PostAction( ACTIONS::refreshPreview ); + + // update the cursor so it looks correct before another event + setCursor(); + }; + + Activate(); // Must be done after Activate() so that it gets set into the correct context @@ -1859,6 +1871,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } SCH_COMMIT commit( m_toolMgr ); + std::list> itemsToPlace; // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -1930,7 +1943,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) if( isText ) { - item = createNewText( cursorPos, LAYER_NOTES ); + item = createNewText( cursorPos ); description = _( "Add Text" ); } else if( isHierLabel ) @@ -1951,28 +1964,28 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) label->SetTextSize( VECTOR2I( schematic->Settings().m_DefaultTextSize, schematic->Settings().m_DefaultTextSize ) ); label->SetFlags( IS_NEW | IS_MOVING ); - item = label; + itemsToPlace.push_back( std::unique_ptr( label ) ); } else { - item = createNewText( cursorPos, LAYER_HIERLABEL ); + createNewLabel( cursorPos, LAYER_HIERLABEL, itemsToPlace ); } description = _( "Add Hierarchical Label" ); } else if( isNetLabel ) { - item = createNewText( cursorPos, LAYER_LOCLABEL ); + createNewLabel( cursorPos, LAYER_LOCLABEL, itemsToPlace ); description = _( "Add Label" ); } else if( isGlobalLabel ) { - item = createNewText( cursorPos, LAYER_GLOBLABEL ); + createNewLabel( cursorPos, LAYER_GLOBLABEL, itemsToPlace ); description = _( "Add Label" ); } else if( isClassLabel ) { - item = createNewText( cursorPos, LAYER_NETCLASS_REFS ); + createNewLabel( cursorPos, LAYER_NETCLASS_REFS, itemsToPlace ); description = _( "Add Label" ); } else if( isSheetPin ) @@ -2042,23 +2055,15 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) cursorPos = grid.BestSnapAnchor( cursorPos, snapGrid, item ); } - if( item ) + if( !itemsToPlace.empty() ) { - item->SetPosition( cursorPos ); - - item->SetFlags( IS_NEW | IS_MOVING ); - - // Not placed yet, so pass a nullptr screen reference - item->AutoplaceFields( nullptr, AUTOPLACE_AUTO ); - - updatePreview(); - m_selectionTool->AddItemToSel( item ); - m_toolMgr->PostAction( ACTIONS::refreshPreview ); - - // update the cursor so it looks correct before another event - setCursor(); + item = itemsToPlace.front().release(); + itemsToPlace.pop_front(); } + if( item ) + prepItemForPlacement( item, cursorPos ); + controls->SetCursorPosition( cursorPos, false ); } else // ... and second click places: @@ -2123,6 +2128,13 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) item = createNewSheetPinFromLabel( sheet, cursorPos, label ); } + else if( !itemsToPlace.empty() ) + { + + item = itemsToPlace.front().release(); + itemsToPlace.pop_front(); + prepItemForPlacement( item, cursorPos ); + } } } else if( evt->IsClick( BUT_RIGHT ) ) diff --git a/eeschema/tools/sch_drawing_tools.h b/eeschema/tools/sch_drawing_tools.h index 1a9a6f9e62..d904702749 100644 --- a/eeschema/tools/sch_drawing_tools.h +++ b/eeschema/tools/sch_drawing_tools.h @@ -73,7 +73,10 @@ private: ///< Gets the (global) label name driving this wire, if it is driven by a label wxString findWireLabelDriverName( SCH_LINE* aWire ); - SCH_TEXT* createNewText( const VECTOR2I& aPosition, int aType ); + SCH_TEXT* createNewText( const VECTOR2I& aPosition ); + + bool createNewLabel( const VECTOR2I& aPosition, int aType, + std::list>& aLabelList ); SCH_SHEET_PIN* createNewSheetPin( SCH_SHEET* aSheet, const VECTOR2I& aPosition ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 77a61a104c..caa836053e 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2294,7 +2294,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) case SCH_HIER_LABEL_T: case SCH_DIRECTIVE_LABEL_T: { - DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast( curr_item ) ); + DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast( curr_item ), false ); // QuasiModal for syntax help and Scintilla auto-complete dlg.ShowQuasiModal(); diff --git a/include/validators.h b/include/validators.h index 9032a16b8f..f950c59463 100644 --- a/include/validators.h +++ b/include/validators.h @@ -103,7 +103,6 @@ public: virtual bool Validate( wxWindow *aParent ) override; -protected: /// @return the error message if the contents of @a aVal are invalid. wxString IsValid( const wxString& aVal ) const override;