diff --git a/eeschema/dialogs/panel_sym_color_settings.cpp b/eeschema/dialogs/panel_sym_color_settings.cpp index db102b9ded..00acca04c8 100644 --- a/eeschema/dialogs/panel_sym_color_settings.cpp +++ b/eeschema/dialogs/panel_sym_color_settings.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * -* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. +* Copyright (C) 2020-2021 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 @@ -26,8 +26,6 @@ #include #include #include -#include - #include "panel_sym_color_settings.h" @@ -42,7 +40,10 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() { SYMBOL_EDITOR_SETTINGS* cfg = m_frame->GetSettings(); - m_useEeschemaTheme->SetValue( cfg->m_UseEeschemaColorSettings ); + if( cfg->m_UseEeschemaColorSettings ) + m_eeschemaRB->SetValue( true ); + else + m_themeRB->SetValue( true ); COLOR_SETTINGS* current = m_frame->GetSettingsManager()->GetColorSettings( cfg->m_ColorTheme ); @@ -50,23 +51,20 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() int height = 0; int minwidth = width; - m_themeSelection->Clear(); + m_themes->Clear(); for( COLOR_SETTINGS* settings : m_frame->GetSettingsManager()->GetColorSettingsList() ) { - int pos = m_themeSelection->Append( settings->GetName(), static_cast( settings ) ); + int pos = m_themes->Append( settings->GetName(), static_cast( settings ) ); if( settings == current ) - m_themeSelection->SetSelection( pos ); + m_themes->SetSelection( pos ); - m_themeSelection->GetTextExtent( settings->GetName(), &width, &height ); + m_themes->GetTextExtent( settings->GetName(), &width, &height ); minwidth = std::max( minwidth, width ); } - m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) ); - - m_txtTheme->Enable( !m_useEeschemaTheme->GetValue() ); - m_themeSelection->Enable( !m_useEeschemaTheme->GetValue() ); + m_themes->SetMinSize( wxSize( minwidth + 50, -1 ) ); Fit(); @@ -77,34 +75,30 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() bool PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow() { SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); - - auto selected = static_cast( - m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) ); + int sel = m_themes->GetSelection(); + COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings(); - - cfg->m_UseEeschemaColorSettings = m_useEeschemaTheme->GetValue(); - - if( !cfg->m_UseEeschemaColorSettings ) - cfg->m_ColorTheme = selected->GetFilename(); + cfg->m_UseEeschemaColorSettings = m_eeschemaRB->GetValue(); if( cfg->m_UseEeschemaColorSettings ) { EESCHEMA_SETTINGS* eecfg = mgr->GetAppSettings(); - selected = mgr->GetColorSettings( eecfg->m_ColorTheme ); + colors = mgr->GetColorSettings( eecfg->m_ColorTheme ); + } + else + { + cfg->m_ColorTheme = colors->GetFilename(); } - auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); - settings->LoadColors( selected ); + RENDER_SETTINGS* settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); + settings->LoadColors( colors ); return true; } -void PANEL_SYM_COLOR_SETTINGS::OnUseEeschemaThemeChanged( wxCommandEvent& event ) +void PANEL_SYM_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) { - bool useEeschema = m_useEeschemaTheme->GetValue(); - - m_txtTheme->Enable( !useEeschema ); - m_themeSelection->Enable( !useEeschema ); + m_themeRB->SetValue( true ); } diff --git a/eeschema/dialogs/panel_sym_color_settings.h b/eeschema/dialogs/panel_sym_color_settings.h index 132e40f1a1..cf88d1d7d3 100644 --- a/eeschema/dialogs/panel_sym_color_settings.h +++ b/eeschema/dialogs/panel_sym_color_settings.h @@ -35,7 +35,7 @@ public: PANEL_SYM_COLOR_SETTINGS( SYMBOL_EDIT_FRAME* aFrame, wxWindow* aWindow ); protected: - void OnUseEeschemaThemeChanged( wxCommandEvent& event ) override; + void OnThemeChanged( wxCommandEvent& event ) override; private: bool TransferDataToWindow() override; diff --git a/eeschema/dialogs/panel_sym_color_settings_base.cpp b/eeschema/dialogs/panel_sym_color_settings_base.cpp index 380bf5a33f..99a86666f8 100644 --- a/eeschema/dialogs/panel_sym_color_settings_base.cpp +++ b/eeschema/dialogs/panel_sym_color_settings_base.cpp @@ -10,7 +10,7 @@ /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( PANEL_SYM_COLOR_SETTINGS_BASE, wxPanel ) - EVT_CHECKBOX( wxID_ANY, PANEL_SYM_COLOR_SETTINGS_BASE::_wxFB_OnUseEeschemaThemeChanged ) + EVT_CHOICE( wxID_ANY, PANEL_SYM_COLOR_SETTINGS_BASE::_wxFB_OnThemeChanged ) END_EVENT_TABLE() PANEL_SYM_COLOR_SETTINGS_BASE::PANEL_SYM_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 ) @@ -19,25 +19,25 @@ PANEL_SYM_COLOR_SETTINGS_BASE::PANEL_SYM_COLOR_SETTINGS_BASE( wxWindow* parent, p1mainSizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Color Theme") ), wxHORIZONTAL ); + 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 ); - m_useEeschemaTheme->SetValue(true); - sbSizer1->Add( m_useEeschemaTheme, 0, wxALL|wxEXPAND, 10 ); + m_eeschemaRB = new wxRadioButton( sbSizer1->GetStaticBox(), wxID_ANY, _("Use schematic editor color theme"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); + sbSizer1->Add( m_eeschemaRB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_txtTheme = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Theme:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtTheme->Wrap( -1 ); - m_txtTheme->Enable( false ); + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxHORIZONTAL ); - sbSizer1->Add( m_txtTheme, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); + m_themeRB = new wxRadioButton( sbSizer1->GetStaticBox(), wxID_ANY, _("Use theme:"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_themeRB, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - wxArrayString m_themeSelectionChoices; - m_themeSelection = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themeSelectionChoices, 0 ); - m_themeSelection->SetSelection( 0 ); - m_themeSelection->Enable( false ); + wxArrayString m_themesChoices; + m_themes = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themesChoices, 0 ); + m_themes->SetSelection( 0 ); + bSizer2->Add( m_themes, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - sbSizer1->Add( m_themeSelection, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 10 ); + + sbSizer1->Add( bSizer2, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 ); p1mainSizer->Add( sbSizer1, 0, wxALL, 5 ); diff --git a/eeschema/dialogs/panel_sym_color_settings_base.fbp b/eeschema/dialogs/panel_sym_color_settings_base.fbp index d84dd6ccb5..a0be2d5c18 100644 --- a/eeschema/dialogs/panel_sym_color_settings_base.fbp +++ b/eeschema/dialogs/panel_sym_color_settings_base.fbp @@ -63,14 +63,14 @@ Color Theme 250,-1 sbSizer1 - wxHORIZONTAL + wxVERTICAL 1 none - 10 - wxALL|wxEXPAND + 5 + wxBOTTOM|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -84,7 +84,6 @@ 1 0 - 1 1 1 @@ -99,7 +98,7 @@ 0 0 wxID_ANY - Use Eeschema color theme + Use schematic editor color theme 0 @@ -107,7 +106,7 @@ 0 1 - m_useEeschemaTheme + m_eeschemaRB 1 @@ -117,7 +116,7 @@ Resizable 1 - + wxRB_GROUP ; ; forward_declare 0 @@ -125,135 +124,150 @@ wxFILTER_NONE wxDefaultValidator + 0 - OnUseEeschemaThemeChanged - 10 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - - 1 - - 0 - 0 - wxID_ANY - Theme: - 0 - - 0 - - - 0 - - 1 - m_txtTheme - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - 10 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP + 5 + wxEXPAND|wxTOP|wxBOTTOM 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 0 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + - 1 - m_themeSelection - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - + bSizer2 + wxHORIZONTAL + 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 + Use theme: + + 0 + + + 0 + + 1 + m_themeRB + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_themes + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnThemeChanged + + diff --git a/eeschema/dialogs/panel_sym_color_settings_base.h b/eeschema/dialogs/panel_sym_color_settings_base.h index 52cb546143..dba43b75f2 100644 --- a/eeschema/dialogs/panel_sym_color_settings_base.h +++ b/eeschema/dialogs/panel_sym_color_settings_base.h @@ -11,12 +11,11 @@ #include #include #include -#include +#include #include #include #include #include -#include #include #include #include @@ -34,16 +33,16 @@ class PANEL_SYM_COLOR_SETTINGS_BASE : public wxPanel private: // Private event handlers - void _wxFB_OnUseEeschemaThemeChanged( wxCommandEvent& event ){ OnUseEeschemaThemeChanged( event ); } + void _wxFB_OnThemeChanged( wxCommandEvent& event ){ OnThemeChanged( event ); } protected: - wxCheckBox* m_useEeschemaTheme; - wxStaticText* m_txtTheme; - wxChoice* m_themeSelection; + wxRadioButton* m_eeschemaRB; + wxRadioButton* m_themeRB; + wxChoice* m_themes; // Virtual event handlers, overide them in your derived class - virtual void OnUseEeschemaThemeChanged( wxCommandEvent& event ) { event.Skip(); } + virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp index 3c1f385a5d..1fda574ba7 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp @@ -45,20 +45,20 @@ bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataToWindow() int height = 0; int minwidth = width; - m_themeSelection->Clear(); + m_themes->Clear(); for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() ) { - int pos = m_themeSelection->Append( settings->GetName(), static_cast( settings ) ); + int pos = m_themes->Append( settings->GetName(), static_cast( settings ) ); if( settings == current ) - m_themeSelection->SetSelection( pos ); + m_themes->SetSelection( pos ); - m_themeSelection->GetTextExtent( settings->GetName(), &width, &height ); + m_themes->GetTextExtent( settings->GetName(), &width, &height ); minwidth = std::max( minwidth, width ); } - m_themeSelection->SetMinSize( wxSize( minwidth + 50, -1 ) ); + m_themes->SetMinSize( wxSize( minwidth + 50, -1 ) ); Fit(); @@ -69,16 +69,14 @@ bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataToWindow() bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - - auto selected = static_cast( - m_themeSelection->GetClientData( m_themeSelection->GetSelection() ) ); + int sel = m_themes->GetSelection(); + COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); PL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); + cfg->m_ColorTheme = colors->GetFilename(); - cfg->m_ColorTheme = selected->GetFilename(); - - auto settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); - settings->LoadColors( selected ); + RENDER_SETTINGS* settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); + settings->LoadColors( colors ); return true; } \ No newline at end of file diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp index 36bd754ccf..8b85c0a69a 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp @@ -20,12 +20,12 @@ PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( wxWind sbSizer1->SetMinSize( wxSize( 250,-1 ) ); m_txtTheme = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Theme:"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtTheme->Wrap( -1 ); - sbSizer1->Add( m_txtTheme, 0, wxALIGN_CENTER_VERTICAL|wxALL, 10 ); + sbSizer1->Add( m_txtTheme, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - wxArrayString m_themeSelectionChoices; - m_themeSelection = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themeSelectionChoices, 0 ); - m_themeSelection->SetSelection( 0 ); - sbSizer1->Add( m_themeSelection, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 10 ); + wxArrayString m_themesChoices; + m_themes = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_themesChoices, 0 ); + m_themes->SetSelection( 0 ); + sbSizer1->Add( m_themes, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); p1mainSizer->Add( sbSizer1, 0, wxALL, 10 ); diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp index b79b9bd908..ee6613b3da 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp @@ -67,8 +67,8 @@ 1 none - 10 - wxALIGN_CENTER_VERTICAL|wxALL + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -128,8 +128,8 @@ - 10 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 1 1 @@ -167,7 +167,7 @@ 0 1 - m_themeSelection + m_themes 1 diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h index 19596c6df4..26c05d08d7 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h @@ -33,7 +33,7 @@ class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE : public wxPanel protected: wxStaticText* m_txtTheme; - wxChoice* m_themeSelection; + wxChoice* m_themes; public: