mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-13 00:04:19 +00:00
Merged new demo code + tidied a few bits and pieces.
This commit is contained in:
commit
b9fe4d5811
2326 changed files with 882105 additions and 441 deletions
102
Examples/AnimationAppExample/Source/Main.cpp
Normal file
102
Examples/AnimationAppExample/Source/Main.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated by the Introjucer!
|
||||
|
||||
It contains the basic startup code for a Juce application.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
||||
Component* createMainContentComponent();
|
||||
|
||||
//==============================================================================
|
||||
class AnimationAppExampleApplication : public JUCEApplication
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
AnimationAppExampleApplication() {}
|
||||
|
||||
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 (createMainContentComponent(), true);
|
||||
setResizable (true, 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 (AnimationAppExampleApplication)
|
||||
98
Examples/AnimationAppExample/Source/MainComponent.cpp
Normal file
98
Examples/AnimationAppExample/Source/MainComponent.cpp
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file was auto-generated!
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef MAINCOMPONENT_H_INCLUDED
|
||||
#define MAINCOMPONENT_H_INCLUDED
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
||||
//==============================================================================
|
||||
/*
|
||||
This component lives inside our window, and this is where you should put all
|
||||
your controls and content.
|
||||
*/
|
||||
class MainContentComponent : public AnimatedAppComponent
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
||||
|
||||
MainContentComponent()
|
||||
{
|
||||
setSize (500, 400);
|
||||
setFramesPerSecond (60);
|
||||
}
|
||||
|
||||
~MainContentComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
// fill background
|
||||
g.fillAll (Colours::black);
|
||||
|
||||
int fishLength = 15;
|
||||
|
||||
// set the drawing colour
|
||||
g.setColour (Colours::white);
|
||||
|
||||
// Create a new path object for the spine
|
||||
Path p;
|
||||
|
||||
//
|
||||
for (int i = 0; i < fishLength; ++i)
|
||||
{
|
||||
float radius = 100 + 10 * sin (getFrameCounter() * 0.1 + i * 0.5f);
|
||||
float x = getWidth()/2 + 1.5f * radius * sin (getFrameCounter() * 0.02f + i * 0.12f);
|
||||
float y = getHeight()/2 + radius * cos (getFrameCounter() * 0.04f + i * 0.12f);
|
||||
|
||||
// draw the ellipses of the fish
|
||||
g.fillEllipse(x - i, y - i, 2 + 2*i, 2 + 2*i);
|
||||
|
||||
// start a new path at the beginning otherwise add the next point
|
||||
if (i == 0)
|
||||
p.startNewSubPath(x, y);
|
||||
else
|
||||
p.lineTo (x, y);
|
||||
}
|
||||
|
||||
// stroke the path that we have created
|
||||
g.strokePath (p, PathStrokeType (4));
|
||||
|
||||
}
|
||||
|
||||
void resized()
|
||||
{
|
||||
// This is called when the MainContentComponent is resized.
|
||||
// If you add any child components, this is where you should
|
||||
// update their positions.
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
||||
// private member variables
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
|
||||
};
|
||||
|
||||
|
||||
Component* createMainContentComponent() { return new MainContentComponent(); };
|
||||
|
||||
#endif // MAINCOMPONENT_H_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue