Krotos Modules 3
Loading...
Searching...
No Matches
krotos::SampleBrowser Class Reference

A scrollable list of samples with mute/solo, play and remove buttons. As it is a subclass of PopupMenu::CustomComponent, it must be added to a PopupMenu. Populate the browser by passing in an Array of SampleBrowser::Sample objects. More...

#include <SampleBrowser.h>

Inheritance diagram for krotos::SampleBrowser:

Classes

class  ButtonLAF
 
struct  ComponentIds
 
struct  Sample
 Wrapper object for sample data used by the browser. The Value objects are shared reference objects which their corresponding buttons will listen to. More...
 

Public Member Functions

 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 through a list of all samples.
 
 ~SampleBrowser ()
 
void getIdealSize (int &width, int &height) override
 Returns the ideal size of the browser that has been set.
 
void resized () override
 
void setCuedSample (int sampleIndex, bool isCued)
 Set the sample at the given index to display as cued.
 
void setSampleFunctionButtonsVisibility (bool isVisible)
 Change the visibility of the functions buttons on the individual sample list items i.e. mute, solo, and delete.
 

Public Attributes

std::function< void(int sampleIndex, bool muteState)> onSampleMuted
 Assign this callback to do something when a sample has been muted in the browser.
 
std::function< void(int sampleIndex, bool soloState)> onSampleSolo
 Assign this callback to do something when a sample has been soloed in the browser.
 
std::function< void(int sampleIndex)> onSampleSelected
 Assign this callback to do something when a sample has been selected in the browser. in the browser.
 
std::function< void(int sampleIndex)> onSampleDeleted
 

Private Member Functions

bool allMuteButtonsOn ()
 

Private Attributes

int m_idealWidth = 0
 
int m_idealHeight = 0
 
Viewport m_scrollableArea
 
Component m_itemsParent
 
OwnedArray< SampleItemm_sampleItems
 
OwnedArray< Samplem_samples
 
int m_itemHeight {34}
 
ButtonLAF m_textButtonLAF
 

Detailed Description

A scrollable list of samples with mute/solo, play and remove buttons. As it is a subclass of PopupMenu::CustomComponent, it must be added to a PopupMenu. Populate the browser by passing in an Array of SampleBrowser::Sample objects.

Constructor & Destructor Documentation

◆ SampleBrowser()

krotos::SampleBrowser::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 through a list of all samples.

Parameters
widthThe desired width of the browser.
heightThe desired height of the browser.
itemHeightThe height of each sample item in the displayed list.
samplesToShowThe samples to show in the browser. The index of these samples corresponds to their index within the sample engine.

◆ ~SampleBrowser()

krotos::SampleBrowser::~SampleBrowser ( )

Member Function Documentation

◆ allMuteButtonsOn()

bool krotos::SampleBrowser::allMuteButtonsOn ( )
private

◆ getIdealSize()

void krotos::SampleBrowser::getIdealSize ( int & width,
int & height )
override

Returns the ideal size of the browser that has been set.

◆ resized()

void krotos::SampleBrowser::resized ( )
override

◆ setCuedSample()

void krotos::SampleBrowser::setCuedSample ( int sampleIndex,
bool isCued )

Set the sample at the given index to display as cued.

Parameters
sampleIndexThe index of the sample to cue.
isCuedTrue to cue the sample, false to un-cue it.

◆ setSampleFunctionButtonsVisibility()

void krotos::SampleBrowser::setSampleFunctionButtonsVisibility ( bool isVisible)

Change the visibility of the functions buttons on the individual sample list items i.e. mute, solo, and delete.

Parameters
isVisibleTrue to show and False to hide all buttons.

Member Data Documentation

◆ m_idealHeight

int krotos::SampleBrowser::m_idealHeight = 0
private

◆ m_idealWidth

int krotos::SampleBrowser::m_idealWidth = 0
private

◆ m_itemHeight

int krotos::SampleBrowser::m_itemHeight {34}
private

◆ m_itemsParent

Component krotos::SampleBrowser::m_itemsParent
private

◆ m_sampleItems

OwnedArray<SampleItem> krotos::SampleBrowser::m_sampleItems
private

◆ m_samples

OwnedArray<Sample> krotos::SampleBrowser::m_samples
private

◆ m_scrollableArea

Viewport krotos::SampleBrowser::m_scrollableArea
private

◆ m_textButtonLAF

ButtonLAF krotos::SampleBrowser::m_textButtonLAF
private

◆ onSampleDeleted

std::function<void(int sampleIndex)> krotos::SampleBrowser::onSampleDeleted

◆ onSampleMuted

std::function<void(int sampleIndex, bool muteState)> krotos::SampleBrowser::onSampleMuted

Assign this callback to do something when a sample has been muted in the browser.

Parameters
sampleIndexThe index of the sample that has been muted.
soloStateIs mute activated.

◆ onSampleSelected

std::function<void(int sampleIndex)> krotos::SampleBrowser::onSampleSelected

Assign this callback to do something when a sample has been selected in the browser. in the browser.

Parameters
sampleIndexThe index of the sample that has been selected.

◆ onSampleSolo

std::function<void(int sampleIndex, bool soloState)> krotos::SampleBrowser::onSampleSolo

Assign this callback to do something when a sample has been soloed in the browser.

Parameters
sampleIndexThe index of the sample that has been soloed.
soloStateIs solo activated.

The documentation for this class was generated from the following files: