Browse Source

Cleaned up a few more ScopedPointer uses

tags/2021-05-28
jules 7 years ago
parent
commit
33c0940d74
15 changed files with 129 additions and 155 deletions
  1. +17
    -24
      extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h
  2. +27
    -39
      extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h
  3. +1
    -1
      extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h
  4. +1
    -1
      extras/Projucer/Source/Application/jucer_AutoUpdater.cpp
  5. +1
    -1
      extras/Projucer/Source/Application/jucer_MainWindow.cpp
  6. +1
    -1
      extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h
  7. +4
    -5
      extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementGroup.cpp
  8. +1
    -1
      extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h
  9. +8
    -10
      extras/Projucer/Source/ComponentEditor/UI/jucer_EditingPanelBase.cpp
  10. +1
    -1
      extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.h
  11. +1
    -1
      extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.h
  12. +42
    -41
      extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp
  13. +4
    -3
      extras/Projucer/Source/LiveBuildEngine/jucer_DiagnosticMessage.h
  14. +1
    -1
      extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h
  15. +19
    -25
      extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h

+ 17
- 24
extras/Projucer/Source/Application/Windows/jucer_AboutWindowComponent.h View File

@@ -28,15 +28,10 @@
//============================================================================== //==============================================================================
class AboutWindowComponent : public Component,
private Button::Listener
class AboutWindowComponent : public Component
{ {
public: public:
AboutWindowComponent() 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; bool showPurchaseButton = false;
@@ -67,8 +62,13 @@ public:
if (showPurchaseButton) 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); 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)); aboutButton.setBounds (centreSlice.removeFromBottom (20));
} }
@@ -123,12 +123,14 @@ public:
} }
private: 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.") };
HyperlinkButton aboutButton { "About Us", URL ("https://juce.com") };
TextButton licenseButton { "Purchase License" };
Rectangle<float> huckleberryLogoBounds;
Rectangle<float> juceLogoBounds;
Rectangle<float> huckleberryLogoBounds, juceLogoBounds;
ScopedPointer<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png, ScopedPointer<Drawable> juceLogo { Drawable::createFromImageData (BinaryData::juce_icon_png,
BinaryData::juce_icon_pngSize) }; BinaryData::juce_icon_pngSize) };
@@ -136,14 +138,5 @@ private:
ScopedPointer<Drawable> huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg, ScopedPointer<Drawable> huckleberryLogo { Drawable::createFromImageData (BinaryData::huckleberry_icon_svg,
BinaryData::huckleberry_icon_svgSize) }; 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) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AboutWindowComponent)
}; };

+ 27
- 39
extras/Projucer/Source/Application/Windows/jucer_ApplicationUsageDataWindowComponent.h View File

