6 : PopupMenu::CustomComponent(false), m_idealWidth(width), m_idealHeight(height), m_itemHeight(itemHeight),
7 m_samples(std::move(samplesToShow))
17 sampleItem->muteButton.getToggleStateValue().referTo(
m_samples[i]->muted);
18 sampleItem->soloButton.getToggleStateValue().referTo(
m_samples[i]->solo);
21 sampleItem->sampleSelectButton.setEnabled(!
static_cast<bool>(
m_samples[i]->muted.getValue()));
24 sampleItem->soloButton.onClick = [
this, sampleItem, sampleIndex]() {
25 bool isSolo = sampleItem->soloButton.getToggleState();
29 m_sampleItems[i]->muteButton.setToggleState(isSolo && (i != sampleIndex), dontSendNotification);
34 if (i != sampleIndex && isSolo)
36 m_sampleItems[i]->soloButton.setToggleState(
false, dontSendNotification);
53 sampleItem->muteButton.onClick = [
this, sampleItem, sampleIndex]() {
56 sampleItem->muteButton.setToggleState(
false, dontSendNotification);
58 sampleItem->sampleSelectButton.setEnabled(!sampleItem->muteButton.getToggleState());
62 onSampleMuted(sampleIndex, sampleItem->muteButton.getToggleState());
67 sampleItem->sampleSelectButton.onClick = [
this, sampleIndex] {
74 sampleItem->deleteButton.onClick = [
this, sampleIndex] {
99 item->setLookAndFeel(
nullptr);
107 if (!sample->muteButton.getToggleState())
140 if (sampleIndex >= 0 && sampleIndex < itemCount)
144 item->setCued(
false);
152 const Value& otherMuted,
const Value& otherSolo)
153 : name(otherName), path(otherPath), index(otherIndex)
155 muted.referTo(otherMuted);
156 solo.referTo(otherSolo);
170 muted.referTo(other.
muted);
171 solo.referTo(other.
solo);
176 bool shouldDrawButtonAsDown)
178 Font font(button.getHeight());
182 auto defaultOpacity = button.getComponentID().contains(
"Icon") ? 0.1f : isHighlighted ? 1.0f : 0.5f;
183 auto opacity = button.isEnabled()
184 ? (button.isMouseButtonDown() ? 1.0f : (button.isMouseOver() ? 0.7f : defaultOpacity))
188 button.findColour(button.getToggleState() ? TextButton::textColourOnId : TextButton::textColourOffId)
189 .withMultipliedAlpha(opacity));
192 button.getComponentID() ==
"SampleSelectButton" ? Justification::centredLeft : Justification::centred;
195 button.getWidth(), button.getHeight(), justification, 1, 1.0f);
202 sample->muteButton.setVisible(isVisible);
203 sample->soloButton.setVisible(isVisible);
204 sample->deleteButton.setVisible(isVisible);
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
An individual sample item component shown in the SampleBrowser. A parent component for the various bu...
Definition SampleItem.h:8
static const Identifier CuedId
Identifier used for the boolean LAF property to draw this item as cued or not.
Definition SampleItem.h:45
String ellipsizeStringToWidth(const Font &font, const String &input, const int maxWidth)
Cuts the center out of a String to make it fit a given pixel width.
Definition helpers.cpp:93
Definition AirAbsorptionFilter.cpp:2
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