mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Used Button::onClick to simplify a bunch of library classes and demo code
This commit is contained in:
parent
be5f2d62c4
commit
ce8b2d865a
52 changed files with 557 additions and 954 deletions
|
|
@ -121,7 +121,6 @@ struct BallComponent : public Component
|
|||
|
||||
//==============================================================================
|
||||
class AnimationDemo : public Component,
|
||||
private Button::Listener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
|
|
@ -132,10 +131,10 @@ public:
|
|||
|
||||
for (int i = 11; --i >= 0;)
|
||||
{
|
||||
Button* b = createButton();
|
||||
auto* b = createButton();
|
||||
componentsToAnimate.add (b);
|
||||
addAndMakeVisible (b);
|
||||
b->addListener (this);
|
||||
b->onClick = [this] { triggerAnimation(); };
|
||||
}
|
||||
|
||||
addAndMakeVisible (ballGenerator);
|
||||
|
|
@ -253,7 +252,7 @@ private:
|
|||
return b;
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
void triggerAnimation()
|
||||
{
|
||||
for (int i = 0; i < componentsToAnimate.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -290,8 +290,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class AudioLatencyDemo : public Component,
|
||||
private Button::Listener
|
||||
class AudioLatencyDemo : public Component
|
||||
{
|
||||
public:
|
||||
AudioLatencyDemo()
|
||||
|
|
@ -318,8 +317,8 @@ public:
|
|||
"microphone somewhere near your speakers...");
|
||||
|
||||
addAndMakeVisible (startTestButton);
|
||||
startTestButton.addListener (this);
|
||||
startTestButton.setButtonText ("Test Latency");
|
||||
startTestButton.onClick = [this]() { startTest(); };
|
||||
|
||||
MainAppWindow::getSharedAudioDeviceManager().addAudioCallback (liveAudioScroller);
|
||||
}
|
||||
|
|
@ -327,7 +326,6 @@ public:
|
|||
~AudioLatencyDemo()
|
||||
{
|
||||
MainAppWindow::getSharedAudioDeviceManager().removeAudioCallback (liveAudioScroller);
|
||||
startTestButton.removeListener (this);
|
||||
latencyTester.reset();
|
||||
liveAudioScroller.reset();
|
||||
}
|
||||
|
|
@ -359,12 +357,6 @@ private:
|
|||
TextButton startTestButton;
|
||||
TextEditor resultsBox;
|
||||
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
{
|
||||
if (buttonThatWasClicked == &startTestButton)
|
||||
startTest();
|
||||
}
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
resultsBox.setColour (TextEditor::backgroundColourId,
|
||||
|
|
|
|||
|
|
@ -233,7 +233,6 @@ private:
|
|||
//==============================================================================
|
||||
class AudioPlaybackDemo : public Component,
|
||||
private FileBrowserListener,
|
||||
private Button::Listener,
|
||||
private Slider::Listener,
|
||||
private ChangeListener
|
||||
{
|
||||
|
|
@ -254,7 +253,7 @@ public:
|
|||
|
||||
addAndMakeVisible (followTransportButton);
|
||||
followTransportButton.setButtonText ("Follow Transport");
|
||||
followTransportButton.addListener (this);
|
||||
followTransportButton.onClick = [this]() { updateFollowTransportState(); };
|
||||
|
||||
addAndMakeVisible (explanation);
|
||||
explanation.setText ("Select an audio file in the treeview above, and this page will display its waveform, and let you play it..", dontSendNotification);
|
||||
|
|
@ -276,9 +275,9 @@ public:
|
|||
|
||||
addAndMakeVisible (startStopButton);
|
||||
startStopButton.setButtonText ("Play/Stop");
|
||||
startStopButton.addListener (this);
|
||||
startStopButton.setColour (TextButton::buttonColourId, Colour (0xff79ed7f));
|
||||
startStopButton.setColour (TextButton::textColourOffId, Colours::black);
|
||||
startStopButton.onClick = [this]() { startOrStop(); };
|
||||
|
||||
addAndMakeVisible (fileTreeComp);
|
||||
|
||||
|
|
@ -305,7 +304,6 @@ public:
|
|||
deviceManager.removeAudioCallback (&audioSourcePlayer);
|
||||
fileTreeComp.removeListener (this);
|
||||
thumbnail->removeChangeListener (this);
|
||||
followTransportButton.removeListener (this);
|
||||
zoomSlider.removeListener (this);
|
||||
}
|
||||
|
||||
|
|
@ -378,6 +376,24 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void startOrStop()
|
||||
{
|
||||
if (transportSource.isPlaying())
|
||||
{
|
||||
transportSource.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
transportSource.setPosition (0);
|
||||
transportSource.start();
|
||||
}
|
||||
}
|
||||
|
||||
void updateFollowTransportState()
|
||||
{
|
||||
thumbnail->setFollowsTransport (followTransportButton.getToggleState());
|
||||
}
|
||||
|
||||
void selectionChanged() override
|
||||
{
|
||||
showFile (fileTreeComp.getSelectedFile());
|
||||
|
|
@ -393,26 +409,6 @@ private:
|
|||
thumbnail->setZoomFactor (zoomSlider.getValue());
|
||||
}
|
||||
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
{
|
||||
if (buttonThatWasClicked == &startStopButton)
|
||||
{
|
||||
if (transportSource.isPlaying())
|
||||
{
|
||||
transportSource.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
transportSource.setPosition (0);
|
||||
transportSource.start();
|
||||
}
|
||||
}
|
||||
else if (buttonThatWasClicked == &followTransportButton)
|
||||
{
|
||||
thumbnail->setFollowsTransport (followTransportButton.getToggleState());
|
||||
}
|
||||
}
|
||||
|
||||
void changeListenerCallback (ChangeBroadcaster* source) override
|
||||
{
|
||||
if (source == thumbnail)
|
||||
|
|
|
|||
|
|
@ -210,8 +210,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class AudioRecordingDemo : public Component,
|
||||
private Button::Listener
|
||||
class AudioRecordingDemo : public Component
|
||||
{
|
||||
public:
|
||||
AudioRecordingDemo()
|
||||
|
|
@ -231,10 +230,17 @@ public:
|
|||
|
||||
addAndMakeVisible (recordButton);
|
||||
recordButton.setButtonText ("Record");
|
||||
recordButton.addListener (this);
|
||||
recordButton.setColour (TextButton::buttonColourId, Colour (0xffff5c5c));
|
||||
recordButton.setColour (TextButton::textColourOnId, Colours::black);
|
||||
|
||||
recordButton.onClick = [this]()
|
||||
{
|
||||
if (recorder.isRecording())
|
||||
stopRecording();
|
||||
else
|
||||
startRecording();
|
||||
};
|
||||
|
||||
addAndMakeVisible (recordingThumbnail);
|
||||
|
||||
deviceManager.addAudioCallback (&liveAudioScroller);
|
||||
|
|
@ -271,8 +277,9 @@ private:
|
|||
|
||||
void startRecording()
|
||||
{
|
||||
const File file (File::getSpecialLocation (File::userDocumentsDirectory)
|
||||
.getNonexistentChildFile ("JUCE Demo Audio Recording", ".wav"));
|
||||
auto file = File::getSpecialLocation (File::userDocumentsDirectory)
|
||||
.getNonexistentChildFile ("JUCE Demo Audio Recording", ".wav");
|
||||
|
||||
recorder.startRecording (file);
|
||||
|
||||
recordButton.setButtonText ("Stop");
|
||||
|
|
@ -286,17 +293,6 @@ private:
|
|||
recordingThumbnail.setDisplayFullThumbnail (true);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &recordButton)
|
||||
{
|
||||
if (recorder.isRecording())
|
||||
stopRecording();
|
||||
else
|
||||
startRecording();
|
||||
}
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioRecordingDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -231,8 +231,7 @@ struct SynthAudioSource : public AudioSource
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class AudioSynthesiserDemo : public Component,
|
||||
private Button::Listener
|
||||
class AudioSynthesiserDemo : public Component
|
||||
{
|
||||
public:
|
||||
AudioSynthesiserDemo()
|
||||
|
|
@ -245,13 +244,13 @@ public:
|
|||
addAndMakeVisible (sineButton);
|
||||
sineButton.setButtonText ("Use sine wave");
|
||||
sineButton.setRadioGroupId (321);
|
||||
sineButton.addListener (this);
|
||||
sineButton.setToggleState (true, dontSendNotification);
|
||||
sineButton.onClick = [this]() { synthAudioSource.setUsingSineWaveSound(); };
|
||||
|
||||
addAndMakeVisible (sampledButton);
|
||||
sampledButton.setButtonText ("Use sampled sound");
|
||||
sampledButton.setRadioGroupId (321);
|
||||
sampledButton.addListener (this);
|
||||
sampledButton.onClick = [this]() { synthAudioSource.setUsingSampledSound(); };
|
||||
|
||||
addAndMakeVisible (liveAudioDisplayComp);
|
||||
|
||||
|
|
@ -298,15 +297,6 @@ private:
|
|||
ToggleButton sampledButton;
|
||||
LiveScrollingAudioDisplay liveAudioDisplayComp;
|
||||
|
||||
//==============================================================================
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
{
|
||||
if (buttonThatWasClicked == &sineButton)
|
||||
synthAudioSource.setUsingSineWaveSound();
|
||||
else if (buttonThatWasClicked == &sampledButton)
|
||||
synthAudioSource.setUsingSampledSound();
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSynthesiserDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
//==============================================================================
|
||||
class CameraDemo : public Component,
|
||||
private ComboBox::Listener,
|
||||
private Button::Listener,
|
||||
private CameraDevice::Listener,
|
||||
private AsyncUpdater
|
||||
{
|
||||
|
|
@ -50,11 +49,11 @@ public:
|
|||
cameraSelectorComboBox.addListener (this);
|
||||
|
||||
addAndMakeVisible (snapshotButton);
|
||||
snapshotButton.addListener (this);
|
||||
snapshotButton.onClick = [this]() { takeSnapshot(); };
|
||||
snapshotButton.setEnabled (false);
|
||||
|
||||
addAndMakeVisible (recordMovieButton);
|
||||
recordMovieButton.addListener (this);
|
||||
recordMovieButton.onClick = [this]() { startRecording(); };
|
||||
recordMovieButton.setEnabled (false);
|
||||
|
||||
addAndMakeVisible (lastSnapshot);
|
||||
|
|
@ -70,9 +69,9 @@ public:
|
|||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> r (getLocalBounds().reduced (5));
|
||||
auto r = getLocalBounds().reduced (5);
|
||||
|
||||
Rectangle<int> top (r.removeFromTop (25));
|
||||
auto top = r.removeFromTop (25);
|
||||
cameraSelectorComboBox.setBounds (top.removeFromLeft (250));
|
||||
|
||||
r.removeFromTop (4);
|
||||
|
|
@ -85,7 +84,7 @@ public:
|
|||
recordMovieButton.setBounds (top.removeFromLeft (recordMovieButton.getWidth()));
|
||||
|
||||
r.removeFromTop (4);
|
||||
Rectangle<int> previewArea (r.removeFromTop (r.getHeight() / 2));
|
||||
auto previewArea = r.removeFromTop (r.getHeight() / 2);
|
||||
|
||||
if (cameraPreviewComp != nullptr)
|
||||
cameraPreviewComp->setBounds (previewArea);
|
||||
|
|
@ -112,7 +111,7 @@ private:
|
|||
cameraSelectorComboBox.addItem ("No camera", 1);
|
||||
cameraSelectorComboBox.addSeparator();
|
||||
|
||||
StringArray cameras = CameraDevice::getAvailableDevices();
|
||||
auto cameras = CameraDevice::getAvailableDevices();
|
||||
|
||||
for (int i = 0; i < cameras.size(); ++i)
|
||||
cameraSelectorComboBox.addItem (cameras[i], i + 2);
|
||||
|
|
@ -140,42 +139,39 @@ private:
|
|||
resized();
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
void startRecording()
|
||||
{
|
||||
if (cameraDevice != nullptr)
|
||||
{
|
||||
if (b == &recordMovieButton)
|
||||
// The user has clicked the record movie button..
|
||||
if (! recordingMovie)
|
||||
{
|
||||
// The user has clicked the record movie button..
|
||||
if (! recordingMovie)
|
||||
{
|
||||
// Start recording to a file on the user's desktop..
|
||||
recordingMovie = true;
|
||||
// Start recording to a file on the user's desktop..
|
||||
recordingMovie = true;
|
||||
|
||||
File file (File::getSpecialLocation (File::userDesktopDirectory)
|
||||
.getNonexistentChildFile ("JuceCameraDemo",
|
||||
CameraDevice::getFileExtension()));
|
||||
auto file = File::getSpecialLocation (File::userDesktopDirectory)
|
||||
.getNonexistentChildFile ("JuceCameraDemo", CameraDevice::getFileExtension());
|
||||
|
||||
cameraDevice->startRecordingToFile (file);
|
||||
recordMovieButton.setButtonText ("Stop Recording");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Already recording, so stop...
|
||||
recordingMovie = false;
|
||||
cameraDevice->stopRecording();
|
||||
recordMovieButton.setButtonText ("Start recording (to a file on your desktop)");
|
||||
}
|
||||
cameraDevice->startRecordingToFile (file);
|
||||
recordMovieButton.setButtonText ("Stop Recording");
|
||||
}
|
||||
else
|
||||
{
|
||||
// When the user clicks the snapshot button, we'll attach ourselves to
|
||||
// the camera as a listener, and wait for an image to arrive...
|
||||
cameraDevice->addListener (this);
|
||||
// Already recording, so stop...
|
||||
recordingMovie = false;
|
||||
cameraDevice->stopRecording();
|
||||
recordMovieButton.setButtonText ("Start recording (to a file on your desktop)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void takeSnapshot()
|
||||
{
|
||||
// When the user clicks the snapshot button, we'll attach ourselves to
|
||||
// the camera as a listener, and wait for an image to arrive...
|
||||
cameraDevice->addListener (this);
|
||||
}
|
||||
|
||||
// This is called by the camera device when a new image arrives
|
||||
void imageReceived (const Image& image) override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ static String valueTreeToString (const ValueTree& v)
|
|||
|
||||
//==============================================================================
|
||||
class ChildProcessDemo : public Component,
|
||||
private Button::Listener,
|
||||
private MessageListener
|
||||
{
|
||||
public:
|
||||
|
|
@ -64,15 +63,15 @@ public:
|
|||
|
||||
addAndMakeVisible (launchButton);
|
||||
launchButton.setButtonText ("Launch Child Process");
|
||||
launchButton.addListener (this);
|
||||
launchButton.onClick = [this]() { launchChildProcess(); };
|
||||
|
||||
addAndMakeVisible (pingButton);
|
||||
pingButton.setButtonText ("Send Ping");
|
||||
pingButton.addListener (this);
|
||||
pingButton.onClick = [this]() { pingChildProcess(); };
|
||||
|
||||
addAndMakeVisible (killButton);
|
||||
killButton.setButtonText ("Kill Child Process");
|
||||
killButton.addListener (this);
|
||||
killButton.onClick = [this]() { killChildProcess(); };
|
||||
|
||||
addAndMakeVisible (testResultsBox);
|
||||
testResultsBox.setMultiLine (true);
|
||||
|
|
@ -184,13 +183,6 @@ private:
|
|||
TextButton launchButton, pingButton, killButton;
|
||||
TextEditor testResultsBox;
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &launchButton) launchChildProcess();
|
||||
if (button == &pingButton) pingChildProcess();
|
||||
if (button == &killButton) killChildProcess();
|
||||
}
|
||||
|
||||
struct LogMessage : public Message
|
||||
{
|
||||
LogMessage (const String& m) : message (m) {}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@
|
|||
#include "../JuceDemoHeader.h"
|
||||
|
||||
|
||||
class RSAComponent : public Component,
|
||||
private Button::Listener
|
||||
class RSAComponent : public Component
|
||||
{
|
||||
public:
|
||||
RSAComponent()
|
||||
|
|
@ -44,7 +43,7 @@ public:
|
|||
|
||||
addAndMakeVisible (generateRSAButton);
|
||||
generateRSAButton.setButtonText ("Generate RSA");
|
||||
generateRSAButton.addListener (this);
|
||||
generateRSAButton.onClick = [this]() { createRSAKey(); };
|
||||
|
||||
addAndMakeVisible (rsaResultBox);
|
||||
rsaResultBox.setReadOnly (true);
|
||||
|
|
@ -53,7 +52,7 @@ public:
|
|||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> area (getLocalBounds());
|
||||
auto area = getLocalBounds();
|
||||
rsaGroup.setBounds (area);
|
||||
area.removeFromTop (10);
|
||||
area.reduce (5, 5);
|
||||
|
|
@ -104,12 +103,6 @@ private:
|
|||
Label bitSizeLabel;
|
||||
TextEditor bitSize, rsaResultBox;
|
||||
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
{
|
||||
if (buttonThatWasClicked == &generateRSAButton)
|
||||
createRSAKey();
|
||||
}
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
rsaGroup.setColour (GroupComponent::outlineColourId,
|
||||
|
|
|
|||
|
|
@ -88,8 +88,7 @@ public:
|
|||
|
||||
|
||||
//==============================================================================
|
||||
class DialogsDemo : public Component,
|
||||
private Button::Listener
|
||||
class DialogsDemo : public Component
|
||||
{
|
||||
public:
|
||||
enum DialogType
|
||||
|
|
@ -118,7 +117,7 @@ public:
|
|||
|
||||
addAndMakeVisible (nativeButton);
|
||||
nativeButton.setButtonText ("Use Native Windows");
|
||||
nativeButton.addListener (this);
|
||||
nativeButton.onClick = [this]() { getLookAndFeel().setUsingNativeAlertWindows (nativeButton.getToggleState()); };
|
||||
|
||||
static const char* windowNames[] =
|
||||
{
|
||||
|
|
@ -144,23 +143,14 @@ public:
|
|||
|
||||
for (int i = 0; i < numDialogs; ++i)
|
||||
{
|
||||
TextButton* newButton = new TextButton();
|
||||
auto* newButton = new TextButton();
|
||||
windowButtons.add (newButton);
|
||||
addAndMakeVisible (newButton);
|
||||
newButton->setButtonText (windowNames[i]);
|
||||
newButton->addListener (this);
|
||||
newButton->onClick = [this, i, newButton]() { showWindow (*newButton, static_cast<DialogType> (i)); };
|
||||
}
|
||||
}
|
||||
|
||||
~DialogsDemo()
|
||||
{
|
||||
nativeButton.removeListener (this);
|
||||
|
||||
for (int i = windowButtons.size(); --i >= 0;)
|
||||
if (TextButton* button = windowButtons.getUnchecked (i))
|
||||
button->removeListener (this);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
|
|
@ -451,20 +441,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &nativeButton)
|
||||
{
|
||||
getLookAndFeel().setUsingNativeAlertWindows (nativeButton.getToggleState());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = windowButtons.size(); --i >= 0;)
|
||||
if (button == windowButtons.getUnchecked (i))
|
||||
return showWindow (*button, static_cast<DialogType> (i));
|
||||
}
|
||||
|
||||
ImagePreviewComponent imagePreview;
|
||||
ScopedPointer<FileChooser> fc;
|
||||
|
||||
|
|
|
|||
|
|
@ -145,8 +145,7 @@ struct DemoFlexPanel : public juce::Component,
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
struct FlexBoxDemo : public juce::Component,
|
||||
private juce::Button::Listener
|
||||
struct FlexBoxDemo : public juce::Component
|
||||
{
|
||||
FlexBoxDemo()
|
||||
{
|
||||
|
|
@ -184,11 +183,10 @@ struct FlexBoxDemo : public juce::Component,
|
|||
int leftMargin = 15;
|
||||
int topMargin = 45;
|
||||
|
||||
setupToggleButton (flexDirectionRowButton, "row", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (flexDirectionRowReverseButton, "row-reverse", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (flexDirectionColumnButton, "column", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (flexDirectionColumnReverseButton, "column-reverse", groupID, leftMargin, topMargin + i++ * 22);
|
||||
flexDirectionRowButton.setToggleState (true, dontSendNotification);
|
||||
createToggleButton ("row", groupID, leftMargin, topMargin + i++ * 22, true, [this]() { flexBox.flexDirection = FlexBox::Direction::row; }).setToggleState (true, dontSendNotification);
|
||||
createToggleButton ("row-reverse", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.flexDirection = FlexBox::Direction::rowReverse; });
|
||||
createToggleButton ("column", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.flexDirection = FlexBox::Direction::column; });
|
||||
createToggleButton ("column-reverse", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.flexDirection = FlexBox::Direction::columnReverse; });
|
||||
|
||||
auto wrapGroup = addControl (new GroupComponent ("wrap", "flex-wrap"));
|
||||
wrapGroup->setBounds (160, 30, 140, 110);
|
||||
|
|
@ -197,10 +195,9 @@ struct FlexBoxDemo : public juce::Component,
|
|||
++groupID;
|
||||
leftMargin = 165;
|
||||
|
||||
setupToggleButton (flexNoWrapButton, "nowrap", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (flexWrapButton, "wrap", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (flexWrapReverseButton, "wrap-reverse", groupID, leftMargin, topMargin + i++ * 22);
|
||||
flexWrapButton.setToggleState (true, sendNotification);
|
||||
createToggleButton ("nowrap", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.flexWrap = FlexBox::Wrap::noWrap; });
|
||||
createToggleButton ("wrap", groupID, leftMargin, topMargin + i++ * 22, true, [this]() { flexBox.flexWrap = FlexBox::Wrap::wrap; });
|
||||
createToggleButton ("wrap-reverse", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.flexWrap = FlexBox::Wrap::wrapReverse; });
|
||||
|
||||
auto justifyGroup = addControl (new GroupComponent ("justify", "justify-content"));
|
||||
justifyGroup->setBounds (10, 150, 140, 140);
|
||||
|
|
@ -210,12 +207,11 @@ struct FlexBoxDemo : public juce::Component,
|
|||
leftMargin = 15;
|
||||
topMargin = 165;
|
||||
|
||||
setupToggleButton (justifyFlexStartButton, "flex-start", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (justifyFlexEndButton, "flex-end", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (justifyCenterButton, "center", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (justifySpaceBetweenButton, "space-between", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (justifySpaceAroundButton, "space-around", groupID, leftMargin, topMargin + i++ * 22);
|
||||
justifyFlexStartButton.setToggleState (true, sendNotification);
|
||||
createToggleButton ("flex-start", groupID, leftMargin, topMargin + i++ * 22, true, [this]() { flexBox.justifyContent = FlexBox::JustifyContent::flexStart; });
|
||||
createToggleButton ("flex-end", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.justifyContent = FlexBox::JustifyContent::flexEnd; });
|
||||
createToggleButton ("center", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.justifyContent = FlexBox::JustifyContent::center; });
|
||||
createToggleButton ("space-between", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.justifyContent = FlexBox::JustifyContent::spaceBetween; });
|
||||
createToggleButton ("space-around", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.justifyContent = FlexBox::JustifyContent::spaceAround; });
|
||||
|
||||
auto alignGroup = addControl (new GroupComponent ("align", "align-items"));
|
||||
alignGroup->setBounds (160, 150, 140, 140);
|
||||
|
|
@ -225,11 +221,10 @@ struct FlexBoxDemo : public juce::Component,
|
|||
leftMargin = 165;
|
||||
topMargin = 165;
|
||||
|
||||
setupToggleButton (alignStretchButton, "stretch", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignFlexStartButton, "flex-start", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignFlexEndButton, "flex-end", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignCenterButton, "center", groupID, leftMargin, topMargin + i++ * 22);
|
||||
alignStretchButton.setToggleState (true, sendNotification);
|
||||
createToggleButton ("stretch", groupID, leftMargin, topMargin + i++ * 22, true, [this]() { flexBox.alignItems = FlexBox::AlignItems::stretch; });
|
||||
createToggleButton ("flex-start", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignItems = FlexBox::AlignItems::flexStart; });
|
||||
createToggleButton ("flex-end", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignItems = FlexBox::AlignItems::flexEnd; });
|
||||
createToggleButton ("center", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignItems = FlexBox::AlignItems::center; });
|
||||
|
||||
auto alignContentGroup = addControl (new GroupComponent ("content", "align-content"));
|
||||
alignContentGroup->setBounds (10, 300, 140, 160);
|
||||
|
|
@ -239,13 +234,12 @@ struct FlexBoxDemo : public juce::Component,
|
|||
leftMargin = 15;
|
||||
topMargin = 315;
|
||||
|
||||
setupToggleButton (alignContentStretchButton, "stretch", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignContentFlexStartButton, "flex-start", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignContentFlexEndButton, "flex-end", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignContentCenterButton, "center", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignContentSpaceBetweenButton, "space-between", groupID, leftMargin, topMargin + i++ * 22);
|
||||
setupToggleButton (alignContentSpaceAroundButton, "space-around", groupID, leftMargin, topMargin + i++ * 22);
|
||||
alignContentStretchButton.setToggleState (true, sendNotification);
|
||||
createToggleButton ("stretch", groupID, leftMargin, topMargin + i++ * 22, true, [this]() { flexBox.alignContent = FlexBox::AlignContent::stretch; });
|
||||
createToggleButton ("flex-start", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignContent = FlexBox::AlignContent::flexStart; });
|
||||
createToggleButton ("flex-end", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignContent = FlexBox::AlignContent::flexEnd; });
|
||||
createToggleButton ("center", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignContent = FlexBox::AlignContent::center; });
|
||||
createToggleButton ("space-between", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignContent = FlexBox::AlignContent::spaceBetween; });
|
||||
createToggleButton ("space-around", groupID, leftMargin, topMargin + i++ * 22, false, [this]() { flexBox.alignContent = FlexBox::AlignContent::spaceAround; });
|
||||
}
|
||||
|
||||
void setupFlexBoxItems()
|
||||
|
|
@ -265,21 +259,21 @@ struct FlexBoxDemo : public juce::Component,
|
|||
|
||||
auto& flexItem = flexBox.items.getReference (flexBox.items.size() - 1);
|
||||
|
||||
auto panel = new DemoFlexPanel (colour, flexItem);
|
||||
panels.add (panel);
|
||||
auto panel = panels.add (new DemoFlexPanel (colour, flexItem));
|
||||
flexItem.associatedComponent = panel;
|
||||
addAndMakeVisible (panel);
|
||||
}
|
||||
|
||||
void setupToggleButton (ToggleButton& tb, StringRef text, int groupID, int x, int y)
|
||||
ToggleButton& createToggleButton (StringRef text, int groupID, int x, int y, bool toggleOn, std::function<void()> fn)
|
||||
{
|
||||
tb.setButtonText (text);
|
||||
tb.setRadioGroupId (groupID);
|
||||
tb.setToggleState (false, dontSendNotification);
|
||||
tb.addListener (this);
|
||||
tb.setBounds (x, y, 130, 22);
|
||||
|
||||
auto* tb = buttons.add (new ToggleButton());
|
||||
tb->setButtonText (text);
|
||||
tb->setRadioGroupId (groupID);
|
||||
tb->setToggleState (toggleOn, dontSendNotification);
|
||||
tb->onClick = fn;
|
||||
tb->setBounds (x, y, 130, 22);
|
||||
addAndMakeVisible (tb);
|
||||
return *tb;
|
||||
}
|
||||
|
||||
template <typename ComponentType>
|
||||
|
|
@ -290,69 +284,11 @@ struct FlexBoxDemo : public juce::Component,
|
|||
return newControlComp;
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b->getToggleState())
|
||||
{
|
||||
if (b == &flexDirectionRowButton) flexBox.flexDirection = FlexBox::Direction::row;
|
||||
else if (b == &flexDirectionRowReverseButton) flexBox.flexDirection = FlexBox::Direction::rowReverse;
|
||||
else if (b == &flexDirectionColumnButton) flexBox.flexDirection = FlexBox::Direction::column;
|
||||
else if (b == &flexDirectionColumnReverseButton) flexBox.flexDirection = FlexBox::Direction::columnReverse;
|
||||
else if (b == &flexNoWrapButton) flexBox.flexWrap = FlexBox::Wrap::noWrap;
|
||||
else if (b == &flexWrapButton) flexBox.flexWrap = FlexBox::Wrap::wrap;
|
||||
else if (b == &flexWrapReverseButton) flexBox.flexWrap = FlexBox::Wrap::wrapReverse;
|
||||
else if (b == &justifyFlexStartButton) flexBox.justifyContent = FlexBox::JustifyContent::flexStart;
|
||||
else if (b == &justifyFlexEndButton) flexBox.justifyContent = FlexBox::JustifyContent::flexEnd;
|
||||
else if (b == &justifyCenterButton) flexBox.justifyContent = FlexBox::JustifyContent::center;
|
||||
else if (b == &justifySpaceBetweenButton) flexBox.justifyContent = FlexBox::JustifyContent::spaceBetween;
|
||||
else if (b == &justifySpaceAroundButton) flexBox.justifyContent = FlexBox::JustifyContent::spaceAround;
|
||||
else if (b == &alignStretchButton) flexBox.alignItems = FlexBox::AlignItems::stretch;
|
||||
else if (b == &alignFlexStartButton) flexBox.alignItems = FlexBox::AlignItems::flexStart;
|
||||
else if (b == &alignFlexEndButton) flexBox.alignItems = FlexBox::AlignItems::flexEnd;
|
||||
else if (b == &alignCenterButton) flexBox.alignItems = FlexBox::AlignItems::center;
|
||||
else if (b == &alignContentStretchButton) flexBox.alignContent = FlexBox::AlignContent::stretch;
|
||||
else if (b == &alignContentFlexStartButton) flexBox.alignContent = FlexBox::AlignContent::flexStart;
|
||||
else if (b == &alignContentFlexEndButton) flexBox.alignContent = FlexBox::AlignContent::flexEnd;
|
||||
else if (b == &alignContentCenterButton) flexBox.alignContent = FlexBox::AlignContent::center;
|
||||
else if (b == &alignContentSpaceBetweenButton) flexBox.alignContent = FlexBox::AlignContent::spaceBetween;
|
||||
else if (b == &alignContentSpaceAroundButton) flexBox.alignContent = FlexBox::AlignContent::spaceAround;
|
||||
else return;
|
||||
|
||||
resized();
|
||||
}
|
||||
}
|
||||
|
||||
FlexBox flexBox;
|
||||
|
||||
OwnedArray<DemoFlexPanel> panels;
|
||||
OwnedArray<Component> controls;
|
||||
|
||||
ToggleButton flexDirectionRowButton,
|
||||
flexDirectionRowReverseButton,
|
||||
flexDirectionColumnButton,
|
||||
flexDirectionColumnReverseButton,
|
||||
|
||||
flexNoWrapButton,
|
||||
flexWrapButton,
|
||||
flexWrapReverseButton,
|
||||
|
||||
justifyFlexStartButton,
|
||||
justifyFlexEndButton,
|
||||
justifyCenterButton,
|
||||
justifySpaceBetweenButton,
|
||||
justifySpaceAroundButton,
|
||||
|
||||
alignStretchButton,
|
||||
alignFlexStartButton,
|
||||
alignFlexEndButton,
|
||||
alignCenterButton,
|
||||
|
||||
alignContentStretchButton,
|
||||
alignContentFlexStartButton,
|
||||
alignContentFlexEndButton,
|
||||
alignContentCenterButton,
|
||||
alignContentSpaceBetweenButton,
|
||||
alignContentSpaceAroundButton;
|
||||
OwnedArray<ToggleButton> buttons;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlexBoxDemo)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
class FontsDemo : public Component,
|
||||
private ListBoxModel,
|
||||
private Slider::Listener,
|
||||
private Button::Listener,
|
||||
private ComboBox::Listener
|
||||
{
|
||||
public:
|
||||
|
|
@ -59,8 +58,8 @@ public:
|
|||
heightSlider.addListener (this);
|
||||
kerningSlider.addListener (this);
|
||||
scaleSlider.addListener (this);
|
||||
boldToggle.addListener (this);
|
||||
italicToggle.addListener (this);
|
||||
boldToggle.onClick = [this]() { refreshPreviewBoxFont(); };
|
||||
italicToggle.onClick = [this]() { refreshPreviewBoxFont(); };
|
||||
styleBox.addListener (this);
|
||||
|
||||
Font::findFonts (fonts); // Generate the list of fonts
|
||||
|
|
@ -157,12 +156,6 @@ public:
|
|||
else if (sliderThatWasMoved == &scaleSlider) refreshPreviewBoxFont();
|
||||
}
|
||||
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
{
|
||||
if (buttonThatWasClicked == &boldToggle) refreshPreviewBoxFont();
|
||||
else if (buttonThatWasClicked == &italicToggle) refreshPreviewBoxFont();
|
||||
}
|
||||
|
||||
// The following methods implement the ListBoxModel virtual methods:
|
||||
int getNumRows() override
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ struct LiveConstantDemoComponent : public Component
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class LiveConstantEditorDemo : public Component,
|
||||
private Button::Listener
|
||||
class LiveConstantEditorDemo : public Component
|
||||
{
|
||||
public:
|
||||
LiveConstantEditorDemo()
|
||||
|
|
@ -75,7 +74,7 @@ public:
|
|||
addAndMakeVisible (descriptionLabel);
|
||||
addAndMakeVisible (startButton);
|
||||
addChildComponent (demoComp);
|
||||
startButton.addListener (this);
|
||||
startButton.onClick = [this]() { start(); };
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
@ -95,12 +94,7 @@ public:
|
|||
demoComp.setBounds (r.withTrimmedTop (10));
|
||||
}
|
||||
|
||||
private:
|
||||
Label descriptionLabel;
|
||||
TextButton startButton;
|
||||
LiveConstantDemoComponent demoComp;
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
void start()
|
||||
{
|
||||
startButton.setVisible (false);
|
||||
demoComp.setVisible (true);
|
||||
|
|
@ -110,6 +104,11 @@ private:
|
|||
dontSendNotification);
|
||||
}
|
||||
|
||||
private:
|
||||
Label descriptionLabel;
|
||||
TextButton startButton;
|
||||
LiveConstantDemoComponent demoComp;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LiveConstantEditorDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -505,8 +505,7 @@ struct LookAndFeelDemoComponent : public Component
|
|||
|
||||
//==============================================================================
|
||||
class LookAndFeelDemo : public Component,
|
||||
private ComboBox::Listener,
|
||||
private Button::Listener
|
||||
private ComboBox::Listener
|
||||
{
|
||||
public:
|
||||
LookAndFeelDemo()
|
||||
|
|
@ -542,7 +541,7 @@ public:
|
|||
|
||||
addAndMakeVisible (randomButton);
|
||||
randomButton.setButtonText ("Assign Randomly");
|
||||
randomButton.addListener (this);
|
||||
randomButton.onClick = [this]() { lafBox.setSelectedItemIndex (Random().nextInt (lafBox.getNumItems())); };
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
@ -619,12 +618,6 @@ private:
|
|||
setAllLookAndFeels (lookAndFeels[lafBox.getSelectedItemIndex()]);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == &randomButton)
|
||||
lafBox.setSelectedItemIndex (Random::getSystemRandom().nextInt (lafBox.getNumItems()));
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeelDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -163,8 +163,7 @@ private:
|
|||
By default this will look for notes saved to the desktop and load them up.
|
||||
*/
|
||||
class MDIDemo : public Component,
|
||||
public FileDragAndDropTarget,
|
||||
private Button::Listener
|
||||
public FileDragAndDropTarget
|
||||
{
|
||||
public:
|
||||
MDIDemo()
|
||||
|
|
@ -173,11 +172,11 @@ public:
|
|||
|
||||
showInTabsButton.setButtonText ("Show with tabs");
|
||||
showInTabsButton.setToggleState (false, dontSendNotification);
|
||||
showInTabsButton.addListener (this);
|
||||
showInTabsButton.onClick = [this]() { updateLayoutMode(); };
|
||||
addAndMakeVisible (showInTabsButton);
|
||||
|
||||
addNoteButton.setButtonText ("Create a new note");
|
||||
addNoteButton.addListener (this);
|
||||
addNoteButton.onClick = [this]() { addNote (String ("Note ") + String (multiDocumentPanel.getNumDocuments() + 1), "Hello World!"); };
|
||||
addAndMakeVisible (addNoteButton);
|
||||
|
||||
addAndMakeVisible (multiDocumentPanel);
|
||||
|
|
@ -188,12 +187,6 @@ public:
|
|||
addExistingNotes();
|
||||
}
|
||||
|
||||
~MDIDemo()
|
||||
{
|
||||
addNoteButton.removeListener (this);
|
||||
showInTabsButton.removeListener (this);
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground));
|
||||
|
|
@ -226,11 +219,9 @@ public:
|
|||
|
||||
void createNotesForFiles (const Array<File>& files)
|
||||
{
|
||||
for (int i = 0; i < files.size(); ++i)
|
||||
for (auto& file : files)
|
||||
{
|
||||
const File file (files[i]);
|
||||
|
||||
String content = file.loadFileAsString();
|
||||
auto content = file.loadFileAsString();
|
||||
|
||||
if (content.length() > 20000)
|
||||
content = "Too long!";
|
||||
|
|
@ -265,14 +256,6 @@ private:
|
|||
createNotesForFiles (files);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == &showInTabsButton)
|
||||
updateLayoutMode();
|
||||
else if (b == &addNoteButton)
|
||||
addNote (String ("Note ") + String (multiDocumentPanel.getNumDocuments() + 1), "Hello World!");
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MDIDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -205,14 +205,10 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class MultithreadingDemo : public Component,
|
||||
private Timer,
|
||||
private Button::Listener
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
MultithreadingDemo()
|
||||
: pool (3),
|
||||
controlButton ("Thread type"),
|
||||
isUsingPool (false)
|
||||
{
|
||||
setOpaque (true);
|
||||
|
||||
|
|
@ -221,7 +217,7 @@ public:
|
|||
controlButton.setTopLeftPosition (20, 20);
|
||||
controlButton.setTriggeredOnMouseDown (true);
|
||||
controlButton.setAlwaysOnTop (true);
|
||||
controlButton.addListener (this);
|
||||
controlButton.onClick = [this]() { showMenu(); };
|
||||
}
|
||||
|
||||
~MultithreadingDemo()
|
||||
|
|
@ -251,9 +247,9 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ThreadPool pool;
|
||||
TextButton controlButton;
|
||||
bool isUsingPool;
|
||||
ThreadPool pool { 3 };
|
||||
TextButton controlButton { "Thread type" };
|
||||
bool isUsingPool = false;
|
||||
|
||||
OwnedArray<Component> balls;
|
||||
|
||||
|
|
@ -319,7 +315,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
void showMenu()
|
||||
{
|
||||
PopupMenu m;
|
||||
m.addItem (1, "Use one thread per ball", true, ! isUsingPool);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
//==============================================================================
|
||||
class NetworkingDemo : public Component,
|
||||
private Button::Listener,
|
||||
private TextEditor::Listener,
|
||||
private Thread
|
||||
{
|
||||
|
|
@ -46,7 +45,7 @@ public:
|
|||
|
||||
addAndMakeVisible (fetchButton);
|
||||
fetchButton.setButtonText ("Download URL Contents");
|
||||
fetchButton.addListener (this);
|
||||
fetchButton.onClick = [this]() { startThread(); };
|
||||
|
||||
addAndMakeVisible (resultsBox);
|
||||
}
|
||||
|
|
@ -58,10 +57,10 @@ public:
|
|||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> area (getLocalBounds());
|
||||
auto area = getLocalBounds();
|
||||
|
||||
{
|
||||
Rectangle<int> topArea (area.removeFromTop (40));
|
||||
auto topArea = area.removeFromTop (40);
|
||||
fetchButton.setBounds (topArea.removeFromRight (180).reduced (8));
|
||||
urlBox.setBounds (topArea.reduced (8));
|
||||
}
|
||||
|
|
@ -107,12 +106,6 @@ private:
|
|||
CodeDocument resultsDocument;
|
||||
CodeEditorComponent resultsBox;
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &fetchButton)
|
||||
startThread();
|
||||
}
|
||||
|
||||
void textEditorReturnKeyPressed (TextEditor&) override
|
||||
{
|
||||
fetchButton.triggerClick();
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ struct OpenGLDemoClasses
|
|||
|
||||
void disable (OpenGLContext& openGLContext)
|
||||
{
|
||||
if (position != nullptr) openGLContext.extensions.glDisableVertexAttribArray (position->attributeID);
|
||||
if (normal != nullptr) openGLContext.extensions.glDisableVertexAttribArray (normal->attributeID);
|
||||
if (sourceColour != nullptr) openGLContext.extensions.glDisableVertexAttribArray (sourceColour->attributeID);
|
||||
if (position != nullptr) openGLContext.extensions.glDisableVertexAttribArray (position->attributeID);
|
||||
if (normal != nullptr) openGLContext.extensions.glDisableVertexAttribArray (normal->attributeID);
|
||||
if (sourceColour != nullptr) openGLContext.extensions.glDisableVertexAttribArray (sourceColour->attributeID);
|
||||
if (textureCoordIn != nullptr) openGLContext.extensions.glDisableVertexAttribArray (textureCoordIn->attributeID);
|
||||
}
|
||||
|
||||
|
|
@ -144,20 +144,18 @@ struct OpenGLDemoClasses
|
|||
Shape (OpenGLContext& openGLContext)
|
||||
{
|
||||
if (shapeFile.load (BinaryData::teapot_obj).wasOk())
|
||||
for (int i = 0; i < shapeFile.shapes.size(); ++i)
|
||||
vertexBuffers.add (new VertexBuffer (openGLContext, *shapeFile.shapes.getUnchecked(i)));
|
||||
|
||||
for (auto* s : shapeFile.shapes)
|
||||
vertexBuffers.add (new VertexBuffer (openGLContext, *s));
|
||||
}
|
||||
|
||||
void draw (OpenGLContext& openGLContext, Attributes& attributes)
|
||||
{
|
||||
for (int i = 0; i < vertexBuffers.size(); ++i)
|
||||
for (auto* vertexBuffer : vertexBuffers)
|
||||
{
|
||||
VertexBuffer& vertexBuffer = *vertexBuffers.getUnchecked (i);
|
||||
vertexBuffer.bind();
|
||||
vertexBuffer->bind();
|
||||
|
||||
attributes.enable (openGLContext);
|
||||
glDrawElements (GL_TRIANGLES, vertexBuffer.numIndices, GL_UNSIGNED_INT, 0);
|
||||
glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, 0);
|
||||
attributes.disable (openGLContext);
|
||||
}
|
||||
}
|
||||
|
|
@ -333,7 +331,6 @@ struct OpenGLDemoClasses
|
|||
private CodeDocument::Listener,
|
||||
private ComboBox::Listener,
|
||||
private Slider::Listener,
|
||||
private Button::Listener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
|
|
@ -364,7 +361,7 @@ struct OpenGLDemoClasses
|
|||
speedLabel.attachToComponent (&speedSlider, true);
|
||||
|
||||
addAndMakeVisible (showBackgroundToggle);
|
||||
showBackgroundToggle.addListener (this);
|
||||
showBackgroundToggle.onClick = [this]() { demo.doBackgroundDrawing = showBackgroundToggle.getToggleState(); };
|
||||
|
||||
addAndMakeVisible (tabbedComp);
|
||||
tabbedComp.setTabBarDepth (25);
|
||||
|
|
@ -387,7 +384,7 @@ struct OpenGLDemoClasses
|
|||
addAndMakeVisible (presetBox);
|
||||
presetBox.addListener (this);
|
||||
|
||||
Array<ShaderPreset> presets (getPresets());
|
||||
auto presets = getPresets();
|
||||
StringArray presetNames;
|
||||
|
||||
for (int i = 0; i < presets.size(); ++i)
|
||||
|
|
@ -415,11 +412,11 @@ struct OpenGLDemoClasses
|
|||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> area (getLocalBounds().reduced (4));
|
||||
auto area = getLocalBounds().reduced (4);
|
||||
|
||||
Rectangle<int> top (area.removeFromTop (75));
|
||||
auto top = area.removeFromTop (75);
|
||||
|
||||
Rectangle<int> sliders (top.removeFromRight (area.getWidth() / 2));
|
||||
auto sliders = top.removeFromRight (area.getWidth() / 2);
|
||||
showBackgroundToggle.setBounds (sliders.removeFromBottom (25));
|
||||
speedSlider.setBounds (sliders.removeFromBottom (25));
|
||||
sizeSlider.setBounds (sliders.removeFromBottom (25));
|
||||
|
|
@ -427,9 +424,9 @@ struct OpenGLDemoClasses
|
|||
top.removeFromRight (70);
|
||||
statusLabel.setBounds (top);
|
||||
|
||||
Rectangle<int> shaderArea (area.removeFromBottom (area.getHeight() / 2));
|
||||
auto shaderArea = area.removeFromBottom (area.getHeight() / 2);
|
||||
|
||||
Rectangle<int> presets (shaderArea.removeFromTop (25));
|
||||
auto presets = shaderArea.removeFromTop (25);
|
||||
presets.removeFromLeft (100);
|
||||
presetBox.setBounds (presets.removeFromLeft (150));
|
||||
presets.removeFromLeft (100);
|
||||
|
|
@ -523,11 +520,6 @@ struct OpenGLDemoClasses
|
|||
demo.rotationSpeed = (float) speedSlider.getValue();
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
{
|
||||
demo.doBackgroundDrawing = showBackgroundToggle.getToggleState();
|
||||
}
|
||||
|
||||
enum { shaderLinkDelay = 500 };
|
||||
|
||||
void codeDocumentTextInserted (const String& /*newText*/, int /*insertIndex*/) override
|
||||
|
|
@ -597,7 +589,7 @@ struct OpenGLDemoClasses
|
|||
public:
|
||||
OpenGLDemo()
|
||||
{
|
||||
if (MainAppWindow* mw = MainAppWindow::getMainAppWindow())
|
||||
if (auto* mw = MainAppWindow::getMainAppWindow())
|
||||
mw->setRenderingEngine (0);
|
||||
|
||||
setOpaque (true);
|
||||
|
|
|
|||
|
|
@ -37,13 +37,12 @@ struct ColourMessage : public Message
|
|||
/** Returns the colour of a ColourMessage of white if the message is not a ColourMessage. */
|
||||
static Colour getColour (const Message& message)
|
||||
{
|
||||
if (const ColourMessage* cm = dynamic_cast<const ColourMessage*> (&message))
|
||||
if (auto* cm = dynamic_cast<const ColourMessage*> (&message))
|
||||
return cm->colour;
|
||||
|
||||
return Colours::white;
|
||||
}
|
||||
|
||||
private:
|
||||
Colour colour;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ColourMessage)
|
||||
|
|
@ -61,8 +60,6 @@ class FlashingComponent : public Component,
|
|||
{
|
||||
public:
|
||||
FlashingComponent()
|
||||
: flashAlpha (0.0f),
|
||||
colour (Colours::red)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -107,8 +104,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
float flashAlpha;
|
||||
Colour colour;
|
||||
float flashAlpha = 0;
|
||||
Colour colour { Colours::red };
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
|
|
@ -130,8 +127,7 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class TimersAndEventsDemo : public Component,
|
||||
private ChangeListener,
|
||||
private Button::Listener
|
||||
private ChangeListener
|
||||
{
|
||||
public:
|
||||
TimersAndEventsDemo()
|
||||
|
|
@ -141,7 +137,7 @@ public:
|
|||
// Create and add our FlashingComponents with some random colours and sizes
|
||||
for (int i = 0; i < numFlashingComponents; ++i)
|
||||
{
|
||||
FlashingComponent* newFlasher = new FlashingComponent();
|
||||
auto* newFlasher = new FlashingComponent();
|
||||
flashingComponents.add (newFlasher);
|
||||
|
||||
newFlasher->setFlashColour (getRandomBrightColour());
|
||||
|
|
@ -154,20 +150,19 @@ public:
|
|||
}
|
||||
|
||||
addAndMakeVisible (stopButton);
|
||||
stopButton.addListener (this);
|
||||
stopButton.setButtonText ("Stop");
|
||||
stopButton.onClick = [this]() { stopButtonClicked(); };
|
||||
|
||||
addAndMakeVisible (randomColourButton);
|
||||
randomColourButton.addListener (this);
|
||||
randomColourButton.setButtonText ("Set Random Colour");
|
||||
randomColourButton.onClick = [this]() { randomColourButtonClicked(); };
|
||||
|
||||
// lay out our components in a psudo random grid
|
||||
Rectangle<int> area (0, 100, 150, 150);
|
||||
|
||||
for (int i = 0; i < flashingComponents.size(); ++i)
|
||||
for (auto* comp : flashingComponents)
|
||||
{
|
||||
FlashingComponent* comp = flashingComponents.getUnchecked (i);
|
||||
Rectangle<int> buttonArea (area.withSize (comp->getWidth(), comp->getHeight()));
|
||||
auto buttonArea = area.withSize (comp->getWidth(), comp->getHeight());
|
||||
buttonArea.translate (random.nextInt (area.getWidth() - comp->getWidth()),
|
||||
random.nextInt (area.getHeight() - comp->getHeight()));
|
||||
comp->setBounds (buttonArea);
|
||||
|
|
@ -185,11 +180,8 @@ public:
|
|||
|
||||
~TimersAndEventsDemo()
|
||||
{
|
||||
stopButton.removeListener (this);
|
||||
randomColourButton.removeListener (this);
|
||||
|
||||
for (int i = flashingComponents.size(); --i >= 0;)
|
||||
flashingComponents.getUnchecked (i)->removeChangeListener (this);
|
||||
for (auto* fc : flashingComponents)
|
||||
fc->removeChangeListener (this);
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
@ -200,7 +192,7 @@ public:
|
|||
|
||||
void paintOverChildren (Graphics& g) override
|
||||
{
|
||||
const Rectangle<int> explanationArea (getLocalBounds().removeFromTop (100));
|
||||
auto explanationArea = getLocalBounds().removeFromTop (100);
|
||||
|
||||
AttributedString s;
|
||||
s.append ("Click on a circle to make it flash. When it has finished flashing it will send a message which causes the next circle to flash");
|
||||
|
|
@ -208,14 +200,13 @@ public:
|
|||
s.append ("Click the \"Set Random Colour\" button to change the colour of one of the circles.");
|
||||
s.append (newLine);
|
||||
s.setFont (Font (16.0f));
|
||||
s.setColour (getUIColourIfAvailable(LookAndFeel_V4::ColourScheme::UIColour::defaultText,
|
||||
Colours::lightgrey));
|
||||
s.setColour (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::defaultText, Colours::lightgrey));
|
||||
s.draw (g, explanationArea.reduced (10).toFloat());
|
||||
}
|
||||
|
||||
void resized() override
|
||||
{
|
||||
Rectangle<int> area (getLocalBounds().removeFromBottom (40));
|
||||
auto area = getLocalBounds().removeFromBottom (40);
|
||||
randomColourButton.setBounds (area.removeFromLeft (166).reduced (8));
|
||||
stopButton.setBounds (area.removeFromRight (166).reduced (8));
|
||||
}
|
||||
|
|
@ -234,19 +225,17 @@ private:
|
|||
flashingComponents.getUnchecked ((i + 1) % flashingComponents.size())->startFlashing();
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
void randomColourButtonClicked()
|
||||
{
|
||||
if (button == &randomColourButton)
|
||||
{
|
||||
// Here we post a new ColourMessage with a random colour to a random flashing component.
|
||||
// This will send a message to the component asynchronously and trigger its handleMessage callback
|
||||
flashingComponents.getUnchecked (random.nextInt (flashingComponents.size()))->postMessage (new ColourMessage (getRandomBrightColour()));
|
||||
}
|
||||
else if (button == &stopButton)
|
||||
{
|
||||
for (int i = 0; i < flashingComponents.size(); ++i)
|
||||
flashingComponents.getUnchecked (i)->stopFlashing();
|
||||
}
|
||||
// Here we post a new ColourMessage with a random colour to a random flashing component.
|
||||
// This will send a message to the component asynchronously and trigger its handleMessage callback
|
||||
flashingComponents.getUnchecked (random.nextInt (flashingComponents.size()))->postMessage (new ColourMessage (getRandomBrightColour()));
|
||||
}
|
||||
|
||||
void stopButtonClicked()
|
||||
{
|
||||
for (auto* fc : flashingComponents)
|
||||
fc->stopFlashing();
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimersAndEventsDemo)
|
||||
|
|
|
|||
|
|
@ -106,17 +106,15 @@ struct UnitTestClasses
|
|||
|
||||
|
||||
//==============================================================================
|
||||
class UnitTestsDemo : public Component,
|
||||
public Button::Listener
|
||||
class UnitTestsDemo : public Component
|
||||
{
|
||||
public:
|
||||
UnitTestsDemo()
|
||||
: startTestButton ("Run Unit Tests...")
|
||||
{
|
||||
setOpaque (true);
|
||||
|
||||
addAndMakeVisible (startTestButton);
|
||||
startTestButton.addListener (this);
|
||||
startTestButton.onClick = [this]() { start(); };
|
||||
|
||||
addAndMakeVisible (testResultsBox);
|
||||
testResultsBox.setMultiLine (true);
|
||||
|
|
@ -160,10 +158,9 @@ struct UnitTestClasses
|
|||
testResultsBox.setBounds (bounds);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* buttonThatWasClicked) override
|
||||
void start()
|
||||
{
|
||||
if (buttonThatWasClicked == &startTestButton)
|
||||
startTest (categoriesBox.getText());
|
||||
startTest (categoriesBox.getText());
|
||||
}
|
||||
|
||||
void startTest (const String& category)
|
||||
|
|
@ -201,7 +198,7 @@ struct UnitTestClasses
|
|||
private:
|
||||
ScopedPointer<TestRunnerThread> currentTestThread;
|
||||
|
||||
TextButton startTestButton;
|
||||
TextButton startTestButton { "Run Unit Tests..." };
|
||||
ComboBox categoriesBox;
|
||||
TextEditor testResultsBox;
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ private:
|
|||
//==============================================================================
|
||||
class ValueTreesDemo : public Component,
|
||||
public DragAndDropContainer,
|
||||
private Button::Listener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
|
|
@ -174,8 +173,8 @@ public:
|
|||
|
||||
addAndMakeVisible (undoButton);
|
||||
addAndMakeVisible (redoButton);
|
||||
undoButton.addListener (this);
|
||||
redoButton.addListener (this);
|
||||
undoButton.onClick = [this]() { undoManager.undo(); };
|
||||
redoButton.onClick = [this]() { undoManager.redo(); };
|
||||
|
||||
startTimer (500);
|
||||
}
|
||||
|
|
@ -271,14 +270,6 @@ public:
|
|||
return Component::keyPressed (key);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == &undoButton)
|
||||
undoManager.undo();
|
||||
else if (b == &redoButton)
|
||||
undoManager.redo();
|
||||
}
|
||||
|
||||
private:
|
||||
TreeView tree;
|
||||
TextButton undoButton, redoButton;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ private:
|
|||
//==============================================================================
|
||||
class VideoDemo : public Component,
|
||||
public DragAndDropContainer,
|
||||
private Button::Listener,
|
||||
private FileBrowserListener
|
||||
{
|
||||
public:
|
||||
|
|
@ -144,8 +143,8 @@ public:
|
|||
loadLeftButton.setButtonText ("Load Left");
|
||||
loadRightButton.setButtonText ("Load Right");
|
||||
|
||||
loadLeftButton.addListener (this);
|
||||
loadRightButton.addListener (this);
|
||||
loadLeftButton .onClick = [this]() { movieCompLeft .setFile (fileTree.getSelectedFile (0)); };
|
||||
loadRightButton.onClick = [this]() { movieCompRight.setFile (fileTree.getSelectedFile (0)); };
|
||||
|
||||
addAndMakeVisible (loadLeftButton);
|
||||
addAndMakeVisible (loadRightButton);
|
||||
|
|
@ -168,8 +167,6 @@ public:
|
|||
|
||||
~VideoDemo()
|
||||
{
|
||||
loadLeftButton.removeListener (this);
|
||||
loadRightButton.removeListener (this);
|
||||
fileTree.removeListener (this);
|
||||
}
|
||||
|
||||
|
|
@ -214,14 +211,6 @@ private:
|
|||
TextButton loadLeftButton, loadRightButton;
|
||||
MovieComponentWithFileBrowser movieCompLeft, movieCompRight;
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &loadLeftButton)
|
||||
movieCompLeft.setFile (fileTree.getSelectedFile (0));
|
||||
else if (button == &loadRightButton)
|
||||
movieCompRight.setFile (fileTree.getSelectedFile (0));
|
||||
}
|
||||
|
||||
void selectionChanged() override
|
||||
{
|
||||
// we're just going to update the drag description of out tree so that rows can be dragged onto the file players
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class WebBrowserDemo : public Component,
|
||||
private TextEditor::Listener,
|
||||
private Button::Listener
|
||||
private TextEditor::Listener
|
||||
{
|
||||
public:
|
||||
WebBrowserDemo()
|
||||
|
|
@ -90,11 +89,11 @@ public:
|
|||
|
||||
// add some buttons..
|
||||
addAndMakeVisible (goButton);
|
||||
goButton.addListener (this);
|
||||
goButton.onClick = [this]() { webView->goToURL (addressTextBox.getText()); };
|
||||
addAndMakeVisible (backButton);
|
||||
backButton.addListener (this);
|
||||
backButton.onClick = [this]() { webView->goBack(); };
|
||||
addAndMakeVisible (forwardButton);
|
||||
forwardButton.addListener (this);
|
||||
forwardButton.onClick = [this]() { webView->goForward(); };
|
||||
|
||||
// send the browser to a start page..
|
||||
webView->goToURL ("https://www.juce.com");
|
||||
|
|
@ -130,16 +129,6 @@ private:
|
|||
webView->goToURL (addressTextBox.getText());
|
||||
}
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == &backButton)
|
||||
webView->goBack();
|
||||
else if (b == &forwardButton)
|
||||
webView->goForward();
|
||||
else if (b == &goButton)
|
||||
webView->goToURL (addressTextBox.getText());
|
||||
}
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
addressTextBox.applyFontToAllText (addressTextBox.getFont());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "../JuceDemoHeader.h"
|
||||
|
||||
|
||||
static void showBubbleMessage (Component* targetComponent, const String& textToShow,
|
||||
static void showBubbleMessage (Component& targetComponent, const String& textToShow,
|
||||
ScopedPointer<BubbleMessageComponent>& bmc)
|
||||
{
|
||||
bmc = new BubbleMessageComponent();
|
||||
|
|
@ -39,14 +39,14 @@ static void showBubbleMessage (Component* targetComponent, const String& textToS
|
|||
}
|
||||
else
|
||||
{
|
||||
targetComponent->getTopLevelComponent()->addChildComponent (bmc);
|
||||
targetComponent.getTopLevelComponent()->addChildComponent (bmc);
|
||||
}
|
||||
|
||||
AttributedString text (textToShow);
|
||||
text.setJustification (Justification::centred);
|
||||
text.setColour (targetComponent->findColour (TextButton::textColourOffId));
|
||||
text.setColour (targetComponent.findColour (TextButton::textColourOffId));
|
||||
|
||||
bmc->showAt (targetComponent, text, 2000, true, false);
|
||||
bmc->showAt (&targetComponent, text, 2000, true, false);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -247,8 +247,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
struct ButtonsPage : public Component,
|
||||
public Button::Listener
|
||||
struct ButtonsPage : public Component
|
||||
{
|
||||
ButtonsPage()
|
||||
{
|
||||
|
|
@ -352,58 +351,68 @@ struct ButtonsPage : public Component,
|
|||
down.setImage (ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize));
|
||||
down.setOverlayColour (Colours::black.withAlpha (0.3f));
|
||||
|
||||
auto popupMessageCallback = [this]()
|
||||
{
|
||||
if (auto* focused = Component::getCurrentlyFocusedComponent())
|
||||
showBubbleMessage (*focused,
|
||||
"This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing "
|
||||
"at a component or somewhere on the screen.\n\n"
|
||||
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.",
|
||||
this->bubbleMessage);
|
||||
};
|
||||
|
||||
{
|
||||
// create an image-above-text button from these drawables..
|
||||
DrawableButton* db = addToList (new DrawableButton ("Button 1", DrawableButton::ImageAboveTextLabel));
|
||||
auto db = addToList (new DrawableButton ("Button 1", DrawableButton::ImageAboveTextLabel));
|
||||
db->setImages (&normal, &over, &down);
|
||||
db->setBounds (260, 60, 80, 80);
|
||||
db->setTooltip ("This is a DrawableButton with a label");
|
||||
db->addListener (this);
|
||||
db->onClick = popupMessageCallback;
|
||||
}
|
||||
|
||||
{
|
||||
// create an image-only button from these drawables..
|
||||
DrawableButton* db = addToList (new DrawableButton ("Button 2", DrawableButton::ImageFitted));
|
||||
auto db = addToList (new DrawableButton ("Button 2", DrawableButton::ImageFitted));
|
||||
db->setImages (&normal, &over, &down);
|
||||
db->setClickingTogglesState (true);
|
||||
db->setBounds (370, 60, 80, 80);
|
||||
db->setTooltip ("This is an image-only DrawableButton");
|
||||
db->addListener (this);
|
||||
db->onClick = popupMessageCallback;
|
||||
}
|
||||
|
||||
{
|
||||
// create an image-on-button-shape button from the same drawables..
|
||||
DrawableButton* db = addToList (new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground));
|
||||
auto db = addToList (new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground));
|
||||
db->setImages (&normal, 0, 0);
|
||||
db->setBounds (260, 160, 110, 25);
|
||||
db->setTooltip ("This is a DrawableButton on a standard button background");
|
||||
db->addListener (this);
|
||||
db->onClick = popupMessageCallback;
|
||||
}
|
||||
|
||||
{
|
||||
DrawableButton* db = addToList (new DrawableButton ("Button 4", DrawableButton::ImageOnButtonBackground));
|
||||
auto db = addToList (new DrawableButton ("Button 4", DrawableButton::ImageOnButtonBackground));
|
||||
db->setImages (&normal, &over, &down);
|
||||
db->setClickingTogglesState (true);
|
||||
db->setColour (DrawableButton::backgroundColourId, Colours::white);
|
||||
db->setColour (DrawableButton::backgroundOnColourId, Colours::yellow);
|
||||
db->setBounds (400, 150, 50, 50);
|
||||
db->setTooltip ("This is a DrawableButton on a standard button background");
|
||||
db->addListener (this);
|
||||
db->onClick = popupMessageCallback;
|
||||
}
|
||||
|
||||
{
|
||||
ShapeButton* sb = addToList (new ShapeButton ("ShapeButton",
|
||||
getRandomDarkColour(),
|
||||
getRandomDarkColour(),
|
||||
getRandomDarkColour()));
|
||||
auto sb = addToList (new ShapeButton ("ShapeButton",
|
||||
getRandomDarkColour(),
|
||||
getRandomDarkColour(),
|
||||
getRandomDarkColour()));
|
||||
sb->setShape (MainAppWindow::getJUCELogoPath(), false, true, false);
|
||||
sb->setBounds (260, 220, 200, 120);
|
||||
}
|
||||
|
||||
{
|
||||
ImageButton* ib = addToList (new ImageButton ("ImageButton"));
|
||||
auto ib = addToList (new ImageButton ("ImageButton"));
|
||||
|
||||
Image juceImage = ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize);
|
||||
auto juceImage = ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize);
|
||||
|
||||
ib->setImages (true, true, true,
|
||||
juceImage, 0.7f, Colours::transparentBlack,
|
||||
|
|
@ -430,15 +439,6 @@ private:
|
|||
return newComp;
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
showBubbleMessage (button,
|
||||
"This is a demo of the BubbleMessageComponent, which lets you pop up a message pointing "
|
||||
"at a component or somewhere on the screen.\n\n"
|
||||
"The message bubbles will disappear after a timeout period, or when the mouse is clicked.",
|
||||
bubbleMessage);
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonsPage)
|
||||
};
|
||||
|
||||
|
|
@ -481,16 +481,15 @@ struct MiscPage : public Component
|
|||
|
||||
//==============================================================================
|
||||
class ToolbarDemoComp : public Component,
|
||||
public Slider::Listener,
|
||||
public Button::Listener
|
||||
private Slider::Listener
|
||||
{
|
||||
public:
|
||||
ToolbarDemoComp()
|
||||
: depthLabel (String(), "Toolbar depth:"),
|
||||
infoLabel (String(), "As well as showing off toolbars, this demo illustrates how to store "
|
||||
"a set of SVG files in a Zip file, embed that in your application, and read "
|
||||
"them back in at runtime.\n\nThe icon images here are taken from the open-source "
|
||||
"Tango icon project."),
|
||||
: depthLabel ({}, "Toolbar depth:"),
|
||||
infoLabel ({}, "As well as showing off toolbars, this demo illustrates how to store "
|
||||
"a set of SVG files in a Zip file, embed that in your application, and read "
|
||||
"them back in at runtime.\n\nThe icon images here are taken from the open-source "
|
||||
"Tango icon project."),
|
||||
orientationButton ("Vertical/Horizontal"),
|
||||
customiseButton ("Customise...")
|
||||
{
|
||||
|
|
@ -517,12 +516,12 @@ public:
|
|||
depthLabel.attachToComponent (&depthSlider, false);
|
||||
|
||||
addAndMakeVisible (orientationButton);
|
||||
orientationButton.addListener (this);
|
||||
orientationButton.onClick = [this]() { toolbar.setVertical (! toolbar.isVertical()); resized(); };
|
||||
orientationButton.changeWidthToFitText (22);
|
||||
orientationButton.setTopLeftPosition (depthSlider.getX(), depthSlider.getBottom() + 20);
|
||||
|
||||
addAndMakeVisible (customiseButton);
|
||||
customiseButton.addListener (this);
|
||||
customiseButton.onClick = [this]() { toolbar.showCustomisationDialog (factory); };
|
||||
customiseButton.changeWidthToFitText (22);
|
||||
customiseButton.setTopLeftPosition (orientationButton.getRight() + 20, orientationButton.getY());
|
||||
}
|
||||
|
|
@ -542,19 +541,6 @@ public:
|
|||
resized();
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &orientationButton)
|
||||
{
|
||||
toolbar.setVertical (! toolbar.isVertical());
|
||||
resized();
|
||||
}
|
||||
else if (button == &customiseButton)
|
||||
{
|
||||
toolbar.showCustomisationDialog (factory);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Toolbar toolbar;
|
||||
Slider depthSlider;
|
||||
|
|
@ -1276,8 +1262,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
struct BurgerMenuHeader : public Component,
|
||||
private Button::Listener
|
||||
struct BurgerMenuHeader : public Component
|
||||
{
|
||||
BurgerMenuHeader()
|
||||
{
|
||||
|
|
@ -1299,7 +1284,7 @@ struct BurgerMenuHeader : public Component,
|
|||
p.loadPathFromData (burgerMenuPathData, sizeof (burgerMenuPathData));
|
||||
burgerButton.setShape (p, true, true, false);
|
||||
|
||||
burgerButton.addListener (this);
|
||||
burgerButton.onClick = [this]() { showOrHide(); };
|
||||
addAndMakeVisible (burgerButton);
|
||||
}
|
||||
|
||||
|
|
@ -1328,7 +1313,7 @@ private:
|
|||
titleLabel.setBounds (r);
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
void showOrHide()
|
||||
{
|
||||
auto& panel = MainAppWindow::getSharedSidePanel();
|
||||
|
||||
|
|
@ -1344,8 +1329,7 @@ private:
|
|||
//==============================================================================
|
||||
class MenusDemo : public Component,
|
||||
public MenuBarModel,
|
||||
public ChangeBroadcaster,
|
||||
private Button::Listener
|
||||
public ChangeBroadcaster
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -1363,7 +1347,7 @@ public:
|
|||
|
||||
popupButton.setButtonText ("Show Popup Menu");
|
||||
popupButton.setTriggeredOnMouseDown (true);
|
||||
popupButton.addListener (this);
|
||||
popupButton.onClick = [this]() { getDummyPopupMenu().showMenuAsync (PopupMenu::Options().withTargetComponent (&popupButton), nullptr); };
|
||||
addAndMakeVisible (popupButton);
|
||||
addChildComponent (menuHeader);
|
||||
|
||||
|
|
@ -1378,8 +1362,6 @@ public:
|
|||
MenuBarModel::setMacMainMenu (nullptr);
|
||||
#endif
|
||||
PopupMenu::dismissAllActiveMenus();
|
||||
|
||||
popupButton.removeListener (this);
|
||||
}
|
||||
|
||||
void resized() override
|
||||
|
|
@ -1565,13 +1547,6 @@ private:
|
|||
return m;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &popupButton)
|
||||
getDummyPopupMenu().showMenuAsync (PopupMenu::Options().withTargetComponent (&popupButton), nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
class CustomMenuComponent : public PopupMenu::CustomComponent,
|
||||
private Timer
|
||||
|
|
@ -1677,7 +1652,7 @@ public:
|
|||
|
||||
void mouseDown (const MouseEvent&) override
|
||||
{
|
||||
showBubbleMessage (this,
|
||||
showBubbleMessage (*this,
|
||||
"This is a custom tab component\n"
|
||||
"\n"
|
||||
"You can use these to implement things like close-buttons "
|
||||
|
|
|
|||
|
|
@ -187,8 +187,7 @@ private:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
class WindowsDemo : public Component,
|
||||
private Button::Listener
|
||||
class WindowsDemo : public Component
|
||||
{
|
||||
public:
|
||||
enum Windows
|
||||
|
|
@ -205,11 +204,11 @@ public:
|
|||
|
||||
showWindowsButton.setButtonText ("Show Windows");
|
||||
addAndMakeVisible (showWindowsButton);
|
||||
showWindowsButton.addListener (this);
|
||||
showWindowsButton.onClick = [this]() { showAllWindows(); };
|
||||
|
||||
closeWindowsButton.setButtonText ("Close Windows");
|
||||
addAndMakeVisible (closeWindowsButton);
|
||||
closeWindowsButton.addListener (this);
|
||||
closeWindowsButton.onClick = [this]() { closeAllWindows(); };
|
||||
}
|
||||
|
||||
~WindowsDemo()
|
||||
|
|
@ -224,9 +223,6 @@ public:
|
|||
}
|
||||
|
||||
closeAllWindows();
|
||||
|
||||
closeWindowsButton.removeListener (this);
|
||||
showWindowsButton.removeListener (this);
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
@ -341,14 +337,6 @@ private:
|
|||
balls->setVisible (true);
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
{
|
||||
if (button == &showWindowsButton)
|
||||
showAllWindows();
|
||||
else if (button == &closeWindowsButton)
|
||||
closeAllWindows();
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowsDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,35 +29,6 @@ void handleGUIEditorMenuCommand (int);
|
|||
void registerGUIEditorCommands();
|
||||
|
||||
|
||||
void attachCallback (Button& button, std::function<void()> callback)
|
||||
{
|
||||
struct ButtonCallback : public Button::Listener,
|
||||
private ComponentListener
|
||||
{
|
||||
ButtonCallback (Button& b, std::function<void()> f) : target (b), fn (f)
|
||||
{
|
||||
target.addListener (this);
|
||||
target.addComponentListener (this);
|
||||
}
|
||||
|
||||
~ButtonCallback()
|
||||
{
|
||||
target.removeListener (this);
|
||||
}
|
||||
|
||||
void componentBeingDeleted (Component&) override { delete this; }
|
||||
void buttonClicked (Button*) override { fn(); }
|
||||
|
||||
Button& target;
|
||||
std::function<void()> fn;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonCallback)
|
||||
};
|
||||
|
||||
new ButtonCallback (button, callback);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
struct ProjucerApplication::MainMenuModel : public MenuBarModel
|
||||
{
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ PluginListComponent::PluginListComponent (AudioPluginFormatManager& manager, Kno
|
|||
addAndMakeVisible (table);
|
||||
|
||||
addAndMakeVisible (optionsButton);
|
||||
optionsButton.addListener (this);
|
||||
optionsButton.onClick = [this]() { showOptionsMenu(); };
|
||||
optionsButton.setTriggeredOnMouseDown (true);
|
||||
|
||||
setSize (400, 600);
|
||||
|
|
@ -290,28 +290,25 @@ void PluginListComponent::optionsMenuCallback (int result)
|
|||
}
|
||||
}
|
||||
|
||||
void PluginListComponent::buttonClicked (Button* button)
|
||||
void PluginListComponent::showOptionsMenu()
|
||||
{
|
||||
if (button == &optionsButton)
|
||||
PopupMenu menu;
|
||||
menu.addItem (1, TRANS("Clear list"));
|
||||
menu.addItem (2, TRANS("Remove selected plug-in from list"), table.getNumSelectedRows() > 0);
|
||||
menu.addItem (3, TRANS("Show folder containing selected plug-in"), canShowSelectedFolder());
|
||||
menu.addItem (4, TRANS("Remove any plug-ins whose files no longer exist"));
|
||||
menu.addSeparator();
|
||||
|
||||
for (int i = 0; i < formatManager.getNumFormats(); ++i)
|
||||
{
|
||||
PopupMenu menu;
|
||||
menu.addItem (1, TRANS("Clear list"));
|
||||
menu.addItem (2, TRANS("Remove selected plug-in from list"), table.getNumSelectedRows() > 0);
|
||||
menu.addItem (3, TRANS("Show folder containing selected plug-in"), canShowSelectedFolder());
|
||||
menu.addItem (4, TRANS("Remove any plug-ins whose files no longer exist"));
|
||||
menu.addSeparator();
|
||||
auto* format = formatManager.getFormat (i);
|
||||
|
||||
for (int i = 0; i < formatManager.getNumFormats(); ++i)
|
||||
{
|
||||
AudioPluginFormat* const format = formatManager.getFormat (i);
|
||||
|
||||
if (format->canScanForPlugins())
|
||||
menu.addItem (10 + i, "Scan for new or updated " + format->getName() + " plug-ins");
|
||||
}
|
||||
|
||||
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (&optionsButton),
|
||||
ModalCallbackFunction::forComponent (optionsMenuStaticCallback, this));
|
||||
if (format->canScanForPlugins())
|
||||
menu.addItem (10 + i, "Scan for new or updated " + format->getName() + " plug-ins");
|
||||
}
|
||||
|
||||
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (&optionsButton),
|
||||
ModalCallbackFunction::forComponent (optionsMenuStaticCallback, this));
|
||||
}
|
||||
|
||||
bool PluginListComponent::isInterestedInFileDrag (const StringArray& /*files*/)
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ namespace juce
|
|||
*/
|
||||
class JUCE_API PluginListComponent : public Component,
|
||||
public FileDragAndDropTarget,
|
||||
private ChangeListener,
|
||||
private Button::Listener
|
||||
private ChangeListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -119,11 +118,11 @@ private:
|
|||
bool canShowSelectedFolder() const;
|
||||
void removeMissingPlugins();
|
||||
void removePluginItem (int index);
|
||||
void showOptionsMenu();
|
||||
|
||||
void resized() override;
|
||||
bool isInterestedInFileDrag (const StringArray&) override;
|
||||
void filesDropped (const StringArray&, int, int) override;
|
||||
void buttonClicked (Button*) override;
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListComponent)
|
||||
|
|
|
|||
|
|
@ -27,14 +27,12 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
class SimpleDeviceManagerInputLevelMeter : public Component,
|
||||
public Timer
|
||||
struct SimpleDeviceManagerInputLevelMeter : public Component,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager& m)
|
||||
: manager (m), level (0)
|
||||
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager& m) : manager (m)
|
||||
{
|
||||
startTimer (50);
|
||||
startTimerHz (20);
|
||||
manager.enableInputLevelMeasurement (true);
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +45,7 @@ public:
|
|||
{
|
||||
if (isShowing())
|
||||
{
|
||||
const float newLevel = (float) manager.getCurrentInputLevel();
|
||||
auto newLevel = (float) manager.getCurrentInputLevel();
|
||||
|
||||
if (std::abs (level - newLevel) > 0.005f)
|
||||
{
|
||||
|
|
@ -67,9 +65,8 @@ public:
|
|||
(float) exp (log (level) / 3.0)); // (add a bit of a skew to make the level more obvious)
|
||||
}
|
||||
|
||||
private:
|
||||
AudioDeviceManager& manager;
|
||||
float level;
|
||||
float level = 0;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SimpleDeviceManagerInputLevelMeter)
|
||||
};
|
||||
|
|
@ -81,7 +78,7 @@ class AudioDeviceSelectorComponent::MidiInputSelectorComponentListBox : public
|
|||
{
|
||||
public:
|
||||
MidiInputSelectorComponentListBox (AudioDeviceManager& dm, const String& noItems)
|
||||
: ListBox (String(), nullptr),
|
||||
: ListBox ({}, nullptr),
|
||||
deviceManager (dm),
|
||||
noItemsMessage (noItems)
|
||||
{
|
||||
|
|
@ -108,11 +105,11 @@ public:
|
|||
g.fillAll (findColour (TextEditor::highlightColourId)
|
||||
.withMultipliedAlpha (0.3f));
|
||||
|
||||
const String item (items [row]);
|
||||
auto item = items[row];
|
||||
bool enabled = deviceManager.isMidiInputEnabled (item);
|
||||
|
||||
const int x = getTickX();
|
||||
const float tickW = height * 0.75f;
|
||||
auto x = getTickX();
|
||||
auto tickW = height * 0.75f;
|
||||
|
||||
getLookAndFeel().drawTickBox (g, *this, x - tickW, (height - tickW) / 2, tickW, tickW,
|
||||
enabled, true, true, false);
|
||||
|
|
@ -145,7 +142,7 @@ public:
|
|||
{
|
||||
ListBox::paint (g);
|
||||
|
||||
if (items.size() == 0)
|
||||
if (items.isEmpty())
|
||||
{
|
||||
g.setColour (Colours::grey);
|
||||
g.setFont (13.0f);
|
||||
|
|
@ -155,9 +152,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
int getBestHeight (const int preferredHeight)
|
||||
int getBestHeight (int preferredHeight)
|
||||
{
|
||||
const int extra = getOutlineThickness() * 2;
|
||||
auto extra = getOutlineThickness() * 2;
|
||||
|
||||
return jmax (getRowHeight() * 2 + extra,
|
||||
jmin (getRowHeight() * getNumRows() + extra,
|
||||
|
|
@ -174,7 +171,7 @@ private:
|
|||
{
|
||||
if (isPositiveAndBelow (row, items.size()))
|
||||
{
|
||||
const String item (items [row]);
|
||||
auto item = items[row];
|
||||
deviceManager.setMidiInputEnabled (item, ! deviceManager.isMidiInputEnabled (item));
|
||||
}
|
||||
}
|
||||
|
|
@ -202,8 +199,7 @@ static String getNoDeviceString() { return "<< " + TRANS("none") + " >>"; }
|
|||
//==============================================================================
|
||||
class AudioDeviceSettingsPanel : public Component,
|
||||
private ChangeListener,
|
||||
private ComboBox::Listener,
|
||||
private Button::Listener
|
||||
private ComboBox::Listener
|
||||
{
|
||||
public:
|
||||
AudioDeviceSettingsPanel (AudioIODeviceType& t, AudioDeviceSetupDetails& setupDetails,
|
||||
|
|
@ -213,7 +209,7 @@ public:
|
|||
if (hideAdvancedOptionsWithButton)
|
||||
{
|
||||
addAndMakeVisible (showAdvancedSettingsButton = new TextButton (TRANS("Show advanced settings...")));
|
||||
showAdvancedSettingsButton->addListener (this);
|
||||
showAdvancedSettingsButton->onClick = [this]() { showAdvanced(); };
|
||||
}
|
||||
|
||||
type.scanForDevices();
|
||||
|
|
@ -228,7 +224,7 @@ public:
|
|||
|
||||
void resized() override
|
||||
{
|
||||
if (AudioDeviceSelectorComponent* parent = findParentComponentOfClass<AudioDeviceSelectorComponent>())
|
||||
if (auto* parent = findParentComponentOfClass<AudioDeviceSelectorComponent>())
|
||||
{
|
||||
Rectangle<int> r (proportionOfWidth (0.35f), 0, proportionOfWidth (0.6f), 3000);
|
||||
|
||||
|
|
@ -238,7 +234,7 @@ public:
|
|||
|
||||
if (outputDeviceDropDown != nullptr)
|
||||
{
|
||||
Rectangle<int> row (r.removeFromTop (h));
|
||||
auto row = r.removeFromTop (h);
|
||||
|
||||
if (testButton != nullptr)
|
||||
{
|
||||
|
|
@ -253,7 +249,7 @@ public:
|
|||
|
||||
if (inputDeviceDropDown != nullptr)
|
||||
{
|
||||
Rectangle<int> row (r.removeFromTop (h));
|
||||
auto row = r.removeFromTop (h);
|
||||
|
||||
inputLevelMeter->setBounds (row.removeFromRight (testButton != nullptr ? testButton->getWidth() : row.getWidth() / 6));
|
||||
row.removeFromRight (space);
|
||||
|
|
@ -304,7 +300,7 @@ public:
|
|||
|
||||
if (showUIButton != nullptr || resetDeviceButton != nullptr)
|
||||
{
|
||||
Rectangle<int> buttons (r.removeFromTop (h));
|
||||
auto buttons = r.removeFromTop (h);
|
||||
|
||||
if (showUIButton != nullptr)
|
||||
{
|
||||
|
|
@ -393,7 +389,7 @@ public:
|
|||
|
||||
bool showDeviceControlPanel()
|
||||
{
|
||||
if (AudioIODevice* const device = setup.manager->getCurrentAudioDevice())
|
||||
if (auto* device = setup.manager->getCurrentAudioDevice())
|
||||
{
|
||||
Component modalWindow;
|
||||
modalWindow.setOpaque (true);
|
||||
|
|
@ -406,32 +402,27 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
void showAdvanced()
|
||||
{
|
||||
if (button == showAdvancedSettingsButton)
|
||||
showAdvancedSettingsButton->setVisible (false);
|
||||
resized();
|
||||
}
|
||||
|
||||
void showDeviceUIPanel()
|
||||
{
|
||||
if (showDeviceControlPanel())
|
||||
{
|
||||
showAdvancedSettingsButton->setVisible (false);
|
||||
resized();
|
||||
}
|
||||
else if (button == showUIButton)
|
||||
{
|
||||
if (showDeviceControlPanel())
|
||||
{
|
||||
setup.manager->closeAudioDevice();
|
||||
setup.manager->restartLastAudioDevice();
|
||||
getTopLevelComponent()->toFront (true);
|
||||
}
|
||||
}
|
||||
else if (button == testButton && testButton != nullptr)
|
||||
{
|
||||
setup.manager->playTestSound();
|
||||
}
|
||||
else if (button == resetDeviceButton)
|
||||
{
|
||||
resetDevice();
|
||||
setup.manager->closeAudioDevice();
|
||||
setup.manager->restartLastAudioDevice();
|
||||
getTopLevelComponent()->toFront (true);
|
||||
}
|
||||
}
|
||||
|
||||
void playTestSound()
|
||||
{
|
||||
setup.manager->playTestSound();
|
||||
}
|
||||
|
||||
void updateAllControls()
|
||||
{
|
||||
updateOutputsComboBox();
|
||||
|
|
@ -440,7 +431,7 @@ public:
|
|||
updateControlPanelButton();
|
||||
updateResetButton();
|
||||
|
||||
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
if (auto* currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
{
|
||||
if (setup.maxNumOutputChannels > 0
|
||||
&& setup.minNumOutputChannels < setup.manager->getCurrentAudioDevice()->getOutputChannelNames().size())
|
||||
|
|
@ -450,7 +441,7 @@ public:
|
|||
addAndMakeVisible (outputChanList
|
||||
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioOutputType,
|
||||
TRANS ("(no audio output channels found)")));
|
||||
outputChanLabel = new Label (String(), TRANS("Active output channels:"));
|
||||
outputChanLabel = new Label ({}, TRANS("Active output channels:"));
|
||||
outputChanLabel->setJustificationType (Justification::centredRight);
|
||||
outputChanLabel->attachToComponent (outputChanList, true);
|
||||
}
|
||||
|
|
@ -471,7 +462,7 @@ public:
|
|||
addAndMakeVisible (inputChanList
|
||||
= new ChannelSelectorListBox (setup, ChannelSelectorListBox::audioInputType,
|
||||
TRANS("(no audio input channels found)")));
|
||||
inputChanLabel = new Label (String(), TRANS("Active input channels:"));
|
||||
inputChanLabel = new Label ({}, TRANS("Active input channels:"));
|
||||
inputChanLabel->setJustificationType (Justification::centredRight);
|
||||
inputChanLabel->attachToComponent (inputChanList, true);
|
||||
}
|
||||
|
|
@ -534,13 +525,12 @@ private:
|
|||
ScopedPointer<Component> inputLevelMeter;
|
||||
ScopedPointer<TextButton> showUIButton, showAdvancedSettingsButton, resetDeviceButton;
|
||||
|
||||
void showCorrectDeviceName (ComboBox* const box, const bool isInput)
|
||||
void showCorrectDeviceName (ComboBox* box, bool isInput)
|
||||
{
|
||||
if (box != nullptr)
|
||||
{
|
||||
AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice();
|
||||
|
||||
const int index = type.getIndexOfDevice (currentDevice, isInput);
|
||||
auto* currentDevice = setup.manager->getCurrentAudioDevice();
|
||||
auto index = type.getIndexOfDevice (currentDevice, isInput);
|
||||
|
||||
box->setSelectedId (index + 1, dontSendNotification);
|
||||
|
||||
|
|
@ -581,7 +571,7 @@ private:
|
|||
{
|
||||
addAndMakeVisible (showUIButton = new TextButton (TRANS ("Control Panel"),
|
||||
TRANS ("Opens the device's own control panel")));
|
||||
showUIButton->addListener (this);
|
||||
showUIButton->onClick = [this]() { showDeviceUIPanel(); };
|
||||
}
|
||||
|
||||
resized();
|
||||
|
|
@ -589,7 +579,7 @@ private:
|
|||
|
||||
void updateResetButton()
|
||||
{
|
||||
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
if (auto* currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
{
|
||||
if (currentDevice->hasControlPanel())
|
||||
{
|
||||
|
|
@ -598,7 +588,7 @@ private:
|
|||
addAndMakeVisible (resetDeviceButton = new TextButton (TRANS ("Reset Device"),
|
||||
TRANS ("Resets the audio interface - sometimes needed after changing a device's properties in its custom control panel")));
|
||||
|
||||
resetDeviceButton->addListener (this);
|
||||
resetDeviceButton->onClick = [this]() { resetDevice(); };
|
||||
resized();
|
||||
}
|
||||
|
||||
|
|
@ -615,20 +605,19 @@ private:
|
|||
{
|
||||
if (outputDeviceDropDown == nullptr)
|
||||
{
|
||||
outputDeviceDropDown = new ComboBox (String());
|
||||
outputDeviceDropDown = new ComboBox();
|
||||
outputDeviceDropDown->addListener (this);
|
||||
addAndMakeVisible (outputDeviceDropDown);
|
||||
|
||||
outputDeviceLabel = new Label (String(),
|
||||
type.hasSeparateInputsAndOutputs() ? TRANS("Output:")
|
||||
: TRANS("Device:"));
|
||||
outputDeviceLabel = new Label ({}, type.hasSeparateInputsAndOutputs() ? TRANS("Output:")
|
||||
: TRANS("Device:"));
|
||||
outputDeviceLabel->attachToComponent (outputDeviceDropDown, true);
|
||||
|
||||
if (setup.maxNumOutputChannels > 0)
|
||||
{
|
||||
addAndMakeVisible (testButton = new TextButton (TRANS("Test"),
|
||||
TRANS("Plays a test tone")));
|
||||
testButton->addListener (this);
|
||||
testButton->onClick = [this]() { playTestSound(); };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -644,11 +633,11 @@ private:
|
|||
{
|
||||
if (inputDeviceDropDown == nullptr)
|
||||
{
|
||||
inputDeviceDropDown = new ComboBox (String());
|
||||
inputDeviceDropDown = new ComboBox();
|
||||
inputDeviceDropDown->addListener (this);
|
||||
addAndMakeVisible (inputDeviceDropDown);
|
||||
|
||||
inputDeviceLabel = new Label (String(), TRANS("Input:"));
|
||||
inputDeviceLabel = new Label ({}, TRANS("Input:"));
|
||||
inputDeviceLabel->attachToComponent (inputDeviceDropDown, true);
|
||||
|
||||
addAndMakeVisible (inputLevelMeter
|
||||
|
|
@ -665,9 +654,9 @@ private:
|
|||
{
|
||||
if (sampleRateDropDown == nullptr)
|
||||
{
|
||||
addAndMakeVisible (sampleRateDropDown = new ComboBox (String()));
|
||||
addAndMakeVisible (sampleRateDropDown = new ComboBox());
|
||||
|
||||
sampleRateLabel = new Label (String(), TRANS("Sample rate:"));
|
||||
sampleRateLabel = new Label ({}, TRANS("Sample rate:"));
|
||||
sampleRateLabel->attachToComponent (sampleRateDropDown, true);
|
||||
}
|
||||
else
|
||||
|
|
@ -676,12 +665,10 @@ private:
|
|||
sampleRateDropDown->removeListener (this);
|
||||
}
|
||||
|
||||
const Array<double> rates (currentDevice->getAvailableSampleRates());
|
||||
|
||||
for (int i = 0; i < rates.size(); ++i)
|
||||
for (auto rate : currentDevice->getAvailableSampleRates())
|
||||
{
|
||||
const int rate = roundToInt (rates[i]);
|
||||
sampleRateDropDown->addItem (String (rate) + " Hz", rate);
|
||||
auto intRate = roundToInt (rate);
|
||||
sampleRateDropDown->addItem (String (intRate) + " Hz", intRate);
|
||||
}
|
||||
|
||||
sampleRateDropDown->setSelectedId (roundToInt (currentDevice->getCurrentSampleRate()), dontSendNotification);
|
||||
|
|
@ -692,9 +679,9 @@ private:
|
|||
{
|
||||
if (bufferSizeDropDown == nullptr)
|
||||
{
|
||||
addAndMakeVisible (bufferSizeDropDown = new ComboBox (String()));
|
||||
addAndMakeVisible (bufferSizeDropDown = new ComboBox());
|
||||
|
||||
bufferSizeLabel = new Label (String(), TRANS("Audio buffer size:"));
|
||||
bufferSizeLabel = new Label ({}, TRANS("Audio buffer size:"));
|
||||
bufferSizeLabel->attachToComponent (bufferSizeDropDown, true);
|
||||
}
|
||||
else
|
||||
|
|
@ -703,17 +690,13 @@ private:
|
|||
bufferSizeDropDown->removeListener (this);
|
||||
}
|
||||
|
||||
const Array<int> bufferSizes (currentDevice->getAvailableBufferSizes());
|
||||
auto currentRate = currentDevice->getCurrentSampleRate();
|
||||
|
||||
double currentRate = currentDevice->getCurrentSampleRate();
|
||||
if (currentRate == 0)
|
||||
currentRate = 48000.0;
|
||||
|
||||
for (int i = 0; i < bufferSizes.size(); ++i)
|
||||
{
|
||||
const int bs = bufferSizes[i];
|
||||
for (auto bs : currentDevice->getAvailableBufferSizes())
|
||||
bufferSizeDropDown->addItem (String (bs) + " samples (" + String (bs * 1000.0 / currentRate, 1) + " ms)", bs);
|
||||
}
|
||||
|
||||
bufferSizeDropDown->setSelectedId (currentDevice->getCurrentBufferSizeSamples(), dontSendNotification);
|
||||
bufferSizeDropDown->addListener (this);
|
||||
|
|
@ -732,10 +715,8 @@ public:
|
|||
};
|
||||
|
||||
//==============================================================================
|
||||
ChannelSelectorListBox (const AudioDeviceSetupDetails& setupDetails,
|
||||
const BoxType boxType, const String& noItemsText)
|
||||
: ListBox (String(), nullptr),
|
||||
setup (setupDetails), type (boxType), noItemsMessage (noItemsText)
|
||||
ChannelSelectorListBox (const AudioDeviceSetupDetails& setupDetails, BoxType boxType, const String& noItemsText)
|
||||
: ListBox ({}, nullptr), setup (setupDetails), type (boxType), noItemsMessage (noItemsText)
|
||||
{
|
||||
refresh();
|
||||
setModel (this);
|
||||
|
|
@ -746,7 +727,7 @@ public:
|
|||
{
|
||||
items.clear();
|
||||
|
||||
if (AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
if (auto* currentDevice = setup.manager->getCurrentAudioDevice())
|
||||
{
|
||||
if (type == audioInputType)
|
||||
items = currentDevice->getInputChannelNames();
|
||||
|
|
@ -759,7 +740,7 @@ public:
|
|||
|
||||
for (int i = 0; i < items.size(); i += 2)
|
||||
{
|
||||
const String& name = items[i];
|
||||
auto& name = items[i];
|
||||
|
||||
if (i + 1 >= items.size())
|
||||
pairs.add (name.trim());
|
||||
|
|
@ -786,7 +767,7 @@ public:
|
|||
{
|
||||
g.fillAll (findColour (ListBox::backgroundColourId));
|
||||
|
||||
const String item (items [row]);
|
||||
auto item = items[row];
|
||||
bool enabled = false;
|
||||
|
||||
AudioDeviceManager::AudioDeviceSetup config;
|
||||
|
|
@ -795,20 +776,20 @@ public:
|
|||
if (setup.useStereoPairs)
|
||||
{
|
||||
if (type == audioInputType)
|
||||
enabled = config.inputChannels [row * 2] || config.inputChannels [row * 2 + 1];
|
||||
enabled = config.inputChannels[row * 2] || config.inputChannels[row * 2 + 1];
|
||||
else if (type == audioOutputType)
|
||||
enabled = config.outputChannels [row * 2] || config.outputChannels [row * 2 + 1];
|
||||
enabled = config.outputChannels[row * 2] || config.outputChannels[row * 2 + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == audioInputType)
|
||||
enabled = config.inputChannels [row];
|
||||
enabled = config.inputChannels[row];
|
||||
else if (type == audioOutputType)
|
||||
enabled = config.outputChannels [row];
|
||||
enabled = config.outputChannels[row];
|
||||
}
|
||||
|
||||
const int x = getTickX();
|
||||
const float tickW = height * 0.75f;
|
||||
auto x = getTickX();
|
||||
auto tickW = height * 0.75f;
|
||||
|
||||
getLookAndFeel().drawTickBox (g, *this, x - tickW, (height - tickW) / 2, tickW, tickW,
|
||||
enabled, true, true, false);
|
||||
|
|
@ -841,7 +822,7 @@ public:
|
|||
{
|
||||
ListBox::paint (g);
|
||||
|
||||
if (items.size() == 0)
|
||||
if (items.isEmpty())
|
||||
{
|
||||
g.setColour (Colours::grey);
|
||||
g.setFont (13.0f);
|
||||
|
|
@ -881,7 +862,7 @@ public:
|
|||
return name1.trim() + " + " + name2.substring (commonBit.length()).trim();
|
||||
}
|
||||
|
||||
void flipEnablement (const int row)
|
||||
void flipEnablement (int row)
|
||||
{
|
||||
jassert (type == audioInputType || type == audioOutputType);
|
||||
|
||||
|
|
@ -893,11 +874,11 @@ public:
|
|||
if (setup.useStereoPairs)
|
||||
{
|
||||
BigInteger bits;
|
||||
BigInteger& original = (type == audioInputType ? config.inputChannels
|
||||
: config.outputChannels);
|
||||
auto& original = (type == audioInputType ? config.inputChannels
|
||||
: config.outputChannels);
|
||||
|
||||
for (int i = 0; i < 256; i += 2)
|
||||
bits.setBit (i / 2, original [i] || original [i + 1]);
|
||||
bits.setBit (i / 2, original[i] || original[i + 1]);
|
||||
|
||||
if (type == audioInputType)
|
||||
{
|
||||
|
|
@ -911,7 +892,7 @@ public:
|
|||
}
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
original.setBit (i, bits [i / 2]);
|
||||
original.setBit (i, bits[i / 2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -927,7 +908,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
String error (setup.manager->setAudioDeviceSetup (config, true));
|
||||
auto error = setup.manager->setAudioDeviceSetup (config, true);
|
||||
|
||||
if (error.isNotEmpty())
|
||||
{
|
||||
|
|
@ -938,9 +919,9 @@ public:
|
|||
|
||||
static void flipBit (BigInteger& chans, int index, int minNumber, int maxNumber)
|
||||
{
|
||||
const int numActive = chans.countNumberOfSetBits();
|
||||
auto numActive = chans.countNumberOfSetBits();
|
||||
|
||||
if (chans [index])
|
||||
if (chans[index])
|
||||
{
|
||||
if (numActive > minNumber)
|
||||
chans.setBit (index, false);
|
||||
|
|
@ -949,11 +930,8 @@ public:
|
|||
{
|
||||
if (numActive >= maxNumber)
|
||||
{
|
||||
const int firstActiveChan = chans.findNextSetBit (0);
|
||||
|
||||
chans.setBit (index > firstActiveChan
|
||||
? firstActiveChan : chans.getHighestBit(),
|
||||
false);
|
||||
auto firstActiveChan = chans.findNextSetBit (0);
|
||||
chans.clearBit (index > firstActiveChan ? firstActiveChan : chans.getHighestBit());
|
||||
}
|
||||
|
||||
chans.setBit (index, true);
|
||||
|
|
@ -977,22 +955,22 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager& dm,
|
||||
const int minInputChannels_,
|
||||
const int maxInputChannels_,
|
||||
const int minOutputChannels_,
|
||||
const int maxOutputChannels_,
|
||||
const bool showMidiInputOptions,
|
||||
const bool showMidiOutputSelector,
|
||||
const bool showChannelsAsStereoPairs_,
|
||||
const bool hideAdvancedOptionsWithButton_)
|
||||
int minInputChannelsToUse,
|
||||
int maxInputChannelsToUse,
|
||||
int minOutputChannelsToUse,
|
||||
int maxOutputChannelsToUse,
|
||||
bool showMidiInputOptions,
|
||||
bool showMidiOutputSelector,
|
||||
bool showChannelsAsStereoPairsToUse,
|
||||
bool hideAdvancedOptionsWithButtonToUse)
|
||||
: deviceManager (dm),
|
||||
itemHeight (24),
|
||||
minOutputChannels (minOutputChannels_),
|
||||
maxOutputChannels (maxOutputChannels_),
|
||||
minInputChannels (minInputChannels_),
|
||||
maxInputChannels (maxInputChannels_),
|
||||
showChannelsAsStereoPairs (showChannelsAsStereoPairs_),
|
||||
hideAdvancedOptionsWithButton (hideAdvancedOptionsWithButton_)
|
||||
minOutputChannels (minOutputChannelsToUse),
|
||||
maxOutputChannels (maxOutputChannelsToUse),
|
||||
minInputChannels (minInputChannelsToUse),
|
||||
maxInputChannels (maxInputChannelsToUse),
|
||||
showChannelsAsStereoPairs (showChannelsAsStereoPairsToUse),
|
||||
hideAdvancedOptionsWithButton (hideAdvancedOptionsWithButtonToUse)
|
||||
{
|
||||
jassert (minOutputChannels >= 0 && minOutputChannels <= maxOutputChannels);
|
||||
jassert (minInputChannels >= 0 && minInputChannels <= maxInputChannels);
|
||||
|
|
@ -1001,7 +979,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
|
|||
|
||||
if (types.size() > 1)
|
||||
{
|
||||
deviceTypeDropDown = new ComboBox (String());
|
||||
deviceTypeDropDown = new ComboBox();
|
||||
|
||||
for (int i = 0; i < types.size(); ++i)
|
||||
deviceTypeDropDown->addItem (types.getUnchecked(i)->getTypeName(), i + 1);
|
||||
|
|
@ -1009,7 +987,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
|
|||
addAndMakeVisible (deviceTypeDropDown);
|
||||
deviceTypeDropDown->addListener (this);
|
||||
|
||||
deviceTypeDropDownLabel = new Label (String(), TRANS("Audio device type:"));
|
||||
deviceTypeDropDownLabel = new Label ({}, TRANS("Audio device type:"));
|
||||
deviceTypeDropDownLabel->setJustificationType (Justification::centredRight);
|
||||
deviceTypeDropDownLabel->attachToComponent (deviceTypeDropDown, true);
|
||||
}
|
||||
|
|
@ -1020,7 +998,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
|
|||
= new MidiInputSelectorComponentListBox (deviceManager,
|
||||
"(" + TRANS("No MIDI inputs available") + ")"));
|
||||
|
||||
midiInputsLabel = new Label (String(), TRANS ("Active MIDI inputs:"));
|
||||
midiInputsLabel = new Label ({}, TRANS ("Active MIDI inputs:"));
|
||||
midiInputsLabel->setJustificationType (Justification::topRight);
|
||||
midiInputsLabel->attachToComponent (midiInputsList, true);
|
||||
|
||||
|
|
@ -1028,7 +1006,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
|
|||
{
|
||||
addAndMakeVisible (bluetoothButton = new TextButton (TRANS("Bluetooth MIDI"),
|
||||
TRANS("Scan for bluetooth MIDI devices")));
|
||||
bluetoothButton->addListener (this);
|
||||
bluetoothButton->onClick = [this]() { handleBluetoothButton(); };
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1040,7 +1018,7 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
|
|||
|
||||
if (showMidiOutputSelector)
|
||||
{
|
||||
addAndMakeVisible (midiOutputSelector = new ComboBox (String()));
|
||||
addAndMakeVisible (midiOutputSelector = new ComboBox());
|
||||
midiOutputSelector->addListener (this);
|
||||
|
||||
midiOutputLabel = new Label ("lm", TRANS("MIDI Output:"));
|
||||
|
|
@ -1071,7 +1049,7 @@ void AudioDeviceSelectorComponent::setItemHeight (int newItemHeight)
|
|||
void AudioDeviceSelectorComponent::resized()
|
||||
{
|
||||
Rectangle<int> r (proportionOfWidth (0.35f), 15, proportionOfWidth (0.6f), 3000);
|
||||
const int space = itemHeight / 4;
|
||||
auto space = itemHeight / 4;
|
||||
|
||||
if (deviceTypeDropDown != nullptr)
|
||||
{
|
||||
|
|
@ -1121,7 +1099,7 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha
|
|||
{
|
||||
if (comboBoxThatHasChanged == deviceTypeDropDown)
|
||||
{
|
||||
if (AudioIODeviceType* const type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1])
|
||||
if (auto* type = deviceManager.getAvailableDeviceTypes() [deviceTypeDropDown->getSelectedId() - 1])
|
||||
{
|
||||
audioDeviceSettingsComp.reset();
|
||||
deviceManager.setCurrentAudioDeviceType (type->getTypeName(), true);
|
||||
|
|
@ -1130,10 +1108,10 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha
|
|||
}
|
||||
else if (comboBoxThatHasChanged == midiOutputSelector)
|
||||
{
|
||||
String midiDeviceName (midiOutputSelector->getText());
|
||||
auto midiDeviceName = midiOutputSelector->getText();
|
||||
|
||||
if (midiDeviceName == getNoDeviceString())
|
||||
midiDeviceName = String();
|
||||
midiDeviceName = {};
|
||||
|
||||
deviceManager.setDefaultMidiOutput (midiDeviceName);
|
||||
}
|
||||
|
|
@ -1203,16 +1181,13 @@ void AudioDeviceSelectorComponent::updateAllControls()
|
|||
resized();
|
||||
}
|
||||
|
||||
void AudioDeviceSelectorComponent::buttonClicked (Button* btn)
|
||||
void AudioDeviceSelectorComponent::handleBluetoothButton()
|
||||
{
|
||||
if (bluetoothButton == btn)
|
||||
{
|
||||
if (! RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi))
|
||||
RuntimePermissions::request (RuntimePermissions::bluetoothMidi, nullptr);
|
||||
if (! RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi))
|
||||
RuntimePermissions::request (RuntimePermissions::bluetoothMidi, nullptr);
|
||||
|
||||
if (RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi))
|
||||
BluetoothMidiDevicePairingDialogue::open();
|
||||
}
|
||||
if (RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi))
|
||||
BluetoothMidiDevicePairingDialogue::open();
|
||||
}
|
||||
|
||||
ListBox* AudioDeviceSelectorComponent::getMidiInputSelectorListBox() const noexcept
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ namespace juce
|
|||
class JUCE_API AudioDeviceSelectorComponent : public Component,
|
||||
private ChangeListener,
|
||||
private ComboBox::Listener,
|
||||
private Button::Listener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
|
|
@ -94,9 +93,6 @@ public:
|
|||
void timerCallback() override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
void buttonClicked (Button*) override;
|
||||
|
||||
//==============================================================================
|
||||
ScopedPointer<ComboBox> deviceTypeDropDown;
|
||||
ScopedPointer<Label> deviceTypeDropDownLabel;
|
||||
|
|
@ -114,6 +110,7 @@ private:
|
|||
ScopedPointer<Label> midiInputsLabel, midiOutputLabel;
|
||||
ScopedPointer<TextButton> bluetoothButton;
|
||||
|
||||
void handleBluetoothButton();
|
||||
void comboBoxChanged (ComboBox*) override;
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
void updateAllControls();
|
||||
|
|
|
|||
|
|
@ -37,23 +37,20 @@ struct EventHandler
|
|||
EventHandler() {}
|
||||
~EventHandler() {}
|
||||
|
||||
/** Assigns a void std::function to this callback.
|
||||
/** Assigns a lambda to this callback.
|
||||
Note that this will replace any existing function that was previously assigned.
|
||||
*/
|
||||
void operator= (std::function<void()> callbackToAttach)
|
||||
void operator= (const std::function<void()>& callbackToAttach)
|
||||
{
|
||||
callback = [=](OwnerClass&) { callbackToAttach(); };
|
||||
callback = callbackToAttach;
|
||||
}
|
||||
|
||||
/** Assigns a std::function to this callback which takes a reference to the
|
||||
source object that's making the callback.
|
||||
In the example of this class being used inside, e.g. a Button, then the
|
||||
callback parameter would be the Button that is doing the calling.
|
||||
/** Assigns a lambda to this callback.
|
||||
Note that this will replace any existing function that was previously assigned.
|
||||
*/
|
||||
void operator= (std::function<void(OwnerClass&)> callbackToAttach)
|
||||
void operator= (std::function<void()>&& callbackToAttach)
|
||||
{
|
||||
callback = static_cast<std::function<void(OwnerClass&)>&&> (callbackToAttach);
|
||||
callback = static_cast<std::function<void()>&&> (callbackToAttach);
|
||||
}
|
||||
|
||||
/** Removes any existing function that was previously assigned to the callback. */
|
||||
|
|
@ -63,14 +60,14 @@ struct EventHandler
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
void invoke (OwnerClass& owner)
|
||||
void invoke()
|
||||
{
|
||||
if (callback != nullptr)
|
||||
callback (owner);
|
||||
callback();
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(OwnerClass&)> callback;
|
||||
std::function<void()> callback;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EventHandler)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ void Button::sendClickMessage (const ModifierKeys& modifiers)
|
|||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
onClick.invoke (*this);
|
||||
onClick.invoke();
|
||||
}
|
||||
|
||||
void Button::sendStateMessage()
|
||||
|
|
@ -416,7 +416,7 @@ void Button::sendStateMessage()
|
|||
if (checker.shouldBailOut())
|
||||
return;
|
||||
|
||||
onStateChange.invoke (*this);
|
||||
onStateChange.invoke();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ public:
|
|||
*/
|
||||
void removeListener (Listener* listener);
|
||||
|
||||
//==============================================================================
|
||||
/** You can assign a lambda to this callback object to have it called when the button is clicked. */
|
||||
EventHandler<Button> onClick;
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
|
|||
fileLabel.attachToComponent (&filenameBox, true);
|
||||
|
||||
addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton());
|
||||
goUpButton->addListener (this);
|
||||
goUpButton->onClick = [this]() { goUp(); };
|
||||
goUpButton->setTooltip (TRANS ("Go up to parent directory"));
|
||||
|
||||
if (previewComp != nullptr)
|
||||
|
|
@ -482,11 +482,6 @@ void FileBrowserComponent::textEditorFocusLost (TextEditor&)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void FileBrowserComponent::buttonClicked (Button*)
|
||||
{
|
||||
goUp();
|
||||
}
|
||||
|
||||
void FileBrowserComponent::comboBoxChanged (ComboBox*)
|
||||
{
|
||||
auto newText = currentPathBox.getText().trim().unquoted();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ namespace juce
|
|||
class JUCE_API FileBrowserComponent : public Component,
|
||||
private FileBrowserListener,
|
||||
private TextEditor::Listener,
|
||||
private Button::Listener,
|
||||
private ComboBox::Listener,
|
||||
private FileFilter,
|
||||
private Timer
|
||||
|
|
@ -237,8 +236,6 @@ public:
|
|||
/** @internal */
|
||||
void lookAndFeelChanged() override;
|
||||
/** @internal */
|
||||
void buttonClicked (Button*) override;
|
||||
/** @internal */
|
||||
void comboBoxChanged (ComboBox*) override;
|
||||
/** @internal */
|
||||
void textEditorTextChanged (TextEditor&) override;
|
||||
|
|
|
|||
|
|
@ -104,9 +104,10 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
|
|||
setResizable (true, true);
|
||||
setResizeLimits (300, 300, 1200, 1000);
|
||||
|
||||
content->okButton.addListener (this);
|
||||
content->cancelButton.addListener (this);
|
||||
content->newFolderButton.addListener (this);
|
||||
content->okButton.onClick = [this]() { okButtonPressed(); };
|
||||
content->cancelButton.onClick = [this]() { closeButtonPressed(); };
|
||||
content->newFolderButton.onClick = [this]() { createNewFolder(); };
|
||||
|
||||
content->chooserComponent.addListener (this);
|
||||
|
||||
FileChooserDialogBox::selectionChanged();
|
||||
|
|
@ -154,13 +155,6 @@ int FileChooserDialogBox::getDefaultWidth() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void FileChooserDialogBox::buttonClicked (Button* button)
|
||||
{
|
||||
if (button == &(content->okButton)) okButtonPressed();
|
||||
if (button == &(content->cancelButton)) closeButtonPressed();
|
||||
if (button == &(content->newFolderButton)) createNewFolder();
|
||||
}
|
||||
|
||||
void FileChooserDialogBox::closeButtonPressed()
|
||||
{
|
||||
setVisible (false);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ namespace juce
|
|||
@see FileChooser
|
||||
*/
|
||||
class JUCE_API FileChooserDialogBox : public ResizableWindow,
|
||||
private Button::Listener,
|
||||
private FileBrowserListener
|
||||
{
|
||||
public:
|
||||
|
|
@ -136,7 +135,6 @@ private:
|
|||
ContentComponent* content;
|
||||
const bool warnAboutOverwritingExistingFiles;
|
||||
|
||||
void buttonClicked (Button*) override;
|
||||
void closeButtonPressed();
|
||||
void selectionChanged() override;
|
||||
void fileClicked (const File&, const MouseEvent&) override;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ FileSearchPathListComponent::FileSearchPathListComponent()
|
|||
: addButton ("+"),
|
||||
removeButton ("-"),
|
||||
changeButton (TRANS ("change...")),
|
||||
upButton (String(), DrawableButton::ImageOnButtonBackground),
|
||||
downButton (String(), DrawableButton::ImageOnButtonBackground)
|
||||
upButton ({}, DrawableButton::ImageOnButtonBackground),
|
||||
downButton ({}, DrawableButton::ImageOnButtonBackground)
|
||||
{
|
||||
listBox.setModel (this);
|
||||
addAndMakeVisible (listBox);
|
||||
|
|
@ -41,37 +41,39 @@ FileSearchPathListComponent::FileSearchPathListComponent()
|
|||
listBox.setOutlineThickness (1);
|
||||
|
||||
addAndMakeVisible (addButton);
|
||||
addButton.addListener (this);
|
||||
addButton.onClick = [this]() { addPath(); };
|
||||
addButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop);
|
||||
|
||||
addAndMakeVisible (removeButton);
|
||||
removeButton.addListener (this);
|
||||
removeButton.onClick = [this]() { deleteSelected(); };
|
||||
removeButton.setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight | Button::ConnectedOnBottom | Button::ConnectedOnTop);
|
||||
|
||||
addAndMakeVisible (changeButton);
|
||||
changeButton.addListener (this);
|
||||
changeButton.onClick = [this]() { editSelected(); };
|
||||
|
||||
addAndMakeVisible (upButton);
|
||||
upButton.addListener (this);
|
||||
upButton.onClick = [this]() { moveSelection (-1); };
|
||||
|
||||
auto arrowColour = findColour (ListBox::textColourId);
|
||||
|
||||
{
|
||||
Path arrowPath;
|
||||
arrowPath.addArrow (Line<float> (50.0f, 100.0f, 50.0f, 0.0f), 40.0f, 100.0f, 50.0f);
|
||||
arrowPath.addArrow ({ 50.0f, 100.0f, 50.0f, 0.0f }, 40.0f, 100.0f, 50.0f);
|
||||
DrawablePath arrowImage;
|
||||
arrowImage.setFill (Colours::black.withAlpha (0.4f));
|
||||
arrowImage.setFill (arrowColour);
|
||||
arrowImage.setPath (arrowPath);
|
||||
|
||||
upButton.setImages (&arrowImage);
|
||||
}
|
||||
|
||||
addAndMakeVisible (downButton);
|
||||
downButton.addListener (this);
|
||||
downButton.onClick = [this]() { moveSelection (1); };
|
||||
|
||||
{
|
||||
Path arrowPath;
|
||||
arrowPath.addArrow (Line<float> (50.0f, 0.0f, 50.0f, 100.0f), 40.0f, 100.0f, 50.0f);
|
||||
arrowPath.addArrow ({ 50.0f, 0.0f, 50.0f, 100.0f }, 40.0f, 100.0f, 50.0f);
|
||||
DrawablePath arrowImage;
|
||||
arrowImage.setFill (Colours::black.withAlpha (0.4f));
|
||||
arrowImage.setFill (arrowColour);
|
||||
arrowImage.setPath (arrowPath);
|
||||
|
||||
downButton.setImages (&arrowImage);
|
||||
|
|
@ -132,7 +134,7 @@ void FileSearchPathListComponent::paintListBoxItem (int rowNumber, Graphics& g,
|
|||
f.setHorizontalScale (0.9f);
|
||||
g.setFont (f);
|
||||
|
||||
g.drawText (path [rowNumber].getFullPathName(),
|
||||
g.drawText (path[rowNumber].getFullPathName(),
|
||||
4, 0, width - 6, height,
|
||||
Justification::centredLeft, true);
|
||||
}
|
||||
|
|
@ -149,7 +151,7 @@ void FileSearchPathListComponent::deleteKeyPressed (int row)
|
|||
void FileSearchPathListComponent::returnKeyPressed (int row)
|
||||
{
|
||||
#if JUCE_MODAL_LOOPS_PERMITTED
|
||||
FileChooser chooser (TRANS("Change folder..."), path [row], "*");
|
||||
FileChooser chooser (TRANS("Change folder..."), path[row], "*");
|
||||
|
||||
if (chooser.browseForDirectory())
|
||||
{
|
||||
|
|
@ -208,66 +210,66 @@ void FileSearchPathListComponent::filesDropped (const StringArray& filenames, in
|
|||
|
||||
if (f.isDirectory())
|
||||
{
|
||||
const int row = listBox.getRowContainingPosition (0, mouseY - listBox.getY());
|
||||
auto row = listBox.getRowContainingPosition (0, mouseY - listBox.getY());
|
||||
path.add (f, row);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FileSearchPathListComponent::buttonClicked (Button* button)
|
||||
void FileSearchPathListComponent::addPath()
|
||||
{
|
||||
const int currentRow = listBox.getSelectedRow();
|
||||
auto start = defaultBrowseTarget;
|
||||
|
||||
if (button == &removeButton)
|
||||
{
|
||||
deleteKeyPressed (currentRow);
|
||||
}
|
||||
else if (button == &addButton)
|
||||
{
|
||||
File start (defaultBrowseTarget);
|
||||
if (start == File())
|
||||
start = path[0];
|
||||
|
||||
if (start == File())
|
||||
start = path [0];
|
||||
if (start == File())
|
||||
start = File::getCurrentWorkingDirectory();
|
||||
|
||||
if (start == File())
|
||||
start = File::getCurrentWorkingDirectory();
|
||||
#if JUCE_MODAL_LOOPS_PERMITTED
|
||||
FileChooser chooser (TRANS("Add a folder..."), start, "*");
|
||||
|
||||
#if JUCE_MODAL_LOOPS_PERMITTED
|
||||
FileChooser chooser (TRANS("Add a folder..."), start, "*");
|
||||
if (chooser.browseForDirectory())
|
||||
path.add (chooser.getResult(), listBox.getSelectedRow());
|
||||
|
||||
if (chooser.browseForDirectory())
|
||||
path.add (chooser.getResult(), currentRow);
|
||||
#else
|
||||
jassertfalse; // needs rewriting to deal with non-modal environments
|
||||
#endif
|
||||
}
|
||||
else if (button == &changeButton)
|
||||
{
|
||||
returnKeyPressed (currentRow);
|
||||
}
|
||||
else if (button == &upButton)
|
||||
{
|
||||
if (currentRow > 0 && currentRow < path.getNumPaths())
|
||||
{
|
||||
const File f (path[currentRow]);
|
||||
path.remove (currentRow);
|
||||
path.add (f, currentRow - 1);
|
||||
listBox.selectRow (currentRow - 1);
|
||||
}
|
||||
}
|
||||
else if (button == &downButton)
|
||||
{
|
||||
if (currentRow >= 0 && currentRow < path.getNumPaths() - 1)
|
||||
{
|
||||
const File f (path[currentRow]);
|
||||
path.remove (currentRow);
|
||||
path.add (f, currentRow + 1);
|
||||
listBox.selectRow (currentRow + 1);
|
||||
}
|
||||
}
|
||||
changed();
|
||||
#else
|
||||
jassertfalse; // needs rewriting to deal with non-modal environments
|
||||
#endif
|
||||
}
|
||||
|
||||
void FileSearchPathListComponent::deleteSelected()
|
||||
{
|
||||
deleteKeyPressed (listBox.getSelectedRow());
|
||||
changed();
|
||||
}
|
||||
|
||||
void FileSearchPathListComponent::editSelected()
|
||||
{
|
||||
returnKeyPressed (listBox.getSelectedRow());
|
||||
changed();
|
||||
}
|
||||
|
||||
void FileSearchPathListComponent::moveSelection (int delta)
|
||||
{
|
||||
jassert (delta == -1 || delta == 1);
|
||||
auto currentRow = listBox.getSelectedRow();
|
||||
|
||||
if (isPositiveAndBelow (currentRow, path.getNumPaths()))
|
||||
{
|
||||
auto newRow = jlimit (0, path.getNumPaths() - 1, currentRow + delta);
|
||||
|
||||
if (currentRow != newRow)
|
||||
{
|
||||
auto f = path[currentRow];
|
||||
path.remove (currentRow);
|
||||
path.add (f, newRow);
|
||||
listBox.selectRow (newRow);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ namespace juce
|
|||
class JUCE_API FileSearchPathListComponent : public Component,
|
||||
public SettableTooltipClient,
|
||||
public FileDragAndDropTarget,
|
||||
private Button::Listener,
|
||||
private ListBoxModel
|
||||
{
|
||||
public:
|
||||
|
|
@ -95,8 +94,6 @@ public:
|
|||
bool isInterestedInFileDrag (const StringArray&) override;
|
||||
/** @internal */
|
||||
void filesDropped (const StringArray& files, int, int) override;
|
||||
/** @internal */
|
||||
void buttonClicked (Button*) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
@ -110,6 +107,11 @@ private:
|
|||
void changed();
|
||||
void updateButtons();
|
||||
|
||||
void addPath();
|
||||
void deleteSelected();
|
||||
void editSelected();
|
||||
void moveSelection (int);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileSearchPathListComponent)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,17 +29,15 @@ namespace juce
|
|||
|
||||
FilenameComponent::FilenameComponent (const String& name,
|
||||
const File& currentFile,
|
||||
const bool canEditFilename,
|
||||
const bool isDirectory,
|
||||
const bool isForSaving,
|
||||
bool canEditFilename,
|
||||
bool isDirectory,
|
||||
bool isForSaving,
|
||||
const String& fileBrowserWildcard,
|
||||
const String& suffix,
|
||||
const String& textWhenNothingSelected)
|
||||
: Component (name),
|
||||
maxRecentFiles (30),
|
||||
isDir (isDirectory),
|
||||
isSaving (isForSaving),
|
||||
isFileDragOver (false),
|
||||
wildcard (fileBrowserWildcard),
|
||||
enforcedSuffix (suffix)
|
||||
{
|
||||
|
|
@ -92,9 +90,8 @@ void FilenameComponent::lookAndFeelChanged()
|
|||
|
||||
addAndMakeVisible (browseButton = getLookAndFeel().createFilenameComponentBrowseButton (browseButtonText));
|
||||
browseButton->setConnectedEdges (Button::ConnectedOnLeft);
|
||||
browseButton->onClick = [this]() { showChooser(); };
|
||||
resized();
|
||||
|
||||
browseButton->addListener (this);
|
||||
}
|
||||
|
||||
void FilenameComponent::setTooltip (const String& newTooltip)
|
||||
|
|
@ -114,7 +111,7 @@ File FilenameComponent::getLocationToBrowse()
|
|||
: getCurrentFile();
|
||||
}
|
||||
|
||||
void FilenameComponent::buttonClicked (Button*)
|
||||
void FilenameComponent::showChooser()
|
||||
{
|
||||
#if JUCE_MODAL_LOOPS_PERMITTED
|
||||
FileChooser fc (isDir ? TRANS ("Choose a new directory")
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ class JUCE_API FilenameComponent : public Component,
|
|||
public SettableTooltipClient,
|
||||
public FileDragAndDropTarget,
|
||||
private AsyncUpdater,
|
||||
private Button::Listener,
|
||||
private ComboBox::Listener
|
||||
{
|
||||
public:
|
||||
|
|
@ -218,14 +217,14 @@ private:
|
|||
ComboBox filenameBox;
|
||||
String lastFilename;
|
||||
ScopedPointer<Button> browseButton;
|
||||
int maxRecentFiles;
|
||||
bool isDir, isSaving, isFileDragOver;
|
||||
int maxRecentFiles = 30;
|
||||
bool isDir, isSaving, isFileDragOver = false;
|
||||
String wildcard, enforcedSuffix, browseButtonText;
|
||||
ListenerList <FilenameComponentListener> listeners;
|
||||
File defaultBrowseFile;
|
||||
|
||||
void comboBoxChanged (ComboBox*) override;
|
||||
void buttonClicked (Button*) override;
|
||||
void showChooser();
|
||||
void handleAsyncUpdate() override;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FilenameComponent)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ SidePanel::SidePanel (StringRef title, int width, bool positionOnLeft,
|
|||
|
||||
addAndMakeVisible (titleLabel);
|
||||
|
||||
dismissButton.addListener (this);
|
||||
dismissButton.onClick = [this]() { showOrHide (false); };
|
||||
addAndMakeVisible (dismissButton);
|
||||
|
||||
Desktop::getInstance().addGlobalMouseListener (this);
|
||||
|
|
@ -202,11 +202,6 @@ void SidePanel::componentMovedOrResized (Component& component, bool wasMoved, bo
|
|||
setBounds (calculateBoundsInParent (component));
|
||||
}
|
||||
|
||||
void SidePanel::buttonClicked (Button*)
|
||||
{
|
||||
showOrHide (false);
|
||||
}
|
||||
|
||||
Rectangle<int> SidePanel::calculateBoundsInParent (Component& parentComp) const
|
||||
{
|
||||
auto parentBounds = parentComp.getBounds();
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ namespace juce
|
|||
*/
|
||||
//==============================================================================
|
||||
class SidePanel : public Component,
|
||||
private ComponentListener,
|
||||
private Button::Listener
|
||||
private ComponentListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -175,7 +174,6 @@ private:
|
|||
//==========================================================================
|
||||
void lookAndFeelChanged() override;
|
||||
void componentMovedOrResized (Component&, bool wasMoved, bool wasResized) override;
|
||||
void buttonClicked (Button*) override;
|
||||
|
||||
Rectangle<int> calculateBoundsInParent (Component&) const;
|
||||
void calculateAndRemoveShadowBounds (Rectangle<int>& bounds);
|
||||
|
|
|
|||
|
|
@ -171,8 +171,7 @@ void TabBarButton::resized()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
class TabbedButtonBar::BehindFrontTabComp : public Component,
|
||||
public Button::Listener
|
||||
class TabbedButtonBar::BehindFrontTabComp : public Component
|
||||
{
|
||||
public:
|
||||
BehindFrontTabComp (TabbedButtonBar& tb) : owner (tb)
|
||||
|
|
@ -190,12 +189,6 @@ public:
|
|||
repaint();
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
{
|
||||
owner.showExtraItemsMenu();
|
||||
}
|
||||
|
||||
private:
|
||||
TabbedButtonBar& owner;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (BehindFrontTabComp)
|
||||
|
|
@ -441,9 +434,9 @@ void TabbedButtonBar::updateTabPositions (bool animate)
|
|||
if (extraTabsButton == nullptr)
|
||||
{
|
||||
addAndMakeVisible (extraTabsButton = lf.createTabBarExtrasButton());
|
||||
extraTabsButton->addListener (behindFrontTab);
|
||||
extraTabsButton->setAlwaysOnTop (true);
|
||||
extraTabsButton->setTriggeredOnMouseDown (true);
|
||||
extraTabsButton->onClick = [this]() { showExtraItemsMenu(); };
|
||||
}
|
||||
|
||||
auto buttonSize = jmin (proportionOfWidth (0.7f), proportionOfHeight (0.7f));
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ BooleanPropertyComponent::BooleanPropertyComponent (const String& name,
|
|||
{
|
||||
addAndMakeVisible (button);
|
||||
button.setClickingTogglesState (false);
|
||||
button.addListener (this);
|
||||
button.onClick = [this]() { setState (! getState()); };
|
||||
}
|
||||
|
||||
BooleanPropertyComponent::BooleanPropertyComponent (const Value& valueToControl,
|
||||
|
|
@ -84,9 +84,4 @@ void BooleanPropertyComponent::refresh()
|
|||
button.setButtonText (button.getToggleState() ? onText : offText);
|
||||
}
|
||||
|
||||
void BooleanPropertyComponent::buttonClicked (Button*)
|
||||
{
|
||||
setState (! getState());
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ namespace juce
|
|||
|
||||
@see PropertyComponent
|
||||
*/
|
||||
class JUCE_API BooleanPropertyComponent : public PropertyComponent,
|
||||
private Button::Listener
|
||||
class JUCE_API BooleanPropertyComponent : public PropertyComponent
|
||||
{
|
||||
protected:
|
||||
//==============================================================================
|
||||
|
|
@ -98,8 +97,6 @@ public:
|
|||
void paint (Graphics&) override;
|
||||
/** @internal */
|
||||
void refresh() override;
|
||||
/** @internal */
|
||||
void buttonClicked (Button*) override;
|
||||
|
||||
private:
|
||||
ToggleButton button;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,12 @@
|
|||
namespace juce
|
||||
{
|
||||
|
||||
ButtonPropertyComponent::ButtonPropertyComponent (const String& name,
|
||||
const bool triggerOnMouseDown)
|
||||
ButtonPropertyComponent::ButtonPropertyComponent (const String& name, bool triggerOnMouseDown)
|
||||
: PropertyComponent (name)
|
||||
{
|
||||
addAndMakeVisible (button);
|
||||
button.setTriggeredOnMouseDown (triggerOnMouseDown);
|
||||
button.addListener (this);
|
||||
button.onClick = [this]() { buttonClicked(); };
|
||||
}
|
||||
|
||||
ButtonPropertyComponent::~ButtonPropertyComponent()
|
||||
|
|
@ -45,9 +44,4 @@ void ButtonPropertyComponent::refresh()
|
|||
button.setButtonText (getButtonText());
|
||||
}
|
||||
|
||||
void ButtonPropertyComponent::buttonClicked (Button*)
|
||||
{
|
||||
buttonClicked();
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ namespace juce
|
|||
|
||||
@see PropertyComponent
|
||||
*/
|
||||
class JUCE_API ButtonPropertyComponent : public PropertyComponent,
|
||||
private Button::Listener
|
||||
class JUCE_API ButtonPropertyComponent : public PropertyComponent
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -66,8 +65,6 @@ public:
|
|||
//==============================================================================
|
||||
/** @internal */
|
||||
void refresh();
|
||||
/** @internal */
|
||||
void buttonClicked (Button*);
|
||||
|
||||
private:
|
||||
TextButton button;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ namespace juce
|
|||
|
||||
class Slider::Pimpl : public AsyncUpdater, // this needs to be public otherwise it will cause an
|
||||
// error when JUCE_DLL_BUILD=1
|
||||
private Button::Listener,
|
||||
private Label::Listener,
|
||||
private Value::Listener
|
||||
{
|
||||
|
|
@ -350,11 +349,10 @@ public:
|
|||
JUCE_DECLARE_NON_COPYABLE (DragInProgress)
|
||||
};
|
||||
|
||||
void buttonClicked (Button* button) override
|
||||
void incrementOrDecrement (double delta)
|
||||
{
|
||||
if (style == IncDecButtons)
|
||||
{
|
||||
auto delta = (button == incButton) ? interval : -interval;
|
||||
auto newValue = owner.snapValue (getValue() + delta, notDragging);
|
||||
|
||||
if (currentDrag != nullptr)
|
||||
|
|
@ -569,10 +567,10 @@ public:
|
|||
if (style == IncDecButtons)
|
||||
{
|
||||
owner.addAndMakeVisible (incButton = lf.createSliderButton (owner, true));
|
||||
incButton->addListener (this);
|
||||
incButton->onClick = [this]() { incrementOrDecrement (interval); };
|
||||
|
||||
owner.addAndMakeVisible (decButton = lf.createSliderButton (owner, false));
|
||||
decButton->addListener (this);
|
||||
decButton->onClick = [this]() { incrementOrDecrement (-interval); };
|
||||
|
||||
if (incDecButtonMode != incDecButtonsNotDraggable)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ const char* const Toolbar::toolbarDragDescriptor = "_toolbarItem_";
|
|||
class Toolbar::Spacer : public ToolbarItemComponent
|
||||
{
|
||||
public:
|
||||
Spacer (const int itemId_, const float fixedSize_, const bool drawBar_)
|
||||
: ToolbarItemComponent (itemId_, String(), false),
|
||||
fixedSize (fixedSize_),
|
||||
drawBar (drawBar_)
|
||||
Spacer (int itemID, float sizeToUse, bool shouldDrawBar)
|
||||
: ToolbarItemComponent (itemID, {}, false),
|
||||
fixedSize (sizeToUse),
|
||||
drawBar (shouldDrawBar)
|
||||
{
|
||||
setWantsKeyboardFocus (false);
|
||||
}
|
||||
|
|
@ -78,14 +78,14 @@ public:
|
|||
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
const int w = getWidth();
|
||||
const int h = getHeight();
|
||||
auto w = getWidth();
|
||||
auto h = getHeight();
|
||||
|
||||
if (drawBar)
|
||||
{
|
||||
g.setColour (findColour (Toolbar::separatorColourId, true));
|
||||
|
||||
const float thickness = 0.2f;
|
||||
auto thickness = 0.2f;
|
||||
|
||||
if (isToolbarVertical())
|
||||
g.fillRect (w * 0.1f, h * (0.5f - thickness * 0.5f), w * 0.8f, h * thickness);
|
||||
|
|
@ -97,8 +97,8 @@ public:
|
|||
{
|
||||
g.setColour (findColour (Toolbar::separatorColourId, true));
|
||||
|
||||
const int indentX = jmin (2, (w - 3) / 2);
|
||||
const int indentY = jmin (2, (h - 3) / 2);
|
||||
auto indentX = jmin (2, (w - 3) / 2);
|
||||
auto indentY = jmin (2, (h - 3) / 2);
|
||||
g.drawRect (indentX, indentY, w - indentX * 2, h - indentY * 2, 1);
|
||||
|
||||
if (fixedSize <= 0)
|
||||
|
|
@ -137,8 +137,8 @@ public:
|
|||
}
|
||||
|
||||
Path p;
|
||||
p.addArrow (Line<float> (x1, y1, x2, y2), 1.5f, hw, hl);
|
||||
p.addArrow (Line<float> (x3, y3, x4, y4), 1.5f, hw, hl);
|
||||
p.addArrow ({ x1, y1, x2, y2 }, 1.5f, hw, hl);
|
||||
p.addArrow ({ x3, y3, x4, y4 }, 1.5f, hw, hl);
|
||||
g.fillPath (p);
|
||||
}
|
||||
}
|
||||
|
|
@ -155,14 +155,14 @@ private:
|
|||
class Toolbar::MissingItemsComponent : public PopupMenu::CustomComponent
|
||||
{
|
||||
public:
|
||||
MissingItemsComponent (Toolbar& bar, const int h)
|
||||
MissingItemsComponent (Toolbar& bar, int h)
|
||||
: PopupMenu::CustomComponent (true),
|
||||
owner (&bar),
|
||||
height (h)
|
||||
{
|
||||
for (int i = bar.items.size(); --i >= 0;)
|
||||
{
|
||||
ToolbarItemComponent* const tc = bar.items.getUnchecked(i);
|
||||
auto* tc = bar.items.getUnchecked(i);
|
||||
|
||||
if (dynamic_cast<Spacer*> (tc) == nullptr && ! tc->isVisible())
|
||||
{
|
||||
|
|
@ -183,7 +183,7 @@ public:
|
|||
if (auto* tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i)))
|
||||
{
|
||||
tc->setVisible (false);
|
||||
const int index = oldIndexes.removeAndReturn (i);
|
||||
auto index = oldIndexes.removeAndReturn (i);
|
||||
owner->addChildComponent (tc, index);
|
||||
--i;
|
||||
}
|
||||
|
|
@ -196,8 +196,8 @@ public:
|
|||
void layout (const int preferredWidth)
|
||||
{
|
||||
const int indent = 8;
|
||||
int x = indent;
|
||||
int y = indent;
|
||||
auto x = indent;
|
||||
auto y = indent;
|
||||
int maxX = 0;
|
||||
|
||||
for (auto* c : getChildren())
|
||||
|
|
@ -242,14 +242,11 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
Toolbar::Toolbar()
|
||||
: vertical (false),
|
||||
isEditingActive (false),
|
||||
toolbarStyle (Toolbar::iconsOnly)
|
||||
{
|
||||
addChildComponent (missingItemsButton = getLookAndFeel().createToolbarMissingItemsButton (*this));
|
||||
|
||||
missingItemsButton->setAlwaysOnTop (true);
|
||||
missingItemsButton->addListener (this);
|
||||
missingItemsButton->onClick = [this]() { showMissingItems(); };
|
||||
}
|
||||
|
||||
Toolbar::~Toolbar()
|
||||
|
|
@ -288,7 +285,7 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory,
|
|||
// An ID can't be zero - this might indicate a mistake somewhere?
|
||||
jassert (itemId != 0);
|
||||
|
||||
if (ToolbarItemComponent* const tc = createItem (factory, itemId))
|
||||
if (auto* tc = createItem (factory, itemId))
|
||||
{
|
||||
#if JUCE_DEBUG
|
||||
Array<int> allowedIds;
|
||||
|
|
@ -304,9 +301,7 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory,
|
|||
}
|
||||
}
|
||||
|
||||
void Toolbar::addItem (ToolbarItemFactory& factory,
|
||||
const int itemId,
|
||||
const int insertIndex)
|
||||
void Toolbar::addItem (ToolbarItemFactory& factory, int itemId, int insertIndex)
|
||||
{
|
||||
addItemInternal (factory, itemId, insertIndex);
|
||||
resized();
|
||||
|
|
@ -319,8 +314,8 @@ void Toolbar::addDefaultItems (ToolbarItemFactory& factoryToUse)
|
|||
|
||||
clear();
|
||||
|
||||
for (int i = 0; i < ids.size(); ++i)
|
||||
addItemInternal (factoryToUse, ids.getUnchecked (i), -1);
|
||||
for (auto i : ids)
|
||||
addItemInternal (factoryToUse, i, -1);
|
||||
|
||||
resized();
|
||||
}
|
||||
|
|
@ -333,7 +328,7 @@ void Toolbar::removeToolbarItem (const int itemIndex)
|
|||
|
||||
ToolbarItemComponent* Toolbar::removeAndReturnItem (const int itemIndex)
|
||||
{
|
||||
if (ToolbarItemComponent* const tc = items.removeAndReturn (itemIndex))
|
||||
if (auto* tc = items.removeAndReturn (itemIndex))
|
||||
{
|
||||
removeChildComponent (tc);
|
||||
resized();
|
||||
|
|
@ -350,7 +345,7 @@ int Toolbar::getNumItems() const noexcept
|
|||
|
||||
int Toolbar::getItemId (const int itemIndex) const noexcept
|
||||
{
|
||||
if (ToolbarItemComponent* const tc = getItemComponent (itemIndex))
|
||||
if (auto* tc = getItemComponent (itemIndex))
|
||||
return tc->getItemId();
|
||||
|
||||
return 0;
|
||||
|
|
@ -367,7 +362,7 @@ ToolbarItemComponent* Toolbar::getNextActiveComponent (int index, const int delt
|
|||
{
|
||||
index += delta;
|
||||
|
||||
if (ToolbarItemComponent* const tc = getItemComponent (index))
|
||||
if (auto* tc = getItemComponent (index))
|
||||
{
|
||||
if (tc->isActive)
|
||||
return tc;
|
||||
|
|
@ -409,8 +404,8 @@ bool Toolbar::restoreFromString (ToolbarItemFactory& factoryToUse,
|
|||
|
||||
clear();
|
||||
|
||||
for (int i = 0; i < tokens.size(); ++i)
|
||||
addItemInternal (factoryToUse, tokens[i].getIntValue(), -1);
|
||||
for (auto& t : tokens)
|
||||
addItemInternal (factoryToUse, t.getIntValue(), -1);
|
||||
|
||||
resized();
|
||||
return true;
|
||||
|
|
@ -446,22 +441,20 @@ void Toolbar::resized()
|
|||
updateAllItemPositions (false);
|
||||
}
|
||||
|
||||
void Toolbar::updateAllItemPositions (const bool animate)
|
||||
void Toolbar::updateAllItemPositions (bool animate)
|
||||
{
|
||||
if (getWidth() > 0 && getHeight() > 0)
|
||||
{
|
||||
StretchableObjectResizer resizer;
|
||||
|
||||
for (int i = 0; i < items.size(); ++i)
|
||||
for (auto* tc : items)
|
||||
{
|
||||
ToolbarItemComponent* const tc = items.getUnchecked(i);
|
||||
|
||||
tc->setEditingMode (isEditingActive ? ToolbarItemComponent::editableOnToolbar
|
||||
: ToolbarItemComponent::normalMode);
|
||||
|
||||
tc->setStyle (toolbarStyle);
|
||||
|
||||
Spacer* const spacer = dynamic_cast<Spacer*> (tc);
|
||||
auto* spacer = dynamic_cast<Spacer*> (tc);
|
||||
|
||||
int preferredSize = 1, minSize = 1, maxSize = 1;
|
||||
|
||||
|
|
@ -488,7 +481,7 @@ void Toolbar::updateAllItemPositions (const bool animate)
|
|||
|
||||
const bool itemsOffTheEnd = totalLength > getLength();
|
||||
|
||||
const int extrasButtonSize = getThickness() / 2;
|
||||
auto extrasButtonSize = getThickness() / 2;
|
||||
missingItemsButton->setSize (extrasButtonSize, extrasButtonSize);
|
||||
missingItemsButton->setVisible (itemsOffTheEnd);
|
||||
missingItemsButton->setEnabled (! isEditingActive);
|
||||
|
|
@ -500,26 +493,26 @@ void Toolbar::updateAllItemPositions (const bool animate)
|
|||
missingItemsButton->setCentrePosition (getWidth() - 4 - extrasButtonSize / 2,
|
||||
getHeight() / 2);
|
||||
|
||||
const int maxLength = itemsOffTheEnd ? (vertical ? missingItemsButton->getY()
|
||||
: missingItemsButton->getX()) - 4
|
||||
: getLength();
|
||||
auto maxLength = itemsOffTheEnd ? (vertical ? missingItemsButton->getY()
|
||||
: missingItemsButton->getX()) - 4
|
||||
: getLength();
|
||||
|
||||
int pos = 0, activeIndex = 0;
|
||||
for (int i = 0; i < items.size(); ++i)
|
||||
{
|
||||
ToolbarItemComponent* const tc = items.getUnchecked(i);
|
||||
|
||||
for (auto* tc : items)
|
||||
{
|
||||
if (tc->isActive)
|
||||
{
|
||||
const int size = (int) resizer.getItemSize (activeIndex++);
|
||||
auto size = (int) resizer.getItemSize (activeIndex++);
|
||||
|
||||
Rectangle<int> newBounds;
|
||||
|
||||
if (vertical)
|
||||
newBounds.setBounds (0, pos, getWidth(), size);
|
||||
else
|
||||
newBounds.setBounds (pos, 0, size, getHeight());
|
||||
|
||||
ComponentAnimator& animator = Desktop::getInstance().getAnimator();
|
||||
auto& animator = Desktop::getInstance().getAnimator();
|
||||
|
||||
if (animate)
|
||||
{
|
||||
|
|
@ -541,7 +534,7 @@ void Toolbar::updateAllItemPositions (const bool animate)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void Toolbar::buttonClicked (Button*)
|
||||
void Toolbar::showMissingItems()
|
||||
{
|
||||
jassert (missingItemsButton->isShowing());
|
||||
|
||||
|
|
@ -561,13 +554,13 @@ bool Toolbar::isInterestedInDragSource (const SourceDetails& dragSourceDetails)
|
|||
|
||||
void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
|
||||
{
|
||||
if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
{
|
||||
if (! items.contains (tc))
|
||||
{
|
||||
if (tc->getEditingMode() == ToolbarItemComponent::editableOnPalette)
|
||||
{
|
||||
if (ToolbarItemPalette* const palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
|
||||
if (auto* palette = tc->findParentComponentOfClass<ToolbarItemPalette>())
|
||||
palette->replaceComponent (*tc);
|
||||
}
|
||||
else
|
||||
|
|
@ -584,18 +577,18 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
|
|||
|
||||
for (int i = getNumItems(); --i >= 0;)
|
||||
{
|
||||
const int currentIndex = items.indexOf (tc);
|
||||
int newIndex = currentIndex;
|
||||
auto currentIndex = items.indexOf (tc);
|
||||
auto newIndex = currentIndex;
|
||||
|
||||
const int dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
|
||||
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
|
||||
const int dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
|
||||
auto dragObjectLeft = vertical ? (dragSourceDetails.localPosition.getY() - tc->dragOffsetY)
|
||||
: (dragSourceDetails.localPosition.getX() - tc->dragOffsetX);
|
||||
auto dragObjectRight = dragObjectLeft + (vertical ? tc->getHeight() : tc->getWidth());
|
||||
|
||||
const Rectangle<int> current (animator.getComponentDestination (getChildComponent (newIndex)));
|
||||
auto current = animator.getComponentDestination (getChildComponent (newIndex));
|
||||
|
||||
if (ToolbarItemComponent* const prev = getNextActiveComponent (newIndex, -1))
|
||||
if (auto* prev = getNextActiveComponent (newIndex, -1))
|
||||
{
|
||||
const Rectangle<int> previousPos (animator.getComponentDestination (prev));
|
||||
auto previousPos = animator.getComponentDestination (prev);
|
||||
|
||||
if (std::abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX()))
|
||||
< std::abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight())))
|
||||
|
|
@ -604,9 +597,9 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
|
|||
}
|
||||
}
|
||||
|
||||
if (ToolbarItemComponent* const next = getNextActiveComponent (newIndex, 1))
|
||||
if (auto* next = getNextActiveComponent (newIndex, 1))
|
||||
{
|
||||
const Rectangle<int> nextPos (animator.getComponentDestination (next));
|
||||
auto nextPos = animator.getComponentDestination (next);
|
||||
|
||||
if (std::abs (dragObjectLeft - (vertical ? current.getY() : current.getX()))
|
||||
> std::abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight())))
|
||||
|
|
@ -629,7 +622,7 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
|
|||
|
||||
void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
|
||||
{
|
||||
if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
{
|
||||
if (isParentOf (tc))
|
||||
{
|
||||
|
|
@ -642,7 +635,7 @@ void Toolbar::itemDragExit (const SourceDetails& dragSourceDetails)
|
|||
|
||||
void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
|
||||
{
|
||||
if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
if (auto* tc = dynamic_cast<ToolbarItemComponent*> (dragSourceDetails.sourceComponent.get()))
|
||||
tc->setState (Button::buttonNormal);
|
||||
}
|
||||
|
||||
|
|
@ -680,8 +673,8 @@ public:
|
|||
|
||||
void positionNearBar()
|
||||
{
|
||||
const Rectangle<int> screenSize (toolbar.getParentMonitorArea());
|
||||
Point<int> pos (toolbar.getScreenPosition());
|
||||
auto screenSize = toolbar.getParentMonitorArea();
|
||||
auto pos = toolbar.getScreenPosition();
|
||||
const int gap = 8;
|
||||
|
||||
if (toolbar.isVertical())
|
||||
|
|
@ -708,16 +701,15 @@ private:
|
|||
Toolbar& toolbar;
|
||||
|
||||
class CustomiserPanel : public Component,
|
||||
private ComboBox::Listener,
|
||||
private Button::Listener
|
||||
private ComboBox::Listener
|
||||
{
|
||||
public:
|
||||
CustomiserPanel (ToolbarItemFactory& tbf, Toolbar& bar, int optionFlags)
|
||||
: factory (tbf), toolbar (bar), palette (tbf, bar),
|
||||
instructions (String(), TRANS ("You can drag the items above and drop them onto a toolbar to add them.")
|
||||
+ "\n\n"
|
||||
+ TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
|
||||
defaultButton (TRANS ("Restore to default set of items"))
|
||||
: factory (tbf), toolbar (bar), palette (tbf, bar),
|
||||
instructions ({}, TRANS ("You can drag the items above and drop them onto a toolbar to add them.")
|
||||
+ "\n\n"
|
||||
+ TRANS ("Items on the toolbar can also be dragged around to change their order, or dragged off the edge to delete them.")),
|
||||
defaultButton (TRANS ("Restore to default set of items"))
|
||||
{
|
||||
addAndMakeVisible (palette);
|
||||
|
||||
|
|
@ -748,7 +740,7 @@ private:
|
|||
if ((optionFlags & Toolbar::showResetToDefaultsButton) != 0)
|
||||
{
|
||||
addAndMakeVisible (defaultButton);
|
||||
defaultButton.addListener (this);
|
||||
defaultButton.onClick = [this]() { toolbar.addDefaultItems (factory); };
|
||||
}
|
||||
|
||||
addAndMakeVisible (instructions);
|
||||
|
|
@ -769,16 +761,11 @@ private:
|
|||
palette.resized(); // to make it update the styles
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
{
|
||||
toolbar.addDefaultItems (factory);
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
Colour background;
|
||||
|
||||
if (DialogWindow* const dw = findParentComponentOfClass<DialogWindow>())
|
||||
if (auto* dw = findParentComponentOfClass<DialogWindow>())
|
||||
background = dw->getBackgroundColour();
|
||||
|
||||
g.setColour (background.contrasting().withAlpha (0.3f));
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ class ToolbarItemFactory;
|
|||
*/
|
||||
class JUCE_API Toolbar : public Component,
|
||||
public DragAndDropContainer,
|
||||
public DragAndDropTarget,
|
||||
private Button::Listener
|
||||
public DragAndDropTarget
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
|
@ -312,15 +311,15 @@ public:
|
|||
private:
|
||||
//==============================================================================
|
||||
ScopedPointer<Button> missingItemsButton;
|
||||
bool vertical, isEditingActive;
|
||||
ToolbarItemStyle toolbarStyle;
|
||||
bool vertical = false, isEditingActive = false;
|
||||
ToolbarItemStyle toolbarStyle = iconsOnly;
|
||||
class MissingItemsComponent;
|
||||
friend class MissingItemsComponent;
|
||||
OwnedArray<ToolbarItemComponent> items;
|
||||
class Spacer;
|
||||
class CustomisationDialog;
|
||||
|
||||
void buttonClicked (Button*) override;
|
||||
void showMissingItems();
|
||||
void addItemInternal (ToolbarItemFactory& factory, int itemId, int insertIndex);
|
||||
|
||||
ToolbarItemComponent* getNextActiveComponent (int index, int delta) const;
|
||||
|
|
|
|||
|
|
@ -336,7 +336,6 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
class KeyMappingEditorComponent::TopLevelItem : public TreeViewItem,
|
||||
public Button::Listener,
|
||||
private ChangeListener
|
||||
{
|
||||
public:
|
||||
|
|
@ -372,27 +371,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void resetToDefaultsCallback (int result, KeyMappingEditorComponent* owner)
|
||||
{
|
||||
if (result != 0 && owner != nullptr)
|
||||
owner->getMappings().resetToDefaultMappings();
|
||||
}
|
||||
|
||||
void buttonClicked (Button*) override
|
||||
{
|
||||
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
|
||||
TRANS("Reset to defaults"),
|
||||
TRANS("Are you sure you want to reset all the key-mappings to their default state?"),
|
||||
TRANS("Reset"),
|
||||
String(),
|
||||
&owner,
|
||||
ModalCallbackFunction::forComponent (resetToDefaultsCallback, &owner));
|
||||
}
|
||||
|
||||
private:
|
||||
KeyMappingEditorComponent& owner;
|
||||
};
|
||||
|
||||
static void resetKeyMappingsToDefaultsCallback (int result, KeyMappingEditorComponent* owner)
|
||||
{
|
||||
if (result != 0 && owner != nullptr)
|
||||
owner->getMappings().resetToDefaultMappings();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappingManager,
|
||||
|
|
@ -405,7 +392,16 @@ KeyMappingEditorComponent::KeyMappingEditorComponent (KeyPressMappingSet& mappin
|
|||
if (showResetToDefaultButton)
|
||||
{
|
||||
addAndMakeVisible (resetButton);
|
||||
resetButton.addListener (treeItem.get());
|
||||
|
||||
resetButton.onClick = [this]()
|
||||
{
|
||||
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
|
||||
TRANS("Reset to defaults"),
|
||||
TRANS("Are you sure you want to reset all the key-mappings to their default state?"),
|
||||
TRANS("Reset"),
|
||||
{}, this,
|
||||
ModalCallbackFunction::forComponent (resetKeyMappingsToDefaultsCallback, this));
|
||||
};
|
||||
}
|
||||
|
||||
addAndMakeVisible (tree);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void PreferencesPanel::addSettingsPage (const String& title,
|
|||
const Drawable* overIcon,
|
||||
const Drawable* downIcon)
|
||||
{
|
||||
DrawableButton* const button = new DrawableButton (title, DrawableButton::ImageAboveTextLabel);
|
||||
auto* button = new DrawableButton (title, DrawableButton::ImageAboveTextLabel);
|
||||
buttons.add (button);
|
||||
|
||||
button->setImages (icon, overIcon, downIcon);
|
||||
|
|
@ -69,7 +69,7 @@ void PreferencesPanel::addSettingsPage (const String& title,
|
|||
setCurrentPage (title);
|
||||
}
|
||||
|
||||
void PreferencesPanel::addSettingsPage (const String& title, const void* imageData, const int imageDataSize)
|
||||
void PreferencesPanel::addSettingsPage (const String& title, const void* imageData, int imageDataSize)
|
||||
{
|
||||
DrawableImage icon, iconOver, iconDown;
|
||||
icon.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
|
||||
|
|
@ -131,11 +131,11 @@ void PreferencesPanel::setCurrentPage (const String& pageName)
|
|||
resized();
|
||||
}
|
||||
|
||||
for (int i = 0; i < buttons.size(); ++i)
|
||||
for (auto* b : buttons)
|
||||
{
|
||||
if (buttons.getUnchecked(i)->getName() == pageName)
|
||||
if (b->getName() == pageName)
|
||||
{
|
||||
buttons.getUnchecked(i)->setToggleState (true, dontSendNotification);
|
||||
b->setToggleState (true, dontSendNotification);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -144,11 +144,11 @@ void PreferencesPanel::setCurrentPage (const String& pageName)
|
|||
|
||||
void PreferencesPanel::buttonClicked (Button*)
|
||||
{
|
||||
for (int i = 0; i < buttons.size(); ++i)
|
||||
for (auto* b : buttons)
|
||||
{
|
||||
if (buttons.getUnchecked(i)->getToggleState())
|
||||
if (b->getToggleState())
|
||||
{
|
||||
setCurrentPage (buttons.getUnchecked(i)->getName());
|
||||
setCurrentPage (b->getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue