KiCad PCB EDA Suite
panel_color_settings.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
5  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef PANEL_COLOR_SETTINGS_H
22 #define PANEL_COLOR_SETTINGS_H
23 
24 #include <gal/color4d.h>
26 
27 
28 class COLOR_SETTINGS;
29 class COLOR_SWATCH;
30 
31 
33 {
34 public:
35  PANEL_COLOR_SETTINGS( wxWindow* aParent );
36 
37  ~PANEL_COLOR_SETTINGS() = default;
38 
40  {
41  ID_COPY = wxID_HIGHEST + 1,
44  };
45 
46  virtual void ResetPanel() override;
47 
48  virtual wxString GetResetTooltip() override
49  {
50  return _( "Reset all colors in this theme to the KiCad defaults" );
51  }
52 
53  bool Show( bool show ) override;
54 
55 protected:
56  void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) override;
57 
58  void OnLeftDownTheme( wxMouseEvent& event ) override;
59  void OnThemeChanged( wxCommandEvent& aEvent ) override;
60 
61  void ShowColorContextMenu( wxMouseEvent& aEvent, int aLayer );
62 
63  void OnColorChanged( wxCommandEvent& aEvent );
64 
65  void updateSwatches();
66 
67  void createThemeList( const wxString& aCurrent );
68 
69  void createSwatch( int aLayer, const wxString& aName );
70 
71  void updateColor( int aLayer, const KIGFX::COLOR4D& aColor );
72 
73  virtual bool saveCurrentTheme( bool aValidate );
74 
80  virtual bool validateSave( bool aQuiet = false )
81  {
82  return true;
83  }
84 
88  virtual void onNewThemeSelected() {}
89 
93  virtual void onColorChanged() {}
94 
96 
97  std::map<int, wxStaticText*> m_labels;
98  std::map<int, COLOR_SWATCH*> m_swatches;
99 
101 
110  std::vector<int> m_validLayers;
112 
118  std::string m_colorNamespace;
119 };
120 
121 
122 #endif
virtual bool saveCurrentTheme(bool aValidate)
virtual void ResetPanel() override
Reset the contents of this panel.
std::map< int, wxStaticText * > m_labels
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
std::map< int, COLOR_SWATCH * > m_swatches
void updateColor(int aLayer, const KIGFX::COLOR4D &aColor)
void ShowColorContextMenu(wxMouseEvent &aEvent, int aLayer)
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
Class PANEL_COLOR_SETTINGS_BASE.
bool Show(bool show) override
void createThemeList(const wxString &aCurrent)
COLOR_SETTINGS * m_currentSettings
virtual void onColorChanged()
Event fired when the user changes any color.
PANEL_COLOR_SETTINGS(wxWindow *aParent)
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
virtual wxString GetResetTooltip() override
Get the tooltip the reset button should display when showing this panel.
void OnBtnOpenThemeFolderClicked(wxCommandEvent &event) override
~PANEL_COLOR_SETTINGS()=default
void OnLeftDownTheme(wxMouseEvent &event) override
#define _(s)
Definition: 3d_actions.cpp:33
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
Color settings are a bit different than most of the settings objects in that there can be more than o...
void createSwatch(int aLayer, const wxString &aName)
void OnThemeChanged(wxCommandEvent &aEvent) override
virtual bool validateSave(bool aQuiet=false)
Performs a pre-save validation of the current color theme.
void OnColorChanged(wxCommandEvent &aEvent)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100