Krotos Modules 3
Loading...
Searching...
No Matches
MultiDropComponent.cpp
Go to the documentation of this file.
2
3namespace krotos
4{
5 MultiDropComponent::MultiDropComponent(const String& labelText, const String& kwidgetID, int numModulators)
6 : m_connectedKwidgetID(kwidgetID)
7 {
8 setComponentID(labelText);
9 addAndMakeVisible(m_label);
10 m_label.setText(labelText, dontSendNotification);
11 m_label.setJustificationType(Justification::centred);
12 m_label.setAlpha(0.5f);
16
17 addAndMakeVisible(m_dropArea);
18
19 for (int i = 0; i < numModulators; ++i)
20 {
21 auto* dc = new DropComponent(labelText + " " + String(i + 1), kwidgetID);
23 {
24 if (numModulators % 4 == 0)
25 {
26 dc->setRoundedCorner(static_cast<DropComponent::RoundedCorner>(i % 4));
27 }
28 else if (numModulators % 2 == 0)
29 {
30 auto cornerStyle =
32 dc->setRoundedCorner(cornerStyle);
33 }
34 }
36 }
37 }
38
40 {
41 auto bounds = getLocalBounds();
42
43 if (m_drawHeader)
44 {
45 const auto labelHeight = static_cast<int>(m_labelFontHeight) + 2;
46 const auto labelBounds = bounds.removeFromTop(labelHeight);
47 m_label.setFont(m_label.getFont().withHeight(m_labelFontHeight).boldened());
48 m_label.setBounds(labelBounds);
49 }
50
51 m_dropArea.setBounds(bounds);
52 }
53
54 void MultiDropComponent::paint(juce::Graphics& g)
55 {
56 g.setColour(findColour(ListBox::ColourIds::outlineColourId));
57 g.fillRoundedRectangle(getLocalBounds().toFloat(), 4.0f);
58 }
59
60} // namespace krotos
A component for dropping draggable juce objects onto.
Definition DropComponent.h:11
RoundedCorner
Rounded corner state enum.
Definition DropComponent.h:67
@ Top
Definition DropComponent.h:72
@ Bottom
Definition DropComponent.h:73
void drawSingleRowAsColumn(bool isColumn)
Set this to true if a DropArea with a single row of items should draw as a column,...
Definition ModulationAssignerDropArea.h:54
DropComponent * addDropComponent(DropComponent *newComp)
Definition ModulationAssignerDropArea.cpp:71
void setNumComponentsPerRow(int min, int max)
Set the min / max number of drop components allowed per row in the flex box.
Definition ModulationAssignerDropArea.h:44
void setMargin(float margin)
Sets the flex box margin.
Definition ModulationAssignerDropArea.cpp:141
void resized() override
Definition MultiDropComponent.cpp:39
void paint(Graphics &g) override
Definition MultiDropComponent.cpp:54
Label m_label
Definition MultiDropComponent.h:49
static constexpr float m_labelFontHeight
Definition MultiDropComponent.h:50
bool m_automaticCornerRounding
Definition MultiDropComponent.h:52
ModulationAssignerDropArea m_dropArea
Definition MultiDropComponent.h:47
MultiDropComponent(const String &labelText, const String &kwidgetID, int numModulators)
Definition MultiDropComponent.cpp:5
bool m_drawHeader
Definition MultiDropComponent.h:51
Definition AirAbsorptionFilter.cpp:2