Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <JuceHeader.h>
- #include "PlaylistComponent.h"
- //==============================================================================
- PlaylistComponent::PlaylistComponent()
- {
- // In your constructor, you should add any child components, and
- // initialise any special settings that your component needs.
- trackTitles.push_back("Track 1");
- trackTitles.push_back("Track 2");
- trackTitles.push_back("Track 3");
- trackTitles.push_back("Track 4");
- trackTitles.push_back("Track 5");
- trackTitles.push_back("Track 6");
- trackTitles.push_back("Track 7");
- trackTitles.push_back("Track 8");
- trackTitles.push_back("Track 9");
- tableComponent.getHeader().addColumn("Tracks", 1, 150);
- tableComponent.setModel(this);
- addAndMakeVisible(tableComponent);
- }
- int PlaylistComponent::getNumRows()
- {
- return trackTitles.size();
- }
- void PlaylistComponent::paintRowBackground(juce::Graphics& g,
- int rowNumber,
- int width,
- int height,
- bool rowIsSelected
- )
- {
- if (rowIsSelected)
- {
- g.fillAll(juce::Colours::orange);
- }
- else
- {
- g.fillAll(juce::Colours::darkgrey);
- }
- }
- void PlaylistComponent::paintCell(juce::Graphics& g,
- int rowNumber,
- int columnId,
- int width,
- int height,
- bool rowIsSelected
- )
- {
- DBG("PlaylistComponent::paintCell called");
- DBG("rowNumber: " + std::to_string(rowNumber));
- DBG("getNumRows: " + std::to_string(getNumRows()));
- if (rowNumber < getNumRows())
- {
- g.drawText(trackTitles[rowNumber],
- 2,
- 0,
- width - 4,
- height,
- juce::Justification::centredLeft,
- true
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement