From a0421b172ada658fe125e5a3d3a5bcfce4884ebc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 11 Jun 2022 20:58:12 +0100 Subject: [PATCH] Add missing color swatch to Symbol Editor Text Properties. Fixes https://gitlab.com/kicad/code/kicad/issues/11791 --- .../dialogs/dialog_lib_text_properties.cpp | 12 +- .../dialog_lib_text_properties_base.cpp | 33 +- .../dialog_lib_text_properties_base.fbp | 448 +++++++++++++----- .../dialogs/dialog_lib_text_properties_base.h | 5 + 4 files changed, 371 insertions(+), 127 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index 5b63e06896..1f7e5f52c4 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -36,10 +37,12 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText ) : DIALOG_LIB_TEXT_PROPERTIES_BASE( aParent ), + m_parent( aParent ), + m_graphicText( aText ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) { - m_parent = aParent; - m_graphicText = aText; + COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings(); + COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), false, [this]() @@ -83,6 +86,9 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aPare m_separator5->SetIsSeparator(); + m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + m_textColorSwatch->SetSwatchBackground( schematicBackground ); + m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); m_vertical->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); @@ -122,6 +128,7 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() m_StyledTextCtrl->SetValue( m_graphicText->GetText() ); m_fontCtrl->SetFontSelection( m_graphicText->GetFont() ); + m_textColorSwatch->SetSwatchColor( m_graphicText->GetTextColor(), false ); m_italic->Check( m_graphicText->IsItalic() ); m_bold->Check( m_graphicText->IsBold() ); @@ -236,6 +243,7 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() m_graphicText->SetItalic( m_italic->IsChecked() ); m_graphicText->SetBold( m_bold->IsChecked() ); + m_graphicText->SetTextColor( m_textColorSwatch->GetSwatchColor() ); if( m_hAlignLeft->IsChecked() ) m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.cpp b/eeschema/dialogs/dialog_lib_text_properties_base.cpp index 80fa9738ed..6d8cd54b1f 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.cpp @@ -6,6 +6,7 @@ /////////////////////////////////////////////////////////////////////////// #include "widgets/bitmap_button.h" +#include "widgets/color_swatch.h" #include "widgets/font_choice.h" #include "dialog_lib_text_properties_base.h" @@ -158,12 +159,38 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare m_textSizeLabel->Wrap( -1 ); gbSizer1->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_textSizeCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + wxBoxSizer* bSizer71; + bSizer71 = new wxBoxSizer( wxHORIZONTAL ); + + m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizer71->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); - gbSizer1->Add( m_textSizeUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + bSizer71->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 ); + + m_textColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textColorLabel->Wrap( -1 ); + bSizer71->Add( m_textColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); + + + bSizer71->Add( 5, 0, 0, 0, 5 ); + + m_panelBorderColor1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer221; + bSizer221 = new wxBoxSizer( wxVERTICAL ); + + m_textColorSwatch = new COLOR_SWATCH( m_panelBorderColor1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer221->Add( m_textColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelBorderColor1->SetSizer( bSizer221 ); + m_panelBorderColor1->Layout(); + bSizer221->Fit( m_panelBorderColor1 ); + bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + gbSizer1->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); gbSizer1->Add( m_privateCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 2 ), wxLEFT, 5 ); diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.fbp b/eeschema/dialogs/dialog_lib_text_properties_base.fbp index 2e55169235..036609f281 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.fbp @@ -1511,131 +1511,335 @@ 5 1 1 - wxALIGN_CENTER_VERTICAL + wxEXPAND 3 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 + - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - 1 - 2 - wxALIGN_CENTER_VERTICAL|wxLEFT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 + bSizer71 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + -1,-1 + 0 + -1,-1 + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 3 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + -1,-1 + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 15 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Color: + 0 + + 0 + + + 0 + + 1 + m_textColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; Not forward_declare + 0 + + + + + -1 + + + + 5 + + 0 + + 0 + protected + 5 + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelBorderColor1 + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer221 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_textColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.h b/eeschema/dialogs/dialog_lib_text_properties_base.h index e10bc9499c..392f2249ab 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.h +++ b/eeschema/dialogs/dialog_lib_text_properties_base.h @@ -11,6 +11,7 @@ #include #include class BITMAP_BUTTON; +class COLOR_SWATCH; class FONT_CHOICE; #include "dialog_shim.h" @@ -29,6 +30,7 @@ class FONT_CHOICE; #include #include #include +#include #include #include #include @@ -66,6 +68,9 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl; wxStaticText* m_textSizeUnits; + wxStaticText* m_textColorLabel; + wxPanel* m_panelBorderColor1; + COLOR_SWATCH* m_textColorSwatch; wxCheckBox* m_privateCheckbox; wxCheckBox* m_CommonUnit; wxCheckBox* m_CommonConvert;