@@ -28,8 +28,7 @@
//============================================================================== //==============================================================================
class ApplicationUsageDataWindowComponent : public Component,
private Button::Listener
class ApplicationUsageDataWindowComponent : public Component
{ {
public: public:
ApplicationUsageDataWindowComponent (bool showCheckbox) ApplicationUsageDataWindowComponent (bool showCheckbox)
@@ -62,29 +61,32 @@ public:
privacyPolicyLink.setURL (URL ("https://juce.com/privacy-policy")); privacyPolicyLink.setURL (URL ("https://juce.com/privacy-policy"));
addAndMakeVisible (okButton); addAndMakeVisible (okButton);
okButton.setButtonText ("OK");
okButton.addListener (this);
if (showCheckbox) if (showCheckbox)
{ {
addAndMakeVisible (shareApplicationUsageDataToggle = new ToggleButton());
addAndMakeVisible (shareApplicationUsageDataToggle);
auto* controller = ProjucerApplication::getApp().licenseController.get(); auto* controller = ProjucerApplication::getApp().licenseController.get();
if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::disabled) if (controller != nullptr && controller->getState().applicationUsageDataState == LicenseState::ApplicationUsageData::disabled)
shareApplicationUsageDataToggle->setToggleState (false, dontSendNotification);
shareApplicationUsageDataToggle.setToggleState (false, dontSendNotification);
else 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 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; auto newApplicationUsageDataState = LicenseState::ApplicationUsageData::enabled;
if (shareApplicationUsageDataToggle != nullptr && ! shareApplicationUsageDataToggle->getToggleState())
if (shareApplicationUsageDataToggle.isShowing() && ! shareApplicationUsageDataToggle.getToggleState())
newApplicationUsageDataState = LicenseState::ApplicationUsageData::disabled; newApplicationUsageDataState = LicenseState::ApplicationUsageData::disabled;
controller->setApplicationUsageDataState (newApplicationUsageDataState); controller->setApplicationUsageDataState (newApplicationUsageDataState);
@@ -113,13 +115,13 @@ public:
juceEULALink.setBounds (linkBounds.removeFromLeft (linkBounds.getWidth() / 2).reduced (2)); juceEULALink.setBounds (linkBounds.removeFromLeft (linkBounds.getWidth() / 2).reduced (2));
privacyPolicyLink.setBounds (linkBounds.reduced (2)); privacyPolicyLink.setBounds (linkBounds.reduced (2));
if (shareApplicationUsageDataToggle != nullptr)
if (shareApplicationUsageDataToggle.isShowing())
{ {
bounds.removeFromTop (10); bounds.removeFromTop (10);
auto toggleBounds = bounds.removeFromTop (40); 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); bounds.removeFromTop (10);
@@ -127,16 +129,17 @@ public:
auto buttonW = 125; auto buttonW = 125;
auto buttonH = 40; auto buttonH = 40;
if (upgradeLicenseButton != nullptr)
if (upgradeLicenseButton.isShowing())
{ {
auto left = bounds.removeFromLeft (bounds.getWidth() / 2); 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.setSize (buttonW, buttonH);
okButton.setCentrePosition (bounds.getCentreX(), bounds.getCentreY()); okButton.setCentrePosition (bounds.getCentreX(), bounds.getCentreY());
okButton.onClick = [] { ProjucerApplication::getApp().dismissApplicationUsageDataAgreementPopup(); };
} }
void paint (Graphics& g) override void paint (Graphics& g) override
@@ -147,28 +150,13 @@ public:
private: private:
Label headerLabel, bodyLabel; Label headerLabel, bodyLabel;
HyperlinkButton juceEULALink, privacyPolicyLink; 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 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) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationUsageDataWindowComponent)


+ 1
- 1
extras/Projucer/Source/Application/Windows/jucer_FloatingToolWindow.h View File

@@ -57,7 +57,7 @@ struct FloatingToolWindow : public DialogWindow
centreAroundComponent (Component::getCurrentlyFocusedComponent(), defaultW, defaultH); centreAroundComponent (Component::getCurrentlyFocusedComponent(), defaultW, defaultH);
setVisible (true); setVisible (true);
owner = this;
owner.reset (this);
} }
~FloatingToolWindow() ~FloatingToolWindow()


+ 1
- 1
extras/Projucer/Source/Application/jucer_AutoUpdater.cpp View File

@@ -303,7 +303,7 @@ public:
juceIcon = Drawable::createFromImageData (BinaryData::juce_icon_png, juceIcon = Drawable::createFromImageData (BinaryData::juce_icon_png,
BinaryData::juce_icon_pngSize); BinaryData::juce_icon_pngSize);
setSize (518, overwritePath ? 345 : 269);
setSize (518, overwritePath != nullptr ? 345 : 269);
lookAndFeelChanged(); lookAndFeelChanged();
} }


+ 1
- 1
extras/Projucer/Source/Application/jucer_MainWindow.cpp View File

@@ -162,7 +162,7 @@ void MainWindow::setProject (Project* newProject)
{ {
createProjectContentCompIfNeeded(); createProjectContentCompIfNeeded();
getProjectContentComponent()->setProject (newProject); getProjectContentComponent()->setProject (newProject);
currentProject = newProject;
currentProject.reset (newProject);
if (currentProject != nullptr) if (currentProject != nullptr)
projectNameValue.referTo (currentProject->getProjectValue (Ids::name)); projectNameValue.referTo (currentProject->getProjectValue (Ids::name));


+ 1
- 1
extras/Projucer/Source/ComponentEditor/Components/jucer_TabbedComponentHandler.h View File

@@ -380,7 +380,7 @@ private:
{ {
jucerComp.reset(); jucerComp.reset();
jucerComp = new TestComponent (ComponentTypeHandler::findParentDocument (this), 0, false);
jucerComp.reset (new TestComponent (ComponentTypeHandler::findParentDocument (this), 0, false));
jucerComp->setFilename (jucerComponentFile); jucerComp->setFilename (jucerComponentFile);
jucerComp->setToInitialSize(); jucerComp->setToInitialSize();


+ 4
- 5
extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementGroup.cpp View File

@@ -52,12 +52,11 @@ void PaintElementGroup::ungroup (const bool undoable)
getOwner()->removeElement (this, undoable); getOwner()->removeElement (this, undoable);
} }
void PaintElementGroup::groupSelected (PaintRoutine* const routine)
void PaintElementGroup::groupSelected (PaintRoutine* routine)
{ {
if (routine->getSelectedElements().getNumSelected() > 1) if (routine->getSelectedElements().getNumSelected() > 1)
{ {
PaintElementGroup* newGroup = new PaintElementGroup (routine);
auto* newGroup = new PaintElementGroup (routine);
int frontIndex = -1; int frontIndex = -1;
for (int i = 0; i < routine->getNumElements(); ++i) 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()); 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); newGroup->subElements.add (newOne);
if (i > frontIndex) if (i > frontIndex)
@@ -76,7 +75,7 @@ void PaintElementGroup::groupSelected (PaintRoutine* const routine)
routine->deleteSelected(); routine->deleteSelected();
PaintElement* const g = routine->addNewElement (newGroup, frontIndex, true);
auto* g = routine->addNewElement (newGroup, frontIndex, true);
routine->getSelectedElements().selectOnly (g); routine->getSelectedElements().selectOnly (g);
} }
} }


+ 1
- 1
extras/Projucer/Source/ComponentEditor/Properties/jucer_ColourPropertyComponent.h View File

@@ -35,7 +35,7 @@ public:
const bool canReset) const bool canReset)
: PropertyComponent (name) : PropertyComponent (name)
{ {
colourPropEditor = new ColourPropEditorComponent (this, canReset);
colourPropEditor.reset (new ColourPropEditorComponent (this, canReset));
addAndMakeVisible (colourPropEditor); addAndMakeVisible (colourPropEditor);
} }


+ 8
- 10
extras/Projucer/Source/ComponentEditor/UI/jucer_EditingPanelBase.cpp View File

@@ -32,16 +32,15 @@
class EditingPanelBase::MagnifierComponent : public Component class EditingPanelBase::MagnifierComponent : public Component
{ {
public: 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) void childBoundsChanged (Component* child)
{ {
const Rectangle<int> childArea (getLocalArea (child, child->getLocalBounds()));
auto childArea = getLocalArea (child, child->getLocalBounds());
setSize (childArea.getWidth(), childArea.getHeight()); setSize (childArea.getWidth(), childArea.getHeight());
} }
@@ -54,7 +53,7 @@ public:
} }
private: private:
double scaleFactor;
double scaleFactor = 1.0;
ScopedPointer<Component> content; ScopedPointer<Component> content;
}; };
@@ -62,8 +61,7 @@ private:
class ZoomingViewport : public Viewport class ZoomingViewport : public Viewport
{ {
public: public:
ZoomingViewport (EditingPanelBase* const p)
: panel (p), isSpaceDown (false)
ZoomingViewport (EditingPanelBase* p) : panel (p)
{ {
} }
@@ -88,7 +86,7 @@ public:
if (isSpaceDown) if (isSpaceDown)
{ {
DraggerOverlayComp* const dc = new DraggerOverlayComp();
auto dc = new DraggerOverlayComp();
addAndMakeVisible (dc); addAndMakeVisible (dc);
dc->setBounds (getLocalBounds()); dc->setBounds (getLocalBounds());
} }
@@ -102,7 +100,7 @@ public:
private: private:
EditingPanelBase* const panel; EditingPanelBase* const panel;
bool isSpaceDown;
bool isSpaceDown = false;
//============================================================================== //==============================================================================
class DraggerOverlayComp : public Component class DraggerOverlayComp : public Component


+ 1
- 1
extras/Projucer/Source/ComponentEditor/UI/jucer_JucerDocumentEditor.h View File

@@ -41,7 +41,7 @@ public:
JucerDocumentEditor (JucerDocument* const document); JucerDocumentEditor (JucerDocument* const document);
~JucerDocumentEditor(); ~JucerDocumentEditor();
JucerDocument* getDocument() const noexcept { return document; }
JucerDocument* getDocument() const noexcept { return document.get(); }
void refreshPropertiesPanel() const; void refreshPropertiesPanel() const;
void updateTabs(); void updateTabs();


+ 1
- 1
extras/Projucer/Source/ComponentEditor/UI/jucer_TestComponent.h View File

@@ -48,7 +48,7 @@ public:
File findFile() const; File findFile() const;
JucerDocument* getDocument() const noexcept { return loadedDocument; }
JucerDocument* getDocument() const noexcept { return loadedDocument.get(); }
JucerDocument* getOwnerDocument() const noexcept { return ownerDocument; } JucerDocument* getOwnerDocument() const noexcept { return ownerDocument; }
void setToInitialSize(); void setToInitialSize();


+ 42
- 41
extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp View File

@@ -38,10 +38,8 @@ BinaryResources::~BinaryResources()
BinaryResources& BinaryResources::operator= (const BinaryResources& other) 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; return *this;
} }
@@ -69,17 +67,17 @@ StringArray BinaryResources::getResourceNames() const
{ {
StringArray s; 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; return s;
} }
BinaryResources::BinaryResource* BinaryResources::findResource (const String& name) const noexcept 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; return nullptr;
} }
@@ -91,9 +89,9 @@ const BinaryResources::BinaryResource* BinaryResources::getResource (const Strin
const BinaryResources::BinaryResource* BinaryResources::getResourceForFile (const File& file) const 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; 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) void BinaryResources::add (const String& name, const String& originalFileName, const MemoryBlock& data)
{ {
BinaryResource* r = findResource (name);
auto* r = findResource (name);
if (r == nullptr) if (r == nullptr)
{ {
@@ -128,7 +126,7 @@ void BinaryResources::add (const String& name, const String& originalFileName, c
bool BinaryResources::reload (const int index) bool BinaryResources::reload (const int index)
{ {
return resources[index] != 0
return resources[index] != nullptr
&& add (resources [index]->name, && add (resources [index]->name,
File (resources [index]->originalFilename)); File (resources [index]->originalFilename));
} }
@@ -159,16 +157,15 @@ String BinaryResources::browseForResource (const String& title,
return name; return name;
} }
return String();
return {};
} }
String BinaryResources::findUniqueName (const String& rootName) const 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; int suffix = 1;
while (names.contains (name)) while (names.contains (name))
@@ -177,9 +174,9 @@ String BinaryResources::findUniqueName (const String& rootName) const
return name; return name;
} }
void BinaryResources::remove (const int i)
void BinaryResources::remove (int i)
{ {
if (resources[i] != 0)
if (resources[i] != nullptr)
{ {
resources.remove (i); resources.remove (i);
changed(); changed();
@@ -188,13 +185,13 @@ void BinaryResources::remove (const int i)
const Drawable* BinaryResources::getDrawable (const String& name) const 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) 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; return nullptr;
@@ -202,11 +199,11 @@ const Drawable* BinaryResources::getDrawable (const String& name) const
Image BinaryResources::getImageFromCache (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) if (res->data.getSize() > 0)
return ImageCache::getFromMemory (res->data.getData(), (int) res->data.getSize()); return ImageCache::getFromMemory (res->data.getData(), (int) res->data.getSize());
return Image();
return {};
} }
void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cppFile) 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.trim();
tokens.removeEmptyStrings(); 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); jassert (resourceName.isNotEmpty() && resourceSize > 0);
if (resourceName.isNotEmpty() && resourceSize > 0) if (resourceName.isNotEmpty() && resourceSize > 0)
{ {
const int firstLine = i;
auto firstLine = i;
while (i < cpp.size()) while (i < cpp.size())
if (cpp [i++].contains ("}")) if (cpp [i++].contains ("}"))
break; break;
const String dataString (cpp.joinIntoString (" ", firstLine, i - firstLine)
.fromFirstOccurrenceOf ("{", false, false));
auto dataString = cpp.joinIntoString (" ", firstLine, i - firstLine)
.fromFirstOccurrenceOf ("{", false, false);
MemoryOutputStream out; MemoryOutputStream out;
String::CharPointerType t (dataString.getCharPointer()); String::CharPointerType t (dataString.getCharPointer());
@@ -248,17 +245,21 @@ void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cp
while (! t.isEmpty()) while (! t.isEmpty())
{ {
const juce_wchar c = t.getAndAdvance();
auto c = t.getAndAdvance();
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
{
n = n * 10 + (c - '0'); n = n * 10 + (c - '0');
}
else if (c == ',') else if (c == ',')
{ {
out.writeByte ((char) n); out.writeByte ((char) n);
n = 0; n = 0;
} }
else if (c == '}') else if (c == '}')
{
break; break;
}
} }
jassert (resourceSize < (int) out.getDataSize() && resourceSize > (int) out.getDataSize() - 2); jassert (resourceSize < (int) out.getDataSize() && resourceSize > (int) out.getDataSize() - 2);
@@ -284,21 +285,21 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
defs << "//==============================================================================\n"; defs << "//==============================================================================\n";
defs << "// Binary resources - be careful not to edit any of these sections!\n\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 code.publicMemberDeclarations
<< "static const char* " << "static const char* "
<< resources[i]->name
<< r->name
<< ";\nstatic const int " << ";\nstatic const int "
<< resources[i]->name
<< r->name
<< "Size;\n"; << "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() defs << "// JUCER_RESOURCE: " << name << ", " << (int) mb.getSize()
<< ", \"" << ", \""
<< File (resources[i]->originalFilename)
<< File (r->originalFilename)
.getRelativePathFrom (code.document->getCppFile()) .getRelativePathFrom (code.document->getCppFile())
.replaceCharacter ('\\', '/') .replaceCharacter ('\\', '/')
<< "\"\n"; << "\"\n";
@@ -313,7 +314,7 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const
for (size_t j = 0; j < mb.getSize(); ++j) 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 << ','; defs << num << ',';
charsOnLine += 2; charsOnLine += 2;


+ 4
- 3
extras/Projucer/Source/LiveBuildEngine/jucer_DiagnosticMessage.h View File

@@ -43,7 +43,7 @@ struct DiagnosticMessage
DiagnosticMessage& operator= (const DiagnosticMessage& other) DiagnosticMessage& operator= (const DiagnosticMessage& other)
{ {
associatedDiagnostic = createCopyIfNotNull (other.associatedDiagnostic.get());
associatedDiagnostic.reset (createCopyIfNotNull (other.associatedDiagnostic.get()));
message = other.message; message = other.message;
mainFile = other.mainFile; mainFile = other.mainFile;
range = other.range; range = other.range;
@@ -110,8 +110,9 @@ struct DiagnosticMessage
d.type = (Type) static_cast<int> (v[Ids::type]); d.type = (Type) static_cast<int> (v[Ids::type]);
auto associated = v.getChild (0); auto associated = v.getChild (0);
if (associated.isValid()) if (associated.isValid())
d.associatedDiagnostic = new DiagnosticMessage (fromValueTree (associated));
d.associatedDiagnostic.reset (new DiagnosticMessage (fromValueTree (associated)));
return d; return d;
} }
@@ -150,7 +151,7 @@ struct DiagnosticList
if (lastMessage.message.isEmpty()) if (lastMessage.message.isEmpty())
return; // seems to happen sometimes, but with seemingly duplicated messages (?) return; // seems to happen sometimes, but with seemingly duplicated messages (?)
m.associatedDiagnostic = new DiagnosticMessage (lastMessage);
m.associatedDiagnostic.reset (new DiagnosticMessage (lastMessage));
} }
else else
{ {


+ 1
- 1
extras/Projucer/Source/Project/UI/jucer_FileGroupInformationComponent.h View File

@@ -99,7 +99,7 @@ public:
|| dynamic_cast<FileOptionComponent*> (existing.get())->item != child) || dynamic_cast<FileOptionComponent*> (existing.get())->item != child)
{ {
existing.reset(); existing.reset();
existing = new FileOptionComponent (child, dynamic_cast<ListBoxHeader*> (list.getHeaderComponent()));
existing.reset (new FileOptionComponent (child, dynamic_cast<ListBoxHeader*> (list.getHeaderComponent())));
} }
} }


