UI: components update

This commit is contained in:
redtide 2021-04-10 18:08:49 +02:00
parent 4481bc33b0
commit fcc723fa0a
3 changed files with 30 additions and 9 deletions

View file

@ -249,18 +249,18 @@ public:
void setHue(float hue); void setHue(float hue);
SStyledKnob* getControl() const { return knob_; } 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 setNameLabelFont(CFontRef font);
void setNameLabelFontColor(CColor color) { label_->setFontColor(color); } void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); }
void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); } void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); ccLabel_->invalid(); }
void setCCLabelFont(CFontRef font); void setCCLabelFont(CFontRef font);
void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); } void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); ccLabel_->invalid(); }
void setKnobLineIndicatorColor(CColor color) { knob_->setLineIndicatorColor(color); } void setKnobLineIndicatorColor(CColor color) { knob_->setLineIndicatorColor(color); knob_->invalid(); }
void setKnobFont(CFontRef font) { knob_->setFont(font); } void setKnobFont(CFontRef font) { knob_->setFont(font); knob_->invalid(); }
void setKnobFontColor(CColor color) { knob_->setFontColor(color); } void setKnobFontColor(CColor color) { knob_->setFontColor(color); knob_->invalid(); }
using ValueToStringFunction = SStyledKnob::ValueToStringFunction; 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: private:
void updateViewSizes(); void updateViewSizes();

View file

@ -141,6 +141,24 @@ int SPiano::getKeyRole(unsigned key)
return role; 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) void SPiano::draw(CDrawContext* dc)
{ {
Impl& impl = *impl_; Impl& impl = *impl_;
@ -155,7 +173,7 @@ void SPiano::draw(CDrawContext* dc)
SharedPointer<CGraphicsPath> path; SharedPointer<CGraphicsPath> path;
path = owned(dc->createGraphicsPath()); path = owned(dc->createGraphicsPath());
path->addRoundRect(dim.bounds, impl.backgroundRadius_); path->addRoundRect(dim.bounds, impl.backgroundRadius_);
dc->setFillColor(CColor(0xca, 0xca, 0xca)); dc->setFillColor(impl.backgroundFill_);
dc->drawGraphicsPath(path, CDrawContext::kPathFilled); dc->drawGraphicsPath(path, CDrawContext::kPathFilled);
} }

View file

@ -40,6 +40,9 @@ public:
std::function<void(unsigned, float)> onKeyPressed; std::function<void(unsigned, float)> onKeyPressed;
std::function<void(unsigned, float)> onKeyReleased; std::function<void(unsigned, float)> onKeyReleased;
void setBackColor(const CColor&);
void setFontColor(const CColor&);
protected: protected:
void draw(CDrawContext* dc) override; void draw(CDrawContext* dc) override;
CMouseEventResult onMouseDown(CPoint& where, const CButtonState& buttons) override; CMouseEventResult onMouseDown(CPoint& where, const CButtonState& buttons) override;