Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yairchu committed Jun 29, 2023
2 parents bf9418e + 578d2b9 commit 61d24d7
Show file tree
Hide file tree
Showing 24 changed files with 393 additions and 184 deletions.
45 changes: 44 additions & 1 deletion examples/GUI/WidgetsDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ struct ButtonsPage : public Component


//==============================================================================
struct MiscPage : public Component
struct MiscPage : public Component,
private Timer
{
MiscPage()
{
Expand All @@ -482,6 +483,21 @@ struct MiscPage : public Component
comboBox.addItem ("combo box item " + String (i), i);

comboBox.setSelectedId (1);

addAndMakeVisible (linearProgressBar);
linearProgressBar.setStyle (ProgressBar::Style::linear);
linearProgressBar.setBounds (10, 115, 200, 24);

addAndMakeVisible (circularProgressBar);
circularProgressBar.setStyle (ProgressBar::Style::circular);
circularProgressBar.setBounds (10, 145, 200, 100);

startTimerHz (10);
}

~MiscPage() override
{
stopTimer();
}

void lookAndFeelChanged() override
Expand All @@ -490,10 +506,37 @@ struct MiscPage : public Component
textEditor2.applyFontToAllText (textEditor2.getFont());
}

void timerCallback() override
{
constexpr auto minValue = -0.2;
constexpr auto maxValue = 1.2;
constexpr auto maxIncrement = 0.05;

if (progress >= maxValue)
progress = minValue;
else
progress += Random::getSystemRandom().nextDouble() * maxIncrement;

if (isPositiveAndNotGreaterThan (progress, 1.0))
{
linearProgressBar.setPercentageDisplay (true);
circularProgressBar.setPercentageDisplay (true);
}
else
{
linearProgressBar.setTextToDisplay ("Linear progress bar");
circularProgressBar.setTextToDisplay ("Circular progress bar");
}
}

TextEditor textEditor1,
textEditor2 { "Password", (juce_wchar) 0x2022 };

ComboBox comboBox { "Combo" };

double progress { 0.0 };
ProgressBar linearProgressBar { progress };
ProgressBar circularProgressBar { progress };
};

//==============================================================================
Expand Down
144 changes: 134 additions & 10 deletions examples/GUI/WindowsDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ class WindowsDemo : public Component
addAndMakeVisible (closeWindowsButton);
closeWindowsButton.onClick = [this] { closeAllWindows(); };

addAndMakeVisible (alertWindowResult);
alertWindowResult.setJustificationType (Justification::centred);

setSize (250, 250);
}

Expand All @@ -253,14 +256,27 @@ class WindowsDemo : public Component

void resized() override
{
Rectangle<int> buttonSize (0, 0, 108, 28);
FlexBox flexBox;
flexBox.flexDirection = FlexBox::Direction::column;
flexBox.justifyContent = FlexBox::JustifyContent::center;

constexpr auto buttonWidth = 108.0f;
constexpr auto componentHeight = 24.0f;
constexpr auto gap = 4.0f;

flexBox.items.add (FlexItem { showWindowsButton }.withHeight (componentHeight)
.withMinWidth (buttonWidth)
.withAlignSelf (FlexItem::AlignSelf::center));

Rectangle<int> area ((getWidth() / 2) - (buttonSize.getWidth() / 2),
(getHeight() / 2) - buttonSize.getHeight(),
buttonSize.getWidth(), buttonSize.getHeight());
flexBox.items.add (FlexItem{}.withHeight (gap));
flexBox.items.add (FlexItem { closeWindowsButton }.withHeight (componentHeight)
.withMinWidth (buttonWidth)
.withAlignSelf (FlexItem::AlignSelf::center));

showWindowsButton .setBounds (area.reduced (2));
closeWindowsButton.setBounds (area.translated (0, buttonSize.getHeight()).reduced (2));
flexBox.items.add (FlexItem{}.withHeight (gap));
flexBox.items.add (FlexItem { alertWindowResult }.withHeight (componentHeight));

flexBox.performLayout (getLocalBounds());
}

private:
Expand All @@ -272,6 +288,7 @@ class WindowsDemo : public Component

TextButton showWindowsButton { "Show Windows" },
closeWindowsButton { "Close Windows" };
Label alertWindowResult { "Alert Window result" };

void showAllWindows()
{
Expand All @@ -280,6 +297,7 @@ class WindowsDemo : public Component
showDocumentWindow (false);
showDocumentWindow (true);
showTransparentWindow();
showAlertWindow();
showDialogWindow();
}

Expand All @@ -289,6 +307,12 @@ class WindowsDemo : public Component
window.deleteAndZero();

windows.clear();
alertWindowResult.setText ("", dontSendNotification);
}

