Krotos Modules 3
Loading...
Searching...
No Matches
AttachedSlider.h
Go to the documentation of this file.
1#pragma once
2namespace krotos
3{
4 //==============================================================================
9 class AttachedSlider : public Component
10 {
11 public:
12 enum class LabelPosition
13 {
14 Above,
15 Below,
16 Left
17 };
18
20 AttachedSlider(const String& labelText, bool setLabelVisible = true,
21 const String& dragAndDropDescription = String());
22
23 void resized() override;
24 void paint(Graphics& g) override;
25
27 Label& getLabel();
28
30 Slider& getSlider();
31
33 Slider& getControlComponent();
34
36 std::unique_ptr<SliderParameterAttachment>& getAttachment();
37
39 void setDebugColour(Colour newColour);
40
43 void setDragAndDropDescription(const var& description);
44
47
49 void setLabelPosition(LabelPosition position) { m_labelPosition = position; }
50
51 void mouseMove(const MouseEvent& event) override;
52
53 void mouseExit(const MouseEvent& /*event*/) override;
54
56 void setValueSuffix(String valueSuffix) { m_valueSuffix = valueSuffix; }
57
59 void setValueFormat(String valueFormat) { m_valueFormat = valueFormat; }
60
63 void setLabelYPosition(int newPos);
64
65 private:
70 struct Layout
71 {
72 const int lhLabelWidth{26};
73 const int lhFontHeight{13};
74
75 struct Above
76 {
77 const Rectangle<int> linearSliderLabelBounds{0, 10, 87, 10};
78 const Rectangle<int> rotarySliderLabelBounds{0, 0, 70, 14};
81
82 String panSuffix(double value) const;
83 void updateLabel();
84
85 String m_valueFormat{""};
86 String m_valueSuffix{""};
87 bool m_mouseIsOver{false};
91 Slider m_slider;
92 std::unique_ptr<SliderParameterAttachment> m_attachment;
93
95
96 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AttachedSlider)
97 };
98} // namespace krotos
This class combines a Slider, Label, and a SliderAttachment to simplify the process of adding knobs t...
Definition AttachedSlider.h:10
Slider m_slider
Definition AttachedSlider.h:91
String m_labelText
Definition AttachedSlider.h:88
void setLabelYPosition(int newPos)
Definition AttachedSlider.cpp:182
void setValueSuffix(String valueSuffix)
Definition AttachedSlider.h:56
Label & getLabel()
Definition AttachedSlider.cpp:163
LabelPosition
Definition AttachedSlider.h:13
std::unique_ptr< SliderParameterAttachment > & getAttachment()
Definition AttachedSlider.cpp:169
void setDebugColour(Colour newColour)
Definition AttachedSlider.cpp:171
void resized() override
Definition AttachedSlider.cpp:89
String panSuffix(double value) const
Definition AttachedSlider.cpp:60
void updateLabel()
Definition AttachedSlider.cpp:39
void paint(Graphics &g) override
Definition AttachedSlider.cpp:87
DraggableLabel m_label
Definition AttachedSlider.h:90
int m_labelYPositionOverride
Definition AttachedSlider.h:94
Slider & getControlComponent()
Definition AttachedSlider.cpp:167
void setDragAndDropDescription(const var &description)
Definition AttachedSlider.cpp:176
bool m_mouseIsOver
Definition AttachedSlider.h:87
String m_valueFormat
Definition AttachedSlider.h:85
struct krotos::AttachedSlider::Layout m_layout
LabelPosition m_labelPosition
Definition AttachedSlider.h:89
LabelPosition getLabelPosition() const
Definition AttachedSlider.h:46
void setValueFormat(String valueFormat)
Definition AttachedSlider.h:59
Slider & getSlider()
Definition AttachedSlider.cpp:165
void mouseMove(const MouseEvent &event) override
Definition AttachedSlider.cpp:72
void mouseExit(const MouseEvent &) override
Definition AttachedSlider.cpp:81
AttachedSlider(const String &labelText, bool setLabelVisible=true, const String &dragAndDropDescription=String())
Definition AttachedSlider.cpp:5
std::unique_ptr< SliderParameterAttachment > m_attachment
Definition AttachedSlider.h:92
void setLabelPosition(LabelPosition position)
Definition AttachedSlider.h:49
String m_valueSuffix
Definition AttachedSlider.h:86
A Label that can be dragged and dropped e.g. onto a DropComponent.
Definition DraggableLabel.h:9
Definition AirAbsorptionFilter.cpp:2
Definition AttachedSlider.h:76
const Rectangle< int > linearSliderLabelBounds
Definition AttachedSlider.h:77
const Rectangle< int > rotarySliderLabelBounds
Definition AttachedSlider.h:78
Definition AttachedSlider.h:71
const int lhFontHeight
Definition AttachedSlider.h:73
const int lhLabelWidth
Definition AttachedSlider.h:72
struct krotos::AttachedSlider::Layout::Above above