From 4e77678299c21d4ef01e84a6ddcca79779174ab9 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 13 Feb 2012 14:09:30 +0000 Subject: [PATCH] Introjucer: App icons are now specified per-exporter type rather than globally for the project. --- extras/Introjucer/Introjucer.jucer | 18 +-- .../jucer_ProjectExport_XCode.h | 4 +- .../Project Saving/jucer_ProjectExporter.cpp | 107 ++++++++++++------ .../Project Saving/jucer_ProjectExporter.h | 8 +- .../Source/Project/jucer_Project.cpp | 50 +++----- .../Introjucer/Source/Project/jucer_Project.h | 6 +- .../Source/Utility/jucer_PresetIDs.h | 2 + extras/JuceDemo/Juce Demo.jucer | 21 ++-- extras/the jucer/Jucer.jucer | 14 ++- .../values/juce_ValueTree.cpp | 6 + .../values/juce_ValueTree.h | 5 + 11 files changed, 138 insertions(+), 103 deletions(-) diff --git a/extras/Introjucer/Introjucer.jucer b/extras/Introjucer/Introjucer.jucer index df3fd08898..f3655fc78a 100644 --- a/extras/Introjucer/Introjucer.jucer +++ b/extras/Introjucer/Introjucer.jucer @@ -10,11 +10,11 @@ pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="TheIntrojucerAU" pluginAUViewClass="TheIntrojucerAU_V1" - pluginRTASCategory="" bundleIdentifier="com.rawmaterialsoftware.introjucer" - bigIcon="rVgowdy"> + pluginRTASCategory="" bundleIdentifier="com.rawmaterialsoftware.introjucer"> + juceFolder="../.." documentExtensions=".jucer" objCExtraSuffix="zNNCr" + bigIcon="rVgowdy"> @@ -23,27 +23,31 @@ + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../.." libraryType="1" + bigIcon="rVgowdy"> + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../.." libraryType="1" + bigIcon="rVgowdy"> - + + rtasFolder="c:\SDKs\PT_80_SDK" libraryType="1" juceFolder="../.." + bigIcon="rVgowdy"> diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 75518f7a55..7fd682e2db 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -388,11 +388,11 @@ private: { Array images; - Image bigIcon (project.getBigIcon()); + Image bigIcon (getBigIcon()); if (bigIcon.isValid()) images.add (bigIcon); - Image smallIcon (project.getSmallIcon()); + Image smallIcon (getSmallIcon()); if (smallIcon.isValid()) images.add (smallIcon); diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp index 3a57e6db2a..bbddcffbe8 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp @@ -220,6 +220,31 @@ void ProjectExporter::createPropertyEditors (PropertyListBuilder& props) "Extra command-line flags to be passed to the compiler. This string can contain references to preprocessor definitions in the form ${NAME_OF_DEFINITION}, which will be replaced with their values."); props.add (new TextPropertyComponent (getExtraLinkerFlags(), "Extra linker flags", 2048, false), "Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries. This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values."); + + { + OwnedArray images; + project.findAllImageItems (images); + + StringArray choices; + Array ids; + + choices.add (""); + ids.add (var::null); + choices.add (String::empty); + ids.add (var::null); + + for (int i = 0; i < images.size(); ++i) + { + choices.add (images.getUnchecked(i)->getName().toString()); + ids.add (images.getUnchecked(i)->getID()); + } + + props.add (new ChoicePropertyComponent (getSmallIconImageItemID(), "Icon (small)", choices, ids), + "Sets an icon to use for the executable."); + + props.add (new ChoicePropertyComponent (getBigIconImageItemID(), "Icon (large)", choices, ids), + "Sets an icon to use for the executable."); + } } StringPairArray ProjectExporter::getAllPreprocessorDefs (const ProjectExporter::BuildConfiguration& config) const @@ -243,42 +268,6 @@ String ProjectExporter::replacePreprocessorTokens (const ProjectExporter::BuildC return replacePreprocessorDefs (getAllPreprocessorDefs (config), sourceString); } -Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) -{ - Image im; - - const Image im1 (project.getSmallIcon()); - const Image im2 (project.getBigIcon()); - - if (im1.isValid() && im2.isValid()) - { - 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) - im = im2; - else - return Image::null; - } - else - { - im = im1.isValid() ? im1 : im2; - } - - if (size == im.getWidth() && size == im.getHeight()) - return im; - - if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size) - return Image::null; - - 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; -} - Project::Item& ProjectExporter::getModulesGroup() { if (modulesGroup == nullptr) @@ -389,6 +378,52 @@ void ProjectExporter::createDefaultConfigs() } } +Image ProjectExporter::getBigIcon() +{ + return project.getMainGroup().findItemWithID (getBigIconImageItemID().toString()).loadAsImageFile(); +} + +Image ProjectExporter::getSmallIcon() +{ + return project.getMainGroup().findItemWithID (getSmallIconImageItemID().toString()).loadAsImageFile(); +} + +Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBigEnough) +{ + Image im; + + const Image im1 (getSmallIcon()); + const Image im2 (getBigIcon()); + + if (im1.isValid() && im2.isValid()) + { + 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) + im = im2; + else + return Image::null; + } + else + { + im = im1.isValid() ? im1 : im2; + } + + if (size == im.getWidth() && size == im.getHeight()) + return im; + + if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size) + return Image::null; + + 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; +} + //============================================================================== ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_) : index (-1), exporter (exporter_) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h index 8fcc4f7d67..6f87456828 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h @@ -86,6 +86,12 @@ public: RelativePath rebaseFromProjectFolderToBuildTarget (const RelativePath& path) const; void addToExtraSearchPaths (const RelativePath& pathFromProjectFolder); + Value getBigIconImageItemID() const { return getSetting (Ids::bigIcon); } + Value getSmallIconImageItemID() const { return getSetting (Ids::smallIcon); } + Image getBigIcon(); + Image getSmallIcon(); + Image getBestIconForSize (int size, bool returnNullIfNothingBigEnough); + String getExporterIdentifierMacro() const { return "JUCER_" + settings.getType().toString() + "_" @@ -247,8 +253,6 @@ protected: return name; } - Image getBestIconForSize (int size, bool returnNullIfNothingBigEnough); - //============================================================================== static void overwriteFileIfDifferentOrThrow (const File& file, const MemoryOutputStream& newData) { diff --git a/extras/Introjucer/Source/Project/jucer_Project.cpp b/extras/Introjucer/Source/Project/jucer_Project.cpp index 84ddd6bba8..ee8e899b8e 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.cpp +++ b/extras/Introjucer/Source/Project/jucer_Project.cpp @@ -111,6 +111,8 @@ void Project::setMissingDefaultValues() getVersion() = "1.0.0"; updateOldStyleConfigList(); + moveOldPropertyFromProjectToAllExporters (Ids::bigIcon); + moveOldPropertyFromProjectToAllExporters (Ids::smallIcon); for (Project::ExporterIterator exporter (*this); exporter.next();) if (exporter->getNumConfigurations() == 0) @@ -160,6 +162,17 @@ void Project::updateOldStyleConfigList() } } +void Project::moveOldPropertyFromProjectToAllExporters (Identifier name) +{ + if (projectRoot.hasProperty (name)) + { + for (Project::ExporterIterator exporter (*this); exporter.next();) + exporter->settings.setProperty (name, projectRoot [name], nullptr); + + projectRoot.removeProperty (name, nullptr); + } +} + void Project::addDefaultModules (bool shouldCopyFilesLocally) { addModule ("juce_core", shouldCopyFilesLocally); @@ -337,32 +350,7 @@ void Project::createPropertyEditors (PropertyListBuilder& props) props.add (new TextPropertyComponent (getBundleIdentifier(), "Bundle Identifier", 256, false), "A unique identifier for this product, mainly for use in Mac builds. It should be something like 'com.yourcompanyname.yourproductname'"); - { - OwnedArray images; - findAllImageItems (images); - - StringArray choices; - Array ids; - - choices.add (""); - ids.add (var::null); - choices.add (String::empty); - ids.add (var::null); - - for (int i = 0; i < images.size(); ++i) - { - choices.add (images.getUnchecked(i)->getName().toString()); - ids.add (images.getUnchecked(i)->getID()); - } - - props.add (new ChoicePropertyComponent (getSmallIconImageItemID(), "Icon (small)", choices, ids), - "Sets an icon to use for the executable."); - - props.add (new ChoicePropertyComponent (getBigIconImageItemID(), "Icon (large)", choices, ids), - "Sets an icon to use for the executable."); - } - - getProjectType().createPropertyEditors(*this, props); + getProjectType().createPropertyEditors (*this, props); props.add (new TextPropertyComponent (getProjectPreprocessorDefs(), "Preprocessor definitions", 32768, false), "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace or commas to separate the items - to include a space or comma in a definition, precede it with a backslash."); @@ -385,16 +373,6 @@ String Project::getVersionAsHex() const return "0x" + String::toHexString (value); } -Image Project::getBigIcon() -{ - return getMainGroup().findItemWithID (getBigIconImageItemID().toString()).loadAsImageFile(); -} - -Image Project::getSmallIcon() -{ - return getMainGroup().findItemWithID (getSmallIconImageItemID().toString()).loadAsImageFile(); -} - StringPairArray Project::getPreprocessorDefs() const { return parsePreprocessorDefs (getProjectPreprocessorDefs().toString()); diff --git a/extras/Introjucer/Source/Project/jucer_Project.h b/extras/Introjucer/Source/Project/jucer_Project.h index e1989992fb..3cb988ea0d 100644 --- a/extras/Introjucer/Source/Project/jucer_Project.h +++ b/extras/Introjucer/Source/Project/jucer_Project.h @@ -87,11 +87,6 @@ public: Value getProjectPreprocessorDefs() const { return getProjectValue (Ids::defines); } StringPairArray getPreprocessorDefs() const; - Value getBigIconImageItemID() const { return getProjectValue ("bigIcon"); } - Value getSmallIconImageItemID() const { return getProjectValue ("smallIcon"); } - Image getBigIcon(); - Image getSmallIcon(); - //============================================================================== File getAppIncludeFile() const { return getGeneratedCodeFolder().getChildFile (getJuceSourceHFilename()); } File getGeneratedCodeFolder() const { return getFile().getSiblingFile ("JuceLibraryCode"); } @@ -268,6 +263,7 @@ private: ValueTree getModulesNode(); void updateOldStyleConfigList(); + void moveOldPropertyFromProjectToAllExporters (Identifier name); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project); }; diff --git a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h index 807cab2d0d..f89681b48f 100644 --- a/extras/Introjucer/Source/Utility/jucer_PresetIDs.h +++ b/extras/Introjucer/Source/Utility/jucer_PresetIDs.h @@ -64,6 +64,8 @@ namespace Ids DECLARE_ID (osxArchitecture); DECLARE_ID (winArchitecture); DECLARE_ID (winWarningLevel); + DECLARE_ID (bigIcon); + DECLARE_ID (smallIcon); DECLARE_ID (jucerVersion); DECLARE_ID (projectType); DECLARE_ID (prebuildCommand); diff --git a/extras/JuceDemo/Juce Demo.jucer b/extras/JuceDemo/Juce Demo.jucer index 5e8db01b81..47ae7a2306 100644 --- a/extras/JuceDemo/Juce Demo.jucer +++ b/extras/JuceDemo/Juce Demo.jucer @@ -7,11 +7,10 @@ pluginCode="Abcd" pluginChannelConfigs="{ {1, 1}, {2, 2} }" pluginIsSynth="0" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="JuceDemoAU" - pluginAUViewClass="JuceDemoAU_V1" pluginRTASCategory="" icon="Duj062Top" - bigIcon="f4hwldS"> + pluginAUViewClass="JuceDemoAU_V1" pluginRTASCategory="" icon="Duj062Top"> + juceFolder="../../../juce" objCExtraSuffix="JSLvvV6j" bigIcon="f4hwldS"> + juceFolder="../../../juce" objCExtraSuffix="JSLvvV6j" bigIcon="f4hwldS"> + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../../../juce" libraryType="1" + bigIcon="f4hwldS"> @@ -42,7 +42,8 @@ + rtasFolder="c:\SDKs\PT_80_SDK" juceFolder="../../../juce" libraryType="1" + bigIcon="f4hwldS"> @@ -50,7 +51,8 @@ defines="JUCE_UNIT_TESTS=1"/> - + @@ -59,7 +61,8 @@ + rtasFolder="c:\SDKs\PT_80_SDK" libraryType="1" juceFolder="../../../juce" + bigIcon="f4hwldS"> @@ -69,7 +72,7 @@ + androidInternetNeeded="1" bigIcon="f4hwldS"> diff --git a/extras/the jucer/Jucer.jucer b/extras/the jucer/Jucer.jucer index fde249e760..716590d4c1 100644 --- a/extras/the jucer/Jucer.jucer +++ b/extras/the jucer/Jucer.jucer @@ -1,28 +1,30 @@ + bundleIdentifier="com.yourcompany.Jucer" jucerVersion="3.0.0"> - + - + - + - + diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 9b0d0b0832..6e69b08dab 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -1009,6 +1009,12 @@ ValueTree ValueTree::readFromData (const void* const data, const size_t numBytes return readFromStream (in); } +ValueTree ValueTree::readFromGZIPData (const void* const data, const size_t numBytes) +{ + MemoryInputStream in (data, numBytes, false); + GZIPDecompressorInputStream gzipStream (in); + return readFromStream (gzipStream); +} //============================================================================== #if JUCE_UNIT_TESTS diff --git a/modules/juce_data_structures/values/juce_ValueTree.h b/modules/juce_data_structures/values/juce_ValueTree.h index 6c44495422..a5dbf839df 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.h +++ b/modules/juce_data_structures/values/juce_ValueTree.h @@ -345,6 +345,11 @@ public: /** Reloads a tree from a data block that was written with writeToStream(). */ static ValueTree readFromData (const void* data, size_t numBytes); + /** Reloads a tree from a data block that was written with writeToStream() and + then zipped using GZIPCompressorOutputStream. + */ + static ValueTree readFromGZIPData (const void* data, size_t numBytes); + //============================================================================== /** Listener class for events that happen to a ValueTree.