b0a75e98db
вайбкод потому что мне в моменте стало понятно. что проще было сразу писать на фреймворке JUCE, чем адаптировать консольное приложение на MiniAudio. обновляться данный репозиторий не будет. СmakeLists адаптирован онли под linux.
91 lines
3.0 KiB
Plaintext
91 lines
3.0 KiB
Plaintext
/*
|
|
==============================================================================
|
|
|
|
This file contains the startup code for a PIP.
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#include <JuceHeader.h>
|
|
#include "${JUCE_PIP_HEADER}"
|
|
|
|
class Application : public juce::JUCEApplication
|
|
{
|
|
public:
|
|
//==============================================================================
|
|
Application() = default;
|
|
|
|
const juce::String getApplicationName() override { return "${JUCE_PIP_NAME}"; }
|
|
const juce::String getApplicationVersion() override { return "${PROJECT_VERSION}"; }
|
|
|
|
void initialise (const juce::String&) override
|
|
{
|
|
mainWindow.reset (new MainWindow ("${JUCE_PIP_NAME}", std::make_unique<${JUCE_PIP_MAIN_CLASS}>(), *this));
|
|
}
|
|
|
|
void shutdown() override { mainWindow = nullptr; }
|
|
|
|
private:
|
|
class MainWindow : public juce::DocumentWindow
|
|
{
|
|
public:
|
|
MainWindow (const juce::String& name, std::unique_ptr<juce::Component> c, JUCEApplication& a)
|
|
: DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
|
|
.findColour (ResizableWindow::backgroundColourId),
|
|
juce::DocumentWindow::allButtons),
|
|
app (a)
|
|
{
|
|
setUsingNativeTitleBar (true);
|
|
|
|
#if JUCE_ANDROID || JUCE_IOS
|
|
setContentOwned (new SafeAreaComponent { std::move (c) }, true);
|
|
setFullScreen (true);
|
|
#else
|
|
setContentOwned (c.release(), true);
|
|
setResizable (true, false);
|
|
setResizeLimits (300, 250, 10000, 10000);
|
|
centreWithSize (getWidth(), getHeight());
|
|
#endif
|
|
|
|
setVisible (true);
|
|
}
|
|
|
|
void closeButtonPressed() override
|
|
{
|
|
app.systemRequestedQuit();
|
|
}
|
|
|
|
#if JUCE_ANDROID || JUCE_IOS
|
|
class SafeAreaComponent : public juce::Component
|
|
{
|
|
public:
|
|
explicit SafeAreaComponent (std::unique_ptr<Component> c)
|
|
: content (std::move (c))
|
|
{
|
|
addAndMakeVisible (*content);
|
|
}
|
|
|
|
void resized() override
|
|
{
|
|
if (const auto* d = Desktop::getInstance().getDisplays().getDisplayForRect (getLocalBounds()))
|
|
content->setBounds (d->safeAreaInsets.subtractedFrom (getLocalBounds()));
|
|
}
|
|
|
|
private:
|
|
std::unique_ptr<Component> content;
|
|
};
|
|
#endif
|
|
|
|
private:
|
|
JUCEApplication& app;
|
|
|
|
//==============================================================================
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
|
|
};
|
|
|
|
std::unique_ptr<MainWindow> mainWindow;
|
|
};
|
|
|
|
//==============================================================================
|
|
START_JUCE_APPLICATION (Application)
|