Skip to content

Instantly share code, notes, and snippets.

/Main.cpp Secret

Created March 28, 2017 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5b49804c0733906069fc053fbb464871 to your computer and use it in GitHub Desktop.
Save anonymous/5b49804c0733906069fc053fbb464871 to your computer and use it in GitHub Desktop.
TestCompSize JUCE example (all files except .jucer go in Source subdir)
/*
==============================================================================
This file was auto-generated!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
#include "MainComponent.h"
//==============================================================================
class TestCompSizeApplication : public JUCEApplication
{
public:
//==============================================================================
TestCompSizeApplication() {}
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);
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 (TestCompSizeApplication)
#include "MainComponent.h"
//==============================================================================
MainContentComponent::MainContentComponent()
{
setSize (600, 400);
addAndMakeVisible(myViewport);
myViewport.setViewedComponent(&myGSliders);
}
MainContentComponent::~MainContentComponent()
{
}
void MainContentComponent::paint (Graphics& g)
{
g.fillAll (Colour (0xff001F36));
g.setFont (Font (16.0f));
g.setColour (Colours::white);
g.drawText ("Hello World!", getLocalBounds(), Justification::centred, true);
}
void MainContentComponent::resized()
{
// This is called when the MainContentComponent is resized.
// If you add any child components, this is where you should
// update their positions.
myViewport.setBoundsRelative(0.0f, 0.0f, 1.0f, 0.2f);
}
/*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#ifndef MAINCOMPONENT_H_INCLUDED
#define MAINCOMPONENT_H_INCLUDED
#include "../JuceLibraryCode/JuceHeader.h"
#include "MyGuiSliders.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:
//==============================================================================
MyGuiSliders myGSliders;
Viewport myViewport;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};
#endif // MAINCOMPONENT_H_INCLUDED
/*
==============================================================================
This is an automatically generated GUI class created by the Projucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 4.3.1
------------------------------------------------------------------------------
The Projucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright (c) 2015 - ROLI Ltd.
==============================================================================
*/
//[Headers] You can add your own extra header files here...
//[/Headers]
#include "MyGuiSliders.h"
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
//==============================================================================
MyGuiSliders::MyGuiSliders ()
{
//[Constructor_pre] You can add your own custom stuff here..
//[/Constructor_pre]
addAndMakeVisible (slider = new Slider ("new slider"));
slider->setRange (0, 10, 0);
slider->setSliderStyle (Slider::LinearHorizontal);
slider->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider->addListener (this);
addAndMakeVisible (slider2 = new Slider ("new slider"));
slider2->setRange (0, 10, 0);
slider2->setSliderStyle (Slider::LinearHorizontal);
slider2->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider2->addListener (this);
addAndMakeVisible (slider3 = new Slider ("new slider"));
slider3->setRange (0, 10, 0);
slider3->setSliderStyle (Slider::LinearHorizontal);
slider3->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider3->addListener (this);
addAndMakeVisible (slider4 = new Slider ("new slider"));
slider4->setRange (0, 10, 0);
slider4->setSliderStyle (Slider::LinearHorizontal);
slider4->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider4->addListener (this);
addAndMakeVisible (slider5 = new Slider ("new slider"));
slider5->setRange (0, 10, 0);
slider5->setSliderStyle (Slider::LinearHorizontal);
slider5->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider5->addListener (this);
addAndMakeVisible (slider6 = new Slider ("new slider"));
slider6->setRange (0, 10, 0);
slider6->setSliderStyle (Slider::LinearHorizontal);
slider6->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider6->addListener (this);
addAndMakeVisible (slider7 = new Slider ("new slider"));
slider7->setRange (0, 10, 0);
slider7->setSliderStyle (Slider::LinearHorizontal);
slider7->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider7->addListener (this);
addAndMakeVisible (slider8 = new Slider ("new slider"));
slider8->setRange (0, 10, 0);
slider8->setSliderStyle (Slider::LinearHorizontal);
slider8->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider8->addListener (this);
addAndMakeVisible (slider9 = new Slider ("new slider"));
slider9->setRange (0, 10, 0);
slider9->setSliderStyle (Slider::LinearHorizontal);
slider9->setTextBoxStyle (Slider::TextBoxLeft, false, 50, 20);
slider9->addListener (this);
//[UserPreSize]
//[/UserPreSize]
setSize (600, 400);
//[Constructor] You can add your own custom stuff here..
//[/Constructor]
}
MyGuiSliders::~MyGuiSliders()
{
//[Destructor_pre]. You can add your own custom destruction code here..
//[/Destructor_pre]
slider = nullptr;
slider2 = nullptr;
slider3 = nullptr;
slider4 = nullptr;
slider5 = nullptr;
slider6 = nullptr;
slider7 = nullptr;
slider8 = nullptr;
slider9 = nullptr;
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]
}
//==============================================================================
void MyGuiSliders::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
g.fillAll (Colours::white);
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
void MyGuiSliders::resized()
{
//[UserPreResize] Add your own custom resize code here..
//[/UserPreResize]
slider->setBounds (8, 8, proportionOfWidth (0.6011f), 24);
slider2->setBounds (8, 40, proportionOfWidth (0.6011f), 24);
slider3->setBounds (8, 72, proportionOfWidth (0.6011f), 24);
slider4->setBounds (8, 104, proportionOfWidth (0.6011f), 24);
slider5->setBounds (8, 136, proportionOfWidth (0.6011f), 24);
slider6->setBounds (8, 168, proportionOfWidth (0.6011f), 24);
slider7->setBounds (8, 200, proportionOfWidth (0.6011f), 24);
slider8->setBounds (8, 232, proportionOfWidth (0.6011f), 24);
slider9->setBounds (8, 264, proportionOfWidth (0.6011f), 24);
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
void MyGuiSliders::sliderValueChanged (Slider* sliderThatWasMoved)
{
//[UsersliderValueChanged_Pre]
//[/UsersliderValueChanged_Pre]
if (sliderThatWasMoved == slider)
{
//[UserSliderCode_slider] -- add your slider handling code here..
//[/UserSliderCode_slider]
}
else if (sliderThatWasMoved == slider2)
{
//[UserSliderCode_slider2] -- add your slider handling code here..
//[/UserSliderCode_slider2]
}
else if (sliderThatWasMoved == slider3)
{
//[UserSliderCode_slider3] -- add your slider handling code here..
//[/UserSliderCode_slider3]
}
else if (sliderThatWasMoved == slider4)
{
//[UserSliderCode_slider4] -- add your slider handling code here..
//[/UserSliderCode_slider4]
}
else if (sliderThatWasMoved == slider5)
{
//[UserSliderCode_slider5] -- add your slider handling code here..
//[/UserSliderCode_slider5]
}
else if (sliderThatWasMoved == slider6)
{
//[UserSliderCode_slider6] -- add your slider handling code here..
//[/UserSliderCode_slider6]
}
else if (sliderThatWasMoved == slider7)
{
//[UserSliderCode_slider7] -- add your slider handling code here..
//[/UserSliderCode_slider7]
}
else if (sliderThatWasMoved == slider8)
{
//[UserSliderCode_slider8] -- add your slider handling code here..
//[/UserSliderCode_slider8]
}
else if (sliderThatWasMoved == slider9)
{
//[UserSliderCode_slider9] -- add your slider handling code here..
//[/UserSliderCode_slider9]
}
//[UsersliderValueChanged_Post]
//[/UsersliderValueChanged_Post]
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
//[/MiscUserCode]
//==============================================================================
#if 0
/* -- Projucer information section --
This is where the Projucer stores the metadata that describe this GUI layout, so
make changes in here at your peril!
BEGIN_JUCER_METADATA
<JUCER_COMPONENT documentType="Component" className="MyGuiSliders" componentName=""
parentClasses="public Component" constructorParams="" variableInitialisers=""
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="0" initialWidth="600" initialHeight="400">
<BACKGROUND backgroundColour="ffffffff"/>
<SLIDER name="new slider" id="12c164e2f3c0a2d2" memberName="slider" virtualName=""
explicitFocusOrder="0" pos="8 8 60.106% 24" min="0" max="10"
int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft" textBoxEditable="1"
textBoxWidth="50" textBoxHeight="20" skewFactor="1" needsCallback="1"/>
<SLIDER name="new slider" id="7545cc450ad79613" memberName="slider2"
virtualName="" explicitFocusOrder="0" pos="8 40 60.106% 24" min="0"
max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="20c78463cf50a271" memberName="slider3"
virtualName="" explicitFocusOrder="0" pos="8 72 60.106% 24" min="0"
max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="e936f07d160eea04" memberName="slider4"
virtualName="" explicitFocusOrder="0" pos="8 104 60.106% 24"
min="0" max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="6a9ad6683c266aa" memberName="slider5" virtualName=""
explicitFocusOrder="0" pos="8 136 60.106% 24" min="0" max="10"
int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft" textBoxEditable="1"
textBoxWidth="50" textBoxHeight="20" skewFactor="1" needsCallback="1"/>
<SLIDER name="new slider" id="fb4c6065386669fd" memberName="slider6"
virtualName="" explicitFocusOrder="0" pos="8 168 60.106% 24"
min="0" max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="992c4504f2ef7891" memberName="slider7"
virtualName="" explicitFocusOrder="0" pos="8 200 60.106% 24"
min="0" max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="1cab44273fe5157a" memberName="slider8"
virtualName="" explicitFocusOrder="0" pos="8 232 60.106% 24"
min="0" max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
<SLIDER name="new slider" id="4635e85fface4210" memberName="slider9"
virtualName="" explicitFocusOrder="0" pos="8 264 60.106% 24"
min="0" max="10" int="0" style="LinearHorizontal" textBoxPos="TextBoxLeft"
textBoxEditable="1" textBoxWidth="50" textBoxHeight="20" skewFactor="1"
needsCallback="1"/>
</JUCER_COMPONENT>
END_JUCER_METADATA
*/
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]
/*
==============================================================================
This is an automatically generated GUI class created by the Projucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 4.3.1
------------------------------------------------------------------------------
The Projucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright (c) 2015 - ROLI Ltd.
==============================================================================
*/
#ifndef __JUCE_HEADER_A8AAA3EE1E49E3C2__
#define __JUCE_HEADER_A8AAA3EE1E49E3C2__
//[Headers] -- You can add your own extra header files here --
#include "../JuceLibraryCode/JuceHeader.h"
//[/Headers]
//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Projucer.
Describe your class and how it works here!
//[/Comments]
*/
class MyGuiSliders : public Component,
public SliderListener
{
public:
//==============================================================================
MyGuiSliders ();
~MyGuiSliders();
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
//[/UserMethods]
void paint (Graphics& g) override;
void resized() override;
void sliderValueChanged (Slider* sliderThatWasMoved) override;
private:
//[UserVariables] -- You can add your own custom variables in this section.
//[/UserVariables]
//==============================================================================
ScopedPointer<Slider> slider;
ScopedPointer<Slider> slider2;
ScopedPointer<Slider> slider3;
ScopedPointer<Slider> slider4;
ScopedPointer<Slider> slider5;
ScopedPointer<Slider> slider6;
ScopedPointer<Slider> slider7;
ScopedPointer<Slider> slider8;
ScopedPointer<Slider> slider9;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MyGuiSliders)
};
//[EndFile] You can add extra defines here...
//[/EndFile]
#endif // __JUCE_HEADER_A8AAA3EE1E49E3C2__
<?xml version="1.0" encoding="UTF-8"?>
<JUCERPROJECT id="LDoR5q" name="TestCompSize" projectType="guiapp" version="1.0.0"
bundleIdentifier="com.yourcompany.TestCompSize" includeBinaryInAppConfig="1"
jucerVersion="4.3.1">
<MAINGROUP id="GTdW6S" name="TestCompSize">
<GROUP id="{7296D03E-4125-797C-10CD-9911E486BEE7}" name="Source">
<FILE id="sUxwCN" name="MyGuiSliders.cpp" compile="1" resource="0"
file="Source/MyGuiSliders.cpp"/>
<FILE id="oIJJsc" name="MyGuiSliders.h" compile="0" resource="0" file="Source/MyGuiSliders.h"/>
<FILE id="s4DRXx" name="MainComponent.cpp" compile="1" resource="0"
file="Source/MainComponent.cpp"/>
<FILE id="CnwjHA" name="MainComponent.h" compile="0" resource="0" file="Source/MainComponent.h"/>
<FILE id="Osfw8D" name="Main.cpp" compile="1" resource="0" file="Source/Main.cpp"/>
</GROUP>
</MAINGROUP>
<EXPORTFORMATS>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
<CONFIGURATIONS>
<CONFIGURATION name="Debug" isDebug="1" optimisation="1" targetName="TestCompSize"/>
<CONFIGURATION name="Release" isDebug="0" optimisation="3" targetName="TestCompSize"/>
</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"/>
<MODULEPATH id="juce_cryptography" path="../../modules"/>
<MODULEPATH id="juce_video" path="../../modules"/>
<MODULEPATH id="juce_opengl" path="../../modules"/>
<MODULEPATH id="juce_audio_basics" path="../../modules"/>
<MODULEPATH id="juce_audio_devices" path="../../modules"/>
<MODULEPATH id="juce_audio_formats" path="../../modules"/>
<MODULEPATH id="juce_audio_processors" path="../../modules"/>
</MODULEPATHS>
</LINUX_MAKE>
</EXPORTFORMATS>
<MODULES>
<MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_audio_devices" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_audio_formats" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_audio_processors" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_core" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_cryptography" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_events" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_gui_basics" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_gui_extra" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_opengl" showAllCode="1" useLocalCopy="0"/>
<MODULE id="juce_video" showAllCode="1" useLocalCopy="0"/>
</MODULES>
<JUCEOPTIONS/>
</JUCERPROJECT>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment