1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-13 00:04:19 +00:00

Added a new example project: ComponentTutorialExample, which includes a PDF tutorial describing the basics of what a Component is.

This commit is contained in:
jules 2015-02-23 10:25:59 +00:00
parent 74f8c9b9ef
commit 946e4dc50d
27 changed files with 9146 additions and 0 deletions

View file

@ -0,0 +1,53 @@
/*
==============================================================================
ToggleLightComponent.h
Created: 11 Feb 2015 9:56:51am
Author: Felix Faire
==============================================================================
*/
#ifndef TOGGLELIGHTCOMPONENT_H_INCLUDED
#define TOGGLELIGHTCOMPONENT_H_INCLUDED
/**
This class represents one of the individual lights in our grid.
*/
class ToggleLightComponent : public Component
{
public:
ToggleLightComponent (String name = "light")
: Component (name),
isOn (false)
{
}
void paint (Graphics& g) override
{
g.fillAll (Colours::black);
// Only shows the red ellipse when the button is on.
if (isOn)
{
g.setColour (Colours::red);
g.fillEllipse (getLocalBounds().toFloat());
}
}
void mouseEnter (const MouseEvent&) override
{
// button toggles state on mouse over.
isOn = ! isOn;
repaint();
}
private:
// member variables for the Component
bool isOn;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleLightComponent)
};
#endif // TOGGLELIGHTCOMPONENT_H_INCLUDED