Merge pull request #821 from jpcima/control-panel-style
Allow to set knob styles on the control panel
This commit is contained in:
commit
327cf9332c
3 changed files with 139 additions and 3 deletions
|
|
@ -876,8 +876,10 @@ void Editor::Impl::createFrameContents()
|
|||
box->setNameLabelText(label);
|
||||
box->setNameLabelFont(font);
|
||||
box->setKnobFont(font);
|
||||
box->setCCLabelFont(font);
|
||||
OnThemeChanged.push_back([box, palette]() {
|
||||
box->setNameLabelFontColor(palette->text);
|
||||
box->setCCLabelFontColor(palette->text);
|
||||
box->setKnobFontColor(palette->text);
|
||||
box->setKnobLineIndicatorColor(palette->knobLineIndicator);
|
||||
});
|
||||
|
|
@ -892,8 +894,16 @@ void Editor::Impl::createFrameContents()
|
|||
container->setBackground(background);
|
||||
return container;
|
||||
};
|
||||
auto createControlsPanel = [](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
|
||||
auto createControlsPanel = [this, &palette](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
|
||||
auto* panel = new SControlsPanel(bounds);
|
||||
OnThemeChanged.push_back([panel, palette]() {
|
||||
panel->setNameLabelFontColor(palette->text);
|
||||
panel->setCCLabelFontColor(palette->valueText);
|
||||
panel->setKnobFontColor(palette->text);
|
||||
panel->setKnobActiveTrackColor(palette->knobActiveTrack);
|
||||
panel->setKnobInactiveTrackColor(palette->knobInactiveTrack);
|
||||
panel->setKnobLineIndicatorColor(palette->knobLineIndicator);
|
||||
});
|
||||
return panel;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -682,6 +682,9 @@ SControlsPanel::SControlsPanel(const CRect& size)
|
|||
CScrollView::kVerticalScrollbar|CScrollView::kDontDrawFrame|CScrollView::kAutoHideScrollbars),
|
||||
listener_(new ControlSlotListener(this))
|
||||
{
|
||||
// slot 0 always exists, keep the default style on the views there
|
||||
getOrCreateSlot(0);
|
||||
|
||||
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||
|
||||
setScrollbarWidth(10.0);
|
||||
|
|
@ -740,6 +743,8 @@ SControlsPanel::ControlSlot* SControlsPanel::getOrCreateSlot(uint32_t index)
|
|||
return true;
|
||||
});
|
||||
|
||||
syncSlotStyle(index);
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
|
|
@ -772,6 +777,60 @@ void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text)
|
|||
box->invalid();
|
||||
}
|
||||
|
||||
void SControlsPanel::setNameLabelFont(CFontRef font)
|
||||
{
|
||||
slots_[0]->box->setNameLabelFont(font);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setNameLabelFontColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setNameLabelFontColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setCCLabelFont(CFontRef font)
|
||||
{
|
||||
slots_[0]->box->setCCLabelFont(font);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setCCLabelFontColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setCCLabelFontColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setKnobActiveTrackColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setKnobActiveTrackColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setKnobInactiveTrackColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setKnobInactiveTrackColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setKnobLineIndicatorColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setKnobLineIndicatorColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setKnobFont(CFontRef font)
|
||||
{
|
||||
slots_[0]->box->setKnobFont(font);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::setKnobFontColor(CColor color)
|
||||
{
|
||||
slots_[0]->box->setKnobFontColor(color);
|
||||
syncAllSlotStyles();
|
||||
}
|
||||
|
||||
void SControlsPanel::recalculateSubViews()
|
||||
{
|
||||
CScrollView::recalculateSubViews();
|
||||
|
|
@ -852,6 +911,41 @@ void SControlsPanel::updateLayout()
|
|||
invalid();
|
||||
}
|
||||
|
||||
void SControlsPanel::syncAllSlotStyles()
|
||||
{
|
||||
uint32_t count = static_cast<uint32_t>(slots_.size());
|
||||
for (uint32_t index = 0; index < count; ++index)
|
||||
syncSlotStyle(index);
|
||||
}
|
||||
|
||||
void SControlsPanel::syncSlotStyle(uint32_t index)
|
||||
{
|
||||
if (index >= slots_.size())
|
||||
return;
|
||||
|
||||
const SKnobCCBox* ref = slots_[0]->box;
|
||||
SKnobCCBox* cur = slots_[index]->box;
|
||||
|
||||
if (!cur)
|
||||
return;
|
||||
|
||||
if (cur != ref) {
|
||||
cur->setNameLabelFont(ref->getNameLabelFont());
|
||||
cur->setNameLabelFontColor(ref->getNameLabelFontColor());
|
||||
|
||||
cur->setCCLabelFont(ref->getCCLabelFont());
|
||||
cur->setCCLabelFontColor(ref->getCCLabelFontColor());
|
||||
|
||||
cur->setKnobActiveTrackColor(ref->getKnobActiveTrackColor());
|
||||
cur->setKnobInactiveTrackColor(ref->getKnobInactiveTrackColor());
|
||||
cur->setKnobLineIndicatorColor(ref->getKnobLineIndicatorColor());
|
||||
cur->setKnobFont(ref->getKnobFont());
|
||||
cur->setKnobFontColor(ref->getKnobFontColor());
|
||||
}
|
||||
|
||||
cur->invalid();
|
||||
}
|
||||
|
||||
void SControlsPanel::ControlSlotListener::valueChanged(CControl* pControl)
|
||||
{
|
||||
if (panel_->ValueChangeFunction)
|
||||
|
|
|
|||
|
|
@ -250,14 +250,34 @@ public:
|
|||
SStyledKnob* getControl() const { return knob_; }
|
||||
|
||||
void setNameLabelText(const UTF8String& name) { label_->setText(name); label_->invalid(); }
|
||||
void setNameLabelFont(CFontRef font);
|
||||
void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); }
|
||||
void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); ccLabel_->invalid(); }
|
||||
|
||||
void setNameLabelFont(CFontRef font);
|
||||
CFontRef getNameLabelFont() const { return label_->getFont(); }
|
||||
|
||||
void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); }
|
||||
CColor getNameLabelFontColor() const { return label_->getFontColor(); }
|
||||
|
||||
void setCCLabelFont(CFontRef font);
|
||||
CFontRef getCCLabelFont() const { return ccLabel_->getFont(); }
|
||||
|
||||
void setCCLabelFontColor(CColor color) { ccLabel_->setFontColor(color); ccLabel_->invalid(); }
|
||||
CColor getCCLabelFontColor() const { return ccLabel_->getFontColor(); }
|
||||
|
||||
void setKnobActiveTrackColor(CColor color) { knob_->setActiveTrackColor(color); knob_->invalid(); }
|
||||
CColor getKnobActiveTrackColor() const { return knob_->getActiveTrackColor(); }
|
||||
|
||||
void setKnobInactiveTrackColor(CColor color) { knob_->setInactiveTrackColor(color); knob_->invalid(); }
|
||||
CColor getKnobInactiveTrackColor() const { return knob_->getInactiveTrackColor(); }
|
||||
|
||||
void setKnobLineIndicatorColor(CColor color) { knob_->setLineIndicatorColor(color); knob_->invalid(); }
|
||||
CColor getKnobLineIndicatorColor() const { return knob_->getLineIndicatorColor(); }
|
||||
|
||||
void setKnobFont(CFontRef font) { knob_->setFont(font); knob_->invalid(); }
|
||||
CFontRef getKnobFont() const { return knob_->getFont(); }
|
||||
|
||||
void setKnobFontColor(CColor color) { knob_->setFontColor(color); knob_->invalid(); }
|
||||
CColor getKnobFontColor() const { return knob_->getFontColor(); }
|
||||
|
||||
using ValueToStringFunction = SStyledKnob::ValueToStringFunction;
|
||||
void setValueToStringFunction(ValueToStringFunction f) { knob_->setValueToStringFunction(std::move(f)); knob_->invalid(); }
|
||||
|
|
@ -286,6 +306,16 @@ public:
|
|||
void setControlDefaultValue(uint32_t index, float value);
|
||||
void setControlLabelText(uint32_t index, UTF8StringPtr text);
|
||||
|
||||
void setNameLabelFont(CFontRef font);
|
||||
void setNameLabelFontColor(CColor color);
|
||||
void setCCLabelFont(CFontRef font);
|
||||
void setCCLabelFontColor(CColor color);
|
||||
void setKnobActiveTrackColor(CColor color);
|
||||
void setKnobInactiveTrackColor(CColor color);
|
||||
void setKnobLineIndicatorColor(CColor color);
|
||||
void setKnobFont(CFontRef font);
|
||||
void setKnobFontColor(CColor color);
|
||||
|
||||
std::function<void(uint32_t, float)> ValueChangeFunction;
|
||||
std::function<void(uint32_t)> BeginEditFunction;
|
||||
std::function<void(uint32_t)> EndEditFunction;
|
||||
|
|
@ -295,6 +325,8 @@ protected:
|
|||
|
||||
private:
|
||||
void updateLayout();
|
||||
void syncAllSlotStyles();
|
||||
void syncSlotStyle(uint32_t index);
|
||||
static std::string getDefaultLabelText(uint32_t index);
|
||||
|
||||
struct ControlSlot;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue