commit
2ca137f22e
6 changed files with 285 additions and 31 deletions
|
|
@ -162,11 +162,11 @@ struct Editor::Impl : EditorController::Receiver,
|
||||||
SharedPointer<CBitmap> backgroundBitmap_;
|
SharedPointer<CBitmap> backgroundBitmap_;
|
||||||
SharedPointer<CBitmap> defaultBackgroundBitmap_;
|
SharedPointer<CBitmap> defaultBackgroundBitmap_;
|
||||||
|
|
||||||
CControl* getSecondaryCCControl(unsigned cc)
|
SKnobCCBox* getSecondaryCCKnob(unsigned cc)
|
||||||
{
|
{
|
||||||
switch (cc) {
|
switch (cc) {
|
||||||
case 7: return volumeCCKnob_ ? volumeCCKnob_->getControl() : nullptr;
|
case 7: return volumeCCKnob_ ? volumeCCKnob_ : nullptr;
|
||||||
case 10: return panCCKnob_ ? panCCKnob_->getControl() : nullptr;
|
case 10: return panCCKnob_ ? panCCKnob_ : nullptr;
|
||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -906,6 +906,10 @@ void Editor::Impl::createFrameContents()
|
||||||
box->setCCLabelFont(font);
|
box->setCCLabelFont(font);
|
||||||
OnThemeChanged.push_back([box, palette]() {
|
OnThemeChanged.push_back([box, palette]() {
|
||||||
box->setNameLabelFontColor(palette->knobText);
|
box->setNameLabelFontColor(palette->knobText);
|
||||||
|
box->setValueEditFontColor(palette->knobText);
|
||||||
|
auto shadingColor = palette->knobText;
|
||||||
|
shadingColor.alpha = 70;
|
||||||
|
box->setShadingRectangleColor(shadingColor);
|
||||||
box->setCCLabelFontColor(palette->knobLabelText);
|
box->setCCLabelFontColor(palette->knobLabelText);
|
||||||
box->setCCLabelBackColor(palette->knobLabelBackground);
|
box->setCCLabelBackColor(palette->knobLabelBackground);
|
||||||
box->setKnobFontColor(palette->knobText);
|
box->setKnobFontColor(palette->knobText);
|
||||||
|
|
@ -913,10 +917,6 @@ void Editor::Impl::createFrameContents()
|
||||||
box->setKnobActiveTrackColor(palette->knobActiveTrack);
|
box->setKnobActiveTrackColor(palette->knobActiveTrack);
|
||||||
box->setKnobInactiveTrackColor(palette->knobInactiveTrack);
|
box->setKnobInactiveTrackColor(palette->knobInactiveTrack);
|
||||||
});
|
});
|
||||||
box->setValueToStringFunction([](float value, std::string& text) -> bool {
|
|
||||||
text = std::to_string(std::lround(value * 127));
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
return box;
|
return box;
|
||||||
};
|
};
|
||||||
auto createBackground = [&background](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
|
auto createBackground = [&background](const CRect& bounds, int, const char*, CHoriTxtAlign, int) {
|
||||||
|
|
@ -932,6 +932,10 @@ void Editor::Impl::createFrameContents()
|
||||||
panel->setCCLabelFont(font);
|
panel->setCCLabelFont(font);
|
||||||
OnThemeChanged.push_back([panel, palette]() {
|
OnThemeChanged.push_back([panel, palette]() {
|
||||||
panel->setNameLabelFontColor(palette->knobText);
|
panel->setNameLabelFontColor(palette->knobText);
|
||||||
|
panel->setValueEditFontColor(palette->knobText);
|
||||||
|
auto shadingColor = palette->knobText;
|
||||||
|
shadingColor.alpha = 70;
|
||||||
|
panel->setShadingRectangleColor(shadingColor);
|
||||||
panel->setCCLabelFontColor(palette->knobLabelText);
|
panel->setCCLabelFontColor(palette->knobLabelText);
|
||||||
panel->setCCLabelBackColor(palette->knobLabelBackground);
|
panel->setCCLabelBackColor(palette->knobLabelBackground);
|
||||||
panel->setKnobFontColor(palette->knobText);
|
panel->setKnobFontColor(palette->knobText);
|
||||||
|
|
@ -1665,7 +1669,7 @@ void Editor::Impl::updateCCValue(unsigned cc, float value)
|
||||||
if (SControlsPanel* panel = controlsPanel_)
|
if (SControlsPanel* panel = controlsPanel_)
|
||||||
panel->setControlValue(cc, value);
|
panel->setControlValue(cc, value);
|
||||||
|
|
||||||
if (CControl* other = getSecondaryCCControl(cc)) {
|
if (SKnobCCBox* other = getSecondaryCCKnob(cc)) {
|
||||||
other->setValue(value);
|
other->setValue(value);
|
||||||
other->invalid();
|
other->invalid();
|
||||||
}
|
}
|
||||||
|
|
@ -1676,7 +1680,7 @@ void Editor::Impl::updateCCDefaultValue(unsigned cc, float value)
|
||||||
if (SControlsPanel* panel = controlsPanel_)
|
if (SControlsPanel* panel = controlsPanel_)
|
||||||
panel->setControlDefaultValue(cc, value);
|
panel->setControlDefaultValue(cc, value);
|
||||||
|
|
||||||
if (CControl* other = getSecondaryCCControl(cc))
|
if (SKnobCCBox* other = getSecondaryCCKnob(cc))
|
||||||
other->setDefaultValue(value);
|
other->setDefaultValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "vstgui/lib/cvstguitimer.h"
|
#include "vstgui/lib/cvstguitimer.h"
|
||||||
#include "vstgui/lib/cframe.h"
|
#include "vstgui/lib/cframe.h"
|
||||||
#include "utility/vstgui_after.h"
|
#include "utility/vstgui_after.h"
|
||||||
|
#include "absl/strings/numbers.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
SBoxContainer::SBoxContainer(const CRect& size)
|
SBoxContainer::SBoxContainer(const CRect& size)
|
||||||
|
|
@ -582,7 +583,7 @@ void SStyledKnob::draw(CDrawContext* dc)
|
||||||
dc->drawLine(p1, p2);
|
dc->drawLine(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueToStringFunction_ && fontColor_.alpha > 0) {
|
if (valueToStringFunction_ && fontColor_.alpha > 0 && !hideValue_) {
|
||||||
std::string text;
|
std::string text;
|
||||||
if (valueToStringFunction_(getValue(), text)) {
|
if (valueToStringFunction_(getValue(), text)) {
|
||||||
dc->setFont(font_);
|
dc->setFont(font_);
|
||||||
|
|
@ -592,12 +593,29 @@ void SStyledKnob::draw(CDrawContext* dc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFilledRect::draw(CDrawContext* dc)
|
||||||
|
{
|
||||||
|
CRect bounds = getViewSize();
|
||||||
|
dc->setFillColor(color_);
|
||||||
|
bool isRounded = radius_ > 0.0;
|
||||||
|
if (isRounded) {
|
||||||
|
auto roundRect = owned(dc->createRoundRectGraphicsPath(bounds, radius_));
|
||||||
|
dc->drawGraphicsPath(roundRect, CDrawContext::kPathFilled);
|
||||||
|
} else {
|
||||||
|
dc->drawRect(bounds, kDrawFilled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
SKnobCCBox::SKnobCCBox(const CRect& size, IControlListener* listener, int32_t tag)
|
SKnobCCBox::SKnobCCBox(const CRect& size, IControlListener* listener, int32_t tag)
|
||||||
: CViewContainer(size),
|
: CViewContainer(size),
|
||||||
label_(makeOwned<CTextLabel>(CRect())),
|
label_(makeOwned<CTextLabel>(CRect())),
|
||||||
|
valueEdit_(makeOwned<CTextEdit>(CRect(), listener, tag)),
|
||||||
knob_(makeOwned<SStyledKnob>(CRect(), listener, tag)),
|
knob_(makeOwned<SStyledKnob>(CRect(), listener, tag)),
|
||||||
ccLabel_(makeOwned<CTextLabel>(CRect()))
|
ccLabel_(makeOwned<CTextLabel>(CRect())),
|
||||||
|
shadingRectangle_(makeOwned<CFilledRect>(CRect())),
|
||||||
|
menuEntry_(makeOwned<CMenuItem>("Use HDCC", tag)),
|
||||||
|
menuListener_(owned(new MenuListener(*this)))
|
||||||
{
|
{
|
||||||
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
|
setBackgroundColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||||
|
|
||||||
|
|
@ -614,17 +632,129 @@ SKnobCCBox::SKnobCCBox(const CRect& size, IControlListener* listener, int32_t ta
|
||||||
ccLabel_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
ccLabel_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||||
ccLabel_->setFontColor(CColor(0xff, 0xff, 0xff));
|
ccLabel_->setFontColor(CColor(0xff, 0xff, 0xff));
|
||||||
|
|
||||||
|
valueEdit_->setBackColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||||
|
valueEdit_->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00));
|
||||||
|
valueEdit_->setFontColor(CColor(0x00, 0x00, 0x00, 0xff));
|
||||||
|
valueEdit_->registerViewListener(this);
|
||||||
|
setHDMode(false);
|
||||||
|
valueEdit_->setVisible(false);
|
||||||
|
|
||||||
|
shadingRectangle_->setVisible(false);
|
||||||
|
|
||||||
addView(label_);
|
addView(label_);
|
||||||
label_->remember();
|
label_->remember();
|
||||||
addView(knob_);
|
addView(knob_);
|
||||||
knob_->remember();
|
knob_->remember();
|
||||||
|
addView(shadingRectangle_);
|
||||||
|
shadingRectangle_->remember();
|
||||||
|
addView(valueEdit_);
|
||||||
|
valueEdit_->remember();
|
||||||
addView(ccLabel_);
|
addView(ccLabel_);
|
||||||
ccLabel_->remember();
|
ccLabel_->remember();
|
||||||
|
|
||||||
updateViewColors();
|
updateViewColors();
|
||||||
updateViewSizes();
|
updateViewSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SKnobCCBox::~SKnobCCBox()
|
||||||
|
{
|
||||||
|
valueEdit_->unregisterViewListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SKnobCCBox::setHDMode(bool mode)
|
||||||
|
{
|
||||||
|
if (mode) {
|
||||||
|
auto valueToString = [](float value, std::string& text, VSTGUI::CParamDisplay*) -> bool {
|
||||||
|
std::string s = std::to_string(value + 0.005f);
|
||||||
|
text = s.substr(0, 4);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
knob_->setValueToStringFunction([valueToString](float value, std::string& text) {
|
||||||
|
return valueToString(value, text, nullptr);
|
||||||
|
});
|
||||||
|
valueEdit_->setValueToStringFunction2(valueToString);
|
||||||
|
|
||||||
|
valueEdit_->setStringToValueFunction([](UTF8StringPtr txt, float& result, CTextEdit*) -> bool {
|
||||||
|
float value;
|
||||||
|
if (absl::SimpleAtof(txt, &value)) {
|
||||||
|
result = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
menuEntry_->setTitle("Use low-res. CC");
|
||||||
|
} else {
|
||||||
|
auto valueToString = [](float value, std::string& text, VSTGUI::CParamDisplay*) -> bool {
|
||||||
|
text = std::to_string(std::lround(value * 127));
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
knob_->setValueToStringFunction([valueToString](float value, std::string& text) {
|
||||||
|
return valueToString(value, text, nullptr);
|
||||||
|
});
|
||||||
|
valueEdit_->setValueToStringFunction2(valueToString);
|
||||||
|
|
||||||
|
valueEdit_->setStringToValueFunction([](UTF8StringPtr txt, float& result, CTextEdit*) -> bool {
|
||||||
|
float value;
|
||||||
|
if (absl::SimpleAtof(txt, &value)) {
|
||||||
|
result = value / 127.0f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
menuEntry_->setTitle("Use high-res. CC");
|
||||||
|
}
|
||||||
|
|
||||||
|
hdMode_ = mode;
|
||||||
|
valueEdit_->setValue(valueEdit_->getValue());
|
||||||
|
invalid();
|
||||||
|
}
|
||||||
|
|
||||||
|
CMouseEventResult SKnobCCBox::onMouseDown(CPoint& where, const CButtonState& buttons)
|
||||||
|
{
|
||||||
|
if (buttons.isRightButton()) {
|
||||||
|
CFrame* frame = getFrame();
|
||||||
|
CPoint frameWhere = where;
|
||||||
|
frameWhere.offset(-getViewSize().left, -getViewSize().top);
|
||||||
|
this->localToFrame(frameWhere);
|
||||||
|
|
||||||
|
auto self = shared(this);
|
||||||
|
frame->doAfterEventProcessing([self, frameWhere]() {
|
||||||
|
if (CFrame* frame = self->getFrame()) {
|
||||||
|
SharedPointer<COptionMenu> menu =
|
||||||
|
owned(new COptionMenu(CRect(), self->menuListener_, -1, nullptr, nullptr, COptionMenu::kPopupStyle));
|
||||||
|
menu->addEntry(self->menuEntry_);
|
||||||
|
self->menuEntry_->remember(); // above call does not increment refcount
|
||||||
|
|
||||||
|
menu->setFont(self->getValueEditFont());
|
||||||
|
menu->setFontColor(self->getValueEditFontColor());
|
||||||
|
menu->setBackColor(self->getValueEditBackColor());
|
||||||
|
menu->popup(frame, frameWhere);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return kMouseEventHandled;
|
||||||
|
} else if (buttons.isDoubleClick() && !valueEdit_->isVisible()) {
|
||||||
|
valueEdit_->setVisible(true);
|
||||||
|
shadingRectangle_->setVisible(true);
|
||||||
|
knob_->setHideValue(true);
|
||||||
|
valueEdit_->takeFocus();
|
||||||
|
invalid();
|
||||||
|
return kMouseEventHandled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CViewContainer::onMouseDown(where, buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SKnobCCBox::viewLostFocus (CView* view)
|
||||||
|
{
|
||||||
|
if (view == valueEdit_.get()) {
|
||||||
|
shadingRectangle_->setVisible(false);
|
||||||
|
valueEdit_->setVisible(false);
|
||||||
|
knob_->setHideValue(false);
|
||||||
|
invalid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SKnobCCBox::setHue(float hue)
|
void SKnobCCBox::setHue(float hue)
|
||||||
{
|
{
|
||||||
hue_ = hue;
|
hue_ = hue;
|
||||||
|
|
@ -637,12 +767,33 @@ void SKnobCCBox::setNameLabelFont(CFontRef font)
|
||||||
updateViewSizes();
|
updateViewSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SKnobCCBox::setValueEditFont(CFontRef font)
|
||||||
|
{
|
||||||
|
label_->setFont(font);
|
||||||
|
updateViewSizes();
|
||||||
|
}
|
||||||
|
|
||||||
void SKnobCCBox::setCCLabelFont(CFontRef font)
|
void SKnobCCBox::setCCLabelFont(CFontRef font)
|
||||||
{
|
{
|
||||||
ccLabel_->setFont(font);
|
ccLabel_->setFont(font);
|
||||||
updateViewSizes();
|
updateViewSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SKnobCCBox::setValue(float value)
|
||||||
|
{
|
||||||
|
float oldValue = knob_->getValue();
|
||||||
|
knob_->setValue(value);
|
||||||
|
valueEdit_->setValue(value);
|
||||||
|
if (value != oldValue)
|
||||||
|
invalid();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SKnobCCBox::setDefaultValue(float value)
|
||||||
|
{
|
||||||
|
knob_->setDefaultValue(value);
|
||||||
|
valueEdit_->setDefaultValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
void SKnobCCBox::updateViewSizes()
|
void SKnobCCBox::updateViewSizes()
|
||||||
{
|
{
|
||||||
const CRect size = getViewSize();
|
const CRect size = getViewSize();
|
||||||
|
|
@ -650,19 +801,30 @@ void SKnobCCBox::updateViewSizes()
|
||||||
|
|
||||||
const CFontRef nameFont = label_->getFont();
|
const CFontRef nameFont = label_->getFont();
|
||||||
const CFontRef ccFont = ccLabel_->getFont();
|
const CFontRef ccFont = ccLabel_->getFont();
|
||||||
|
const CFontRef valueFont = valueEdit_->getFont();
|
||||||
|
|
||||||
nameLabelSize_ = CRect(0.0, 0.0, size.getWidth(), nameFont->getSize() + 2 * ypad);
|
nameLabelSize_ = CRect(0.0, 0.0, size.getWidth(), nameFont->getSize() + 2 * ypad);
|
||||||
ccLabelSize_ = CRect(0.0, size.getHeight() - ccFont->getSize() - 2 * ypad, size.getWidth(), size.getHeight());
|
ccLabelSize_ = CRect(0.0, size.getHeight() - ccFont->getSize() - 2 * ypad, size.getWidth(), size.getHeight());
|
||||||
knobSize_ = CRect(0.0, nameLabelSize_.bottom, size.getWidth(), ccLabelSize_.top);
|
knobSize_ = CRect(0.0, nameLabelSize_.bottom, size.getWidth(), ccLabelSize_.top);
|
||||||
|
valueEditSize_ = CRect(
|
||||||
|
size.getWidth() / 2 - valueFont->getSize(),
|
||||||
|
size.getHeight() / 2 - valueFont->getSize() / 2,
|
||||||
|
size.getWidth() / 2 + valueFont->getSize(),
|
||||||
|
size.getHeight() / 2 + valueFont->getSize() / 2
|
||||||
|
);
|
||||||
|
|
||||||
// remove knob side areas
|
// remove knob side areas
|
||||||
CCoord side = std::max(0.0, knobSize_.getWidth() - knobSize_.getHeight());
|
CCoord side = std::max(0.0, knobSize_.getWidth() - knobSize_.getHeight());
|
||||||
knobSize_.extend(-0.5 * side, 0.0);
|
knobSize_.extend(-0.5 * side, 0.0);
|
||||||
|
shadingRectangleSize_ = knobSize_;
|
||||||
|
shadingRectangleSize_.bottom -= ypad;
|
||||||
|
|
||||||
//
|
//
|
||||||
label_->setViewSize(nameLabelSize_);
|
label_->setViewSize(nameLabelSize_);
|
||||||
knob_->setViewSize(knobSize_);
|
knob_->setViewSize(knobSize_);
|
||||||
ccLabel_->setViewSize(ccLabelSize_);
|
ccLabel_->setViewSize(ccLabelSize_);
|
||||||
|
valueEdit_->setViewSize(valueEditSize_);
|
||||||
|
shadingRectangle_->setViewSize(shadingRectangleSize_);
|
||||||
|
|
||||||
invalid();
|
invalid();
|
||||||
}
|
}
|
||||||
|
|
@ -746,11 +908,6 @@ SControlsPanel::ControlSlot* SControlsPanel::getOrCreateSlot(uint32_t index)
|
||||||
slot->box = box;
|
slot->box = box;
|
||||||
slot->box->setCCLabelText(("CC " + std::to_string(index)).c_str());
|
slot->box->setCCLabelText(("CC " + std::to_string(index)).c_str());
|
||||||
|
|
||||||
slot->box->setValueToStringFunction([](float value, std::string& text) -> bool {
|
|
||||||
text = std::to_string(std::lround(value * 127));
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
syncSlotStyle(index);
|
syncSlotStyle(index);
|
||||||
|
|
||||||
return slot;
|
return slot;
|
||||||
|
|
@ -760,10 +917,9 @@ void SControlsPanel::setControlValue(uint32_t index, float value)
|
||||||
{
|
{
|
||||||
ControlSlot* slot = getOrCreateSlot(index);
|
ControlSlot* slot = getOrCreateSlot(index);
|
||||||
SKnobCCBox* box = slot->box;
|
SKnobCCBox* box = slot->box;
|
||||||
auto* control = box->getControl();
|
float oldValue = box->getValue();
|
||||||
float oldValue = control->getValue();
|
box->setValue(value);
|
||||||
control->setValue(value);
|
if (box->getValue() != oldValue)
|
||||||
if (control->getValue() != oldValue)
|
|
||||||
box->invalid();
|
box->invalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -771,7 +927,7 @@ void SControlsPanel::setControlDefaultValue(uint32_t index, float value)
|
||||||
{
|
{
|
||||||
ControlSlot* slot = getOrCreateSlot(index);
|
ControlSlot* slot = getOrCreateSlot(index);
|
||||||
SKnobCCBox* box = slot->box;
|
SKnobCCBox* box = slot->box;
|
||||||
box->getControl()->setDefaultValue(value);
|
box->setDefaultValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text)
|
void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text)
|
||||||
|
|
@ -788,12 +944,14 @@ void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text)
|
||||||
void SControlsPanel::setNameLabelFont(CFontRef font)
|
void SControlsPanel::setNameLabelFont(CFontRef font)
|
||||||
{
|
{
|
||||||
slots_[0]->box->setNameLabelFont(font);
|
slots_[0]->box->setNameLabelFont(font);
|
||||||
|
slots_[0]->box->setValueEditFont(font);
|
||||||
syncAllSlotStyles();
|
syncAllSlotStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SControlsPanel::setNameLabelFontColor(CColor color)
|
void SControlsPanel::setNameLabelFontColor(CColor color)
|
||||||
{
|
{
|
||||||
slots_[0]->box->setNameLabelFontColor(color);
|
slots_[0]->box->setNameLabelFontColor(color);
|
||||||
|
slots_[0]->box->setValueEditFontColor(color);
|
||||||
syncAllSlotStyles();
|
syncAllSlotStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -815,6 +973,24 @@ void SControlsPanel::setCCLabelFontColor(CColor color)
|
||||||
syncAllSlotStyles();
|
syncAllSlotStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SControlsPanel::setValueEditBackColor(CColor color)
|
||||||
|
{
|
||||||
|
slots_[0]->box->setValueEditBackColor(color);
|
||||||
|
syncAllSlotStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SControlsPanel::setShadingRectangleColor(CColor color)
|
||||||
|
{
|
||||||
|
slots_[0]->box->setShadingRectangleColor(color);
|
||||||
|
syncAllSlotStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SControlsPanel::setValueEditFontColor(CColor color)
|
||||||
|
{
|
||||||
|
slots_[0]->box->setValueEditFontColor(color);
|
||||||
|
syncAllSlotStyles();
|
||||||
|
}
|
||||||
|
|
||||||
void SControlsPanel::setKnobActiveTrackColor(CColor color)
|
void SControlsPanel::setKnobActiveTrackColor(CColor color)
|
||||||
{
|
{
|
||||||
slots_[0]->box->setKnobActiveTrackColor(color);
|
slots_[0]->box->setKnobActiveTrackColor(color);
|
||||||
|
|
@ -947,6 +1123,11 @@ void SControlsPanel::syncSlotStyle(uint32_t index)
|
||||||
cur->setNameLabelFont(ref->getNameLabelFont());
|
cur->setNameLabelFont(ref->getNameLabelFont());
|
||||||
cur->setNameLabelFontColor(ref->getNameLabelFontColor());
|
cur->setNameLabelFontColor(ref->getNameLabelFontColor());
|
||||||
|
|
||||||
|
cur->setValueEditFont(ref->getValueEditFont());
|
||||||
|
cur->setValueEditFontColor(ref->getValueEditFontColor());
|
||||||
|
|
||||||
|
cur->setShadingRectangleColor(ref->getShadingRectangleColor());
|
||||||
|
|
||||||
cur->setCCLabelFont(ref->getCCLabelFont());
|
cur->setCCLabelFont(ref->getCCLabelFont());
|
||||||
cur->setCCLabelFontColor(ref->getCCLabelFontColor());
|
cur->setCCLabelFontColor(ref->getCCLabelFontColor());
|
||||||
cur->setCCLabelBackColor(ref->getCCLabelBackColor());
|
cur->setCCLabelBackColor(ref->getCCLabelBackColor());
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "vstgui/lib/controls/cslider.h"
|
#include "vstgui/lib/controls/cslider.h"
|
||||||
#include "vstgui/lib/controls/cknob.h"
|
#include "vstgui/lib/controls/cknob.h"
|
||||||
#include "vstgui/lib/controls/ctextlabel.h"
|
#include "vstgui/lib/controls/ctextlabel.h"
|
||||||
|
#include "vstgui/lib/controls/ctextedit.h"
|
||||||
#include "vstgui/lib/controls/cbuttons.h"
|
#include "vstgui/lib/controls/cbuttons.h"
|
||||||
#include "vstgui/lib/controls/coptionmenu.h"
|
#include "vstgui/lib/controls/coptionmenu.h"
|
||||||
#include "vstgui/lib/controls/cscrollbar.h"
|
#include "vstgui/lib/controls/cscrollbar.h"
|
||||||
|
|
@ -233,6 +234,9 @@ public:
|
||||||
using ValueToStringFunction = std::function<bool(float value, std::string& result)>;
|
using ValueToStringFunction = std::function<bool(float value, std::string& result)>;
|
||||||
void setValueToStringFunction(ValueToStringFunction func);
|
void setValueToStringFunction(ValueToStringFunction func);
|
||||||
|
|
||||||
|
void setHideValue(bool hide) { hideValue_ = hide; invalid(); }
|
||||||
|
bool getHideValue() const { return hideValue_; }
|
||||||
|
|
||||||
CLASS_METHODS(SStyledKnob, CKnobBase)
|
CLASS_METHODS(SStyledKnob, CKnobBase)
|
||||||
protected:
|
protected:
|
||||||
void draw(CDrawContext* dc) override;
|
void draw(CDrawContext* dc) override;
|
||||||
|
|
@ -241,6 +245,7 @@ private:
|
||||||
CColor activeTrackColor_;
|
CColor activeTrackColor_;
|
||||||
CColor inactiveTrackColor_;
|
CColor inactiveTrackColor_;
|
||||||
CColor lineIndicatorColor_;
|
CColor lineIndicatorColor_;
|
||||||
|
bool hideValue_ { false };
|
||||||
|
|
||||||
SharedPointer<CFontDesc> font_ = kNormalFont;
|
SharedPointer<CFontDesc> font_ = kNormalFont;
|
||||||
CColor fontColor_ { 0x00, 0x00, 0x00 };
|
CColor fontColor_ { 0x00, 0x00, 0x00 };
|
||||||
|
|
@ -248,12 +253,35 @@ private:
|
||||||
ValueToStringFunction valueToStringFunction_;
|
ValueToStringFunction valueToStringFunction_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CFilledRect : public CView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CFilledRect(const CRect& size)
|
||||||
|
: CView(size) {}
|
||||||
|
|
||||||
|
void setRadius(CCoord radius) { radius_ = radius; invalid(); }
|
||||||
|
CCoord getRadius() const { return radius_; }
|
||||||
|
|
||||||
|
void setColor(CColor color){ color_ = color; invalid(); }
|
||||||
|
CColor getColor() { return color_; }
|
||||||
|
protected:
|
||||||
|
void draw(CDrawContext* dc) override;
|
||||||
|
private:
|
||||||
|
CCoord radius_ { 5.0 };
|
||||||
|
CColor color_ { 0, 0, 0, 70 };
|
||||||
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
class SKnobCCBox : public CViewContainer {
|
class SKnobCCBox : public CViewContainer, ViewListenerAdapter {
|
||||||
public:
|
public:
|
||||||
SKnobCCBox(const CRect& size, IControlListener* listener, int32_t tag);
|
SKnobCCBox(const CRect& size, IControlListener* listener, int32_t tag);
|
||||||
|
~SKnobCCBox();
|
||||||
void setHue(float hue);
|
void setHue(float hue);
|
||||||
SStyledKnob* getControl() const { return knob_; }
|
|
||||||
|
float getValue() const { return knob_->getValue(); }
|
||||||
|
float getDefaultValue() const { return knob_->getDefaultValue(); }
|
||||||
|
void setValue(float value);
|
||||||
|
void setDefaultValue(float value);
|
||||||
|
|
||||||
void setNameLabelText(const UTF8String& name) { label_->setText(name); label_->invalid(); }
|
void setNameLabelText(const UTF8String& name) { label_->setText(name); label_->invalid(); }
|
||||||
void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); ccLabel_->invalid(); }
|
void setCCLabelText(const UTF8String& name) { ccLabel_->setText(name); ccLabel_->invalid(); }
|
||||||
|
|
@ -264,6 +292,18 @@ public:
|
||||||
void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); }
|
void setNameLabelFontColor(CColor color) { label_->setFontColor(color); label_->invalid(); }
|
||||||
CColor getNameLabelFontColor() const { return label_->getFontColor(); }
|
CColor getNameLabelFontColor() const { return label_->getFontColor(); }
|
||||||
|
|
||||||
|
void setValueEditFont(CFontRef font);
|
||||||
|
CFontRef getValueEditFont() const { return label_->getFont(); }
|
||||||
|
|
||||||
|
void setValueEditFontColor(CColor color) { valueEdit_->setFontColor(color); valueEdit_->invalid(); }
|
||||||
|
CColor getValueEditFontColor() const { return valueEdit_->getFontColor(); }
|
||||||
|
|
||||||
|
void setValueEditBackColor(CColor color) { valueEdit_->setBackColor(color); valueEdit_->invalid(); }
|
||||||
|
CColor getValueEditBackColor() const { return valueEdit_->getBackColor(); }
|
||||||
|
|
||||||
|
void setShadingRectangleColor(CColor color) { shadingRectangle_->setColor(color); shadingRectangle_->invalid(); }
|
||||||
|
CColor getShadingRectangleColor() const { return shadingRectangle_->getColor(); }
|
||||||
|
|
||||||
void setCCLabelFont(CFontRef font);
|
void setCCLabelFont(CFontRef font);
|
||||||
CFontRef getCCLabelFont() const { return ccLabel_->getFont(); }
|
CFontRef getCCLabelFont() const { return ccLabel_->getFont(); }
|
||||||
|
|
||||||
|
|
@ -288,21 +328,44 @@ public:
|
||||||
void setKnobFontColor(CColor color) { knob_->setFontColor(color); knob_->invalid(); }
|
void setKnobFontColor(CColor color) { knob_->setFontColor(color); knob_->invalid(); }
|
||||||
CColor getKnobFontColor() const { return knob_->getFontColor(); }
|
CColor getKnobFontColor() const { return knob_->getFontColor(); }
|
||||||
|
|
||||||
using ValueToStringFunction = SStyledKnob::ValueToStringFunction;
|
// Edit box listener
|
||||||
void setValueToStringFunction(ValueToStringFunction f) { knob_->setValueToStringFunction(std::move(f)); knob_->invalid(); }
|
void viewLostFocus (CView* view) override;
|
||||||
|
|
||||||
|
bool isHD() const noexcept { return hdMode_; }
|
||||||
|
void setHDMode(bool mode);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CMouseEventResult onMouseDown(CPoint& where, const CButtonState& buttons) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateViewSizes();
|
void updateViewSizes();
|
||||||
void updateViewColors();
|
void updateViewColors();
|
||||||
|
|
||||||
private:
|
|
||||||
SharedPointer<CTextLabel> label_;
|
SharedPointer<CTextLabel> label_;
|
||||||
|
SharedPointer<CTextEdit> valueEdit_;
|
||||||
SharedPointer<SStyledKnob> knob_;
|
SharedPointer<SStyledKnob> knob_;
|
||||||
SharedPointer<CTextLabel> ccLabel_;
|
SharedPointer<CTextLabel> ccLabel_;
|
||||||
|
SharedPointer<CFilledRect> shadingRectangle_;
|
||||||
|
SharedPointer<CMenuItem> menuEntry_;
|
||||||
CRect nameLabelSize_;
|
CRect nameLabelSize_;
|
||||||
CRect knobSize_;
|
CRect knobSize_;
|
||||||
|
CRect shadingRectangleSize_;
|
||||||
CRect ccLabelSize_;
|
CRect ccLabelSize_;
|
||||||
|
CRect valueEditSize_;
|
||||||
|
CRect rectangleSize_;
|
||||||
float hue_ = 0.35;
|
float hue_ = 0.35;
|
||||||
|
|
||||||
|
class MenuListener : public IControlListener, public NonAtomicReferenceCounted {
|
||||||
|
public:
|
||||||
|
explicit MenuListener(SKnobCCBox& box) : box_(box) {}
|
||||||
|
void valueChanged(CControl*) override
|
||||||
|
{
|
||||||
|
box_.setHDMode(!box_.isHD());
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
SKnobCCBox& box_;
|
||||||
|
};
|
||||||
|
SharedPointer<MenuListener> menuListener_;
|
||||||
|
bool hdMode_ { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
@ -320,6 +383,9 @@ public:
|
||||||
void setCCLabelFont(CFontRef font);
|
void setCCLabelFont(CFontRef font);
|
||||||
void setCCLabelBackColor(CColor color);
|
void setCCLabelBackColor(CColor color);
|
||||||
void setCCLabelFontColor(CColor color);
|
void setCCLabelFontColor(CColor color);
|
||||||
|
void setValueEditBackColor(CColor color);
|
||||||
|
void setValueEditFontColor(CColor color);
|
||||||
|
void setShadingRectangleColor(CColor color);
|
||||||
void setKnobActiveTrackColor(CColor color);
|
void setKnobActiveTrackColor(CColor color);
|
||||||
void setKnobInactiveTrackColor(CColor color);
|
void setKnobInactiveTrackColor(CColor color);
|
||||||
void setKnobLineIndicatorColor(CColor color);
|
void setKnobLineIndicatorColor(CColor color);
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ void SPiano::draw(CDrawContext* dc)
|
||||||
case KeyRole::Switch:
|
case KeyRole::Switch:
|
||||||
hcy.h = impl.keySwitchHue_;
|
hcy.h = impl.keySwitchHue_;
|
||||||
break;
|
break;
|
||||||
default: whiteKeyDefault:
|
default:
|
||||||
hcy.y = 1.0;
|
hcy.y = 1.0;
|
||||||
if (impl.keyval_[key])
|
if (impl.keyval_[key])
|
||||||
hcy.c = 0.0;
|
hcy.c = 0.0;
|
||||||
|
|
@ -226,7 +226,7 @@ void SPiano::draw(CDrawContext* dc)
|
||||||
case KeyRole::Switch:
|
case KeyRole::Switch:
|
||||||
hcy.h = impl.keySwitchHue_;
|
hcy.h = impl.keySwitchHue_;
|
||||||
break;
|
break;
|
||||||
default: blackKeyDefault:
|
default:
|
||||||
hcy.c = 0.0;
|
hcy.c = 0.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ struct sfizz_ui_t : EditorController, VSTGUIEditorInterface {
|
||||||
|
|
||||||
/// VSTGUIEditorInterface
|
/// VSTGUIEditorInterface
|
||||||
CFrame* getFrame() const override { return uiFrame.get(); }
|
CFrame* getFrame() const override { return uiFrame.get(); }
|
||||||
|
int32_t getKnobMode () const override { return kLinearMode; }
|
||||||
LV2_Atom_Forge atom_forge;
|
LV2_Atom_Forge atom_forge;
|
||||||
LV2_URID atom_event_transfer_uri;
|
LV2_URID atom_event_transfer_uri;
|
||||||
LV2_URID atom_object_uri;
|
LV2_URID atom_object_uri;
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,9 @@ tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
addProgramList(list);
|
addProgramList(list);
|
||||||
list->addRef();
|
list->addRef();
|
||||||
|
|
||||||
|
// Use linear knobs
|
||||||
|
setKnobMode(kLinearMode);
|
||||||
|
|
||||||
return kResultTrue;
|
return kResultTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue