Krotos Modules 3
Loading...
Searching...
No Matches
DropComponent.h
Go to the documentation of this file.
1#pragma once
2namespace krotos
3{
4 //==============================================================================
10 class DropComponent : public Button, public DragAndDropTarget, private Value::Listener
11 {
12 public:
14 DropComponent(const String& labelText, const String& kwidgetID = "");
15
16 void resized() override;
17
19 Label& getLabel();
20
27 void setText(const String& labelText);
28
34 void setLabelValue(Value& labelValue);
35
36 void paintButton(Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override;
37
38 //==============================================================================
39 // These methods implement the DragAndDropTarget interface, and allow our component
40 // to accept drag-and-drop of objects from other JUCE components..
41
42 bool isInterestedInDragSource(const SourceDetails& /*dragSourceDetails*/) override;
43
44 void itemDragEnter(const SourceDetails& /*dragSourceDetails*/) override;
45
46 void itemDragMove(const SourceDetails& /*dragSourceDetails*/) override;
47
48 void itemDragExit(const SourceDetails& /*dragSourceDetails*/) override;
49
51 std::function<void(var desc)> onDropped;
52
53 void itemDropped(const SourceDetails& dragSourceDetails) override;
54
55 /* Returns the last drag and drop description this component receieved */
56 var getDescription();
57
62
67 {
72 Top, // Top left and top right
73 Bottom, // Bottom left and bottom right
75 None
76 };
77
81 void setRoundedCorner(RoundedCorner cornerToRound, float cornerSize = 4.0f)
82 {
83 m_cornerToRound = cornerToRound;
84 m_cornerSize = cornerSize;
85 };
86
92 void setArmed(bool isArmed);
93
103 static const Identifier DragSource;
104
105 private:
106 Label m_label;
108
110
112
114
116
117 void valueChanged(Value& value) override;
118
119 float m_cornerSize{4.0f};
120 const float m_defaultOpacity{0.5f}, m_hoverOpacity{1.0f}, m_hoverBrightnessAmount{0.055f},
122 bool m_armed{false};
123
124 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DropComponent)
125 };
126} // namespace krotos
A component for dropping draggable juce objects onto.
Definition DropComponent.h:11
const float m_hoverOpacity
Definition DropComponent.h:120
void itemDragMove(const SourceDetails &) override
Definition DropComponent.cpp:95
String m_connectedKwidgetID
Definition DropComponent.h:107
bool m_somethingIsBeingDraggedOver
Definition DropComponent.h:109
Label m_label
Definition DropComponent.h:106
const float m_defaultOpacity
Definition DropComponent.h:120
std::function< void(var desc)> onDropped
Definition DropComponent.h:51
void itemDragExit(const SourceDetails &) override
Definition DropComponent.cpp:97
const float m_armedHoverBrightnessAmount
Definition DropComponent.h:121
void paintButton(Graphics &g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Definition DropComponent.cpp:38
RoundedCorner m_cornerToRound
Definition DropComponent.h:115
Value m_labelValue
Definition DropComponent.h:113
RoundedCorner
Rounded corner state enum.
Definition DropComponent.h:67
@ BottomLeft
Definition DropComponent.h:70
@ BottomRight
Definition DropComponent.h:71
@ Top
Definition DropComponent.h:72
@ TopRight
Definition DropComponent.h:69
@ Bottom
Definition DropComponent.h:73
@ All
Definition DropComponent.h:74
@ TopLeft
Definition DropComponent.h:68
@ None
Definition DropComponent.h:75
void setArmed(bool isArmed)
Sets the component to draw with a visual indication that it has active modulation assigned to it.
Definition DropComponent.cpp:125
var m_lastDesc
Definition DropComponent.h:111
void resized() override
Definition DropComponent.cpp:19
bool isInterestedInDragSource(const SourceDetails &) override
Definition DropComponent.cpp:83
void setLabelValue(Value &labelValue)
Assign a Value object to the DropComponent Label text. This will assign a Listener to the given value...
Definition DropComponent.cpp:30
static const Identifier DragSource
Set this identifier in your drag source component properties so DropComponent will be interested in i...
Definition DropComponent.h:103
float m_cornerSize
Definition DropComponent.h:119
void itemDropped(const SourceDetails &dragSourceDetails) override
Definition DropComponent.cpp:103
void valueChanged(Value &value) override
Definition DropComponent.cpp:120
var getDescription()
Definition DropComponent.cpp:118
bool m_armed
Definition DropComponent.h:122
String & getConnectedKwidgetID()
Returns the ID of the kwidget this drop component is assigning modulation to.
Definition DropComponent.h:61
void setRoundedCorner(RoundedCorner cornerToRound, float cornerSize=4.0f)
Sets which corners to draw as rounded and their size as a radius.
Definition DropComponent.h:81
void setText(const String &labelText)
Definition DropComponent.cpp:24
void itemDragEnter(const SourceDetails &) override
Definition DropComponent.cpp:89
const float m_hoverBrightnessAmount
Definition DropComponent.h:120
DropComponent(const String &labelText, const String &kwidgetID="")
Definition DropComponent.cpp:8
Label & getLabel()
Definition DropComponent.cpp:22
Definition AirAbsorptionFilter.cpp:2