diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp index 72a2829e99..8df6ed710b 100644 --- a/common/widgets/color_swatch.cpp +++ b/common/widgets/color_swatch.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. - * Copyright (C) 2017-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -31,7 +31,8 @@ wxDEFINE_EVENT(COLOR_SWATCH_CHANGED, wxCommandEvent); using KIGFX::COLOR4D; -const static wxSize SWATCH_SIZE_DU( 8, 6 ); +const static wxSize PALETTE_SWATCH_SIZE_DU( 8, 6 ); +const static wxSize DIALOG_SWATCH_SIZE_DU( 24, 10 ); // See selcolor.cpp: extern COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor ); @@ -63,49 +64,69 @@ wxBitmap COLOR_SWATCH::MakeBitmap( COLOR4D aColor, COLOR4D aBackground, wxSize a } -/** - * Function makeColorButton - * creates a wxStaticBitmap and assigns it a solid color and a control ID - */ -static std::unique_ptr makeColorSwatch( wxWindow* aParent, COLOR4D aColor, - COLOR4D aBackground, int aID ) -{ - static wxSize size = aParent->ConvertDialogToPixels( SWATCH_SIZE_DU ); - - wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( aColor, aBackground, size ); - auto ret = std::make_unique( aParent, aID, bitmap ); - - return ret; -} - - COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground, - const COLOR4D aDefault ) : + const COLOR4D aDefault ) : wxPanel( aParent, aID ), m_color( aColor ), m_background( aBackground ), m_default( aDefault ) { + m_size = ConvertDialogToPixels( PALETTE_SWATCH_SIZE_DU ); + auto sizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( sizer ); - auto swatch = makeColorSwatch( this, m_color, m_background, aID ); - m_swatch = swatch.release(); // hold a handle + wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( aColor, aBackground, m_size ); + m_swatch = new wxStaticBitmap( this, aID, bitmap ); sizer->Add( m_swatch, 0, 0 ); + setupEvents(); +} + + +COLOR_SWATCH::COLOR_SWATCH( wxWindow *aParent, wxWindowID aID, const wxPoint &aPos, + const wxSize &aSize, long aStyle ) : + wxPanel( aParent, aID, aPos, aSize, aStyle ) +{ + if( aSize == wxDefaultSize ) + m_size = ConvertDialogToPixels( DIALOG_SWATCH_SIZE_DU ); + else + m_size = aSize; + + SetSize( m_size ); + + auto sizer = new wxBoxSizer( wxHORIZONTAL ); + SetSizer( sizer ); + + wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( KIGFX::COLOR4D::UNSPECIFIED, + KIGFX::COLOR4D::UNSPECIFIED, m_size ); + m_swatch = new wxStaticBitmap( this, aID, bitmap ); + + sizer->Add( m_swatch, 0, 0 ); + + setupEvents(); +} + + +void COLOR_SWATCH::setupEvents() +{ // forward click to any other listeners, since we don't want them m_swatch->Bind( wxEVT_LEFT_DOWN, &COLOR_SWATCH::rePostEvent, this ); m_swatch->Bind( wxEVT_RIGHT_DOWN, &COLOR_SWATCH::rePostEvent, this ); // bind the events that trigger the dialog - m_swatch->Bind( wxEVT_LEFT_DCLICK, [this] ( wxMouseEvent& aEvt ) { - GetNewSwatchColor(); - } ); + m_swatch->Bind( wxEVT_LEFT_DCLICK, + [this] ( wxMouseEvent& aEvt ) + { + GetNewSwatchColor(); + } ); - m_swatch->Bind( wxEVT_MIDDLE_DOWN, [this] ( wxMouseEvent& aEvt ) { - GetNewSwatchColor(); - } ); + m_swatch->Bind( wxEVT_MIDDLE_DOWN, + [this] ( wxMouseEvent& aEvt ) + { + GetNewSwatchColor(); + } ); } @@ -131,20 +152,18 @@ void COLOR_SWATCH::SetSwatchColor( COLOR4D aColor, bool sendEvent ) { m_color = aColor; - wxBitmap bm = MakeBitmap( m_color, m_background, ConvertDialogToPixels( SWATCH_SIZE_DU ) ); + wxBitmap bm = MakeBitmap( m_color, m_background, m_size ); m_swatch->SetBitmap( bm ); if( sendEvent ) - { sendSwatchChangeEvent( *this ); - } } void COLOR_SWATCH::SetSwatchBackground( COLOR4D aBackground ) { m_background = aBackground; - wxBitmap bm = MakeBitmap( m_color, m_background, ConvertDialogToPixels( SWATCH_SIZE_DU ) ); + wxBitmap bm = MakeBitmap( m_color, m_background, m_size ); m_swatch->SetBitmap( bm ); } @@ -168,7 +187,7 @@ void COLOR_SWATCH::GetNewSwatchColor() { m_color = newColor; - wxBitmap bm = MakeBitmap( newColor, m_background, ConvertDialogToPixels( SWATCH_SIZE_DU ) ); + wxBitmap bm = MakeBitmap( newColor, m_background, m_size ); m_swatch->SetBitmap( bm ); sendSwatchChangeEvent( *this ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp index 863b2dafa5..6f694ec663 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 10 2019) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -230,7 +230,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_stdDialogButtonSizer->AddButton( m_stdDialogButtonSizerCancel ); m_stdDialogButtonSizer->Realize(); - bSizerBottom->Add( m_stdDialogButtonSizer, 0, wxEXPAND, 5 ); + bSizerBottom->Add( m_stdDialogButtonSizer, 0, wxEXPAND|wxALL, 5 ); mainSizer->Add( bSizerBottom, 0, wxEXPAND, 5 ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index 258136a0f0..4eb2d520b2 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -14,7 +14,6 @@ dialog_edit_component_in_schematic_base 1000 none - 1 dialog_edit_component_in_schematic_base @@ -26,7 +25,6 @@ 1 1 UI - 0 0 0 @@ -1442,7 +1440,7 @@ 5 - wxEXPAND + wxEXPAND|wxALL 0 0 diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h index 2296d372cd..b93a6165e5 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jul 10 2019) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/eeschema/dialogs/dialog_sch_sheet_props.cpp b/eeschema/dialogs/dialog_sch_sheet_props.cpp index f10fe1736f..b6ff2bbe7d 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2014-2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,13 +34,15 @@ #include #include #include +#include DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet, bool* aClearAnnotationNewItems ) : DIALOG_SCH_SHEET_PROPS_BASE( aParent ), m_frame( aParent ), - m_clearAnnotationNewItems( aClearAnnotationNewItems ) + m_clearAnnotationNewItems( aClearAnnotationNewItems ), + m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) { m_sheet = aSheet; m_fields = new FIELDS_GRID_TABLE( this, aParent, m_sheet ); @@ -126,9 +128,29 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataToWindow() m_grid->ProcessTableMessage( msg ); AdjustGridColumns( m_grid->GetRect().GetWidth() ); - m_heirarchyPath->SetValue( g_CurrentSheet->PathHumanReadable() ); + // border width + m_borderWidth.SetValue( m_sheet->GetBorderWidth() ); - // Set the component's unique ID time stamp. + // set up color swatches + COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); + KIGFX::COLOR4D borderColor = m_sheet->GetBorderColor(); + KIGFX::COLOR4D backgroundColor = m_sheet->GetBackgroundColor(); + + if( borderColor == COLOR4D::UNSPECIFIED ) + borderColor = colorSettings->GetColor( LAYER_SHEET ); + + if( backgroundColor == COLOR4D::UNSPECIFIED ) + backgroundColor = colorSettings->GetColor( LAYER_SHEET_BACKGROUND ); + + m_borderColorSwatch->SetSwatchColor( borderColor, false ); + m_backgroundColorSwatch->SetSwatchColor( backgroundColor, false ); + + KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); + m_borderColorSwatch->SetSwatchBackground( canvas ); + m_backgroundColorSwatch->SetSwatchBackground( canvas ); + + // set up the read-only fields + m_heirarchyPath->SetValue( g_CurrentSheet->PathHumanReadable() ); m_textCtrlTimeStamp->SetValue( m_sheet->m_Uuid.AsString() ); Layout(); @@ -444,6 +466,10 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow() if( m_clearAnnotationNewItems ) *m_clearAnnotationNewItems = clearAnnotation; + m_sheet->SetBorderWidth( m_borderWidth.GetValue() ); + m_sheet->SetBorderColor( m_borderColorSwatch->GetSwatchColor() ); + m_sheet->SetBackgroundColor( m_backgroundColorSwatch->GetSwatchColor() ); + m_frame->TestDanglingEnds(); m_frame->RefreshItem( m_sheet ); m_frame->OnModify(); diff --git a/eeschema/dialogs/dialog_sch_sheet_props.h b/eeschema/dialogs/dialog_sch_sheet_props.h index fa607f7bdc..ee57f6345a 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.h +++ b/eeschema/dialogs/dialog_sch_sheet_props.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,8 +25,9 @@ #ifndef __dialog_sch_sheet_props__ #define __dialog_sch_sheet_props__ -#include #include +#include +#include class SCH_SHEET; @@ -52,6 +53,7 @@ private: wxString m_shownColumns; FIELDS_GRID_TABLE* m_fields; + UNIT_BINDER m_borderWidth; bool TransferDataToWindow() override; bool TransferDataFromWindow() override; diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp index 6029e98bb5..2351855a09 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp @@ -115,12 +115,47 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText2 = new wxStaticText( this, wxID_ANY, _("Hierarchical Path:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText2->Wrap( -1 ); - bSizer5->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + wxStaticBoxSizer* sbSizer2; + sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Style") ), wxHORIZONTAL ); - m_heirarchyPath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); - bSizer5->Add( m_heirarchyPath, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + m_borderWidthLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Border width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthLabel->Wrap( -1 ); + sbSizer2->Add( m_borderWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); + + m_borderWidthCtrl = new wxTextCtrl( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer2->Add( m_borderWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_borderWidthUnits = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthUnits->Wrap( -1 ); + sbSizer2->Add( m_borderWidthUnits, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + + + sbSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_borderColorLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Border color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderColorLabel->Wrap( -1 ); + sbSizer2->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_borderColorSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_borderColorSwatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + m_borderColorSwatch->SetMinSize( wxSize( 48,24 ) ); + + sbSizer2->Add( m_borderColorSwatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + + sbSizer2->Add( 40, 0, 1, wxEXPAND, 5 ); + + m_backgroundColorLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Background fill:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_backgroundColorLabel->Wrap( -1 ); + sbSizer2->Add( m_backgroundColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_backgroundColorSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_backgroundColorSwatch->SetMinSize( wxSize( 48,24 ) ); + + sbSizer2->Add( m_backgroundColorSwatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer5->Add( sbSizer2, 1, wxEXPAND|wxBOTTOM, 5 ); m_longForm->Add( bSizer5, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); @@ -129,29 +164,39 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi mainSizer->Add( m_longForm, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - mainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + mainSizer->Add( m_staticline1, 0, wxEXPAND|wxALL, 5 ); wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizerUUID; - bSizerUUID = new wxBoxSizer( wxHORIZONTAL ); + wxFlexGridSizer* fgSizer1; + fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer1->AddGrowableCol( 1 ); + fgSizer1->SetFlexibleDirection( wxHORIZONTAL ); + fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("Hierarchical Path:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_heirarchyPath = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); + fgSizer1->Add( m_heirarchyPath, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxStaticText* timeStampLabel; timeStampLabel = new wxStaticText( this, wxID_ANY, _("Unique ID:"), wxDefaultPosition, wxDefaultSize, 0 ); timeStampLabel->Wrap( -1 ); - bSizerUUID->Add( timeStampLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + fgSizer1->Add( timeStampLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_textCtrlTimeStamp = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); m_textCtrlTimeStamp->SetToolTip( _("Unique ID that identifies the symbol") ); - bSizerUUID->Add( m_textCtrlTimeStamp, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgSizer1->Add( m_textCtrlTimeStamp, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - bSizerBottom->Add( bSizerUUID, 3, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bSizerBottom->Add( fgSizer1, 1, wxEXPAND|wxALL, 5 ); - bSizerBottom->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizerBottom->Add( 100, 0, 0, wxEXPAND, 5 ); m_stdDialogButtonSizer = new wxStdDialogButtonSizer(); m_stdDialogButtonSizerOK = new wxButton( this, wxID_OK ); diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.fbp b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp index aecb160bd1..80e146bc1c 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.fbp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.fbp @@ -48,7 +48,7 @@ 864,440 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU DIALOG_SHIM; dialog_shim.h - Symbol Properties + Sheet Properties @@ -506,127 +506,468 @@ none 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Hierarchical Path: - 0 - - 0 - - - 0 - - 1 - m_staticText2 - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxEXPAND|wxBOTTOM 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 + wxID_ANY - - 0 - - - - 0 + Style - 1 - m_heirarchyPath - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_READONLY - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - + sbSizer2 + wxHORIZONTAL + 1 + none + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border width: + 0 + + 0 + + + 0 + + 1 + m_borderWidthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_borderWidthCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + units + 0 + + 0 + + + 0 + + 1 + m_borderWidthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border color: + 0 + + 0 + + + 0 + + 1 + m_borderColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + wxSYS_COLOUR_WINDOW + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + 48,24 + 1 + m_borderColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; Not forward_declare + 0 + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 40 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Background fill: + 0 + + 0 + + + 0 + + 1 + m_backgroundColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + 48,24 + 1 + m_backgroundColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; Not forward_declare + 0 + + + + + + @@ -634,8 +975,8 @@ - 10 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 5 + wxEXPAND|wxALL 0 1 @@ -702,16 +1043,148 @@ none 5 - wxEXPAND|wxRIGHT|wxLEFT - 3 - + wxEXPAND|wxALL + 1 + + 2 + wxHORIZONTAL + 1 + + 0 - bSizerUUID - wxHORIZONTAL + fgSizer1 + wxFLEX_GROWMODE_SPECIFIED none + 0 + 0 + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Hierarchical Path: + 0 + + 0 + + + 0 + + 1 + m_staticText2 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_heirarchyPath + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -772,8 +1245,8 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL - 1 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 1 1 @@ -839,11 +1312,11 @@ 5 wxEXPAND - 1 + 0 0 protected - 0 + 100 diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.h b/eeschema/dialogs/dialog_sch_sheet_props_base.h index 69a13daca5..43e48a82c3 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.h +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.h @@ -12,6 +12,7 @@ #include class WX_GRID; +#include "widgets/color_swatch.h" #include "dialog_shim.h" #include #include @@ -48,9 +49,16 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM wxBitmapButton* m_bpMoveUp; wxBitmapButton* m_bpMoveDown; wxBitmapButton* m_bpDelete; + wxStaticText* m_borderWidthLabel; + wxTextCtrl* m_borderWidthCtrl; + wxStaticText* m_borderWidthUnits; + wxStaticText* m_borderColorLabel; + COLOR_SWATCH* m_borderColorSwatch; + wxStaticText* m_backgroundColorLabel; + COLOR_SWATCH* m_backgroundColorSwatch; + wxStaticLine* m_staticline1; wxStaticText* m_staticText2; wxTextCtrl* m_heirarchyPath; - wxStaticLine* m_staticline1; wxTextCtrl* m_textCtrlTimeStamp; wxStdDialogButtonSizer* m_stdDialogButtonSizer; wxButton* m_stdDialogButtonSizerOK; @@ -68,7 +76,7 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM public: - DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,440 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,440 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_SCH_SHEET_PROPS_BASE(); }; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index f4b9e24233..75efe5fd3d 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 CERN - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -230,8 +230,7 @@ float SCH_PAINTER::getShadowWidth() // For best visuals the selection width must be a cross between the zoom level and the // default line width. - return static_cast( - fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() ); + return static_cast( fabs( matrix.GetScale().x * 2.75 ) + GetSelectionThickness() ); } @@ -246,6 +245,19 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr if( lineColor != COLOR4D::UNSPECIFIED ) color = lineColor; } + else if( aItem->Type() == SCH_SHEET_T ) + { + SCH_SHEET* sheet = (SCH_SHEET*) aItem; + COLOR4D sheetColor = COLOR4D::UNSPECIFIED; + + if( aLayer == LAYER_SHEET ) + sheetColor = sheet->GetBorderColor(); + else if( aLayer == LAYER_SHEET_BACKGROUND ) + sheetColor = sheet->GetBackgroundColor(); + + if( sheetColor != COLOR4D::UNSPECIFIED ) + color = sheetColor; + } if( aItem->IsBrightened() && !aDrawingShadows ) // Selection disambiguation, etc. { @@ -1547,23 +1559,9 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer ) if( aLayer == LAYER_SHEET_BACKGROUND ) { - m_gal->SetIsStroke( aSheet->IsSelected() ); - m_gal->SetLineWidth( getShadowWidth() ); - m_gal->SetStrokeColor( getRenderColor( aSheet, LAYER_SHEET_BACKGROUND, true ) ); - - if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look - { - // Select a fill color working well with black and white background color, - // both in Opengl and Cairo - m_gal->SetFillColor( COLOR4D( 0.1, 0.5, 0.5, 0.3 ) ); - m_gal->SetIsFill( true ); - } - else - { - // Could be modified later, when sheets can have their own fill color - m_gal->SetFillColor( getRenderColor( aSheet, LAYER_SHEET_BACKGROUND, true ) ); - m_gal->SetIsFill( aSheet->IsSelected() && GetSelectionFillShapes() ); - } + m_gal->SetFillColor( getRenderColor( aSheet, LAYER_SHEET_BACKGROUND, true ) ); + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); m_gal->DrawRectangle( pos, pos + size ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 35a4807e32..163fa57538 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -89,6 +89,10 @@ SCH_SHEET::SCH_SHEET( const wxPoint& pos ) : } m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO; + + m_borderWidth = GetDefaultLineThickness(); + m_borderColor = KIGFX::COLOR4D::UNSPECIFIED; + m_backgroundColor = KIGFX::COLOR4D::UNSPECIFIED; } @@ -109,6 +113,10 @@ SCH_SHEET::SCH_SHEET( const SCH_SHEET& aSheet ) : m_pins.back()->SetParent( this ); } + m_borderWidth = aSheet.m_borderWidth; + m_borderColor = aSheet.m_borderColor; + m_backgroundColor = aSheet.m_backgroundColor; + if( m_screen ) m_screen->IncRefCount(); } @@ -202,6 +210,10 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem ) for( SCH_SHEET_PIN* sheetPin : sheet->m_pins ) sheetPin->SetParent( sheet ); + + std::swap( m_borderWidth, sheet->m_borderWidth ); + std::swap( m_borderColor, sheet->m_borderColor ); + std::swap( m_backgroundColor, sheet->m_backgroundColor ); } @@ -422,7 +434,7 @@ SCH_SHEET_PIN* SCH_SHEET::GetPin( const wxPoint& aPosition ) int SCH_SHEET::GetPenSize() const { - return GetDefaultLineThickness(); + return GetBorderWidth(); } @@ -485,7 +497,7 @@ void SCH_SHEET::Print( wxDC* aDC, const wxPoint& aOffset ) wxString Text; wxPoint pos = m_pos + aOffset; int lineWidth = GetPenSize(); - COLOR4D color = GetLayerColor( m_Layer ); + COLOR4D color = GetBorderColor(); GRRect( nullptr, aDC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, color ); @@ -711,6 +723,7 @@ void SCH_SHEET::MirrorY( int aYaxis_position ) sheetPin->MirrorY( aYaxis_position ); } + void SCH_SHEET::SetPosition( const wxPoint& aPosition ) { // Remember the sheet and all pin sheet positions must be @@ -719,7 +732,6 @@ void SCH_SHEET::SetPosition( const wxPoint& aPosition ) } - void SCH_SHEET::Resize( const wxSize& aSize ) { if( aSize == m_size ) diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 266348c8fb..b9e75480fd 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -229,6 +229,10 @@ class SCH_SHEET : public SCH_ITEM wxPoint m_pos; // The position of the sheet. wxSize m_size; // The size of the sheet. + int m_borderWidth; + KIGFX::COLOR4D m_borderColor; + KIGFX::COLOR4D m_backgroundColor; + public: SCH_SHEET( const wxPoint& pos = wxPoint( 0, 0 ) ); @@ -294,6 +298,15 @@ public: wxSize GetSize() { return m_size; } void SetSize( const wxSize& aSize ) { m_size = aSize; } + int GetBorderWidth() const { return m_borderWidth; } + void SetBorderWidth( int aWidth ) { m_borderWidth = aWidth; } + + KIGFX::COLOR4D GetBorderColor() const { return m_borderColor; } + void SetBorderColor( KIGFX::COLOR4D aColor ) { m_borderColor = aColor; } + + KIGFX::COLOR4D GetBackgroundColor() const { return m_backgroundColor; } + void SetBackgroundColor( KIGFX::COLOR4D aColor ) { m_backgroundColor = aColor; } + /** * Return the root sheet of this SCH_SHEET object. * @@ -498,6 +511,9 @@ public: for( SCH_SHEET_PIN* pin : m_pins ) pin->Move( aMoveVector ); + + for( SCH_FIELD& field : m_fields ) + field.Move( aMoveVector ); } void MirrorY( int aYaxis_position ) override; diff --git a/include/widgets/color_swatch.h b/include/widgets/color_swatch.h index f95d2f75c3..6392a26b56 100644 --- a/include/widgets/color_swatch.h +++ b/include/widgets/color_swatch.h @@ -47,7 +47,13 @@ public: * @param aID id to use when sending swatch events */ COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground, - const KIGFX::COLOR4D aDefault = KIGFX::COLOR4D::UNSPECIFIED ); + const KIGFX::COLOR4D aDefault = KIGFX::COLOR4D::UNSPECIFIED ); + + /** + * constructor for wxFormBuilder + */ + COLOR_SWATCH( wxWindow *aParent, wxWindowID aId, const wxPoint &aPos = wxDefaultPosition, + const wxSize &aSize = wxDefaultSize, long aStyle = 0 ); /** * Set the current swatch color directly. @@ -74,6 +80,7 @@ public: static wxBitmap MakeBitmap( KIGFX::COLOR4D aColor, KIGFX::COLOR4D aBackground, wxSize aSize ); private: + void setupEvents(); /** * Pass unwanted events on to listeners of this object @@ -91,6 +98,8 @@ private: ///> Handle of the actual swatch shown wxStaticBitmap* m_swatch; + + wxSize m_size; };