+ 19
- 25
extras/Projucer/Source/Utility/UI/jucer_UserSettingsPopup.h View File

@@ -30,9 +30,8 @@
//============================================================================== //==============================================================================
class UserSettingsPopup : public Component class UserSettingsPopup : public Component
#if ! JUCER_ENABLE_GPL_MODE #if ! JUCER_ENABLE_GPL_MODE
, private Button::Listener,
private LicenseController::StateChangedCallback
#endif
, private LicenseController::StateChangedCallback
#endif
{ {
public: public:
UserSettingsPopup (bool isShownInsideWebview) UserSettingsPopup (bool isShownInsideWebview)
@@ -63,13 +62,24 @@ public:
licenseTypeLabel->setMinimumHorizontalScale (1.0f); licenseTypeLabel->setMinimumHorizontalScale (1.0f);
addAndMakeVisible (logoutButton = new TextButton (isInsideWebview ? "Select different account..." : "Logout")); addAndMakeVisible (logoutButton = new TextButton (isInsideWebview ? "Select different account..." : "Logout"));
logoutButton->addListener (this);
logoutButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); logoutButton->setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
logoutButton->onClick = [this]
{
dismissCalloutBox();
ProjucerApplication::getApp().doLogout();
};
if (! isInsideWebview) if (! isInsideWebview)
{ {
addAndMakeVisible (switchLicenseButton = new TextButton ("Switch License")); 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()) if (auto* controller = ProjucerApplication::getApp().licenseController.get())
@@ -109,23 +119,13 @@ public:
private: 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 void licenseStateChanged (const LicenseState& state) override
{ {
hasLicenseType = (state.type != LicenseState::Type::noLicenseChosenYet); hasLicenseType = (state.type != LicenseState::Type::noLicenseChosenYet);
@@ -134,12 +134,6 @@ private:
licenseTypeLabel->setText (LicenseState::licenseTypeToString (state.type), NotificationType::dontSendNotification); licenseTypeLabel->setText (LicenseState::licenseTypeToString (state.type), NotificationType::dontSendNotification);
} }
void dismissCalloutBox()
{
if (auto* parent = findParentComponentOfClass<CallOutBox>())
parent->dismiss();
}
void lookAndFeelChanged() override void lookAndFeelChanged() override
{ {
if (logoutButton != nullptr) if (logoutButton != nullptr)


Loading…
Cancel
Save