From fcc723fa0a5af972203f287aed9e506aa43172cc Mon Sep 17 00:00:00 2001 From: redtide Date: Sat, 10 Apr 2021 18:08:49 +0200 Subject: [PATCH] UI: components update --- plugins/editor/src/editor/GUIComponents.h | 16 ++++++++-------- plugins/editor/src/editor/GUIPiano.cpp | 20 +++++++++++++++++++- plugins/editor/src/editor/GUIPiano.h | 3 +++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/plugins/editor/src/editor/GUIComponents.h b/plugins/editor/src/editor/GUIComponents.h index a69faee9..f771405f 100644 --- a/plugins/editor/src/editor/GUIComponents.h +++ b/plugins/editor/src/editor/GUIComponents.h @@ -249,18 +249,18 @@ public: void setHue(float hue); SStyledKnob* getControl() const { return knob_; } - void setNameLabelText(const UTF8String& name) { label_->setText(name); } + void setNameLabelText(const UTF8String& name) { label_->setText(name); label_->invalid(); } void setNameLabelFont(CFontRef font); - void setNameLabelFontColor(CColor color) { label_->setFontColor(color); } - void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); } + void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); } + void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); ccLabel_->invalid(); } void setCCLabelFont(CFontRef font); - void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); } - void setKnobLineIndicatorColor(CColor color) { knob_->setLineIndicatorColor(color); } - void setKnobFont(CFontRef font) { knob_->setFont(font); } - void setKnobFontColor(CColor color) { knob_->setFontColor(color); } + void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); ccLabel_->invalid(); } + void setKnobLineIndicatorColor(CColor color) { knob_->setLineIndicatorColor(color); knob_->invalid(); } + void setKnobFont(CFontRef font) { knob_->setFont(font); knob_->invalid(); } + void setKnobFontColor(CColor color) { knob_->setFontColor(color); knob_->invalid(); } using ValueToStringFunction = SStyledKnob::ValueToStringFunction; - void setValueToStringFunction(ValueToStringFunction f) { knob_->setValueToStringFunction(std::move(f)); } + void setValueToStringFunction(ValueToStringFunction f) { knob_->setValueToStringFunction(std::move(f)); knob_->invalid(); } private: void updateViewSizes(); diff --git a/plugins/editor/src/editor/GUIPiano.cpp b/plugins/editor/src/editor/GUIPiano.cpp index 68f1636c..9ea88959 100644 --- a/plugins/editor/src/editor/GUIPiano.cpp +++ b/plugins/editor/src/editor/GUIPiano.cpp @@ -141,6 +141,24 @@ int SPiano::getKeyRole(unsigned key) return role; } +void SPiano::setBackColor(const CColor &color) +{ + Impl& impl = *impl_; + if (impl.backgroundFill_ != color) { + impl.backgroundFill_ = color; + invalid(); + } +} + +void SPiano::setFontColor(const CColor &color) +{ + Impl& impl = *impl_; + if (impl.labelStroke_ != color) { + impl.labelStroke_ = color; + invalid(); + } +} + void SPiano::draw(CDrawContext* dc) { Impl& impl = *impl_; @@ -155,7 +173,7 @@ void SPiano::draw(CDrawContext* dc) SharedPointer path; path = owned(dc->createGraphicsPath()); path->addRoundRect(dim.bounds, impl.backgroundRadius_); - dc->setFillColor(CColor(0xca, 0xca, 0xca)); + dc->setFillColor(impl.backgroundFill_); dc->drawGraphicsPath(path, CDrawContext::kPathFilled); } diff --git a/plugins/editor/src/editor/GUIPiano.h b/plugins/editor/src/editor/GUIPiano.h index 4bb662dc..9cbccd29 100644 --- a/plugins/editor/src/editor/GUIPiano.h +++ b/plugins/editor/src/editor/GUIPiano.h @@ -40,6 +40,9 @@ public: std::function onKeyPressed; std::function onKeyReleased; + void setBackColor(const CColor&); + void setFontColor(const CColor&); + protected: void draw(CDrawContext* dc) override; CMouseEventResult onMouseDown(CPoint& where, const CButtonState& buttons) override;