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.

48 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. // Only shows the red ellipse when the button is on.
  23. if (isOn)
  24. {
  25. g.setColour (getLookAndFeel().findColour (Slider::thumbColourId));
  26. g.fillEllipse (getLocalBounds().toFloat());
  27. }
  28. }
  29. void mouseEnter (const MouseEvent&) override
  30. {
  31. // button toggles state on mouse over.
  32. isOn = ! isOn;
  33. repaint();
  34. }
  35. private:
  36. // member variables for the Component
  37. bool isOn;
  38. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleLightComponent)
  39. };