static auto getDisplayArea()
{
return Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea.reduced (20);
}

void showDialogWindow()
Expand Down Expand Up @@ -333,8 +357,7 @@ class WindowsDemo : public Component
| RectanglePlacement::yTop
| RectanglePlacement::doNotResize);

auto result = placement.appliedTo (area, Desktop::getInstance().getDisplays()
.getPrimaryDisplay()->userArea.reduced (20));
auto result = placement.appliedTo (area, getDisplayArea());
dw->setBounds (result);

dw->setResizable (true, ! native);
Expand All @@ -354,12 +377,113 @@ class WindowsDemo : public Component
| RectanglePlacement::yBottom
| RectanglePlacement::doNotResize);

auto result = placement.appliedTo (area, Desktop::getInstance().getDisplays()
.getPrimaryDisplay()->userArea.reduced (20));
auto result = placement.appliedTo (area, getDisplayArea());
balls->setBounds (result);

balls->setVisible (true);
}

void showAlertWindow()
{
auto* alertWindow = new AlertWindow ("Alert Window",
"For more complex dialogs, you can easily add components to an AlertWindow, such as...",
MessageBoxIconType::InfoIcon);
windows.add (alertWindow);

alertWindow->addTextBlock ("Text block");
alertWindow->addComboBox ("Combo box", {"Combo box", "Item 2", "Item 3"});
alertWindow->addTextEditor ("Text editor", "Text editor");
alertWindow->addTextEditor ("Password", "password", "including for passwords", true);
alertWindowCustomComponent.emplace();
alertWindow->addCustomComponent (&(*alertWindowCustomComponent));
alertWindow->addTextBlock ("Progress bar");
alertWindow->addProgressBarComponent (alertWindowCustomComponent->value, ProgressBar::Style::linear);
alertWindow->addProgressBarComponent (alertWindowCustomComponent->value, ProgressBar::Style::circular);
alertWindow->addTextBlock ("Press any button, or the escape key, to close the window");

enum AlertWindowResult
{
noButtonPressed,
button1Pressed,
button2Pressed
};

alertWindow->addButton ("Button 1", AlertWindowResult::button1Pressed);
alertWindow->addButton ("Button 2", AlertWindowResult::button2Pressed);

RectanglePlacement placement { RectanglePlacement::yMid
| RectanglePlacement::xLeft
| RectanglePlacement::doNotResize };

alertWindow->setBounds (placement.appliedTo (alertWindow->getBounds(), getDisplayArea()));

alertWindowResult.setText ("", dontSendNotification);
alertWindow->enterModalState (false, ModalCallbackFunction::create ([ref = SafePointer { this }] (int result)
{
if (ref == nullptr)
return;

const auto text = [&]
{
switch (result)
{
case noButtonPressed:
return "Dismissed the Alert Window without pressing a button";
case button1Pressed:
return "Dismissed the Alert Window using Button 1";
case button2Pressed:
return "Dismissed the Alert Window using Button 2";
}

return "Unhandled event when dismissing the Alert Window";
}();

ref->alertWindowResult.setText (text, dontSendNotification);
}), true);
}

class AlertWindowCustomComponent : public Component,
private Slider::Listener
{
public:
AlertWindowCustomComponent()
{
slider.setRange (0.0, 1.0);
slider.setValue (0.5, NotificationType::dontSendNotification);
slider.addListener (this);

addAndMakeVisible (label);
addAndMakeVisible (slider);

setSize (200, 50);
}

~AlertWindowCustomComponent() override
{
slider.removeListener (this);
}

void resized() override
{
auto bounds = getLocalBounds();
label.setBounds (bounds.removeFromTop (getHeight() / 2));
slider.setBounds (bounds);
}

void sliderValueChanged (Slider*) override
{
value = slider.getValue();
}

double value { -1.0 };

private:
Label label { "Label", "Custom component" };
Slider slider { Slider::SliderStyle::LinearHorizontal,
Slider::TextEntryBoxPosition::NoTextBox };
};

std::optional<AlertWindowCustomComponent> alertWindowCustomComponent;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WindowsDemo)
};
6 changes: 3 additions & 3 deletions extras/AudioPluginHost/Source/UI/GraphEditorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,9 @@ void GraphEditorPanel::showPopupMenu (Point<int> mousePos)
menu->showMenuAsync ({},
ModalCallbackFunction::create ([this, mousePos] (int r)
{
if (r > 0)
if (auto* mainWin = findParentComponentOfClass<MainHostWindow>())
createNewPlugin (mainWin->getChosenType (r), mousePos);
if (auto* mainWin = findParentComponentOfClass<MainHostWindow>())
if (const auto chosen = mainWin->getChosenType (r))
createNewPlugin (*chosen, mousePos);
}));
}
}
Expand Down
25 changes: 13 additions & 12 deletions extras/AudioPluginHost/Source/UI/MainHostWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,9 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
}
else
{
if (getIndexChosenByMenu (menuItemID) >= 0)
createPlugin (getChosenType (menuItemID), { proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f) });
if (const auto chosen = getChosenType (menuItemID))
createPlugin (*chosen, { proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f) });
}
}

