kopia lustrzana https://github.com/jameshball/osci-render
Add fullscreen and settings cog to visualiser and remove tooltip
rodzic
a047beae37
commit
51387642af
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" /></svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 986 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z" /></svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 165 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z" /></svg>
|
Po Szerokość: | Wysokość: | Rozmiar: 211 B |
|
@ -19,6 +19,22 @@ VisualiserComponent::VisualiserComponent(int numChannels, OscirenderAudioProcess
|
|||
|
||||
setMouseCursor(juce::MouseCursor::PointingHandCursor);
|
||||
setWantsKeyboardFocus(true);
|
||||
|
||||
addChildComponent(fullScreenButton);
|
||||
addChildComponent(settingsButton);
|
||||
|
||||
fullScreenButton.onClick = [this]() {
|
||||
enableFullScreen();
|
||||
};
|
||||
|
||||
settingsButton.onClick = [this]() {
|
||||
juce::PopupMenu menu;
|
||||
|
||||
menu.addCustomItem(1, roughness, 160, 40, false);
|
||||
menu.addCustomItem(1, intensity, 160, 40, false);
|
||||
|
||||
menu.showMenuAsync(juce::PopupMenu::Options(), [this](int result) {});
|
||||
};
|
||||
}
|
||||
|
||||
VisualiserComponent::~VisualiserComponent() {
|
||||
|
@ -30,13 +46,17 @@ void VisualiserComponent::setFullScreenCallback(std::function<void(FullScreenMod
|
|||
fullScreenCallback = callback;
|
||||
}
|
||||
|
||||
void VisualiserComponent::mouseDoubleClick(const juce::MouseEvent& event) {
|
||||
void VisualiserComponent::enableFullScreen() {
|
||||
if (fullScreenCallback) {
|
||||
fullScreenCallback(FullScreenMode::TOGGLE);
|
||||
}
|
||||
grabKeyboardFocus();
|
||||
}
|
||||
|
||||
void VisualiserComponent::mouseDoubleClick(const juce::MouseEvent& event) {
|
||||
enableFullScreen();
|
||||
}
|
||||
|
||||
void VisualiserComponent::setBuffer(std::vector<float>& newBuffer) {
|
||||
juce::CriticalSection::ScopedLockType scope(lock);
|
||||
buffer.clear();
|
||||
|
@ -106,16 +126,33 @@ void VisualiserComponent::mouseDown(const juce::MouseEvent& event) {
|
|||
stopThread(1000);
|
||||
}
|
||||
repaint();
|
||||
} else if (event.mods.isPopupMenu()) {
|
||||
juce::PopupMenu menu;
|
||||
|
||||
menu.addCustomItem(1, roughness, 160, 40, false);
|
||||
menu.addCustomItem(1, intensity, 160, 40, false);
|
||||
|
||||
menu.showMenuAsync(juce::PopupMenu::Options(), [this](int result) {});
|
||||
}
|
||||
}
|
||||
|
||||
void VisualiserComponent::mouseMove(const juce::MouseEvent& event) {
|
||||
if (event.getScreenX() == lastMouseX && event.getScreenY() == lastMouseY) {
|
||||
return;
|
||||
}
|
||||
lastMouseX = event.getScreenX();
|
||||
lastMouseY = event.getScreenY();
|
||||
|
||||
int newTimerId = juce::Random::getSystemRandom().nextInt();
|
||||
timerId = newTimerId;
|
||||
fullScreenButton.setVisible(true);
|
||||
settingsButton.setVisible(true);
|
||||
auto pos = event.getScreenPosition();
|
||||
|
||||
juce::Timer::callAfterDelay(1000, [this, newTimerId, pos]() {
|
||||
bool onButtonRow = fullScreenButton.getScreenBounds().contains(pos) || settingsButton.getScreenBounds().contains(pos);
|
||||
if (timerId == newTimerId && !onButtonRow) {
|
||||
fullScreenButton.setVisible(false);
|
||||
settingsButton.setVisible(false);
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
repaint();
|
||||
}
|
||||
|
||||
bool VisualiserComponent::keyPressed(const juce::KeyPress& key) {
|
||||
if (key.isKeyCode(juce::KeyPress::escapeKey)) {
|
||||
if (fullScreenCallback) {
|
||||
|
@ -128,11 +165,7 @@ bool VisualiserComponent::keyPressed(const juce::KeyPress& key) {
|
|||
}
|
||||
|
||||
void VisualiserComponent::setFullScreen(bool fullScreen) {
|
||||
if (fullScreen) {
|
||||
setTooltip("");
|
||||
} else {
|
||||
setTooltip("Click to pause. Double click to toggle full screen. Right click to change quality and intensity settings.");
|
||||
}
|
||||
// useful as a callback from parent if needed
|
||||
}
|
||||
|
||||
void VisualiserComponent::paintChannel(juce::Graphics& g, juce::Rectangle<float> area, int channel) {
|
||||
|
@ -189,3 +222,11 @@ void VisualiserComponent::resetBuffer() {
|
|||
sampleRate = (int) audioProcessor.currentSampleRate;
|
||||
tempBuffer = std::vector<float>(2 * sampleRate * BUFFER_LENGTH_SECS);
|
||||
}
|
||||
|
||||
void VisualiserComponent::resized() {
|
||||
auto area = getLocalBounds();
|
||||
area.removeFromBottom(5);
|
||||
auto buttonRow = area.removeFromBottom(25);
|
||||
fullScreenButton.setBounds(buttonRow.removeFromRight(30));
|
||||
settingsButton.setBounds(buttonRow.removeFromRight(30));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "../concurrency/BufferConsumer.h"
|
||||
#include "../PluginProcessor.h"
|
||||
#include "LabelledTextBox.h"
|
||||
#include "SvgButton.h"
|
||||
|
||||
enum class FullScreenMode {
|
||||
TOGGLE,
|
||||
|
@ -17,6 +18,7 @@ public:
|
|||
VisualiserComponent(int numChannels, OscirenderAudioProcessor& p);
|
||||
~VisualiserComponent() override;
|
||||
|
||||
void enableFullScreen();
|
||||
void setFullScreenCallback(std::function<void(FullScreenMode)> callback);
|
||||
void mouseDoubleClick(const juce::MouseEvent& event) override;
|
||||
void setBuffer(std::vector<float>& buffer);
|
||||
|
@ -24,9 +26,11 @@ public:
|
|||
void paintChannel(juce::Graphics&, juce::Rectangle<float> bounds, int channel);
|
||||
void paintXY(juce::Graphics&, juce::Rectangle<float> bounds);
|
||||
void paint(juce::Graphics&) override;
|
||||
void resized() override;
|
||||
void timerCallback() override;
|
||||
void run() override;
|
||||
void mouseDown(const juce::MouseEvent& event) override;
|
||||
void mouseMove(const juce::MouseEvent& event) override;
|
||||
bool keyPressed(const juce::KeyPress& key) override;
|
||||
|
||||
void setFullScreen(bool fullScreen);
|
||||
|
@ -36,6 +40,10 @@ private:
|
|||
const double BUFFER_LENGTH_SECS = 0.02;
|
||||
const double DEFAULT_SAMPLE_RATE = 192000.0;
|
||||
|
||||
std::atomic<int> timerId;
|
||||
std::atomic<int> lastMouseX;
|
||||
std::atomic<int> lastMouseY;
|
||||
|
||||
juce::CriticalSection lock;
|
||||
std::vector<float> buffer;
|
||||
std::vector<juce::Line<float>> prevLines;
|
||||
|
@ -46,6 +54,9 @@ private:
|
|||
LabelledTextBox roughness{"Roughness", 1, 8, 1};
|
||||
LabelledTextBox intensity{"Intensity", 0, 1, 0.01};
|
||||
|
||||
SvgButton fullScreenButton{ "fullScreen", BinaryData::fullscreen_svg, juce::Colours::white, juce::Colours::white };
|
||||
SvgButton settingsButton{ "settings", BinaryData::cog_svg, juce::Colours::white, juce::Colours::white };
|
||||
|
||||
std::vector<float> tempBuffer;
|
||||
int precision = 4;
|
||||
|
||||
|
|
|
@ -23,12 +23,15 @@
|
|||
<FILE id="LbviBq" name="cube.obj" compile="0" resource="1" file="Resources/models/cube.obj"/>
|
||||
</GROUP>
|
||||
<GROUP id="{82BCD6F1-A8BF-F30B-5587-81EE70168883}" name="svg">
|
||||
<FILE id="rl17ZK" name="cog.svg" compile="0" resource="1" file="Resources/svg/cog.svg"/>
|
||||
<FILE id="sDajXu" name="delete.svg" compile="0" resource="1" file="Resources/svg/delete.svg"/>
|
||||
<FILE id="IqXIZW" name="demo.svg" compile="0" resource="1" file="Resources/svg/demo.svg"/>
|
||||
<FILE id="YwkQpy" name="fixed_rotate.svg" compile="0" resource="1"
|
||||
file="Resources/svg/fixed_rotate.svg"/>
|
||||
<FILE id="WIkl6l" name="fullscreen.svg" compile="0" resource="1" file="Resources/svg/fullscreen.svg"/>
|
||||
<FILE id="n1esUp" name="left_arrow.svg" compile="0" resource="1" file="Resources/svg/left_arrow.svg"/>
|
||||
<FILE id="PxYKbt" name="microphone.svg" compile="0" resource="1" file="Resources/svg/microphone.svg"/>
|
||||
<FILE id="hJHxFY" name="open_in_new.svg" compile="0" resource="1" file="Resources/svg/open_in_new.svg"/>
|
||||
<FILE id="pSc1mq" name="osci.svg" compile="0" resource="1" file="Resources/svg/osci.svg"/>
|
||||
<FILE id="f2D5tv" name="pause.svg" compile="0" resource="1" file="Resources/svg/pause.svg"/>
|
||||
<FILE id="D2AI1b" name="pencil.svg" compile="0" resource="1" file="Resources/svg/pencil.svg"/>
|
||||
|
|
Ładowanie…
Reference in New Issue