mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
PIP: Respect screen safe areas for demo projects
This commit is contained in:
parent
34c32cbaf0
commit
cabb396c83
3 changed files with 64 additions and 8 deletions
|
|
@ -20,7 +20,7 @@ public:
|
||||||
|
|
||||||
void initialise (const juce::String&) override
|
void initialise (const juce::String&) override
|
||||||
{
|
{
|
||||||
mainWindow.reset (new MainWindow ("${JUCE_PIP_NAME}", new ${JUCE_PIP_MAIN_CLASS}, *this));
|
mainWindow.reset (new MainWindow ("${JUCE_PIP_NAME}", std::make_unique<${JUCE_PIP_MAIN_CLASS}>(), *this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown() override { mainWindow = nullptr; }
|
void shutdown() override { mainWindow = nullptr; }
|
||||||
|
|
@ -29,18 +29,19 @@ private:
|
||||||
class MainWindow : public juce::DocumentWindow
|
class MainWindow : public juce::DocumentWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MainWindow (const juce::String& name, juce::Component* c, JUCEApplication& a)
|
MainWindow (const juce::String& name, std::unique_ptr<juce::Component> c, JUCEApplication& a)
|
||||||
: DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
|
: DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()
|
||||||
.findColour (ResizableWindow::backgroundColourId),
|
.findColour (ResizableWindow::backgroundColourId),
|
||||||
juce::DocumentWindow::allButtons),
|
juce::DocumentWindow::allButtons),
|
||||||
app (a)
|
app (a)
|
||||||
{
|
{
|
||||||
setUsingNativeTitleBar (true);
|
setUsingNativeTitleBar (true);
|
||||||
setContentOwned (c, true);
|
|
||||||
|
|
||||||
#if JUCE_ANDROID || JUCE_IOS
|
#if JUCE_ANDROID || JUCE_IOS
|
||||||
|
setContentOwned (new SafeAreaComponent { std::move (c) }, true);
|
||||||
setFullScreen (true);
|
setFullScreen (true);
|
||||||
#else
|
#else
|
||||||
|
setContentOwned (c.release(), true);
|
||||||
setResizable (true, false);
|
setResizable (true, false);
|
||||||
setResizeLimits (300, 250, 10000, 10000);
|
setResizeLimits (300, 250, 10000, 10000);
|
||||||
centreWithSize (getWidth(), getHeight());
|
centreWithSize (getWidth(), getHeight());
|
||||||
|
|
@ -54,6 +55,33 @@ private:
|
||||||
app.systemRequestedQuit();
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
void parentSizeChanged() override
|
||||||
|
{
|
||||||
|
if (auto* c = getContentComponent())
|
||||||
|
c->resized();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JUCEApplication& app;
|
JUCEApplication& app;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ static const unsigned char temp_binary_data_4[] =
|
||||||
"\r\n"
|
"\r\n"
|
||||||
" void initialise (const juce::String&) override\r\n"
|
" void initialise (const juce::String&) override\r\n"
|
||||||
" {\r\n"
|
" {\r\n"
|
||||||
" mainWindow.reset (new MainWindow (\"${JUCE_PIP_NAME}\", new ${JUCE_PIP_MAIN_CLASS}, *this));\r\n"
|
" mainWindow.reset (new MainWindow (\"${JUCE_PIP_NAME}\", std::make_unique<${JUCE_PIP_MAIN_CLASS}>(), *this));\r\n"
|
||||||
" }\r\n"
|
" }\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
" void shutdown() override { mainWindow = nullptr; }\r\n"
|
" void shutdown() override { mainWindow = nullptr; }\r\n"
|
||||||
|
|
@ -123,18 +123,19 @@ static const unsigned char temp_binary_data_4[] =
|
||||||
" class MainWindow : public juce::DocumentWindow\r\n"
|
" class MainWindow : public juce::DocumentWindow\r\n"
|
||||||
" {\r\n"
|
" {\r\n"
|
||||||
" public:\r\n"
|
" public:\r\n"
|
||||||
" MainWindow (const juce::String& name, juce::Component* c, JUCEApplication& a)\r\n"
|
" MainWindow (const juce::String& name, std::unique_ptr<juce::Component> c, JUCEApplication& a)\r\n"
|
||||||
" : DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()\r\n"
|
" : DocumentWindow (name, juce::Desktop::getInstance().getDefaultLookAndFeel()\r\n"
|
||||||
" .findColour (ResizableWindow::backgroundColourId),\r\n"
|
" .findColour (ResizableWindow::backgroundColourId),\r\n"
|
||||||
" juce::DocumentWindow::allButtons),\r\n"
|
" juce::DocumentWindow::allButtons),\r\n"
|
||||||
" app (a)\r\n"
|
" app (a)\r\n"
|
||||||
" {\r\n"
|
" {\r\n"
|
||||||
" setUsingNativeTitleBar (true);\r\n"
|
" setUsingNativeTitleBar (true);\r\n"
|
||||||
" setContentOwned (c, true);\r\n"
|
|
||||||
"\r\n"
|
"\r\n"
|
||||||
" #if JUCE_ANDROID || JUCE_IOS\r\n"
|
" #if JUCE_ANDROID || JUCE_IOS\r\n"
|
||||||
|
" setContentOwned (new SafeAreaComponent { std::move (c) }, true);\r\n"
|
||||||
" setFullScreen (true);\r\n"
|
" setFullScreen (true);\r\n"
|
||||||
" #else\r\n"
|
" #else\r\n"
|
||||||
|
" setContentOwned (c.release(), true);\r\n"
|
||||||
" setResizable (true, false);\r\n"
|
" setResizable (true, false);\r\n"
|
||||||
" setResizeLimits (300, 250, 10000, 10000);\r\n"
|
" setResizeLimits (300, 250, 10000, 10000);\r\n"
|
||||||
" centreWithSize (getWidth(), getHeight());\r\n"
|
" centreWithSize (getWidth(), getHeight());\r\n"
|
||||||
|
|
@ -148,6 +149,33 @@ static const unsigned char temp_binary_data_4[] =
|
||||||
" app.systemRequestedQuit();\r\n"
|
" app.systemRequestedQuit();\r\n"
|
||||||
" }\r\n"
|
" }\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
|
" #if JUCE_ANDROID || JUCE_IOS\r\n"
|
||||||
|
" class SafeAreaComponent : public juce::Component\r\n"
|
||||||
|
" {\r\n"
|
||||||
|
" public:\r\n"
|
||||||
|
" explicit SafeAreaComponent (std::unique_ptr<Component> c)\r\n"
|
||||||
|
" : content (std::move (c))\r\n"
|
||||||
|
" {\r\n"
|
||||||
|
" addAndMakeVisible (*content);\r\n"
|
||||||
|
" }\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" void resized() override\r\n"
|
||||||
|
" {\r\n"
|
||||||
|
" if (const auto* d = Desktop::getInstance().getDisplays().getDisplayForRect (getLocalBounds()))\r\n"
|
||||||
|
" content->setBounds (d->safeAreaInsets.subtractedFrom (getLocalBounds()));\r\n"
|
||||||
|
" }\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" private:\r\n"
|
||||||
|
" std::unique_ptr<Component> content;\r\n"
|
||||||
|
" };\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" void parentSizeChanged() override\r\n"
|
||||||
|
" {\r\n"
|
||||||
|
" if (auto* c = getContentComponent())\r\n"
|
||||||
|
" c->resized();\r\n"
|
||||||
|
" }\r\n"
|
||||||
|
" #endif\r\n"
|
||||||
|
"\r\n"
|
||||||
" private:\r\n"
|
" private:\r\n"
|
||||||
" JUCEApplication& app;\r\n"
|
" JUCEApplication& app;\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
|
|
@ -8988,7 +9016,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
|
||||||
case 0x31d21131: numBytes = 1042; return LaunchScreen_storyboard;
|
case 0x31d21131: numBytes = 1042; return LaunchScreen_storyboard;
|
||||||
case 0x24e5a04d: numBytes = 483; return PIPAudioProcessor_cpp_in;
|
case 0x24e5a04d: numBytes = 483; return PIPAudioProcessor_cpp_in;
|
||||||
case 0x956e0109: numBytes = 689; return PIPAudioProcessorWithARA_cpp_in;
|
case 0x956e0109: numBytes = 689; return PIPAudioProcessorWithARA_cpp_in;
|
||||||
case 0xd572ce5a: numBytes = 2275; return PIPComponent_cpp_in;
|
case 0xd572ce5a: numBytes = 3231; return PIPComponent_cpp_in;
|
||||||
case 0x1a77c680: numBytes = 299; return PIPConsole_cpp_in;
|
case 0x1a77c680: numBytes = 299; return PIPConsole_cpp_in;
|
||||||
case 0xa41e649d: numBytes = 2842; return RecentFilesMenuTemplate_nib;
|
case 0xa41e649d: numBytes = 2842; return RecentFilesMenuTemplate_nib;
|
||||||
case 0x667fbbb3: numBytes = 6424; return UnityPluginGUIScript_cs_in;
|
case 0x667fbbb3: numBytes = 6424; return UnityPluginGUIScript_cs_in;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace BinaryData
|
||||||
const int PIPAudioProcessorWithARA_cpp_inSize = 689;
|
const int PIPAudioProcessorWithARA_cpp_inSize = 689;
|
||||||
|
|
||||||
extern const char* PIPComponent_cpp_in;
|
extern const char* PIPComponent_cpp_in;
|
||||||
const int PIPComponent_cpp_inSize = 2275;
|
const int PIPComponent_cpp_inSize = 3231;
|
||||||
|
|
||||||
extern const char* PIPConsole_cpp_in;
|
extern const char* PIPConsole_cpp_in;
|
||||||
const int PIPConsole_cpp_inSize = 299;
|
const int PIPConsole_cpp_inSize = 299;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue