Add a TableListBox
Thursday 6 August 2020
Here we are going to talk about the TableListBox component. This is a built-in class on the JUCE library which allows us to display a table.
1. In PlaylistComponent.h in private: add
juce::TableListBox tableComponent;
2. In PlaylistComponent.cpp in PlaylistComponent::PlaylistComponent() add:
addAndMakeVisible(tableComponent);
3. In resized() add:
tableComponent.setBounds(0, 0, getWidth(), getHeight());
When you compile and build now you can see a grey bar which is where the table header will go. So how can we specify the header?
4. We can configure the columns by going to PlaylistComponent::PlaylistComponent() in PlaylistComponent.cpp. Add the following code before the addAndMakeVisible:
tableComponent.getHeader().addColumn("Track title", 1, 400);
The 1 is the column ID (in Juce 6 this cannot be 0, so start at 1) and the 400 is the width in pixels.
5. We can add a new column, for example:
tableComponent.getHeader().addColumn("Artist", 2, 400);
On a build and compile you can now see the table starting to take shape.
Note: TableListBox inherits from multiple classes. The term for a class that can behave as multiple classes is polymorphism.
More posts in cpp
- Add a component ID and converting between ints and strings
- Implement a play button and add a listener
- Implement paintRowBackground and paintCell
- Add a vector to store a list of files
- Add a TableListBox
- Create a PlaylistComponent in the Projucer project
- Threads
- Implement a timer
- Add getPosition and setPosition functions
- Refactor DJAudioPlayer to use app-scope formatManager
- Draw the thumbnail
- Hook up the load button to trigger the AudioThumbnail load
- The AudioThumbnail class in the API
- Creating a new component - WaveformDisplay
- Implementing drag and drop triggers
- Use a MixerAudioSource to play more than one file at a time
- Implement the listener interfaces to DeckGUI
- Creating a DeckGUI class
- setPosition control
- Implementing setGain and setSpeed
- Add audio playback functionality
- Writing the DJAudioPlayer class
- Creating a new JUCE class with Projucer
- Refactoring our code
- Using ResamplingAudioPlayer to implement variable speed playback
- Add stop, start and volume functionality
- Add a file chooser
- Audio file playback in JUCE
- Realtime sound synthesis in JUCE
- Adding a slider listener
- Introduction to event listeners
- Macros
- Inheritance
- Adding a GUI widget to the JUCE app
- Introduction to JUCE