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.

54 lines
1.2KB

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