diff --git a/extras/Demo/Builds/Android/jni/Android.mk b/extras/Demo/Builds/Android/jni/Android.mk index 738b27f4fb..068cbe7993 100644 --- a/extras/Demo/Builds/Android/jni/Android.mk +++ b/extras/Demo/Builds/Android/jni/Android.mk @@ -63,14 +63,14 @@ LOCAL_SRC_FILES := \ ../../../../../modules/juce_video/juce_video.cpp\ ifeq ($(CONFIG),Debug) - LOCAL_CPPFLAGS += -fsigned-char -fexceptions -frtti -g -I "../../JuceLibraryCode" -I "../../../../modules" -O0 -std=c++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" + LOCAL_CPPFLAGS += -fsigned-char -fexceptions -frtti -g -I "../../JuceLibraryCode" -I "../../../../modules" -O0 -std=c++0x -std=gnu++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" LOCAL_LDLIBS := -llog -lGLESv2 - LOCAL_CFLAGS += -fsigned-char -fexceptions -frtti -g -I "../../JuceLibraryCode" -I "../../../../modules" -O0 -std=c++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" + LOCAL_CFLAGS += -fsigned-char -fexceptions -frtti -g -I "../../JuceLibraryCode" -I "../../../../modules" -O0 -std=c++0x -std=gnu++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" LOCAL_LDLIBS := -llog -lGLESv2 else - LOCAL_CPPFLAGS += -fsigned-char -fexceptions -frtti -I "../../JuceLibraryCode" -I "../../../../modules" -O3 -std=c++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "NDEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" + LOCAL_CPPFLAGS += -fsigned-char -fexceptions -frtti -I "../../JuceLibraryCode" -I "../../../../modules" -O3 -std=c++0x -std=gnu++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "NDEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" LOCAL_LDLIBS := -llog -lGLESv2 - LOCAL_CFLAGS += -fsigned-char -fexceptions -frtti -I "../../JuceLibraryCode" -I "../../../../modules" -O3 -std=c++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "NDEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" + LOCAL_CFLAGS += -fsigned-char -fexceptions -frtti -I "../../JuceLibraryCode" -I "../../../../modules" -O3 -std=c++0x -std=gnu++0x -D "JUCE_ANDROID=1" -D "JUCE_ANDROID_API_VERSION=9" -D "JUCE_ANDROID_ACTIVITY_CLASSNAME=com_juce_jucedemo_JuceDemo" -D JUCE_ANDROID_ACTIVITY_CLASSPATH=\"com/juce/jucedemo/JuceDemo\" -D "NDEBUG=1" -D "JUCE_UNIT_TESTS=1" -D "JUCER_ANDROID_7F0E4A25=1" LOCAL_LDLIBS := -llog -lGLESv2 endif diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index ba30583af2..399ccaf5ed 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -183,20 +183,20 @@ public: writeLocalPropertiesFile (target.getChildFile ("local.properties")); writeStringsFile (target.getChildFile ("res/values/strings.xml")); - const Image bigIcon (getBigIcon()); - const Image smallIcon (getSmallIcon()); + ScopedPointer bigIcon (getBigIcon()); + ScopedPointer smallIcon (getSmallIcon()); - if (bigIcon.isValid() && smallIcon.isValid()) + if (bigIcon != nullptr && smallIcon != nullptr) { - const int step = jmax (bigIcon.getWidth(), bigIcon.getHeight()) / 8; + const int step = jmax (bigIcon->getWidth(), bigIcon->getHeight()) / 8; writeIcon (target.getChildFile ("res/drawable-xhdpi/icon.png"), getBestIconForSize (step * 8, false)); writeIcon (target.getChildFile ("res/drawable-hdpi/icon.png"), getBestIconForSize (step * 6, false)); writeIcon (target.getChildFile ("res/drawable-mdpi/icon.png"), getBestIconForSize (step * 4, false)); writeIcon (target.getChildFile ("res/drawable-ldpi/icon.png"), getBestIconForSize (step * 3, false)); } - else + else if (Drawable* icon = bigIcon != nullptr ? bigIcon : smallIcon) { - writeIcon (target.getChildFile ("res/drawable-mdpi/icon.png"), bigIcon.isValid() ? bigIcon : smallIcon); + writeIcon (target.getChildFile ("res/drawable-mdpi/icon.png"), rescaleImageForIcon (*icon, icon->getWidth())); } } @@ -490,7 +490,7 @@ private: << " -O" << config.getGCCOptimisationFlag(); if (isCPP11Enabled()) - flags << " -std=c++0x"; + flags << " -std=c++0x -std=gnu++0x"; // these flags seem to enable slightly different things on gcc, and both seem to be needed defines = mergePreprocessorDefs (defines, getAllPreprocessorDefs (config)); return flags + createGCCPreprocessorFlags (defines); diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index dc6cd11f9b..cfa1328fd5 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -380,7 +380,7 @@ private: addProjectObject(); } - static Image fixMacIconImageSize (Image& image) + static Image fixMacIconImageSize (Drawable& image) { const int validSizes[] = { 16, 32, 48, 128, 256, 512, 1024 }; @@ -392,7 +392,10 @@ private: for (int i = 0; i < numElementsInArray (validSizes); ++i) { if (w == h && w == validSizes[i]) - return image; + { + bestSize = w; + break; + } if (jmax (w, h) > validSizes[i]) bestSize = validSizes[i]; @@ -447,13 +450,13 @@ private: out << pngData; } - void writeIcnsFile (const Array& images, OutputStream& out) const + void writeIcnsFile (const OwnedArray& images, OutputStream& out) const { MemoryOutputStream data; for (int i = 0; i < images.size(); ++i) { - const Image image (fixMacIconImageSize (images.getReference (i))); + const Image image (fixMacIconImageSize (*images.getUnchecked(i))); jassert (image.getWidth() == image.getHeight()); switch (image.getWidth()) @@ -478,15 +481,15 @@ private: void createIconFile() const { - Array images; + OwnedArray images; - Image bigIcon (getBigIcon()); - if (bigIcon.isValid()) - images.add (bigIcon); + ScopedPointer bigIcon (getBigIcon()); + if (bigIcon != nullptr) + images.add (bigIcon.release()); - Image smallIcon (getSmallIcon()); - if (smallIcon.isValid()) - images.add (smallIcon); + ScopedPointer smallIcon (getSmallIcon()); + if (smallIcon != nullptr) + images.add (smallIcon.release()); if (images.size() > 0) { diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp index 05654658c2..d7f583e660 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -498,68 +498,77 @@ void ProjectExporter::createDefaultConfigs() } } -Image ProjectExporter::getBigIcon() const +Drawable* ProjectExporter::getBigIcon() const { return project.getMainGroup().findItemWithID (settings [Ids::bigIcon]).loadAsImageFile(); } -Image ProjectExporter::getSmallIcon() const +Drawable* ProjectExporter::getSmallIcon() const { return project.getMainGroup().findItemWithID (settings [Ids::smallIcon]).loadAsImageFile(); } Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) const { - Image im; + Drawable* im = nullptr; - const Image im1 (getSmallIcon()); - const Image im2 (getBigIcon()); + ScopedPointer im1 (getSmallIcon()); + ScopedPointer im2 (getBigIcon()); - if (im1.isValid() && im2.isValid()) + if (im1 != nullptr && im2 != nullptr) { - if (im1.getWidth() >= size && im2.getWidth() >= size) - im = im1.getWidth() < im2.getWidth() ? im1 : im2; - else if (im1.getWidth() >= size) + if (im1->getWidth() >= size && im2->getWidth() >= size) + im = im1->getWidth() < im2->getWidth() ? im1 : im2; + else if (im1->getWidth() >= size) im = im1; - else if (im2.getWidth() >= size) + else if (im2->getWidth() >= size) im = im2; - else - return Image::null; } else { - im = im1.isValid() ? im1 : im2; + im = im1 != nullptr ? im1 : im2; } - if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size) - return Image::null; + if (im == nullptr) + return Image(); - return rescaleImageForIcon (im, size); + if (returnNullIfNothingBigEnough && im->getWidth() < size && im->getHeight() < size) + return Image(); + + return rescaleImageForIcon (*im, size); } -Image ProjectExporter::rescaleImageForIcon (Image im, const int size) +Image ProjectExporter::rescaleImageForIcon (Drawable& d, const int size) { - im = SoftwareImageType().convert (im); + if (DrawableImage* drawableImage = dynamic_cast (&d)) + { + Image im = SoftwareImageType().convert (drawableImage->getImage()); - if (size == im.getWidth() && size == im.getHeight()) - return im; + if (size == im.getWidth() && size == im.getHeight()) + return im; - // (scale it down in stages for better resampling) - while (im.getWidth() > 2 * size && im.getHeight() > 2 * size) - im = im.rescaled (im.getWidth() / 2, - im.getHeight() / 2); + // (scale it down in stages for better resampling) + while (im.getWidth() > 2 * size && im.getHeight() > 2 * size) + im = im.rescaled (im.getWidth() / 2, + im.getHeight() / 2); - Image newIm (Image::ARGB, size, size, true, SoftwareImageType()); - Graphics g (newIm); - g.drawImageWithin (im, 0, 0, size, size, - RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false); - return newIm; + Image newIm (Image::ARGB, size, size, true, SoftwareImageType()); + Graphics g (newIm); + g.drawImageWithin (im, 0, 0, size, size, + RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false); + return newIm; + } + + Image im (Image::ARGB, size, size, true, SoftwareImageType()); + Graphics g (im); + d.drawWithin (g, im.getBounds().toFloat(), RectanglePlacement::centred, 1.0f); + return im; } //============================================================================== -ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_) - : index (-1), exporter (exporter_) +ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& e) + : index (-1), exporter (e) { } diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h index 4e123816d7..42686224e6 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h @@ -120,8 +120,8 @@ public: Value getBigIconImageItemID() { return getSetting (Ids::bigIcon); } Value getSmallIconImageItemID() { return getSetting (Ids::smallIcon); } - Image getBigIcon() const; - Image getSmallIcon() const; + Drawable* getBigIcon() const; + Drawable* getSmallIcon() const; Image getBestIconForSize (int size, bool returnNullIfNothingBigEnough) const; String getExporterIdentifierMacro() const @@ -361,7 +361,7 @@ protected: } } - static Image rescaleImageForIcon (Image image, int iconSize); + static Image rescaleImageForIcon (Drawable&, int iconSize); private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectExporter) diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index f61d764e26..efd0e5f4b7 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -520,10 +520,10 @@ Project::Item Project::Item::createCopy() { Item i (*this); i.state = i. String Project::Item::getID() const { return state [Ids::ID]; } void Project::Item::setID (const String& newID) { state.setProperty (Ids::ID, newID, nullptr); } -Image Project::Item::loadAsImageFile() const +Drawable* Project::Item::loadAsImageFile() const { - return isValid() ? ImageCache::getFromFile (getFile()) - : Image::null; + return isValid() ? Drawable::createFromImageFile (getFile()) + : nullptr; } Project::Item Project::Item::createGroup (Project& project, const String& name, const String& uid) @@ -538,7 +538,12 @@ Project::Item Project::Item::createGroup (Project& project, const String& name, bool Project::Item::isFile() const { return state.hasType (Ids::FILE); } bool Project::Item::isGroup() const { return state.hasType (Ids::GROUP) || isMainGroup(); } bool Project::Item::isMainGroup() const { return state.hasType (Ids::MAINGROUP); } -bool Project::Item::isImageFile() const { return isFile() && ImageFileFormat::findImageFormatForFileExtension (getFile()) != nullptr; } + +bool Project::Item::isImageFile() const +{ + return isFile() && (ImageFileFormat::findImageFormatForFileExtension (getFile()) != nullptr + || getFile().hasFileExtension ("svg")); +} Project::Item Project::Item::findItemWithID (const String& targetId) const { diff --git a/extras/Introjucer/Source/Project/jucer_Project.h b/extras/Introjucer/Source/Project/jucer_Project.h index b48eb545dc..b52093331c 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.h +++ b/extras/Introjucer/Source/Project/jucer_Project.h @@ -147,7 +147,7 @@ public: Item findItemWithID (const String& targetId) const; // (recursive search) String getImageFileID() const; - Image loadAsImageFile() const; + Drawable* loadAsImageFile() const; //============================================================================== Value getNameValue(); diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 9734446796..a18effa041 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -188,12 +188,10 @@ struct Expression::Helpers if (input != left && input != right) return TermPtr(); - const Term* const dest = findDestinationFor (topLevelTerm, this); - - if (dest == nullptr) - return new Constant (overallTarget, false); + if (const Term* const dest = findDestinationFor (topLevelTerm, this)) + return dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm); - return dest->createTermToEvaluateInput (scope, this, overallTarget, topLevelTerm); + return new Constant (overallTarget, false); } }; diff --git a/modules/juce_core/text/juce_LocalisedStrings.h b/modules/juce_core/text/juce_LocalisedStrings.h index 83f6be88f6..e8f70f7361 100644 --- a/modules/juce_core/text/juce_LocalisedStrings.h +++ b/modules/juce_core/text/juce_LocalisedStrings.h @@ -101,7 +101,7 @@ public: /** Selects the current set of mappings to be used by the system. The object you pass in will be automatically deleted when no longer needed, so - don't keep a pointer to it. You can also pass in zero to remove the current + don't keep a pointer to it. You can also pass in nullptr to remove the current mappings. See also the TRANS() macro, which uses the current set to do its translation. diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 414dc362cb..f19ec7cd10 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -2288,7 +2288,10 @@ void Component::addComponentListener (ComponentListener* const newListener) { // if component methods are being called from threads other than the message // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. - CHECK_MESSAGE_MANAGER_IS_LOCKED + #if JUCE_DEBUG || JUCE_LOG_ASSERTIONS + if (getParentComponent() != nullptr) + CHECK_MESSAGE_MANAGER_IS_LOCKED; + #endif componentListeners.add (newListener); } diff --git a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp index b8de9afda0..589eb26339 100644 --- a/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp +++ b/modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp @@ -27,7 +27,7 @@ class MarkerListScope : public Expression::Scope public: MarkerListScope (Component& comp) : component (comp) {} - Expression getSymbolValue (const String& symbol) const + Expression getSymbolValue (const String& symbol) const override { switch (RelativeCoordinate::StandardStrings::getTypeOf (symbol)) { @@ -44,7 +44,7 @@ public: return Expression::Scope::getSymbolValue (symbol); } - void visitRelativeScope (const String& scopeName, Visitor& visitor) const + void visitRelativeScope (const String& scopeName, Visitor& visitor) const override { if (scopeName == RelativeCoordinate::Strings::parent) { @@ -58,7 +58,7 @@ public: Expression::Scope::visitRelativeScope (scopeName, visitor); } - String getScopeUID() const + String getScopeUID() const override { return String::toHexString ((pointer_sized_int) (void*) &component) + "m"; } @@ -150,12 +150,12 @@ Component* RelativeCoordinatePositionerBase::ComponentScope::findSiblingComponen class RelativeCoordinatePositionerBase::DependencyFinderScope : public ComponentScope { public: - DependencyFinderScope (Component& comp, RelativeCoordinatePositionerBase& positioner_, bool& ok_) - : ComponentScope (comp), positioner (positioner_), ok (ok_) + DependencyFinderScope (Component& comp, RelativeCoordinatePositionerBase& p, bool& result) + : ComponentScope (comp), positioner (p), ok (result) { } - Expression getSymbolValue (const String& symbol) const + Expression getSymbolValue (const String& symbol) const override { switch (RelativeCoordinate::StandardStrings::getTypeOf (symbol)) { @@ -193,7 +193,7 @@ public: return ComponentScope::getSymbolValue (symbol); } - void visitRelativeScope (const String& scopeName, Visitor& visitor) const + void visitRelativeScope (const String& scopeName, Visitor& visitor) const override { if (Component* const targetComp = (scopeName == RelativeCoordinate::Strings::parent) ? component.getParentComponent()