From 3a70c37d931cab7972a3839205dec6571e2c2db3 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 3 Feb 2021 14:37:07 +0100 Subject: [PATCH] Default text for CC labels --- editor/src/editor/GUIComponents.cpp | 12 ++++++++++-- editor/src/editor/GUIComponents.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/editor/src/editor/GUIComponents.cpp b/editor/src/editor/GUIComponents.cpp index 36217278..157b6b49 100644 --- a/editor/src/editor/GUIComponents.cpp +++ b/editor/src/editor/GUIComponents.cpp @@ -570,7 +570,7 @@ void SControlsPanel::setControlUsed(uint32_t index, bool used) label->setStyle(CTextLabel::kRoundRectStyle); label->setRoundRectRadius(5.0); label->setBackColor(CColor(0x2e, 0x34, 0x36)); - label->setText(("CC " + std::to_string(index)).c_str()); + label->setText(getDefaultLabelText(index)); knob->setActiveTrackColor(CColor(0x00, 0xb6, 0x2a)); knob->setInactiveTrackColor(CColor(0x30, 0x30, 0x30)); knob->setLineIndicatorColor(CColor(0x00, 0x00, 0x00)); @@ -591,6 +591,11 @@ void SControlsPanel::setControlUsed(uint32_t index, bool used) updateLayout(); } +std::string SControlsPanel::getDefaultLabelText(uint32_t index) +{ + return "CC " + std::to_string(index); +} + void SControlsPanel::setControlValue(uint32_t index, float value) { if (index >= slots_.size()) @@ -624,7 +629,10 @@ void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text) if (!slot) return; - slot->label->setText(text); + if (text && text[0] != '\0') + slot->label->setText(text); + else + slot->label->setText(getDefaultLabelText(index).c_str()); } void SControlsPanel::recalculateSubViews() diff --git a/editor/src/editor/GUIComponents.h b/editor/src/editor/GUIComponents.h index 5ba9a6df..e2c987f6 100644 --- a/editor/src/editor/GUIComponents.h +++ b/editor/src/editor/GUIComponents.h @@ -235,6 +235,7 @@ protected: private: void updateLayout(); + static std::string getDefaultLabelText(uint32_t index); private: struct ControlSlot {