mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +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:
parent
74f8c9b9ef
commit
946e4dc50d
27 changed files with 9146 additions and 0 deletions
File diff suppressed because it is too large
Load diff
27
examples/ComponentTutorialExample/Builds/MacOSX/Info.plist
Normal file
27
examples/ComponentTutorialExample/Builds/MacOSX/Info.plist
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist>
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.ComponentTutorialExample</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>ComponentTutorialExample</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
examples/ComponentTutorialExample/Builds/MacOSX/RecentFilesMenuTemplate.nib
generated
Normal file
BIN
examples/ComponentTutorialExample/Builds/MacOSX/RecentFilesMenuTemplate.nib
generated
Normal file
Binary file not shown.
|
|
@ -0,0 +1,19 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{AD9D8963-5B5F-0719-0FDC-C99EAD08D82D}") = "ComponentTutorialExample", "ComponentTutorialExample.vcxproj", "{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,29 @@
|
|||
#ifdef JUCE_USER_DEFINED_RC_FILE
|
||||
#include JUCE_USER_DEFINED_RC_FILE
|
||||
#else
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "ComponentTutorialExample\0"
|
||||
VALUE "FileVersion", "1.0.0\0"
|
||||
VALUE "ProductName", "ComponentTutorialExample\0"
|
||||
VALUE "ProductVersion", "1.0.0\0"
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 65001
|
||||
END
|
||||
END
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2012
|
||||
Project("{AD9D8963-5B5F-0719-0FDC-C99EAD08D82D}") = "ComponentTutorialExample", "ComponentTutorialExample.vcxproj", "{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{5C4DAD38-D6B8-544B-D7CA-5CCE7E034C13}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,29 @@
|
|||
#ifdef JUCE_USER_DEFINED_RC_FILE
|
||||
#include JUCE_USER_DEFINED_RC_FILE
|
||||
#else
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "ComponentTutorialExample\0"
|
||||
VALUE "FileVersion", "1.0.0\0"
|
||||
VALUE "ProductName", "ComponentTutorialExample\0"
|
||||
VALUE "ProductVersion", "1.0.0\0"
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 65001
|
||||
END
|
||||
END
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<JUCERPROJECT id="oNvA5C" name="ComponentTutorialExample" projectType="guiapp"
|
||||
version="1.0.0" bundleIdentifier="com.yourcompany.ComponentTutorialExample"
|
||||
includeBinaryInAppConfig="1" jucerVersion="3.1.1">
|
||||
<MAINGROUP id="WydTVz" name="ComponentTutorialExample">
|
||||
<GROUP id="{F2C8112A-EE4B-7AF1-A0A9-16152D1EF1A7}" name="Source">
|
||||
<FILE id="t4ngZQ" name="ToggleLightGridComponent.h" compile="0" resource="0"
|
||||
file="Source/ToggleLightGridComponent.h"/>
|
||||
<FILE id="xA0WBT" name="ToggleLightComponent.h" compile="0" resource="0"
|
||||
file="Source/ToggleLightComponent.h"/>
|
||||
<FILE id="N8PnZF" name="MainComponent.cpp" compile="1" resource="0"
|
||||
file="Source/MainComponent.cpp"/>
|
||||
<FILE id="IoEaT6" name="MainComponent.h" compile="0" resource="0" file="Source/MainComponent.h"/>
|
||||
<FILE id="F8kkAH" name="Main.cpp" compile="1" resource="0" file="Source/Main.cpp"/>
|
||||
</GROUP>
|
||||
</MAINGROUP>
|
||||
<EXPORTFORMATS>
|
||||
<XCODE_MAC targetFolder="Builds/MacOSX">
|
||||
<CONFIGURATIONS>
|
||||
<CONFIGURATION name="Debug" osxSDK="default" osxCompatibility="default" osxArchitecture="default"
|
||||
isDebug="1" optimisation="1" targetName="ComponentTutorialExample"/>
|
||||
<CONFIGURATION name="Release" osxSDK="default" osxCompatibility="default" osxArchitecture="default"
|
||||
isDebug="0" optimisation="2" targetName="ComponentTutorialExample"/>
|
||||
</CONFIGURATIONS>
|
||||
<MODULEPATHS>
|
||||
<MODULEPATH id="juce_core" path="../../modules"/>
|
||||
<MODULEPATH id="juce_events" path="../../modules"/>
|
||||
<MODULEPATH id="juce_graphics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_data_structures" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_basics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../modules"/>
|
||||
</MODULEPATHS>
|
||||
</XCODE_MAC>
|
||||
<VS2012 targetFolder="Builds/VisualStudio2012">
|
||||
<CONFIGURATIONS>
|
||||
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
|
||||
isDebug="1" optimisation="1" targetName="ComponentTutorialExample"/>
|
||||
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
|
||||
isDebug="0" optimisation="2" targetName="ComponentTutorialExample"/>
|
||||
</CONFIGURATIONS>
|
||||
<MODULEPATHS>
|
||||
<MODULEPATH id="juce_core" path="../../modules"/>
|
||||
<MODULEPATH id="juce_events" path="../../modules"/>
|
||||
<MODULEPATH id="juce_graphics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_data_structures" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_basics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../modules"/>
|
||||
</MODULEPATHS>
|
||||
</VS2012>
|
||||
<VS2010 targetFolder="Builds/VisualStudio2010">
|
||||
<CONFIGURATIONS>
|
||||
<CONFIGURATION name="Debug" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
|
||||
isDebug="1" optimisation="1" targetName="ComponentTutorialExample"/>
|
||||
<CONFIGURATION name="Release" winWarningLevel="4" generateManifest="1" winArchitecture="32-bit"
|
||||
isDebug="0" optimisation="2" targetName="ComponentTutorialExample"/>
|
||||
</CONFIGURATIONS>
|
||||
<MODULEPATHS>
|
||||
<MODULEPATH id="juce_core" path="../../modules"/>
|
||||
<MODULEPATH id="juce_events" path="../../modules"/>
|
||||
<MODULEPATH id="juce_graphics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_data_structures" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_basics" path="../../modules"/>
|
||||
<MODULEPATH id="juce_gui_extra" path="../../modules"/>
|
||||
</MODULEPATHS>
|
||||
</VS2010>
|
||||
</EXPORTFORMATS>
|
||||
<MODULES>
|
||||
<MODULES id="juce_core" showAllCode="1" useLocalCopy="0"/>
|
||||
<MODULES id="juce_data_structures" showAllCode="1" useLocalCopy="0"/>
|
||||
<MODULES id="juce_events" showAllCode="1" useLocalCopy="0"/>
|
||||
<MODULES id="juce_graphics" showAllCode="1" useLocalCopy="0"/>
|
||||
<MODULES id="juce_gui_basics" showAllCode="1" useLocalCopy="0"/>
|
||||
<MODULES id="juce_gui_extra" showAllCode="1" useLocalCopy="0"/>
|
||||
</MODULES>
|
||||
<JUCEOPTIONS/>
|
||||
</JUCERPROJECT>
|
||||
Binary file not shown.
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
|
||||
IMPORTANT! This file is auto-generated each time you save your
|
||||
project - if you alter its contents, your changes may be overwritten!
|
||||
|
||||
There's a section below where you can add your own custom code safely, and the
|
||||
Introjucer will preserve the contents of that block, but the best way to change
|
||||
any of these definitions is by using the Introjucer's project settings.
|
||||
|
||||
Any commented-out settings will assume their default values.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_APPCONFIG_ONVA5C__
|
||||
#define __JUCE_APPCONFIG_ONVA5C__
|
||||
|
||||
//==============================================================================
|
||||
// [BEGIN_USER_CODE_SECTION]
|
||||
|
||||
// (You can add your own code in this section, and the Introjucer will not overwrite it)
|
||||
|
||||
// [END_USER_CODE_SECTION]
|
||||
|
||||
//==============================================================================
|
||||
#define JUCE_MODULE_AVAILABLE_juce_core 1
|
||||
#define JUCE_MODULE_AVAILABLE_juce_data_structures 1
|
||||
#define JUCE_MODULE_AVAILABLE_juce_events 1
|
||||
#define JUCE_MODULE_AVAILABLE_juce_graphics 1
|
||||
#define JUCE_MODULE_AVAILABLE_juce_gui_basics 1
|
||||
#define JUCE_MODULE_AVAILABLE_juce_gui_extra 1
|
||||
|
||||
//==============================================================================
|
||||
// juce_core flags:
|
||||
|
||||
#ifndef JUCE_FORCE_DEBUG
|
||||
//#define JUCE_FORCE_DEBUG
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_LOG_ASSERTIONS
|
||||
//#define JUCE_LOG_ASSERTIONS
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_CHECK_MEMORY_LEAKS
|
||||
//#define JUCE_CHECK_MEMORY_LEAKS
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
|
||||
//#define JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_INCLUDE_ZLIB_CODE
|
||||
//#define JUCE_INCLUDE_ZLIB_CODE
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
// juce_graphics flags:
|
||||
|
||||
#ifndef JUCE_USE_COREIMAGE_LOADER
|
||||
//#define JUCE_USE_COREIMAGE_LOADER
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_USE_DIRECTWRITE
|
||||
//#define JUCE_USE_DIRECTWRITE
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
// juce_gui_basics flags:
|
||||
|
||||
#ifndef JUCE_ENABLE_REPAINT_DEBUGGING
|
||||
//#define JUCE_ENABLE_REPAINT_DEBUGGING
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_USE_XSHM
|
||||
//#define JUCE_USE_XSHM
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_USE_XRENDER
|
||||
//#define JUCE_USE_XRENDER
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_USE_XCURSOR
|
||||
//#define JUCE_USE_XCURSOR
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
// juce_gui_extra flags:
|
||||
|
||||
#ifndef JUCE_WEB_BROWSER
|
||||
//#define JUCE_WEB_BROWSER
|
||||
#endif
|
||||
|
||||
#ifndef JUCE_ENABLE_LIVE_CONSTANT_EDITOR
|
||||
//#define JUCE_ENABLE_LIVE_CONSTANT_EDITOR
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __JUCE_APPCONFIG_ONVA5C__
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
|
||||
IMPORTANT! This file is auto-generated each time you save your
|
||||
project - if you alter its contents, your changes may be overwritten!
|
||||
|
||||
This is the header file that your files should include in order to get all the
|
||||
JUCE library headers. You should avoid including the JUCE headers directly in
|
||||
your own source files, because that wouldn't pick up the correct configuration
|
||||
options for your app.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __APPHEADERFILE_ONVA5C__
|
||||
#define __APPHEADERFILE_ONVA5C__
|
||||
|
||||
#include "AppConfig.h"
|
||||
#include "modules/juce_core/juce_core.h"
|
||||
#include "modules/juce_data_structures/juce_data_structures.h"
|
||||
#include "modules/juce_events/juce_events.h"
|
||||
#include "modules/juce_graphics/juce_graphics.h"
|
||||
#include "modules/juce_gui_basics/juce_gui_basics.h"
|
||||
#include "modules/juce_gui_extra/juce_gui_extra.h"
|
||||
|
||||
#if ! DONT_SET_USING_JUCE_NAMESPACE
|
||||
// If your code uses a lot of JUCE classes, then this will obviously save you
|
||||
// a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE.
|
||||
using namespace juce;
|
||||
#endif
|
||||
|
||||
#if ! JUCE_DONT_DECLARE_PROJECTINFO
|
||||
namespace ProjectInfo
|
||||
{
|
||||
const char* const projectName = "ComponentTutorialExample";
|
||||
const char* const versionString = "1.0.0";
|
||||
const int versionNumber = 0x10000;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __APPHEADERFILE_ONVA5C__
|
||||
12
examples/ComponentTutorialExample/JuceLibraryCode/ReadMe.txt
Normal file
12
examples/ComponentTutorialExample/JuceLibraryCode/ReadMe.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
Important Note!!
|
||||
================
|
||||
|
||||
The purpose of this folder is to contain files that are auto-generated by the Introjucer,
|
||||
and ALL files in this folder will be mercilessly DELETED and completely re-written whenever
|
||||
the Introjucer saves your project.
|
||||
|
||||
Therefore, it's a bad idea to make any manual changes to the files in here, or to
|
||||
put any of your own files in here if you don't want to lose them. (Of course you may choose
|
||||
to add the folder's contents to your version-control system so that you can re-merge your own
|
||||
modifications after the Introjucer has saved its changes).
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_core/juce_core.h"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_data_structures/juce_data_structures.h"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_events/juce_events.h"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_graphics/juce_graphics.h"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_gui_basics/juce_gui_basics.h"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// This is an auto-generated file to redirect any included
|
||||
// module headers to the correct external folder.
|
||||
|
||||
#include "../../../../../modules/juce_gui_extra/juce_gui_extra.h"
|
||||
|
||||
100
examples/ComponentTutorialExample/Source/Main.cpp
Normal file
100
examples/ComponentTutorialExample/Source/Main.cpp
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated by the Introjucer!
|
||||
|
||||
It contains the basic startup code for a Juce application.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "MainComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class ComponentTutorialExampleApplication : public JUCEApplication
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
ComponentTutorialExampleApplication() {}
|
||||
|
||||
const String getApplicationName() override { return ProjectInfo::projectName; }
|
||||
const String getApplicationVersion() override { return ProjectInfo::versionString; }
|
||||
bool moreThanOneInstanceAllowed() override { return true; }
|
||||
|
||||
//==============================================================================
|
||||
void initialise (const String& commandLine) override
|
||||
{
|
||||
// This method is where you should put your application's initialisation code..
|
||||
|
||||
mainWindow = new MainWindow (getApplicationName());
|
||||
}
|
||||
|
||||
void shutdown() override
|
||||
{
|
||||
// Add your application's shutdown code here..
|
||||
|
||||
mainWindow = nullptr; // (deletes our window)
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void systemRequestedQuit() override
|
||||
{
|
||||
// This is called when the app is being asked to quit: you can ignore this
|
||||
// request and let the app carry on running, or call quit() to allow the app to close.
|
||||
quit();
|
||||
}
|
||||
|
||||
void anotherInstanceStarted (const String& commandLine) override
|
||||
{
|
||||
// When another instance of the app is launched while this one is running,
|
||||
// this method is invoked, and the commandLine parameter tells you what
|
||||
// the other instance's command-line arguments were.
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
/*
|
||||
This class implements the desktop window that contains an instance of
|
||||
our MainContentComponent class.
|
||||
*/
|
||||
class MainWindow : public DocumentWindow
|
||||
{
|
||||
public:
|
||||
MainWindow (String name) : DocumentWindow (name,
|
||||
Colours::lightgrey,
|
||||
DocumentWindow::allButtons)
|
||||
{
|
||||
setUsingNativeTitleBar (true);
|
||||
setContentOwned (new MainContentComponent(), true);
|
||||
|
||||
centreWithSize (getWidth(), getHeight());
|
||||
setVisible (true);
|
||||
}
|
||||
|
||||
void closeButtonPressed() override
|
||||
{
|
||||
// This is called when the user tries to close this window. Here, we'll just
|
||||
// ask the app to quit when this happens, but you can change this to do
|
||||
// whatever you need.
|
||||
JUCEApplication::getInstance()->systemRequestedQuit();
|
||||
}
|
||||
|
||||
/* Note: Be careful if you override any DocumentWindow methods - the base
|
||||
class uses a lot of them, so by overriding you might break its functionality.
|
||||
It's best to do all your work in your content component instead, but if
|
||||
you really have to override any DocumentWindow methods, make sure your
|
||||
subclass also calls the superclass's method.
|
||||
*/
|
||||
|
||||
private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
|
||||
};
|
||||
|
||||
private:
|
||||
ScopedPointer<MainWindow> mainWindow;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// This macro generates the main() routine that launches the app.
|
||||
START_JUCE_APPLICATION (ComponentTutorialExampleApplication)
|
||||
35
examples/ComponentTutorialExample/Source/MainComponent.cpp
Normal file
35
examples/ComponentTutorialExample/Source/MainComponent.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated!
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "MainComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
MainContentComponent::MainContentComponent()
|
||||
: lightGrid ("lightGrid") //initialise the ToggleLightGridComponent object
|
||||
{
|
||||
setSize (600, 600);
|
||||
|
||||
// add the light grid to out main component.
|
||||
addAndMakeVisible (lightGrid);
|
||||
}
|
||||
|
||||
MainContentComponent::~MainContentComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void MainContentComponent::paint (Graphics& g)
|
||||
{
|
||||
g.fillAll (Colour (0xff001F36));
|
||||
}
|
||||
|
||||
void MainContentComponent::resized()
|
||||
{
|
||||
// set the size of the grid to fill the whole window.
|
||||
lightGrid.setBounds (getLocalBounds());
|
||||
}
|
||||
41
examples/ComponentTutorialExample/Source/MainComponent.h
Normal file
41
examples/ComponentTutorialExample/Source/MainComponent.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated!
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef MAINCOMPONENT_H_INCLUDED
|
||||
#define MAINCOMPONENT_H_INCLUDED
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
||||
// include our component classes
|
||||
#include "ToggleLightGridComponent.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/*
|
||||
This component lives inside our window, and this is where you should put all
|
||||
your controls and content.
|
||||
*/
|
||||
class MainContentComponent : public Component
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
MainContentComponent();
|
||||
~MainContentComponent();
|
||||
|
||||
void paint (Graphics&) override;
|
||||
void resized() override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
ToggleLightGridComponent lightGrid;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
|
||||
};
|
||||
|
||||
|
||||
#endif // MAINCOMPONENT_H_INCLUDED
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
ToggleLightGridComponent.h
|
||||
Created: 11 Feb 2015 9:57:34am
|
||||
Author: Felix Faire
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef TOGGLELIGHTGRIDCOMPONENT_H_INCLUDED
|
||||
#define TOGGLELIGHTGRIDCOMPONENT_H_INCLUDED
|
||||
|
||||
#include "ToggleLightComponent.h"
|
||||
|
||||
/**
|
||||
This is the parent class that holds multiple ToggleLightComponents in a grid.
|
||||
*/
|
||||
class ToggleLightGridComponent : public Component
|
||||
{
|
||||
public:
|
||||
ToggleLightGridComponent (String name = "grid")
|
||||
: Component (name)
|
||||
{
|
||||
// Adds the child light components and makes them visible
|
||||
// within this component.
|
||||
// (they currently rely on having a default constructor
|
||||
// so they dont have to be individually initialised)
|
||||
for (int i = 0; i < numX * numY; ++i)
|
||||
addAndMakeVisible (toggleLights[i]);
|
||||
}
|
||||
|
||||
void resized() override
|
||||
{
|
||||
// This creates a grid of rectangles to use as the bounds
|
||||
// for all of our lights. The grid is defined with the
|
||||
// width and height of this component.
|
||||
|
||||
int stepX = getWidth() / numX;
|
||||
int stepY = getHeight() / numY;
|
||||
|
||||
for (int x = 0; x < numX; ++x)
|
||||
{
|
||||
for (int y = 0; y < numY; ++y)
|
||||
{
|
||||
// creates the rectangle (x, y, width, height)
|
||||
Rectangle<int> elementBounds (x * stepX, y * stepY, stepX, stepY);
|
||||
|
||||
// set the size and position of the Toggle light to this rectangle.
|
||||
toggleLights[x + numX * y].setBounds (elementBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// member variables for the Component
|
||||
static const int numX = 20;
|
||||
static const int numY = 20;
|
||||
|
||||
ToggleLightComponent toggleLights [numX * numY];
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleLightGridComponent)
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // TOGGLELIGHTGRIDCOMPONENT_H_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue