commit 2d0a6e6ac70e8f494bd5c08e9a3dd294fef44814
parent a7c0990b5f61ac9e6127bba4097614d073a79cb8
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sun, 20 Mar 2022 01:18:04 +0100
support label background color
Diffstat:
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/source/juceUiLib/labelStyle.cpp b/source/juceUiLib/labelStyle.cpp
@@ -4,6 +4,8 @@ namespace genericUI
{
void LabelStyle::apply(juce::Label& _target) const
{
+ if(m_bgColor.getARGB())
+ _target.setColour(juce::Label::ColourIds::backgroundColourId, m_bgColor);
_target.setColour(juce::Label::ColourIds::textColourId, m_color);
_target.setText(m_text, juce::dontSendNotification);
_target.setJustificationType(m_align);
diff --git a/source/juceUiLib/uiObjectStyle.cpp b/source/juceUiLib/uiObjectStyle.cpp
@@ -39,12 +39,20 @@ namespace genericUI
m_text = _object.getProperty("text");
const auto color = _object.getProperty("color");
- if(color.size() == 8)
+ auto parseColor = [&_object](juce::Colour& _target, const std::string& _prop)
{
+ const auto color = _object.getProperty(_prop);
+
+ if(color.size() != 8)
+ return;
+
uint32_t r,g,b,a;
sscanf(color.c_str(), "%02x%02x%02x%02x", &r, &g, &b, &a);
- m_color = juce::Colour(static_cast<uint8_t>(r), static_cast<uint8_t>(g), static_cast<uint8_t>(b), static_cast<uint8_t>(a));
- }
+ _target = juce::Colour(static_cast<uint8_t>(r), static_cast<uint8_t>(g), static_cast<uint8_t>(b), static_cast<uint8_t>(a));
+ };
+
+ parseColor(m_color, "color");
+ parseColor(m_bgColor, "backgroundColor");
const auto alignH = _object.getProperty("alignH");
if(!alignH.empty())
diff --git a/source/juceUiLib/uiObjectStyle.h b/source/juceUiLib/uiObjectStyle.h
@@ -37,6 +37,7 @@ namespace genericUI
int m_textHeight = 0;
std::string m_text;
juce::Colour m_color = juce::Colour(0xffffffff);
+ juce::Colour m_bgColor = juce::Colour(0);
juce::Justification m_align = 0;
bool m_bold = false;
bool m_italic = false;