Krotos Modules 3
Loading...
Searching...
No Matches
SampleBrowser.h
Go to the documentation of this file.
1namespace krotos
2{
3
9 class SampleBrowser : public PopupMenu::CustomComponent
10 {
11 public:
17 struct Sample
18 {
19 String name;
20 String path;
21 int index;
22 Value muted;
23 Value solo;
24
29 Sample(const String& otherName, const String& otherPath, int otherIndex, const Value& otherMuted,
30 const Value& otherSolo);
31
36 Sample(const Sample& other);
37
38 // Assignment operator maintaining shared Value references
39 Sample& operator=(const Sample& other);
40 };
41
51 SampleBrowser(int width, int height, int itemHeight, OwnedArray<Sample> samplesToShow);
53
55 {
56 static const String
58 };
62 void getIdealSize(int& width, int& height) override;
63
64 void resized() override;
65
71 void setCuedSample(int sampleIndex, bool isCued);
72
78 std::function<void(int sampleIndex, bool muteState)> onSampleMuted;
84 std::function<void(int sampleIndex, bool soloState)> onSampleSolo;
85
91 std::function<void(int sampleIndex)> onSampleSelected;
92
93 std::function<void(int sampleIndex)> onSampleDeleted;
94
100 void setSampleFunctionButtonsVisibility(bool isVisible);
101
102 private:
103 bool allMuteButtonsOn();
104
107
109 Component m_itemsParent;
110 OwnedArray<SampleItem> m_sampleItems;
111 OwnedArray<Sample> m_samples;
112
114
115 class ButtonLAF : public LookAndFeel_V4
116 {
117 void drawButtonBackground(Graphics&, Button&, const Colour& backgroundColour,
118 bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override{};
119
120 void drawButtonText(Graphics&, TextButton&, bool shouldDrawButtonAsHighlighted,
121 bool shouldDrawButtonAsDown) override;
122 };
123
125
126 JUCE_LEAK_DETECTOR(SampleBrowser)
127 };
128} // namespace krotos
Definition SampleBrowser.h:116
void drawButtonBackground(Graphics &, Button &, const Colour &backgroundColour, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Definition SampleBrowser.h:117
void drawButtonText(Graphics &, TextButton &, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Definition SampleBrowser.cpp:175
A scrollable list of samples with mute/solo, play and remove buttons. As it is a subclass of PopupMen...
Definition SampleBrowser.h:10
void resized() override
Definition SampleBrowser.cpp:121
OwnedArray< SampleItem > m_sampleItems
Definition SampleBrowser.h:110
Viewport m_scrollableArea
Definition SampleBrowser.h:108
std::function< void(int sampleIndex)> onSampleDeleted
Definition SampleBrowser.h:93
std::function< void(int sampleIndex)> onSampleSelected
Assign this callback to do something when a sample has been selected in the browser....
Definition SampleBrowser.h:91
Component m_itemsParent
Definition SampleBrowser.h:109
OwnedArray< Sample > m_samples
Definition SampleBrowser.h:111
int m_itemHeight
Definition SampleBrowser.h:113
~SampleBrowser()
Definition SampleBrowser.cpp:95
SampleBrowser(int width, int height, int itemHeight, OwnedArray< Sample > samplesToShow)
Creates a sample browser showing a list of given samples. It uses a viewport to allow scrolling throu...
Definition SampleBrowser.cpp:5
int m_idealHeight
Definition SampleBrowser.h:106
void getIdealSize(int &width, int &height) override
Returns the ideal size of the browser that has been set.
Definition SampleBrowser.cpp:115
std::function< void(int sampleIndex, bool muteState)> onSampleMuted
Assign this callback to do something when a sample has been muted in the browser.
Definition SampleBrowser.h:78
int m_idealWidth
Definition SampleBrowser.h:105
ButtonLAF m_textButtonLAF
Definition SampleBrowser.h:124
void setCuedSample(int sampleIndex, bool isCued)
Set the sample at the given index to display as cued.
Definition SampleBrowser.cpp:136
bool allMuteButtonsOn()
Definition SampleBrowser.cpp:103
void setSampleFunctionButtonsVisibility(bool isVisible)
Change the visibility of the functions buttons on the individual sample list items i....
Definition SampleBrowser.cpp:198
std::function< void(int sampleIndex, bool soloState)> onSampleSolo
Assign this callback to do something when a sample has been soloed in the browser.
Definition SampleBrowser.h:84
Definition AirAbsorptionFilter.cpp:2
Definition SampleBrowser.h:55
static const String VerticalViewportScrollbar
Definition SampleBrowser.h:57
Wrapper object for sample data used by the browser. The Value objects are shared reference objects wh...
Definition SampleBrowser.h:18
int index
Definition SampleBrowser.h:21
Value muted
Definition SampleBrowser.h:22
Sample & operator=(const Sample &other)
Definition SampleBrowser.cpp:165
String path
Definition SampleBrowser.h:20
String name
Definition SampleBrowser.h:19
Value solo
Definition SampleBrowser.h:23
Sample(const String &otherName, const String &otherPath, int otherIndex, const Value &otherMuted, const Value &otherSolo)
Create a sample data object to be used in the browser. Values are reference shared allowing attachmen...
Definition SampleBrowser.cpp:151