Browse Source

Introjucer: Added gnu++0x flag for android builds. Support for SVG icons.

tags/2021-05-28
jules 11 years ago
parent
commit
d582a66917
11 changed files with 93 additions and 75 deletions
  1. +4
    -4
      extras/Demo/Builds/Android/jni/Android.mk
  2. +7
    -7
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h
  3. +14
    -11
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h
  4. +40
    -31
      extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp
  5. +3
    -3
      extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h
  6. +9
    -4
      extras/Introjucer/Source/Project/jucer_Project.cpp
  7. +1
    -1
      extras/Introjucer/Source/Project/jucer_Project.h
  8. +3
    -5
      modules/juce_core/maths/juce_Expression.cpp
  9. +1
    -1
      modules/juce_core/text/juce_LocalisedStrings.h
  10. +4
    -1
      modules/juce_gui_basics/components/juce_Component.cpp
  11. +7
    -7
      modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp

+ 4
- 4
extras/Demo/Builds/Android/jni/Android.mk View File

@@ -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


+ 7
- 7
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h View File

@@ -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<Drawable> bigIcon (getBigIcon());
ScopedPointer<Drawable> 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);


+ 14
- 11
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h View File

@@ -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<Image>& images, OutputStream& out) const
void writeIcnsFile (const OwnedArray<Drawable>& 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<Image> images;
OwnedArray<Drawable> images;
Image bigIcon (getBigIcon());
if (bigIcon.isValid())
images.add (bigIcon);
ScopedPointer<Drawable> bigIcon (getBigIcon());
if (bigIcon != nullptr)
images.add (bigIcon.release());
Image smallIcon (getSmallIcon());
if (smallIcon.isValid())
images.add (smallIcon);
ScopedPointer<Drawable> smallIcon (getSmallIcon());
if (smallIcon != nullptr)
images.add (smallIcon.release());
if (images.size() > 0)
{


+ 40
- 31
extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp View File

@@ -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<Drawable> im1 (getSmallIcon());
ScopedPointer<Drawable> 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<DrawableImage*> (&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)
{
}


+ 3
- 3
extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h View File

@@ -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)


+ 9
- 4
extras/Introjucer/Source/Project/jucer_Project.cpp View File

@@ -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
{


+ 1
- 1
extras/Introjucer/Source/Project/jucer_Project.h View File

@@ -147,7 +147,7 @@ public:
Item findItemWithID (const String& targetId) const; // (recursive search)
String getImageFileID() const;
Image loadAsImageFile() const;
Drawable* loadAsImageFile() const;
//==============================================================================
Value getNameValue();


+ 3
- 5
modules/juce_core/maths/juce_Expression.cpp View File

@@ -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);
}
};


+ 1
- 1
modules/juce_core/text/juce_LocalisedStrings.h View File

@@ -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.


+ 4
- 1
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -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);
}


+ 7
- 7
modules/juce_gui_basics/positioning/juce_RelativeCoordinatePositioner.cpp View File

@@ -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()


Loading…
Cancel
Save