commit 095428891b5ce4465c05e46277b740f3fa870935
parent e95844fb6e152bf2ee1ae979977e43db9e6400b2
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sat, 3 Dec 2022 15:59:43 +0100
support offsets for combobox label positioning
Diffstat:
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/source/juceUiLib/comboboxStyle.cpp b/source/juceUiLib/comboboxStyle.cpp
@@ -2,6 +2,14 @@
namespace genericUI
{
+ ComboboxStyle::ComboboxStyle(Editor& _editor): UiObjectStyle(_editor)
+ {
+ m_offsetL = 1;
+ m_offsetT = 1;
+ m_offsetR = -30;
+ m_offsetB = -2;
+ }
+
void ComboboxStyle::apply(juce::ComboBox& _target) const
{
_target.setColour(juce::ComboBox::ColourIds::textColourId, m_color);
@@ -10,4 +18,13 @@ namespace genericUI
void ComboboxStyle::drawComboBox(juce::Graphics& _graphics, int width, int height, bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, juce::ComboBox& _comboBox)
{
}
+
+ void ComboboxStyle::positionComboBoxText(juce::ComboBox& box, juce::Label& label)
+ {
+ label.setBounds (m_offsetL, m_offsetT,
+ box.getWidth() + m_offsetR,
+ box.getHeight() + m_offsetB);
+
+ label.setFont (getComboBoxFont (box));
+ }
}
diff --git a/source/juceUiLib/comboboxStyle.h b/source/juceUiLib/comboboxStyle.h
@@ -7,11 +7,12 @@ namespace genericUI
class ComboboxStyle : public UiObjectStyle
{
public:
- explicit ComboboxStyle(Editor& _editor) : UiObjectStyle(_editor) {}
+ explicit ComboboxStyle(Editor& _editor);
void apply(juce::ComboBox& _target) const;
private:
void drawComboBox(juce::Graphics&, int width, int height, bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, juce::ComboBox&) override;
+ void positionComboBoxText(juce::ComboBox& box, juce::Label& label) override;
};
}
\ No newline at end of file
diff --git a/source/juceUiLib/uiObjectStyle.cpp b/source/juceUiLib/uiObjectStyle.cpp
@@ -87,6 +87,11 @@ namespace genericUI
m_italic = _object.getPropertyInt("italic") != 0;
m_url = _object.getProperty("url");
+
+ m_offsetL = _object.getPropertyInt("offsetL", 1);
+ m_offsetT = _object.getPropertyInt("offsetT", 1);
+ m_offsetR = _object.getPropertyInt("offsetR", -30);
+ m_offsetB = _object.getPropertyInt("offsetB", -2);
}
juce::Font UiObjectStyle::getComboBoxFont(juce::ComboBox& _comboBox)
diff --git a/source/juceUiLib/uiObjectStyle.h b/source/juceUiLib/uiObjectStyle.h
@@ -41,6 +41,10 @@ namespace genericUI
juce::Justification m_align = 0;
bool m_bold = false;
bool m_italic = false;
+ int m_offsetL = 0;
+ int m_offsetT = 0;
+ int m_offsetR = 0;
+ int m_offsetB = 0;
std::string m_url;
};