mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-26 02:14:22 +00:00
Cleaned up a few more ScopedPointer uses
This commit is contained in:
parent
3f565bf81f
commit
33c0940d74
15 changed files with 129 additions and 155 deletions
|
|
@ -28,15 +28,10 @@
|
|||
|
||||
|
||||
//==============================================================================
|
||||
class AboutWindowComponent : public Component,
|
||||
private Button::Listener
|
||||
class AboutWindowComponent : public Component
|
||||
{
|
||||
public:
|
||||
AboutWindowComponent()
|
||||
: titleLabel ("title", "PROJUCER"),
|
||||
versionLabel ("version"),
|
||||
copyrightLabel ("copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.")),
|
||||
aboutButton ("About Us", URL ("https://juce.com"))
|
||||
{
|
||||
bool showPurchaseButton = false;
|
||||
|
||||
|
|
@ -67,8 +62,13 @@ public:
|
|||
|
||||
if (showPurchaseButton)
|
||||
{
|
||||
addAndMakeVisible (licenseButton = new TextButton ("Purchase License"));
|
||||
licenseButton->addListener (this);
|
||||
addAndMakeVisible (licenseButton);
|
||||
|
||||
licenseButton.onClick = []
|
||||
{
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,8 +105,8 @@ public:
|
|||
|
||||
centreSlice.removeFromTop (10);
|
||||
|
||||
if (licenseButton != nullptr)
|
||||
licenseButton->setBounds (centreSlice.removeFromTop (25).reduced (25, 0));
|
||||
if (licenseButton.isShowing())
|
||||
licenseButton.setBounds (centreSlice.removeFromTop (25).reduced (25, 0));
|
||||
|
||||
aboutButton.setBounds (centreSlice.removeFromBottom (20));
|
||||
}
|
||||
|
|
@ -123,12 +123,14 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
Label titleLabel, versionLabel, copyrightLabel;
|
||||
HyperlinkButton aboutButton;
|
||||
ScopedPointer<TextButton> licenseButton;
|
||||
Label titleLabel { "title", "PROJUCER" },
|
||||
versionLabel { "version" },
|
||||
copyrightLabel { "copyright", String (CharPointer_UTF8 ("\xc2\xa9")) + String (" 2017 ROLI Ltd.") };
|
||||
|
||||
Rectangle<float> huckleberryLogoBounds;
|
||||
Rectangle<float> juceLogoBounds;
|
||||
HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
|
||||
TextButton licenseButton { "Purchase License" };
|
||||
|
||||
Rectangle<float> huckleberryLogoBounds, juceLogoBounds;
|
||||
|
||||
ScopedPointer<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
|
||||
BinaryData::juce_icon_pngSize) };
|
||||
|
|
@ -136,14 +138,5 @@ private:
|
|||
ScopedPointer<Drawable> huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
|
||||
BinaryData::huckleberry_icon_svgSize) };
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == licenseButton.get())
|
||||
{
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
}
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
|
||||
//==============================================================================
|
||||
class ApplicationUsageDataWindowComponent : public Component,
|
||||
private Button::Listener
|
||||
class ApplicationUsageDataWindowComponent : public Component
|
||||
{
|
||||
public:
|
||||
ApplicationUsageDataWindowComponent (bool showCheckbox)
|
||||
|
|
@ -62,29 +61,32 @@ public:
|
|||
privacyPolicyLink.setURL (URL ("https://juce.com/privacy-policy"));
|
||||
|
||||
addAndMakeVisible (okButton);
|
||||
okButton.setButtonText ("OK");
|
||||
okButton.addListener (this);
|
||||
|
||||
if (showCheckbox)
|
||||
{
|
||||
addAndMakeVisible (shareApplicationUsageDataToggle = new ToggleButton());
|
||||
addAndMakeVisible (shareApplicationUsageDataToggle);
|
||||
|
||||
auto* controller = ProjucerApplication::getApp().licenseController.get();
|
||||
|
||||
if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::disabled)
|
||||
shareApplicationUsageDataToggle->setToggleState (false, dontSendNotification);
|
||||
shareApplicationUsageDataToggle.setToggleState (false, dontSendNotification);
|
||||
else
|
||||
shareApplicationUsageDataToggle->setToggleState (true, dontSendNotification);
|
||||
shareApplicationUsageDataToggle.setToggleState (true, dontSendNotification);
|
||||
|
||||
addAndMakeVisible(shareApplicationUsageDataLabel = new Label ({}, "Help JUCE to improve its software and services by sharing my application usage data"));
|
||||
shareApplicationUsageDataLabel->setFont (Font (14.0f));
|
||||
shareApplicationUsageDataLabel->setMinimumHorizontalScale (1.0f);
|
||||
addAndMakeVisible (shareApplicationUsageDataLabel);
|
||||
shareApplicationUsageDataLabel.setFont (Font (14.0f));
|
||||
shareApplicationUsageDataLabel.setMinimumHorizontalScale (1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
addAndMakeVisible (upgradeLicenseButton = new TextButton ("Upgrade License"));
|
||||
upgradeLicenseButton->addListener (this);
|
||||
upgradeLicenseButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
|
||||
addAndMakeVisible (upgradeLicenseButton);
|
||||
upgradeLicenseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
|
||||
|
||||
upgradeLicenseButton.onClick = []
|
||||
{
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +96,7 @@ public:
|
|||
{
|
||||
auto newApplicationUsageDataState = LicenseState::ApplicationUsageData::enabled;
|
||||
|
||||
if (shareApplicationUsageDataToggle != nullptr && ! shareApplicationUsageDataToggle->getToggleState())
|
||||
if (shareApplicationUsageDataToggle.isShowing() && ! shareApplicationUsageDataToggle.getToggleState())
|
||||
newApplicationUsageDataState = LicenseState::ApplicationUsageData::disabled;
|
||||
|
||||
controller->setApplicationUsageDataState (newApplicationUsageDataState);
|
||||
|
|
@ -113,13 +115,13 @@ public:
|
|||
juceEULALink.setBounds (linkBounds.removeFromLeft (linkBounds.getWidth() / 2).reduced (2));
|
||||
privacyPolicyLink.setBounds (linkBounds.reduced (2));
|
||||
|
||||
if (shareApplicationUsageDataToggle != nullptr)
|
||||
if (shareApplicationUsageDataToggle.isShowing())
|
||||
{
|
||||
bounds.removeFromTop (10);
|
||||
|
||||
auto toggleBounds = bounds.removeFromTop (40);
|
||||
shareApplicationUsageDataToggle->setBounds (toggleBounds.removeFromLeft (40).reduced (5));
|
||||
shareApplicationUsageDataLabel->setBounds (toggleBounds);
|
||||
shareApplicationUsageDataToggle.setBounds (toggleBounds.removeFromLeft (40).reduced (5));
|
||||
shareApplicationUsageDataLabel.setBounds (toggleBounds);
|
||||
}
|
||||
|
||||
bounds.removeFromTop (10);
|
||||
|
|
@ -127,16 +129,17 @@ public:
|
|||
auto buttonW = 125;
|
||||
auto buttonH = 40;
|
||||
|
||||
if (upgradeLicenseButton != nullptr)
|
||||
if (upgradeLicenseButton.isShowing())
|
||||
{
|
||||
auto left = bounds.removeFromLeft (bounds.getWidth() / 2);
|
||||
|
||||
upgradeLicenseButton->setSize (buttonW, buttonH);
|
||||
upgradeLicenseButton->setCentrePosition (left.getCentreX(), left.getCentreY());
|
||||
upgradeLicenseButton.setSize (buttonW, buttonH);
|
||||
upgradeLicenseButton.setCentrePosition (left.getCentreX(), left.getCentreY());
|
||||
}
|
||||
|
||||
okButton.setSize (buttonW, buttonH);
|
||||
okButton.setCentrePosition (bounds.getCentreX(), bounds.getCentreY());
|
||||
okButton.onClick = [] { ProjucerApplication::getApp().dismissApplicationUsageDataAgreementPopup(); };
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
|
|
@ -147,28 +150,13 @@ public:
|
|||
private:
|
||||
Label headerLabel, bodyLabel;
|
||||
HyperlinkButton juceEULALink, privacyPolicyLink;
|
||||
ScopedPointer<Label> shareApplicationUsageDataLabel;
|
||||
ScopedPointer<ToggleButton> shareApplicationUsageDataToggle;
|
||||
TextButton okButton;
|
||||
ScopedPointer<TextButton> upgradeLicenseButton;
|
||||
|
||||
void buttonClicked (Button* b) override
|
||||
{
|
||||
if (b == &okButton)
|
||||
{
|
||||
ProjucerApplication::getApp().dismissApplicationUsageDataAgreementPopup();
|
||||
}
|
||||
else if (b == upgradeLicenseButton)
|
||||
{
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
}
|
||||
}
|
||||
Label shareApplicationUsageDataLabel { {}, "Help JUCE to improve its software and services by sharing my application usage data" };
|
||||
ToggleButton shareApplicationUsageDataToggle;
|
||||
TextButton okButton { "OK" }, upgradeLicenseButton { "Upgrade License" };
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
if (upgradeLicenseButton != nullptr)
|
||||
upgradeLicenseButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
|
||||
upgradeLicenseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationUsageDataWindowComponent)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ struct FloatingToolWindow : public DialogWindow
|
|||
centreAroundComponent (Component::getCurrentlyFocusedComponent(), defaultW, defaultH);
|
||||
|
||||
setVisible (true);
|
||||
owner = this;
|
||||
owner.reset (this);
|
||||
}
|
||||
|
||||
~FloatingToolWindow()
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public:
|
|||
juceIcon = Drawable::createFromImageData (BinaryData::juce_icon_png,
|
||||
BinaryData::juce_icon_pngSize);
|
||||
|
||||
setSize (518, overwritePath ? 345 : 269);
|
||||
setSize (518, overwritePath != nullptr ? 345 : 269);
|
||||
|
||||
lookAndFeelChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ void MainWindow::setProject (Project* newProject)
|
|||
{
|
||||
createProjectContentCompIfNeeded();
|
||||
getProjectContentComponent()->setProject (newProject);
|
||||
currentProject = newProject;
|
||||
currentProject.reset (newProject);
|
||||
|
||||
if (currentProject != nullptr)
|
||||
projectNameValue.referTo (currentProject->getProjectValue (Ids::name));
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ private:
|
|||
{
|
||||
jucerComp.reset();
|
||||
|
||||
jucerComp = new TestComponent (ComponentTypeHandler::findParentDocument (this), 0, false);
|
||||
jucerComp.reset (new TestComponent (ComponentTypeHandler::findParentDocument (this), 0, false));
|
||||
jucerComp->setFilename (jucerComponentFile);
|
||||
jucerComp->setToInitialSize();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,12 +52,11 @@ void PaintElementGroup::ungroup (const bool undoable)
|
|||
getOwner()->removeElement (this, undoable);
|
||||
}
|
||||
|
||||
void PaintElementGroup::groupSelected (PaintRoutine* const routine)
|
||||
void PaintElementGroup::groupSelected (PaintRoutine* routine)
|
||||
{
|
||||
if (routine->getSelectedElements().getNumSelected() > 1)
|
||||
{
|
||||
PaintElementGroup* newGroup = new PaintElementGroup (routine);
|
||||
|
||||
auto* newGroup = new PaintElementGroup (routine);
|
||||
int frontIndex = -1;
|
||||
|
||||
for (int i = 0; i < routine->getNumElements(); ++i)
|
||||
|
|
@ -66,7 +65,7 @@ void PaintElementGroup::groupSelected (PaintRoutine* const routine)
|
|||
{
|
||||
ScopedPointer<XmlElement> xml (routine->getElement(i)->createXml());
|
||||
|
||||
if (PaintElement* newOne = ObjectTypes::createElementForXml (xml, routine))
|
||||
if (auto* newOne = ObjectTypes::createElementForXml (xml, routine))
|
||||
newGroup->subElements.add (newOne);
|
||||
|
||||
if (i > frontIndex)
|
||||
|
|
@ -76,7 +75,7 @@ void PaintElementGroup::groupSelected (PaintRoutine* const routine)
|
|||
|
||||
routine->deleteSelected();
|
||||
|
||||
PaintElement* const g = routine->addNewElement (newGroup, frontIndex, true);
|
||||
auto* g = routine->addNewElement (newGroup, frontIndex, true);
|
||||
routine->getSelectedElements().selectOnly (g);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
const bool canReset)
|
||||
: PropertyComponent (name)
|
||||
{
|
||||
colourPropEditor = new ColourPropEditorComponent (this, canReset);
|
||||
colourPropEditor.reset (new ColourPropEditorComponent (this, canReset));
|
||||
addAndMakeVisible (colourPropEditor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,16 +32,15 @@
|
|||
class EditingPanelBase::MagnifierComponent : public Component
|
||||
{
|
||||
public:
|
||||
MagnifierComponent (Component* comp)
|
||||
: scaleFactor (1.0), content (comp)
|
||||
MagnifierComponent (Component* c) : content (c)
|
||||
{
|
||||
addAndMakeVisible (content);
|
||||
childBoundsChanged (content);
|
||||
addAndMakeVisible (content.get());
|
||||
childBoundsChanged (content.get());
|
||||
}
|
||||
|
||||
void childBoundsChanged (Component* child)
|
||||
{
|
||||
const Rectangle<int> childArea (getLocalArea (child, child->getLocalBounds()));
|
||||
auto childArea = getLocalArea (child, child->getLocalBounds());
|
||||
setSize (childArea.getWidth(), childArea.getHeight());
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +53,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
double scaleFactor;
|
||||
double scaleFactor = 1.0;
|
||||
ScopedPointer<Component> content;
|
||||
};
|
||||
|
||||
|
|
@ -62,8 +61,7 @@ private:
|
|||
class ZoomingViewport : public Viewport
|
||||
{
|
||||
public:
|
||||
ZoomingViewport (EditingPanelBase* const p)
|
||||
: panel (p), isSpaceDown (false)
|
||||
ZoomingViewport (EditingPanelBase* p) : panel (p)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +86,7 @@ public:
|
|||
|
||||
if (isSpaceDown)
|
||||
{
|
||||
DraggerOverlayComp* const dc = new DraggerOverlayComp();
|
||||
auto dc = new DraggerOverlayComp();
|
||||
addAndMakeVisible (dc);
|
||||
dc->setBounds (getLocalBounds());
|
||||
}
|
||||
|
|
@ -102,7 +100,7 @@ public:
|
|||
|
||||
private:
|
||||
EditingPanelBase* const panel;
|
||||
bool isSpaceDown;
|
||||
bool isSpaceDown = false;
|
||||
|
||||
//==============================================================================
|
||||
class DraggerOverlayComp : public Component
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
JucerDocumentEditor (JucerDocument* const document);
|
||||
~JucerDocumentEditor();
|
||||
|
||||
JucerDocument* getDocument() const noexcept { return document; }
|
||||
JucerDocument* getDocument() const noexcept { return document.get(); }
|
||||
|
||||
void refreshPropertiesPanel() const;
|
||||
void updateTabs();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
File findFile() const;
|
||||
|
||||
JucerDocument* getDocument() const noexcept { return loadedDocument; }
|
||||
JucerDocument* getDocument() const noexcept { return loadedDocument.get(); }
|
||||
JucerDocument* getOwnerDocument() const noexcept { return ownerDocument; }
|
||||
|
||||
void setToInitialSize();
|
||||
|
|
|
|||
|
|
@ -38,10 +38,8 @@ BinaryResources::~BinaryResources()
|
|||
|
||||
BinaryResources& BinaryResources::operator= (const BinaryResources& other)
|
||||
{
|
||||
for (int i = 0; i < other.resources.size(); ++i)
|
||||
add (other.resources[i]->name,
|
||||
other.resources[i]->originalFilename,
|
||||
other.resources[i]->data);
|
||||
for (auto* r : other.resources)
|
||||
add (r->name, r->originalFilename, r->data);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -69,17 +67,17 @@ StringArray BinaryResources::getResourceNames() const
|
|||
{
|
||||
StringArray s;
|
||||
|
||||
for (int i = 0; i < resources.size(); ++i)
|
||||
s.add (resources.getUnchecked(i)->name);
|
||||
for (auto* r : resources)
|
||||
s.add (r->name);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
BinaryResources::BinaryResource* BinaryResources::findResource (const String& name) const noexcept
|
||||
{
|
||||
for (int i = resources.size(); --i >= 0;)
|
||||
if (resources.getUnchecked(i)->name == name)
|
||||
return resources.getUnchecked(i);
|
||||
for (auto* r : resources)
|
||||
if (r->name == name)
|
||||
return r;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -91,9 +89,9 @@ const BinaryResources::BinaryResource* BinaryResources::getResource (const Strin
|
|||
|
||||
const BinaryResources::BinaryResource* BinaryResources::getResourceForFile (const File& file) const
|
||||
{
|
||||
for (int i = resources.size(); --i >= 0;)
|
||||
if (resources.getUnchecked(i)->originalFilename == file.getFullPathName())
|
||||
return resources.getUnchecked(i);
|
||||
for (auto* r : resources)
|
||||
if (r->originalFilename == file.getFullPathName())
|
||||
return r;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -111,7 +109,7 @@ bool BinaryResources::add (const String& name, const File& file)
|
|||
|
||||
void BinaryResources::add (const String& name, const String& originalFileName, const MemoryBlock& data)
|
||||
{
|
||||
BinaryResource* r = findResource (name);
|
||||
auto* r = findResource (name);
|
||||
|
||||
if (r == nullptr)
|
||||
{
|
||||
|
|
@ -128,7 +126,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c
|
|||
|
||||
bool BinaryResources::reload (const int index)
|
||||
{
|
||||
return resources[index] != 0
|
||||
return resources[index] != nullptr
|
||||
&& add (resources [index]->name,
|
||||
File (resources [index]->originalFilename));
|
||||
}
|
||||
|
|
@ -159,16 +157,15 @@ String BinaryResources::browseForResource (const String& title,
|
|||
return name;
|
||||
}
|
||||
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
String BinaryResources::findUniqueName (const String& rootName) const
|
||||
{
|
||||
String nameRoot (CodeHelpers::makeValidIdentifier (rootName, true, true, false));
|
||||
String name (nameRoot);
|
||||
|
||||
const StringArray names (getResourceNames());
|
||||
auto nameRoot = CodeHelpers::makeValidIdentifier (rootName, true, true, false);
|
||||
auto name = nameRoot;
|
||||
|
||||
auto names = getResourceNames();
|
||||
int suffix = 1;
|
||||
|
||||
while (names.contains (name))
|
||||
|
|
@ -177,9 +174,9 @@ String BinaryResources::findUniqueName (const String& rootName) const
|
|||
return name;
|
||||
}
|
||||
|
||||
void BinaryResources::remove (const int i)
|
||||
void BinaryResources::remove (int i)
|
||||
{
|
||||
if (resources[i] != 0)
|
||||
if (resources[i] != nullptr)
|
||||
{
|
||||
resources.remove (i);
|
||||
changed();
|
||||
|
|
@ -188,13 +185,13 @@ void BinaryResources::remove (const int i)
|
|||
|
||||
const Drawable* BinaryResources::getDrawable (const String& name) const
|
||||
{
|
||||
if (BinaryResources::BinaryResource* const res = const_cast<BinaryResources::BinaryResource*> (getResource (name)))
|
||||
if (auto* res = const_cast<BinaryResources::BinaryResource*> (getResource (name)))
|
||||
{
|
||||
if (res->drawable == nullptr && res->data.getSize() > 0)
|
||||
res->drawable = Drawable::createFromImageData (res->data.getData(),
|
||||
res->data.getSize());
|
||||
res->drawable.reset (Drawable::createFromImageData (res->data.getData(),
|
||||
res->data.getSize()));
|
||||
|
||||
return res->drawable;
|
||||
return res->drawable.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -202,11 +199,11 @@ const Drawable* BinaryResources::getDrawable (const String& name) const
|
|||
|
||||
Image BinaryResources::getImageFromCache (const String& name) const
|
||||
{
|
||||
if (const BinaryResources::BinaryResource* const res = getResource (name))
|
||||
if (auto* res = getResource (name))
|
||||
if (res->data.getSize() > 0)
|
||||
return ImageCache::getFromMemory (res->data.getData(), (int) res->data.getSize());
|
||||
|
||||
return Image();
|
||||
return {};
|
||||
}
|
||||
|
||||
void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cppFile)
|
||||
|
|
@ -225,22 +222,22 @@ void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cp
|
|||
tokens.trim();
|
||||
tokens.removeEmptyStrings();
|
||||
|
||||
const String resourceName (tokens[0]);
|
||||
const int resourceSize = tokens[1].getIntValue();
|
||||
const String originalFileName (cppFileLocation.getSiblingFile (tokens[2].unquoted()).getFullPathName());
|
||||
auto resourceName = tokens[0];
|
||||
auto resourceSize = tokens[1].getIntValue();
|
||||
auto originalFileName = cppFileLocation.getSiblingFile (tokens[2].unquoted()).getFullPathName();
|
||||
|
||||
jassert (resourceName.isNotEmpty() && resourceSize > 0);
|
||||
|
||||
if (resourceName.isNotEmpty() && resourceSize > 0)
|
||||
{
|
||||
const int firstLine = i;
|
||||
auto firstLine = i;
|
||||
|
||||
while (i < cpp.size())
|
||||
if (cpp [i++].contains ("}"))
|
||||
break;
|
||||
|
||||
const String dataString (cpp.joinIntoString (" ", firstLine, i - firstLine)
|
||||
.fromFirstOccurrenceOf ("{", false, false));
|
||||
auto dataString = cpp.joinIntoString (" ", firstLine, i - firstLine)
|
||||
.fromFirstOccurrenceOf ("{", false, false);
|
||||
|
||||
MemoryOutputStream out;
|
||||
String::CharPointerType t (dataString.getCharPointer());
|
||||
|
|
@ -248,17 +245,21 @@ void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cp
|
|||
|
||||
while (! t.isEmpty())
|
||||
{
|
||||
const juce_wchar c = t.getAndAdvance();
|
||||
auto c = t.getAndAdvance();
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
n = n * 10 + (c - '0');
|
||||
}
|
||||
else if (c == ',')
|
||||
{
|
||||
out.writeByte ((char) n);
|
||||
n = 0;
|
||||
}
|
||||
else if (c == '}')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
jassert (resourceSize < (int) out.getDataSize() && resourceSize > (int) out.getDataSize() - 2);
|
||||
|
|
@ -284,21 +285,21 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
|
|||
defs << "//==============================================================================\n";
|
||||
defs << "// Binary resources - be careful not to edit any of these sections!\n\n";
|
||||
|
||||
for (int i = 0; i < resources.size(); ++i)
|
||||
for (auto* r : resources)
|
||||
{
|
||||
code.publicMemberDeclarations
|
||||
<< "static const char* "
|
||||
<< resources[i]->name
|
||||
<< r->name
|
||||
<< ";\nstatic const int "
|
||||
<< resources[i]->name
|
||||
<< r->name
|
||||
<< "Size;\n";
|
||||
|
||||
const String name (resources[i]->name);
|
||||
const MemoryBlock& mb = resources[i]->data;
|
||||
auto name = r->name;
|
||||
auto& mb = r->data;
|
||||
|
||||
defs << "// JUCER_RESOURCE: " << name << ", " << (int) mb.getSize()
|
||||
<< ", \""
|
||||
<< File (resources[i]->originalFilename)
|
||||
<< File (r->originalFilename)
|
||||
.getRelativePathFrom (code.document->getCppFile())
|
||||
.replaceCharacter ('\\', '/')
|
||||
<< "\"\n";
|
||||
|
|
@ -313,7 +314,7 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
|
|||
|
||||
for (size_t j = 0; j < mb.getSize(); ++j)
|
||||
{
|
||||
const int num = (int) (unsigned char) mb[j];
|
||||
auto num = (int) (unsigned char) mb[j];
|
||||
defs << num << ',';
|
||||
|
||||
charsOnLine += 2;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ struct DiagnosticMessage
|
|||
|
||||
DiagnosticMessage& operator= (const DiagnosticMessage& other)
|
||||
{
|
||||
associatedDiagnostic = createCopyIfNotNull (other.associatedDiagnostic.get());
|
||||
associatedDiagnostic.reset (createCopyIfNotNull (other.associatedDiagnostic.get()));
|
||||
message = other.message;
|
||||
mainFile = other.mainFile;
|
||||
range = other.range;
|
||||
|
|
@ -110,8 +110,9 @@ struct DiagnosticMessage
|
|||
d.type = (Type) static_cast<int> (v[Ids::type]);
|
||||
|
||||
auto associated = v.getChild (0);
|
||||
|
||||
if (associated.isValid())
|
||||
d.associatedDiagnostic = new DiagnosticMessage (fromValueTree (associated));
|
||||
d.associatedDiagnostic.reset (new DiagnosticMessage (fromValueTree (associated)));
|
||||
|
||||
return d;
|
||||
}
|
||||
|
|
@ -150,7 +151,7 @@ struct DiagnosticList
|
|||
if (lastMessage.message.isEmpty())
|
||||
return; // seems to happen sometimes, but with seemingly duplicated messages (?)
|
||||
|
||||
m.associatedDiagnostic = new DiagnosticMessage (lastMessage);
|
||||
m.associatedDiagnostic.reset (new DiagnosticMessage (lastMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public:
|
|||
|| dynamic_cast<FileOptionComponent*> (existing.get())->item != child)
|
||||
{
|
||||
existing.reset();
|
||||
existing = new FileOptionComponent (child, dynamic_cast<ListBoxHeader*> (list.getHeaderComponent()));
|
||||
existing.reset (new FileOptionComponent (child, dynamic_cast<ListBoxHeader*> (list.getHeaderComponent())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@
|
|||
//==============================================================================
|
||||
class UserSettingsPopup : public Component
|
||||
#if ! JUCER_ENABLE_GPL_MODE
|
||||
, private Button::Listener,
|
||||
private LicenseController::StateChangedCallback
|
||||
#endif
|
||||
, private LicenseController::StateChangedCallback
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
UserSettingsPopup (bool isShownInsideWebview)
|
||||
|
|
@ -63,13 +62,24 @@ public:
|
|||
licenseTypeLabel->setMinimumHorizontalScale (1.0f);
|
||||
|
||||
addAndMakeVisible (logoutButton = new TextButton (isInsideWebview ? "Select different account..." : "Logout"));
|
||||
logoutButton->addListener (this);
|
||||
logoutButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
|
||||
|
||||
logoutButton->onClick = [this]
|
||||
{
|
||||
dismissCalloutBox();
|
||||
ProjucerApplication::getApp().doLogout();
|
||||
};
|
||||
|
||||
if (! isInsideWebview)
|
||||
{
|
||||
addAndMakeVisible (switchLicenseButton = new TextButton ("Switch License"));
|
||||
switchLicenseButton->addListener (this);
|
||||
switchLicenseButton->onClick = [this]
|
||||
{
|
||||
dismissCalloutBox();
|
||||
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
};
|
||||
}
|
||||
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
|
|
@ -109,23 +119,13 @@ public:
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
#if ! JUCER_ENABLE_GPL_MODE
|
||||
void buttonClicked (Button* b) override
|
||||
void dismissCalloutBox()
|
||||
{
|
||||
if (b == logoutButton)
|
||||
{
|
||||
dismissCalloutBox();
|
||||
ProjucerApplication::getApp().doLogout();
|
||||
}
|
||||
else if (b == switchLicenseButton)
|
||||
{
|
||||
dismissCalloutBox();
|
||||
if (auto* controller = ProjucerApplication::getApp().licenseController.get())
|
||||
controller->chooseNewLicense();
|
||||
}
|
||||
if (auto* parent = findParentComponentOfClass<CallOutBox>())
|
||||
parent->dismiss();
|
||||
}
|
||||
|
||||
|
||||
#if ! JUCER_ENABLE_GPL_MODE
|
||||
void licenseStateChanged (const LicenseState& state) override
|
||||
{
|
||||
hasLicenseType = (state.type != LicenseState::Type::noLicenseChosenYet);
|
||||
|
|
@ -134,12 +134,6 @@ private:
|
|||
licenseTypeLabel->setText (LicenseState::licenseTypeToString (state.type), NotificationType::dontSendNotification);
|
||||
}
|
||||
|
||||
void dismissCalloutBox()
|
||||
{
|
||||
if (auto* parent = findParentComponentOfClass<CallOutBox>())
|
||||
parent->dismiss();
|
||||
}
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
if (logoutButton != nullptr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue