Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: components update #812

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions plugins/editor/src/editor/GUIComponents.h
Original file line number Diff line number Diff line change
@@ -249,18 +249,18 @@ class SKnobCCBox : public CViewContainer {
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();
20 changes: 19 additions & 1 deletion plugins/editor/src/editor/GUIPiano.cpp
Original file line number Diff line number Diff line change
@@ -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<CGraphicsPath> 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);
}

3 changes: 3 additions & 0 deletions plugins/editor/src/editor/GUIPiano.h
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@ class SPiano : public CView {
std::function<void(unsigned, float)> onKeyPressed;
std::function<void(unsigned, float)> onKeyReleased;

void setBackColor(const CColor&);
void setFontColor(const CColor&);

protected:
void draw(CDrawContext* dc) override;
CMouseEventResult onMouseDown(CPoint& where, const CButtonState& buttons) override;