Double-click visualiser to make fullscreen

pull/193/head v2.0.4
James Ball 2023-12-29 13:01:09 +00:00 zatwierdzone przez James H Ball
rodzic 53d04d9c23
commit 95ccbacc42
7 zmienionych plików z 95 dodań i 21 usunięć

Wyświetl plik

@ -90,7 +90,30 @@ MainComponent::MainComponent(OscirenderAudioProcessor& p, OscirenderAudioProcess
createFile.triggerClick(); createFile.triggerClick();
}; };
addAndMakeVisible(visualiser); if (!pluginEditor.visualiserFullScreen) {
addAndMakeVisible(pluginEditor.visualiser);
}
pluginEditor.visualiser.setFullScreenCallback([this](FullScreenMode mode) {
if (mode == FullScreenMode::TOGGLE) {
pluginEditor.visualiserFullScreen = !pluginEditor.visualiserFullScreen;
} else if (mode == FullScreenMode::FULL_SCREEN) {
pluginEditor.visualiserFullScreen = true;
} else if (mode == FullScreenMode::MAIN_COMPONENT) {
pluginEditor.visualiserFullScreen = false;
}
if (pluginEditor.visualiserFullScreen) {
removeChildComponent(&pluginEditor.visualiser);
pluginEditor.addAndMakeVisible(pluginEditor.visualiser);
} else {
pluginEditor.removeChildComponent(&pluginEditor.visualiser);
addAndMakeVisible(pluginEditor.visualiser);
}
pluginEditor.resized();
pluginEditor.repaint();
resized();
repaint();
});
addAndMakeVisible(openOscilloscope); addAndMakeVisible(openOscilloscope);
openOscilloscope.onClick = [this] { openOscilloscope.onClick = [this] {
@ -151,15 +174,18 @@ void MainComponent::resized() {
frequencyLabel.setBounds(bounds.removeFromTop(20)); frequencyLabel.setBounds(bounds.removeFromTop(20));
bounds.removeFromTop(padding); bounds.removeFromTop(padding);
// openOscilloscope.setBounds(bounds.removeFromBottom(buttonHeight).withSizeKeepingCentre(160, buttonHeight)); if (!pluginEditor.visualiserFullScreen) {
auto minDim = juce::jmin(bounds.getWidth(), bounds.getHeight()); auto minDim = juce::jmin(bounds.getWidth(), bounds.getHeight());
visualiser.setBounds(bounds.withSizeKeepingCentre(minDim, minDim)); pluginEditor.visualiser.setBounds(bounds.withSizeKeepingCentre(minDim, minDim));
}
} }
void MainComponent::paint(juce::Graphics& g) { void MainComponent::paint(juce::Graphics& g) {
juce::GroupComponent::paint(g); juce::GroupComponent::paint(g);
// add drop shadow to the visualiser if (!pluginEditor.visualiserFullScreen) {
auto dc = juce::DropShadow(juce::Colours::black, 30, juce::Point<int>(0, 0)); // add drop shadow to the visualiser
dc.drawForRectangle(g, visualiser.getBounds()); auto dc = juce::DropShadow(juce::Colours::black, 30, juce::Point<int>(0, 0));
dc.drawForRectangle(g, pluginEditor.visualiser.getBounds());
}
} }

Wyświetl plik

@ -32,7 +32,6 @@ private:
juce::ComboBox fileType; juce::ComboBox fileType;
juce::TextButton createFile{"Create File"}; juce::TextButton createFile{"Create File"};
VisualiserComponent visualiser{2, audioProcessor};
juce::TextButton openOscilloscope{"Open Oscilloscope"}; juce::TextButton openOscilloscope{"Open Oscilloscope"};
juce::Label frequencyLabel; juce::Label frequencyLabel;

Wyświetl plik

