commit e5313eadfa5acdacc435c2f8d9dc94c846b7e7c2
parent 9ce909787a26ac68d3e249cda548599338243bcb
Author: Matt Demanett <matt@demanett.net>
Date: Tue, 28 Sep 2021 23:06:11 -0400
Rack2: nightmode support for buttons, etc, that act like lights.
Diffstat:
4 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/src/mixer.cpp b/src/mixer.cpp
@@ -112,6 +112,15 @@ void MuteButton::onButton(const event::Button& e) {
}
}
+void MuteButton::draw(const DrawArgs& args) {
+ nvgSave(args.vg);
+ if (getParamQuantity() && getParamQuantity()->getValue() > 0.0f) {
+ nvgGlobalTint(args.vg, color::WHITE);
+ }
+ ToggleButton::draw(args);
+ nvgRestore(args.vg);
+}
+
SoloMuteButton::SoloMuteButton() {
shadow = new CircularShadow();
@@ -166,3 +175,12 @@ void SoloMuteButton::onChange(const event::Change& e) {
}
ParamWidget::onChange(e);
}
+
+void SoloMuteButton::draw(const DrawArgs& args) {
+ nvgSave(args.vg);
+ if (getParamQuantity() && getParamQuantity()->getValue() > 0.0f) {
+ nvgGlobalTint(args.vg, color::WHITE);
+ }
+ ParamWidget::draw(args);
+ nvgRestore(args.vg);
+}
diff --git a/src/mixer.hpp b/src/mixer.hpp
@@ -81,6 +81,7 @@ struct MuteButton : ToggleButton {
inline void setRandomize(bool randomize) { _randomize = randomize; }
void onButton(const event::Button& e) override;
+ void draw(const DrawArgs& args) override;
};
struct SoloMuteButton : ParamWidget {
@@ -91,6 +92,7 @@ struct SoloMuteButton : ParamWidget {
SoloMuteButton();
void onButton(const event::Button& e) override;
void onChange(const event::Change& e) override;
+ void draw(const DrawArgs& args) override;
};
} // namespace bogaudio
diff --git a/src/widgets.cpp b/src/widgets.cpp
@@ -227,6 +227,18 @@ void IndicatorKnob::redraw() {
onChange(c);
}
+void IndicatorKnob::draw(const DrawArgs& args) {
+ nvgSave(args.vg);
+ if (getParamQuantity() &&
+ (getParamQuantity()->getValue() < -0.01f || getParamQuantity()->getValue() > 0.01f) &&
+ (!w->_drawColorsCB || w->_drawColorsCB()))
+ {
+ nvgGlobalTint(args.vg, color::WHITE);
+ }
+ Knob::draw(args);
+ nvgRestore(args.vg);
+}
+
void IndicatorKnob::skinChanged(const std::string& skin) {
const Skins& skins = Skins::skins();
const char* knobRim = skins.skinCssValue(skin, "knob-rim");
@@ -337,6 +349,15 @@ IndicatorButtonGreen9::IndicatorButtonGreen9() {
addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/button_9px_1_green.svg")));
}
+void IndicatorButtonGreen9::draw(const DrawArgs& args) {
+ nvgSave(args.vg);
+ if (getParamQuantity() && getParamQuantity()->getValue() > 0.0f) {
+ nvgGlobalTint(args.vg, color::WHITE);
+ }
+ SvgSwitch::draw(args);
+ nvgRestore(args.vg);
+}
+
void InvertingIndicatorButton::IIBWidget::setValue(float v) {
assert(v >= -1.0f && v <= 1.0f);
@@ -474,6 +495,15 @@ void InvertingIndicatorButton::onChange(const event::Change& e) {
ParamWidget::onChange(e);
}
+void InvertingIndicatorButton::draw(const DrawArgs& args) {
+ nvgSave(args.vg);
+ if (getParamQuantity() && (getParamQuantity()->getValue() < -0.01f || getParamQuantity()->getValue() > 0.01f)) {
+ nvgGlobalTint(args.vg, color::WHITE);
+ }
+ ParamWidget::draw(args);
+ nvgRestore(args.vg);
+}
+
NVGcolor bogaudio::decibelsToColor(float db) {
if (db < -80.0f) {
@@ -542,6 +572,8 @@ void VUSlider::draw(const DrawArgs& args) {
stereoDb = *_stereoVuLevel;
}
if (db > 0.0f) {
+ nvgSave(args.vg);
+ nvgGlobalTint(args.vg, color::WHITE);
nvgBeginPath(args.vg);
if (stereo) {
nvgRoundedRect(args.vg, 2, 4, stereo ? 7 : 14, 5, 1.0);
@@ -551,12 +583,16 @@ void VUSlider::draw(const DrawArgs& args) {
}
nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(db)));
nvgFill(args.vg);
+ nvgRestore(args.vg);
}
if (stereo && stereoDb > 0.0f) {
+ nvgSave(args.vg);
+ nvgGlobalTint(args.vg, color::WHITE);
nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, 9, 4, 7, 5, 1.0);
nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(stereoDb)));
nvgFill(args.vg);
+ nvgRestore(args.vg);
}
}
nvgRestore(args.vg);
diff --git a/src/widgets.hpp b/src/widgets.hpp
@@ -82,6 +82,7 @@ struct IndicatorKnob : Knob, SkinnableWidget {
inline void setDrawColorsCallback(std::function<bool()> fn) { w->_drawColorsCB = fn; }
inline void setUnipolarCallback(std::function<bool()> fn) { w->_unipolarCB = fn; }
void redraw();
+ void draw(const DrawArgs& args) override;
void skinChanged(const std::string& skin) override;
};
@@ -140,6 +141,7 @@ struct ToggleButton18 : ToggleButton {
struct IndicatorButtonGreen9 : SvgSwitch {
IndicatorButtonGreen9();
+ void draw(const DrawArgs& args) override;
};
struct InvertingIndicatorButton : ParamWidget {
@@ -167,6 +169,7 @@ struct InvertingIndicatorButton : ParamWidget {
void onDoubleClick(const event::DoubleClick& e) override {}
void onButton(const event::Button& e) override;
void onChange(const event::Change& e) override;
+ void draw(const DrawArgs& args) override;
};
struct InvertingIndicatorButton9 : InvertingIndicatorButton {