Expand Down Expand Up @@ -697,18 +697,19 @@ void MainHostWindow::addPluginsToMenu (PopupMenu& m)
addToMenu (*tree, m, pluginDescriptions, pluginDescriptionsAndPreference);
}

int MainHostWindow::getIndexChosenByMenu (int menuID) const
std::optional<PluginDescriptionAndPreference> MainHostWindow::getChosenType (const int menuID) const
{
const auto i = menuID - menuIDBase;
return isPositiveAndBelow (i, pluginDescriptionsAndPreference.size()) ? i : -1;
}
const auto internalIndex = menuID - 1;

PluginDescriptionAndPreference MainHostWindow::getChosenType (const int menuID) const
{
if (menuID >= 1 && menuID < (int) (1 + internalTypes.size()))
return PluginDescriptionAndPreference { internalTypes[(size_t) (menuID - 1)] };
if (isPositiveAndBelow (internalIndex, internalTypes.size()))
return PluginDescriptionAndPreference { internalTypes[(size_t) internalIndex] };

const auto externalIndex = menuID - menuIDBase;

if (isPositiveAndBelow (externalIndex, pluginDescriptionsAndPreference.size()))
return pluginDescriptionsAndPreference[externalIndex];

return pluginDescriptionsAndPreference[getIndexChosenByMenu (menuID)];
return {};
}

//==============================================================================
Expand Down
4 changes: 1 addition & 3 deletions extras/AudioPluginHost/Source/UI/MainHostWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MainHostWindow : public DocumentWindow,
void createPlugin (const PluginDescriptionAndPreference&, Point<int> pos);

void addPluginsToMenu (PopupMenu&);
PluginDescriptionAndPreference getChosenType (int menuID) const;
std::optional<PluginDescriptionAndPreference> getChosenType (int menuID) const;

std::unique_ptr<GraphDocumentComponent> graphHolder;

Expand All @@ -124,8 +124,6 @@ class MainHostWindow : public DocumentWindow,

void showAudioSettings();

int getIndexChosenByMenu (int menuID) const;

//==============================================================================
AudioDeviceManager deviceManager;
AudioPluginFormatManager formatManager;
Expand Down
11 changes: 8 additions & 3 deletions extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,11 @@ class XcodeProjectExporter : public ProjectExporter
owner.addObject (v);
}

bool shouldUseHardenedRuntime() const
{
return type != VST3Helper && type != LV2Helper && owner.isHardenedRuntimeEnabled();
}

//==============================================================================
String getTargetAttributes() const
{
Expand All @@ -1341,7 +1346,7 @@ class XcodeProjectExporter : public ProjectExporter
|| owner.getProject().isAUPluginHost());
capabilities["Push"] = owner.isPushNotificationsEnabled();
capabilities["Sandbox"] = type == Target::AudioUnitv3PlugIn || owner.isAppSandboxEnabled();
capabilities["HardenedRuntime"] = owner.isHardenedRuntimeEnabled();
capabilities["HardenedRuntime"] = shouldUseHardenedRuntime();

if (owner.iOS && owner.isiCloudPermissionsEnabled())
capabilities["com.apple.iCloud"] = true;
Expand Down Expand Up @@ -1397,7 +1402,7 @@ class XcodeProjectExporter : public ProjectExporter
if (owner.isPushNotificationsEnabled()
|| owner.isAppGroupsEnabled()
|| owner.isAppSandboxEnabled()
|| owner.isHardenedRuntimeEnabled()
|| shouldUseHardenedRuntime()
|| owner.isNetworkingMulticastEnabled()
|| (owner.isiOS() && owner.isiCloudPermissionsEnabled())
|| (owner.isiOS() && owner.getProject().isAUPluginHost()))
Expand Down Expand Up @@ -1687,7 +1692,7 @@ class XcodeProjectExporter : public ProjectExporter

s.set ("CONFIGURATION_BUILD_DIR", addQuotesIfRequired (adjustedConfigBuildDir));

if (owner.isHardenedRuntimeEnabled())
if (shouldUseHardenedRuntime())
s.set ("ENABLE_HARDENED_RUNTIME", "YES");

String gccVersion ("com.apple.compilers.llvm.clang.1_0");
Expand Down
Loading

0 comments on commit 61d24d7

Please sign in to comment.