@ -80,6 +80,10 @@ OscirenderAudioProcessorEditor::OscirenderAudioProcessorEditor(OscirenderAudioPr
addAndMakeVisible(settings); addAndMakeVisible(settings);
addAndMakeVisible(resizerBar); addAndMakeVisible(resizerBar);
if (visualiserFullScreen) {
addAndMakeVisible(visualiser);
}
} }
OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() { OscirenderAudioProcessorEditor::~OscirenderAudioProcessorEditor() {
@ -130,6 +134,12 @@ void OscirenderAudioProcessorEditor::paint(juce::Graphics& g) {
void OscirenderAudioProcessorEditor::resized() { void OscirenderAudioProcessorEditor::resized() {
auto area = getLocalBounds(); auto area = getLocalBounds();
if (visualiserFullScreen) {
visualiser.setBounds(area);
return;
}
if (!usingNativeMenuBar) { if (!usingNativeMenuBar) {
menuBar.setBounds(area.removeFromTop(25)); menuBar.setBounds(area.removeFromTop(25));
} }
@ -327,7 +337,7 @@ void OscirenderAudioProcessorEditor::updateCodeDocument() {
} }
bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) { bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) {
bool consumeKey1 = true; bool consumeKey = false;
{ {
juce::SpinLock::ScopedLockType parserLock(audioProcessor.parsersLock); juce::SpinLock::ScopedLockType parserLock(audioProcessor.parsersLock);
juce::SpinLock::ScopedLockType effectsLock(audioProcessor.effectsLock); juce::SpinLock::ScopedLockType effectsLock(audioProcessor.effectsLock);
@ -344,6 +354,7 @@ bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) {
} }
changedFile = true; changedFile = true;
} }
consumeKey = true;
} else if (key.getTextCharacter() == 'k') { } else if (key.getTextCharacter() == 'k') {
if (numFiles > 1) { if (numFiles > 1) {
currentFile--; currentFile--;
@ -352,8 +363,7 @@ bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) {
} }
changedFile = true; changedFile = true;
} }
} else { consumeKey = true;
consumeKey1 = false;
} }
if (changedFile) { if (changedFile) {
@ -362,7 +372,6 @@ bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) {
} }
} }
bool consumeKey2 = true;
if (key.isKeyCode(juce::KeyPress::escapeKey)) { if (key.isKeyCode(juce::KeyPress::escapeKey)) {
settings.disableMouseRotation(); settings.disableMouseRotation();
} else if (key.getModifiers().isCommandDown() && key.getModifiers().isShiftDown() && key.getKeyCode() == 'S') { } else if (key.getModifiers().isCommandDown() && key.getModifiers().isShiftDown() && key.getKeyCode() == 'S') {
@ -371,11 +380,9 @@ bool OscirenderAudioProcessorEditor::keyPressed(const juce::KeyPress& key) {
saveProject(); saveProject();
} else if (key.getModifiers().isCommandDown() && key.getKeyCode() == 'O') { } else if (key.getModifiers().isCommandDown() && key.getKeyCode() == 'O') {
openProject(); openProject();
} else { }
consumeKey2 = false;
}
return consumeKey1 || consumeKey2; return consumeKey;
} }
void OscirenderAudioProcessorEditor::newProject() { void OscirenderAudioProcessorEditor::newProject() {

Wyświetl plik

@ -35,14 +35,19 @@ public:
void openAudioSettings(); void openAudioSettings();
void resetToDefault(); void resetToDefault();
std::atomic<bool> editingPerspective = false;
OscirenderLookAndFeel lookAndFeel;
private: private:
OscirenderAudioProcessor& audioProcessor; OscirenderAudioProcessor& audioProcessor;
public:
OscirenderLookAndFeel lookAndFeel;
std::atomic<bool> editingPerspective = false;
VisualiserComponent visualiser{2, audioProcessor};
std::atomic<bool> visualiserFullScreen = false;
SettingsComponent settings{audioProcessor, *this}; SettingsComponent settings{audioProcessor, *this};
VolumeComponent volume{audioProcessor}; VolumeComponent volume{audioProcessor};
std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments; std::vector<std::shared_ptr<juce::CodeDocument>> codeDocuments;
std::vector<std::shared_ptr<ErrorCodeEditorComponent>> codeEditors; std::vector<std::shared_ptr<ErrorCodeEditorComponent>> codeEditors;
juce::CodeEditorComponent::ColourScheme colourScheme; juce::CodeEditorComponent::ColourScheme colourScheme;

Wyświetl plik

@ -8,6 +8,9 @@ VisualiserComponent::VisualiserComponent(int numChannels, OscirenderAudioProcess
roughness.textBox.setValue(4); roughness.textBox.setValue(4);
intensity.textBox.setValue(1.0); intensity.textBox.setValue(1.0);
setMouseCursor(juce::MouseCursor::PointingHandCursor);
setWantsKeyboardFocus(true);
} }
VisualiserComponent::~VisualiserComponent() { VisualiserComponent::~VisualiserComponent() {
@ -15,6 +18,17 @@ VisualiserComponent::~VisualiserComponent() {
stopThread(1000); stopThread(1000);
} }
void VisualiserComponent::setFullScreenCallback(std::function<void(FullScreenMode)> callback) {
fullScreenCallback = callback;
}
void VisualiserComponent::mouseDoubleClick(const juce::MouseEvent& event) {
if (fullScreenCallback) {
fullScreenCallback(FullScreenMode::TOGGLE);
}
grabKeyboardFocus();
}
void VisualiserComponent::setBuffer(std::vector<float>& newBuffer) { void VisualiserComponent::setBuffer(std::vector<float>& newBuffer) {
juce::CriticalSection::ScopedLockType scope(lock); juce::CriticalSection::ScopedLockType scope(lock);
buffer.clear(); buffer.clear();
@ -94,6 +108,17 @@ void VisualiserComponent::mouseDown(const juce::MouseEvent& event) {
} }
} }
bool VisualiserComponent::keyPressed(const juce::KeyPress& key) {
if (key.isKeyCode(juce::KeyPress::escapeKey)) {
if (fullScreenCallback) {
fullScreenCallback(FullScreenMode::MAIN_COMPONENT);
}
return true;
}
return false;
}
void VisualiserComponent::paintChannel(juce::Graphics& g, juce::Rectangle<float> area, int channel) { void VisualiserComponent::paintChannel(juce::Graphics& g, juce::Rectangle<float> area, int channel) {
juce::Path path; juce::Path path;

Wyświetl plik

@ -7,11 +7,19 @@
#include "../PluginProcessor.h" #include "../PluginProcessor.h"
#include "LabelledTextBox.h" #include "LabelledTextBox.h"
enum class FullScreenMode {
TOGGLE,
FULL_SCREEN,
MAIN_COMPONENT,
};
class VisualiserComponent : public juce::Component, public juce::Timer, public juce::Thread, public juce::MouseListener { class VisualiserComponent : public juce::Component, public juce::Timer, public juce::Thread, public juce::MouseListener {
public: public:
VisualiserComponent(int numChannels, OscirenderAudioProcessor& p); VisualiserComponent(int numChannels, OscirenderAudioProcessor& p);
~VisualiserComponent() override; ~VisualiserComponent() override;
void setFullScreenCallback(std::function<void(FullScreenMode)> callback);
void mouseDoubleClick(const juce::MouseEvent& event) override;
void setBuffer(std::vector<float>& buffer); void setBuffer(std::vector<float>& buffer);
void setColours(juce::Colour backgroundColour, juce::Colour waveformColour); void setColours(juce::Colour backgroundColour, juce::Colour waveformColour);
void paintChannel(juce::Graphics&, juce::Rectangle<float> bounds, int channel); void paintChannel(juce::Graphics&, juce::Rectangle<float> bounds, int channel);
@ -20,6 +28,8 @@ public:
void timerCallback() override; void timerCallback() override;
void run() override; void run() override;
void mouseDown(const juce::MouseEvent& event) override; void mouseDown(const juce::MouseEvent& event) override;
bool keyPressed(const juce::KeyPress& key) override;
private: private:
const double BUFFER_LENGTH_SECS = 0.02; const double BUFFER_LENGTH_SECS = 0.02;
@ -41,6 +51,8 @@ private:
std::atomic<bool> active = true; std::atomic<bool> active = true;
std::shared_ptr<BufferConsumer> consumer; std::shared_ptr<BufferConsumer> consumer;
std::function<void(FullScreenMode)> fullScreenCallback;
void resetBuffer(); void resetBuffer();

Wyświetl plik

@ -5,7 +5,7 @@
pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn" pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn"
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender" pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
cppLanguageStandard="20" projectLineFeed="&#10;" headerPath="./include" cppLanguageStandard="20" projectLineFeed="&#10;" headerPath="./include"
version="2.0.3" companyName="James H Ball" companyWebsite="https://osci-render.com" version="2.0.4" companyName="James H Ball" companyWebsite="https://osci-render.com"
companyEmail="james@ball.sh"> companyEmail="james@ball.sh">
<MAINGROUP id="j5Ge2T" name="osci-render"> <MAINGROUP id="j5Ge2T" name="osci-render">
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources"> <GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">