Advertisement
Guest User

Untitled

a guest
Jul 24th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #include <JuceHeader.h>
  2. #include "PlaylistComponent.h"
  3.  
  4. //==============================================================================
  5. PlaylistComponent::PlaylistComponent()
  6. {
  7. // In your constructor, you should add any child components, and
  8. // initialise any special settings that your component needs.
  9. trackTitles.push_back("Track 1");
  10. trackTitles.push_back("Track 2");
  11. trackTitles.push_back("Track 3");
  12. trackTitles.push_back("Track 4");
  13. trackTitles.push_back("Track 5");
  14. trackTitles.push_back("Track 6");
  15. trackTitles.push_back("Track 7");
  16. trackTitles.push_back("Track 8");
  17. trackTitles.push_back("Track 9");
  18.  
  19. tableComponent.getHeader().addColumn("Tracks", 1, 150);
  20. tableComponent.setModel(this);
  21.  
  22. addAndMakeVisible(tableComponent);
  23. }
  24.  
  25. int PlaylistComponent::getNumRows()
  26. {
  27. return trackTitles.size();
  28. }
  29.  
  30. void PlaylistComponent::paintRowBackground(juce::Graphics& g,
  31. int rowNumber,
  32. int width,
  33. int height,
  34. bool rowIsSelected
  35. )
  36. {
  37. if (rowIsSelected)
  38. {
  39. g.fillAll(juce::Colours::orange);
  40. }
  41. else
  42. {
  43. g.fillAll(juce::Colours::darkgrey);
  44. }
  45. }
  46.  
  47. void PlaylistComponent::paintCell(juce::Graphics& g,
  48. int rowNumber,
  49. int columnId,
  50. int width,
  51. int height,
  52. bool rowIsSelected
  53. )
  54. {
  55. DBG("PlaylistComponent::paintCell called");
  56. DBG("rowNumber: " + std::to_string(rowNumber));
  57. DBG("getNumRows: " + std::to_string(getNumRows()));
  58. if (rowNumber < getNumRows())
  59. {
  60. g.drawText(trackTitles[rowNumber],
  61. 2,
  62. 0,
  63. width - 4,
  64. height,
  65. juce::Justification::centredLeft,
  66. true
  67. );
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement