From 8c09edeef1f328aa9bc319c54a04daff996c8329 Mon Sep 17 00:00:00 2001 From: redtide Date: Mon, 12 Apr 2021 19:01:33 +0200 Subject: [PATCH] UI: set CC knobs theme colors --- .../editor/resources/Themes/Default/theme.xml | 16 ++++++++++------ plugins/editor/src/editor/Editor.cpp | 13 ++++++++----- plugins/editor/src/editor/GUIComponents.h | 3 +++ plugins/editor/src/editor/Theme.cpp | 2 ++ plugins/editor/src/editor/Theme.h | 4 +++- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/plugins/editor/resources/Themes/Default/theme.xml b/plugins/editor/resources/Themes/Default/theme.xml index 03bd2484..85b09622 100644 --- a/plugins/editor/resources/Themes/Default/theme.xml +++ b/plugins/editor/resources/Themes/Default/theme.xml @@ -8,13 +8,15 @@ #fd9800 #ffffff #2e3436 - #000000 - #fd9800 #ffffff #2e3436 - #00b62a + #000000 + #fd9800 + #006b0b #303030 #000000 + #000000 + #ffffff #2e3436 @@ -23,12 +25,14 @@ #fd9800 #000000 #babdb6 - #b2b2b2 - #fd9800 #000000 #9a9a9a - #00b62a + #b2b2b2 + #fd9800 + #006b0b #606060 #ffffff + #ffffff + #ffffff diff --git a/plugins/editor/src/editor/Editor.cpp b/plugins/editor/src/editor/Editor.cpp index 050de568..16886887 100644 --- a/plugins/editor/src/editor/Editor.cpp +++ b/plugins/editor/src/editor/Editor.cpp @@ -604,7 +604,6 @@ void Editor::Impl::createFrameContents() backgroundBitmap_ = background; { - // Try to load the Default theme from disk or hardcoded one as fallback theme = new Theme; theme_.reset(theme); @@ -876,12 +875,16 @@ void Editor::Impl::createFrameContents() box->setNameLabelText(label); box->setNameLabelFont(font); box->setKnobFont(font); + box->setCCLabelText(label); box->setCCLabelFont(font); OnThemeChanged.push_back([box, palette]() { - box->setNameLabelFontColor(palette->text); - box->setCCLabelFontColor(palette->text); - box->setKnobFontColor(palette->text); + box->setNameLabelFontColor(palette->knobText); + box->setCCLabelFontColor(palette->knobLabelText); + box->setCCLabelBackColor(palette->knobActiveTrack); + box->setKnobFontColor(palette->knobText); box->setKnobLineIndicatorColor(palette->knobLineIndicator); + box->setKnobActiveTrackColor(palette->knobActiveTrack); + box->setKnobInactiveTrackColor(palette->knobInactiveTrack); }); box->setValueToStringFunction([](float value, std::string& text) -> bool { text = std::to_string(std::lround(value * 127)); @@ -1902,7 +1905,7 @@ void Editor::Impl::valueChanged(CControl* ctl) { currentThemeName_ = Theme::getAvailableNames()[int(value)]; Theme::storeCurrentName(currentThemeName_); - // TODO: live reload theme + theme_->load(currentThemeName_); } break; diff --git a/plugins/editor/src/editor/GUIComponents.h b/plugins/editor/src/editor/GUIComponents.h index 26850fd1..d803fa86 100644 --- a/plugins/editor/src/editor/GUIComponents.h +++ b/plugins/editor/src/editor/GUIComponents.h @@ -264,6 +264,9 @@ public: void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); ccLabel_->invalid(); } CColor getCCLabelFontColor() const { return ccLabel_->getFontColor(); } + void setCCLabelBackColor(CColor color) { ccLabel_->setBackColor(color); ccLabel_->invalid(); } + CColor getCCLabelBackColor() const { return ccLabel_->getBackColor(); } + void setKnobActiveTrackColor(CColor color) { knob_->setActiveTrackColor(color); knob_->invalid(); } CColor getKnobActiveTrackColor() const { return knob_->getActiveTrackColor(); } diff --git a/plugins/editor/src/editor/Theme.cpp b/plugins/editor/src/editor/Theme.cpp index a2233827..00342b86 100644 --- a/plugins/editor/src/editor/Theme.cpp +++ b/plugins/editor/src/editor/Theme.cpp @@ -154,7 +154,9 @@ CColor* Theme::getColorFromName(absl::string_view name, bool fromInvertedPalette PALETTE_COLOR_CASE(inactiveText); PALETTE_COLOR_CASE(knobActiveTrack); PALETTE_COLOR_CASE(knobInactiveTrack); + PALETTE_COLOR_CASE(knobLabelText); PALETTE_COLOR_CASE(knobLineIndicator); + PALETTE_COLOR_CASE(knobText); PALETTE_COLOR_CASE(text); PALETTE_COLOR_CASE(titleBoxBackground); PALETTE_COLOR_CASE(titleBoxText); diff --git a/plugins/editor/src/editor/Theme.h b/plugins/editor/src/editor/Theme.h index c3ecab1e..c67b5925 100644 --- a/plugins/editor/src/editor/Theme.h +++ b/plugins/editor/src/editor/Theme.h @@ -29,6 +29,8 @@ struct Palette { CColor knobActiveTrack; CColor knobInactiveTrack; CColor knobLineIndicator; + CColor knobText; + CColor knobLabelText; }; struct Theme { @@ -58,7 +60,7 @@ struct Theme { static std::string loadCurrentName(); static const std::vector& getAvailableNames(); - CColor* getColorFromName(absl::string_view name, bool fromInvertedPalette); + CColor* getColorFromName(absl::string_view name, bool fromInvertedPalette = false); private: static std::vector extractAvailableNames();