The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1KB

  1. /*
  2. ==============================================================================
  3. ToggleLightComponent.h
  4. Created: 11 Feb 2015 9:56:51am
  5. Author: Felix Faire
  6. ==============================================================================
  7. */
  8. #pragma once
  9. /**
  10. This class represents one of the individual lights in our grid.
  11. */
  12. class ToggleLightComponent : public Component
  13. {
  14. public:
  15. ToggleLightComponent (String name = "light")
  16. : Component (name),
  17. isOn (false)
  18. {
  19. }
  20. void paint (Graphics& g) override
  21. {
  22. g.fillAll (Colours::black);
  23. // Only shows the red ellipse when the button is on.
  24. if (isOn)
  25. {
  26. g.setColour (Colours::red);
  27. g.fillEllipse (getLocalBounds().toFloat());
  28. }
  29. }
  30. void mouseEnter (const MouseEvent&) override
  31. {
  32. // button toggles state on mouse over.
  33. isOn = ! isOn;
  34. repaint();
  35. }
  36. private:
  37. // member variables for the Component
  38. bool isOn;
  39. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleLightComponent)
  40. };