41 m_currentSettings( nullptr ),
69 for(
const std::pair<const int, COLOR_SWATCH*>& pair :
m_swatches )
71 int layer = pair.first;
97 return PANEL_COLOR_SETTINGS_BASE::Show( show );
104 wxString sel =
m_cbTheme->GetStringSelection();
115 if( idx == static_cast<int>(
m_cbTheme->GetCount() ) - 2 )
122 if( idx == (
int)
m_cbTheme->GetCount() - 1 )
130 wxTextEntryDialog dlg(
this,
_(
"New theme name:" ),
_(
"Add Color Theme" ) );
131 dlg.SetTextValidator( themeNameValidator );
133 if( dlg.ShowModal() != wxID_OK )
136 wxString themeName = dlg.GetValue();
137 wxFileName fn( themeName + wxT(
".json" ) );
142 wxMessageBox(
_(
"Theme already exists!" ) );
148 newSettings->
SetName( themeName );
156 idx =
m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
189 for( std::pair<int, COLOR_SWATCH*> pair :
m_swatches )
191 pair.second->SetSwatchBackground( background );
193 pair.second->SetReadOnly( isReadOnly );
203 m_cbTheme->GetTextExtent(
_(
"New Theme..." ), &width, &height );
204 int minwidth = width;
210 wxString
name = settings->GetName();
212 if( settings->IsReadOnly() )
213 name += wxS(
" " ) +
_(
"(read-only)" );
215 int pos =
m_cbTheme->Append(
name, static_cast<void*>( settings ) );
217 if( settings->GetFilename() == aCurrent )
221 minwidth = std::max( minwidth, width );
227 m_cbTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
244 COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( clientData );
253 swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
255 m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
261 swatch->Bind( wxEVT_RIGHT_DOWN,
262 [&, aLayer]( wxMouseEvent& aEvent )
274 static_cast<COLOR_SETTINGS*>(
m_cbTheme->GetClientData(
m_cbTheme->GetSelection() ) );
277 COLOR4D saved = selected->GetColor( aLayer );
284 if( !readOnly &&
m_copied != COLOR4D::UNSPECIFIED )
287 if( !readOnly && current != saved )
290 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
291 [&]( wxCommandEvent& aCmd )
293 switch( aCmd.GetId() )
318 COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
335 m_swatches[aLayer]->SetSwatchColor( aColor,
false );
341 for( std::pair<int, COLOR_SWATCH*> pair :
m_swatches )
342 pair.second->SetSwatchBackground( background );
void SetSwatchColor(KIGFX::COLOR4D aColor, bool aSendEvent)
Set the current swatch color directly.
KIGFX::COLOR4D GetSwatchColor() const
virtual bool saveCurrentTheme(bool aValidate)
wxCheckBox * m_optOverrideColors
virtual void ResetPanel() override
Reset the contents of this panel.
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
void SetReadOnly(bool aReadOnly)
wxString GetFilename() const
std::map< int, wxStaticText * > m_labels
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
wxButton * m_btnOpenFolder
std::map< int, COLOR_SWATCH * > m_swatches
void updateColor(int aLayer, const KIGFX::COLOR4D &aColor)
const wxString & GetName() const
wxFlexGridSizer * m_colorsGridSizer
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Registers a new color settings object with the given filename.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxScrolledWindow * m_colorsListWindow
void ShowColorContextMenu(wxMouseEvent &aEvent, int aLayer)
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Class PANEL_COLOR_SETTINGS_BASE.
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
bool Show(bool show) override
void createThemeList(const wxString &aCurrent)
COLOR_SETTINGS * m_currentSettings
void SetOverrideSchItemColors(bool aFlag)
COLOR4D GetDefaultColor(int aLayer)
const BITMAP_OPAQUE copy_xpm[1]
void SetName(const wxString &aName)
constexpr int FIRST_BUTTON_ID
virtual void onColorChanged()
Event fired when the user changes any color.
PANEL_COLOR_SETTINGS(wxWindow *aParent)
SETTINGS_MANAGER * GetSettingsManager()
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
static wxString GetColorSettingsPath()
Returns the path where color scheme files are stored; creating it if missing (normally .
int LAYER_NUM
This can be replaced with int and removed.
void OnBtnOpenThemeFolderClicked(wxCommandEvent &event) override
const BITMAP_OPAQUE paste_xpm[1]
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
COLOR4D GetColor(int aLayer) const
Board layer functions and definitions.
void OnLeftDownTheme(wxMouseEvent &event) override
Class representing a simple color swatch, of the kind used to set layer colors.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
const BITMAP_OPAQUE undo_xpm[1]
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetOverrideSchItemColors() const
void LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
void createSwatch(int aLayer, const wxString &aName)
void OnThemeChanged(wxCommandEvent &aEvent) override
Custom text control validator definitions.
virtual bool validateSave(bool aQuiet=false)
Performs a pre-save validation of the current color theme.
wxString GetPathForSettingsFile(JSON_SETTINGS *aSettings)
Returns the path a given settings file should be loaded from / stored to.
void SetColor(int aLayer, COLOR4D aColor)
void OnColorChanged(wxCommandEvent &aEvent)
A color representation with 4 components: red, green, blue, alpha.