diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index af777411b0..bc43d6063a 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -103,6 +103,8 @@ set( EESCHEMA_DLGS dialogs/panel_eeschema_settings_base.cpp dialogs/panel_libedit_settings.cpp dialogs/panel_libedit_settings_base.cpp + dialogs/panel_libedit_color_settings.cpp + dialogs/panel_libedit_color_settings_base.cpp dialogs/panel_sym_lib_table.cpp dialogs/panel_sym_lib_table_base.cpp ) diff --git a/eeschema/dialogs/panel_libedit_color_settings.cpp b/eeschema/dialogs/panel_libedit_color_settings.cpp new file mode 100644 index 0000000000..863cada7f2 --- /dev/null +++ b/eeschema/dialogs/panel_libedit_color_settings.cpp @@ -0,0 +1,79 @@ +/* +* This program source code file is part of KiCad, a free EDA CAD application. +* +* Copyright (C) 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 +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, you may find one here: +* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +* or you may search the http://www.gnu.org website for the version 2 license, +* or you may write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "panel_libedit_color_settings.h" + + +PANEL_LIBEDIT_COLOR_SETTINGS::PANEL_LIBEDIT_COLOR_SETTINGS( LIB_EDIT_FRAME* aFrame, + wxWindow* aWindow ) + : PANEL_LIBEDIT_COLOR_SETTINGS_BASE( aWindow ), m_frame( aFrame ) +{ +} + + +bool PANEL_LIBEDIT_COLOR_SETTINGS::TransferDataToWindow() +{ + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + + m_useEeschemaTheme->SetValue( cfg->m_UseEeschemaColorSettings ); + + COLOR_SETTINGS* current = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + + for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) + { + int pos = m_themeSelection->Append( settings->GetName(), static_cast( settings ) ); + + if( settings == current ) + m_themeSelection->SetSelection( pos ); + } + + return true; +} + + +bool PANEL_LIBEDIT_COLOR_SETTINGS::TransferDataFromWindow() +{ + auto selected = static_cast( + m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) ); + + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + + cfg->m_UseEeschemaColorSettings = m_useEeschemaTheme->GetValue(); + cfg->m_ColorTheme = selected->GetFilename(); + + if( cfg->m_UseEeschemaColorSettings ) + selected = m_frame->GetColorSettings(); + + auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); + settings->LoadColors( selected ); + + return true; +} diff --git a/eeschema/dialogs/panel_libedit_color_settings.h b/eeschema/dialogs/panel_libedit_color_settings.h new file mode 100644 index 0000000000..7f4c8a1796 --- /dev/null +++ b/eeschema/dialogs/panel_libedit_color_settings.h @@ -0,0 +1,45 @@ +/* +* This program source code file is part of KiCad, a free EDA CAD application. +* +* Copyright (C) 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 +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, you may find one here: +* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +* or you may search the http://www.gnu.org website for the version 2 license, +* or you may write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +*/ + +#ifndef PANEL_LIBEDIT_COLOR_SETTINGS_H +#define PANEL_LIBEDIT_COLOR_SETTINGS_H + +#include "panel_libedit_color_settings_base.h" + +class LIB_EDIT_FRAME; + + +class PANEL_LIBEDIT_COLOR_SETTINGS : public PANEL_LIBEDIT_COLOR_SETTINGS_BASE +{ + LIB_EDIT_FRAME* m_frame; + +public: + PANEL_LIBEDIT_COLOR_SETTINGS( LIB_EDIT_FRAME* aFrame, wxWindow* aWindow ); + +private: + bool TransferDataToWindow() override; + + bool TransferDataFromWindow() override; +}; + +#endif diff --git a/eeschema/dialogs/panel_libedit_color_settings_base.cpp b/eeschema/dialogs/panel_libedit_color_settings_base.cpp new file mode 100644 index 0000000000..9631606871 --- /dev/null +++ b/eeschema/dialogs/panel_libedit_color_settings_base.cpp @@ -0,0 +1,56 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "panel_libedit_color_settings_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_LIBEDIT_COLOR_SETTINGS_BASE::PANEL_LIBEDIT_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* p1mainSizer; + p1mainSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbSizer1; + sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Color Theme") ), wxVERTICAL ); + + sbSizer1->SetMinSize( wxSize( 250,-1 ) ); + m_useEeschemaTheme = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Use Eeschema color theme"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer1->Add( m_useEeschemaTheme, 0, wxALL|wxEXPAND, 10 ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText16 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Theme:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText16->Wrap( -1 ); + bSizer3->Add( m_staticText16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxArrayString m_themeSelectionChoices; + m_themeSelection = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themeSelectionChoices, 0 ); + m_themeSelection->SetSelection( 0 ); + bSizer3->Add( m_themeSelection, 1, wxALL, 5 ); + + + sbSizer1->Add( bSizer3, 0, wxALL|wxEXPAND, 5 ); + + + sbSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + + p1mainSizer->Add( sbSizer1, 0, 0, 5 ); + + + p1mainSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + + this->SetSizer( p1mainSizer ); + this->Layout(); + p1mainSizer->Fit( this ); +} + +PANEL_LIBEDIT_COLOR_SETTINGS_BASE::~PANEL_LIBEDIT_COLOR_SETTINGS_BASE() +{ +} diff --git a/eeschema/dialogs/panel_libedit_color_settings_base.fbp b/eeschema/dialogs/panel_libedit_color_settings_base.fbp new file mode 100644 index 0000000000..a872609f70 --- /dev/null +++ b/eeschema/dialogs/panel_libedit_color_settings_base.fbp @@ -0,0 +1,294 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + table + panel_libedit_color_settings_base + 1000 + none + + 1 + PanelLibeditColorSettingsBase + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_LIBEDIT_COLOR_SETTINGS_BASE + + -1,-1 + ; forward_declare + + + + wxTAB_TRAVERSAL + + + p1mainSizer + wxHORIZONTAL + none + + 5 + + 0 + + wxID_ANY + Color Theme + 250,-1 + sbSizer1 + wxVERTICAL + 1 + none + + 10 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Use Eeschema color theme + + 0 + + + 0 + + 1 + m_useEeschemaTheme + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + bSizer3 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Theme: + 0 + + 0 + + + 0 + + 1 + m_staticText16 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_themeSelection + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + diff --git a/eeschema/dialogs/panel_libedit_color_settings_base.h b/eeschema/dialogs/panel_libedit_color_settings_base.h new file mode 100644 index 0000000000..7e027fa3c5 --- /dev/null +++ b/eeschema/dialogs/panel_libedit_color_settings_base.h @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_LIBEDIT_COLOR_SETTINGS_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_LIBEDIT_COLOR_SETTINGS_BASE : public wxPanel +{ + private: + + protected: + wxCheckBox* m_useEeschemaTheme; + wxStaticText* m_staticText16; + wxChoice* m_themeSelection; + + public: + + PANEL_LIBEDIT_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + ~PANEL_LIBEDIT_COLOR_SETTINGS_BASE(); + +}; + diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 4fec0f71eb..ad4e5eaf7d 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -416,6 +417,7 @@ void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) ); book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); book->AddSubPage( new PANEL_LIBEDIT_SETTINGS( this, book ), _( "Defaults" ) ); + book->AddSubPage( new PANEL_LIBEDIT_COLOR_SETTINGS( this, book ), _( "Color Options" ) ); aHotkeysPanel->AddHotKeys( GetToolManager() ); } diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index c20d95aec5..722629ede4 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -141,6 +141,9 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + auto settings = GetCanvas()->GetView()->GetPainter()->GetSettings(); + settings->LoadColors( GetColorSettings() ); + setupTools(); m_libMgr = new LIB_MANAGER( *this ); @@ -283,6 +286,17 @@ void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg) } +COLOR_SETTINGS* LIB_EDIT_FRAME::GetColorSettings() +{ + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + + if( cfg->m_UseEeschemaColorSettings ) + return m_colorSettings; + else + return Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); +} + + void LIB_EDIT_FRAME::setupTools() { // Create the manager and dispatcher & route draw panel events to the dispatcher diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index d925ab3b37..50fb42b21e 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -265,6 +265,8 @@ public: return m_settings; } + COLOR_SETTINGS* GetColorSettings() override; + /** * Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro: *

diff --git a/eeschema/libedit/libedit_settings.cpp b/eeschema/libedit/libedit_settings.cpp index 47598d3e25..05f33a67ae 100644 --- a/eeschema/libedit/libedit_settings.cpp +++ b/eeschema/libedit/libedit_settings.cpp @@ -62,6 +62,9 @@ LIBEDIT_SETTINGS::LIBEDIT_SETTINGS() : APP_SETTINGS_BASE( "libedit", libeditSche m_params.emplace_back( new PARAM( "edit_component_visible_columns", &m_EditComponentVisibleColumns, "0 1 2 3 4 5 6 7" ) ); + + m_params.emplace_back( + new PARAM( "use_eeschema_color_settings", &m_UseEeschemaColorSettings, true ) ); } diff --git a/eeschema/libedit/libedit_settings.h b/eeschema/libedit/libedit_settings.h index fc44c98d41..de487fd38b 100644 --- a/eeschema/libedit/libedit_settings.h +++ b/eeschema/libedit/libedit_settings.h @@ -65,6 +65,8 @@ public: wxString m_PinTableVisibleColumns; + bool m_UseEeschemaColorSettings; + protected: virtual std::string getLegacyFrameName() const override { return "LibeditFrame"; }