Result unzip (const MemoryBlock& data) { setStatusMessage ("Installing..."); File unzipTarget; bool isUsingTempFolder = false; { MemoryInputStream input (data, false); ZipFile zip (input); if (zip.getNumEntries() == 0) return Result::fail ("The downloaded file wasn't a valid JUCE file!"); unzipTarget = targetFolder; if (unzipTarget.exists()) { isUsingTempFolder = true; unzipTarget = targetFolder.getNonexistentSibling(); if (! unzipTarget.createDirectory()) return Result::fail ("Couldn't create a folder to unzip the new version!"); } Result r (zip.uncompressTo (unzipTarget)); if (r.failed()) { if (isUsingTempFolder) unzipTarget.deleteRecursively(); return r; } } if (isUsingTempFolder) { File oldFolder (targetFolder.getSiblingFile (targetFolder.getFileNameWithoutExtension() + "_old") .getNonexistentSibling()); if (! targetFolder.moveFileTo (oldFolder)) { unzipTarget.deleteRecursively(); return Result::fail ("Could not remove the existing folder!"); } if (! unzipTarget.moveFileTo (targetFolder)) { unzipTarget.deleteRecursively(); return Result::fail ("Could not overwrite the existing folder!"); } } return Result::ok(); }
/* * The directory hierarchy looks like this: * "outputDir" and "assetRoot" are existing directories. * * On success, "bundle->numPackages" will be the number of Zip packages * we created. */ status_t writeAPK(Bundle* bundle, int fd, const sp<OutputSet>& outputSet, bool isOverlay) { #if BENCHMARK fprintf(stdout, "BENCHMARK: Starting APK Bundling \n"); long startAPKTime = clock(); #endif /* BENCHMARK */ status_t result = NO_ERROR; ZipFile* zip = NULL; status_t status; zip = new ZipFile; status = zip->openfd(fd, ZipFile::kOpenReadWrite); if (status != NO_ERROR) { fprintf(stderr, "ERROR: unable to open file as Zip file for writing\n"); result = PERMISSION_DENIED; goto bail; } result = writeAPK(bundle, zip, "file_descriptor", outputSet, isOverlay); if (result != NO_ERROR) { fprintf(stderr, "ERROR: Writing apk failed\n"); goto bail; } /* anything here? */ if (zip->getNumEntries() == 0) { if (bundle->getVerbose()) { printf("Archive is empty -- removing\n"); } delete zip; // close the file so we can remove it in Win32 zip = NULL; close(fd); } assert(result == NO_ERROR); bail: delete zip; // must close before remove in Win32 close(fd); if (result != NO_ERROR) { if (bundle->getVerbose()) { printf("Removing archive due to earlier failures\n"); } } if (result == NO_ERROR && bundle->getVerbose()) printf("Done!\n"); #if BENCHMARK fprintf(stdout, "BENCHMARK: End APK Bundling. Time Elapsed: %f ms \n",(clock() - startAPKTime)/1000.0); #endif /* BENCHMARK */ return result; }
Result unzip (const ModuleList::Module& m, const MemoryBlock& data) { setStatusMessage ("Installing " + m.uid + "..."); MemoryInputStream input (data, false); ZipFile zip (input); if (zip.getNumEntries() == 0) return Result::fail ("The downloaded file wasn't a valid module file!"); return zip.uncompressTo (targetList.getModulesFolder(), true); }
Drawable* ResourceLoader::createSVGDrawable(const String& filename) { initObjectIconMap(); if (iconsFromZipFile.size() == 0) { // If we've not already done so, load all the images from the zip file.. MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false); ZipFile icons (&iconsFileStream, false); for (int i = 0; i < icons.getNumEntries(); ++i) { ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (i)); if (svgFileStream != 0) { iconNames.add (icons.getEntry(i)->filename); iconsFromZipFile.add (Drawable::createFromImageDataStream (*svgFileStream)); } } } return iconsFromZipFile [iconNames.indexOf (filename)];//->createCopy(); }
/* * The directory hierarchy looks like this: * "outputDir" and "assetRoot" are existing directories. * * On success, "bundle->numPackages" will be the number of Zip packages * we created. */ status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet>& outputSet) { #if BENCHMARK fprintf(stdout, "BENCHMARK: Starting APK Bundling \n"); long startAPKTime = clock(); #endif /* BENCHMARK */ status_t result = NO_ERROR; ZipFile* zip = NULL; int count; //bundle->setPackageCount(0); /* * Prep the Zip archive. * * If the file already exists, fail unless "update" or "force" is set. * If "update" is set, update the contents of the existing archive. * Else, if "force" is set, remove the existing archive. */ FileType fileType = getFileType(outputFile.string()); if (fileType == kFileTypeNonexistent) { // okay, create it below } else if (fileType == kFileTypeRegular) { if (bundle->getUpdate()) { // okay, open it below } else if (bundle->getForce()) { if (unlink(outputFile.string()) != 0) { fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.string(), strerror(errno)); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n", outputFile.string()); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string()); goto bail; } if (bundle->getVerbose()) { printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening", outputFile.string()); } status_t status; zip = new ZipFile; status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate); if (status != NO_ERROR) { fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n", outputFile.string()); goto bail; } if (bundle->getVerbose()) { printf("Writing all files...\n"); } count = processAssets(bundle, zip, outputSet); if (count < 0) { fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n", outputFile.string()); result = count; goto bail; } if (bundle->getVerbose()) { printf("Generated %d file%s\n", count, (count==1) ? "" : "s"); } count = processJarFiles(bundle, zip); if (count < 0) { fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n", outputFile.string()); result = count; goto bail; } if (bundle->getVerbose()) printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s"); result = NO_ERROR; /* * Check for cruft. We set the "marked" flag on all entries we created * or decided not to update. If the entry isn't already slated for * deletion, remove it now. */ { if (bundle->getVerbose()) printf("Checking for deleted files\n"); int i, removed = 0; for (i = 0; i < zip->getNumEntries(); i++) { ZipEntry* entry = zip->getEntryByIndex(i); if (!entry->getMarked() && entry->getDeleted()) { if (bundle->getVerbose()) { printf(" (removing crufty '%s')\n", entry->getFileName()); } zip->remove(entry); removed++; } } if (bundle->getVerbose() && removed > 0) printf("Removed %d file%s\n", removed, (removed==1) ? "" : "s"); } /* tell Zip lib to process deletions and other pending changes */ result = zip->flush(); if (result != NO_ERROR) { fprintf(stderr, "ERROR: Zip flush failed, archive may be hosed\n"); goto bail; } /* anything here? */ if (zip->getNumEntries() == 0) { if (bundle->getVerbose()) { printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string()); } delete zip; // close the file so we can remove it in Win32 zip = NULL; if (unlink(outputFile.string()) != 0) { fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); } } // If we've been asked to generate a dependency file for the .ap_ package, // do so here if (bundle->getGenDependencies()) { // The dependency file gets output to the same directory // as the specified output file with an additional .d extension. // e.g. bin/resources.ap_.d String8 dependencyFile = outputFile; dependencyFile.append(".d"); FILE* fp = fopen(dependencyFile.string(), "a"); // Add this file to the dependency file fprintf(fp, "%s \\\n", outputFile.string()); fclose(fp); } assert(result == NO_ERROR); bail: delete zip; // must close before remove in Win32 if (result != NO_ERROR) { if (bundle->getVerbose()) { printf("Removing %s due to earlier failures\n", outputFile.string()); } if (unlink(outputFile.string()) != 0) { fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); } } if (result == NO_ERROR && bundle->getVerbose()) printf("Done!\n"); #if BENCHMARK fprintf(stdout, "BENCHMARK: End APK Bundling. Time Elapsed: %f ms \n",(clock() - startAPKTime)/1000.0); #endif /* BENCHMARK */ return result; }
/* * Handle the "list" command, which can be a simple file dump or * a verbose listing. * * The verbose listing closely matches the output of the Info-ZIP "unzip" * command. */ int doList(Bundle* bundle) { int result = 1; ZipFile* zip = NULL; const ZipEntry* entry; long totalUncLen, totalCompLen; const char* zipFileName; if (bundle->getFileSpecCount() != 1) { fprintf(stderr, "ERROR: specify zip file name (only)\n"); goto bail; } zipFileName = bundle->getFileSpecEntry(0); zip = openReadOnly(zipFileName); if (zip == NULL) goto bail; int count, i; if (bundle->getVerbose()) { printf("Archive: %s\n", zipFileName); printf( " Length Method Size Ratio Offset Date Time CRC-32 Name\n"); printf( "-------- ------ ------- ----- ------- ---- ---- ------ ----\n"); } totalUncLen = totalCompLen = 0; count = zip->getNumEntries(); for (i = 0; i < count; i++) { entry = zip->getEntryByIndex(i); if (bundle->getVerbose()) { char dateBuf[32]; time_t when; when = entry->getModWhen(); strftime(dateBuf, sizeof(dateBuf), "%m-%d-%y %H:%M", localtime(&when)); printf("%8ld %-7.7s %7ld %3d%% %8zd %s %08lx %s\n", (long) entry->getUncompressedLen(), compressionName(entry->getCompressionMethod()), (long) entry->getCompressedLen(), calcPercent(entry->getUncompressedLen(), entry->getCompressedLen()), (size_t) entry->getLFHOffset(), dateBuf, entry->getCRC32(), entry->getFileName()); } else { printf("%s\n", entry->getFileName()); } totalUncLen += entry->getUncompressedLen(); totalCompLen += entry->getCompressedLen(); } if (bundle->getVerbose()) { printf( "-------- ------- --- -------\n"); printf("%8ld %7ld %2d%% %d files\n", totalUncLen, totalCompLen, calcPercent(totalUncLen, totalCompLen), zip->getNumEntries()); } if (bundle->getAndroidList()) { AssetManager assets; if (!assets.addAssetPath(String8(zipFileName), NULL)) { fprintf(stderr, "ERROR: list -a failed because assets could not be loaded\n"); goto bail; } const ResTable& res = assets.getResources(false); if (&res == NULL) { printf("\nNo resource table found.\n"); } else { #ifndef HAVE_ANDROID_OS printf("\nResource table:\n"); res.print(false); #endif } Asset* manifestAsset = assets.openNonAsset("AndroidManifest.xml", Asset::ACCESS_BUFFER); if (manifestAsset == NULL) { printf("\nNo AndroidManifest.xml found.\n"); } else { printf("\nAndroid manifest:\n"); ResXMLTree tree; tree.setTo(manifestAsset->getBuffer(true), manifestAsset->getLength()); printXMLBlock(&tree); } delete manifestAsset; } result = 0; bail: delete zip; return result; }
ssize_t AaptAssets::slurpResourceZip(Bundle* bundle, const char* filename) { int count = 0; SortedVector<AaptGroupEntry> entries; ZipFile* zip = new ZipFile; status_t err = zip->open(filename, ZipFile::kOpenReadOnly); if (err != NO_ERROR) { fprintf(stderr, "error opening zip file %s\n", filename); count = err; delete zip; return -1; } const int N = zip->getNumEntries(); for (int i=0; i<N; i++) { ZipEntry* entry = zip->getEntryByIndex(i); if (entry->getDeleted()) { continue; } String8 entryName(entry->getFileName()); String8 dirName = entryName.getPathDir(); sp<AaptDir> dir = dirName == "" ? this : makeDir(dirName); String8 resType; AaptGroupEntry kind; String8 remain; if (entryName.walkPath(&remain) == kResourceDir) { // these are the resources, pull their type out of the directory name kind.initFromDirName(remain.walkPath().string(), &resType); } else { // these are untyped and don't have an AaptGroupEntry } if (entries.indexOf(kind) < 0) { entries.add(kind); mGroupEntries.add(kind); } // use the one from the zip file if they both exist. dir->removeFile(entryName.getPathLeaf()); sp<AaptFile> file = new AaptFile(entryName, kind, resType); status_t err = dir->addLeafFile(entryName.getPathLeaf(), file); if (err != NO_ERROR) { fprintf(stderr, "err=%s entryName=%s\n", strerror(err), entryName.string()); count = err; goto bail; } file->setCompressionMethod(entry->getCompressionMethod()); #if 0 if (entryName == "AndroidManifest.xml") { printf("AndroidManifest.xml\n"); } printf("\n\nfile: %s\n", entryName.string()); #endif size_t len = entry->getUncompressedLen(); void* data = zip->uncompress(entry); void* buf = file->editData(len); memcpy(buf, data, len); #if 0 const int OFF = 0; const unsigned char* p = (unsigned char*)data; const unsigned char* end = p+len; p += OFF; for (int i=0; i<32 && p < end; i++) { printf("0x%03x ", i*0x10 + OFF); for (int j=0; j<0x10 && p < end; j++) { printf(" %02x", *p); p++; } printf("\n"); } #endif free(data); count++; } bail: delete zip; return count; }
void createSVGDrawable() { lastSVGLoadTime = Time::getCurrentTime(); MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, false); ZipFile icons (&iconsFileStream, false); // Load a random SVG file from our embedded icons.zip file. const ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (Random::getSystemRandom().nextInt (icons.getNumEntries()))); if (svgFileStream != nullptr) { svgDrawable = dynamic_cast <DrawableComposite*> (Drawable::createFromImageDataStream (*svgFileStream)); if (svgDrawable != nullptr) { // to make our icon the right size, we'll set its bounding box to the size and position that we want. svgDrawable->setBoundingBox (RelativeParallelogram (Point<float> (-100, -100), Point<float> (100, -100), Point<float> (-100, 100))); } } }
/* * The directory hierarchy looks like this: * "outputDir" and "assetRoot" are existing directories. * * On success, "bundle->numPackages" will be the number of Zip packages * we created. */ status_t writeAPK(Bundle* bundle, const sp<AaptAssets>& assets, const String8& outputFile) { status_t result = NO_ERROR; ZipFile* zip = NULL; int count; //bundle->setPackageCount(0); /* * Prep the Zip archive. * * If the file already exists, fail unless "update" or "force" is set. * If "update" is set, update the contents of the existing archive. * Else, if "force" is set, remove the existing archive. */ FileType fileType = getFileType(outputFile.string()); if (fileType == kFileTypeNonexistent) { // okay, create it below } else if (fileType == kFileTypeRegular) { if (bundle->getUpdate()) { // okay, open it below } else if (bundle->getForce()) { if (unlink(outputFile.string()) != 0) { fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.string(), strerror(errno)); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n", outputFile.string()); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string()); goto bail; } if (bundle->getVerbose()) { printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening", outputFile.string()); } status_t status; zip = new ZipFile; status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate); if (status != NO_ERROR) { fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n", outputFile.string()); goto bail; } if (bundle->getVerbose()) { printf("Writing all files...\n"); } count = processAssets(bundle, zip, assets); if (count < 0) { fprintf(stderr, "ERROR: unable to process assets while packaging '%s'\n", outputFile.string()); result = count; goto bail; } if (bundle->getVerbose()) { printf("Generated %d file%s\n", count, (count==1) ? "" : "s"); } count = processJarFiles(bundle, zip); if (count < 0) { fprintf(stderr, "ERROR: unable to process jar files while packaging '%s'\n", outputFile.string()); result = count; goto bail; } if (bundle->getVerbose()) printf("Included %d file%s from jar/zip files.\n", count, (count==1) ? "" : "s"); result = NO_ERROR; /* * Check for cruft. We set the "marked" flag on all entries we created * or decided not to update. If the entry isn't already slated for * deletion, remove it now. */ { if (bundle->getVerbose()) printf("Checking for deleted files\n"); int i, removed = 0; for (i = 0; i < zip->getNumEntries(); i++) { ZipEntry* entry = zip->getEntryByIndex(i); if (!entry->getMarked() && entry->getDeleted()) { if (bundle->getVerbose()) { printf(" (removing crufty '%s')\n", entry->getFileName()); } zip->remove(entry); removed++; } } if (bundle->getVerbose() && removed > 0) printf("Removed %d file%s\n", removed, (removed==1) ? "" : "s"); } /* tell Zip lib to process deletions and other pending changes */ result = zip->flush(); if (result != NO_ERROR) { fprintf(stderr, "ERROR: Zip flush failed, archive may be hosed\n"); goto bail; } /* anything here? */ if (zip->getNumEntries() == 0) { if (bundle->getVerbose()) { printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string()); } delete zip; // close the file so we can remove it in Win32 zip = NULL; if (unlink(outputFile.string()) != 0) { fprintf(stderr, "WARNING: could not unlink '%s'\n", outputFile.string()); } } assert(result == NO_ERROR); bail: delete zip; // must close before remove in Win32 if (result != NO_ERROR) { if (bundle->getVerbose()) { printf("Removing %s due to earlier failures\n", outputFile.string()); } if (unlink(outputFile.string()) != 0) { fprintf(stderr, "WARNING: could not unlink '%s'\n", outputFile.string()); } } if (result == NO_ERROR && bundle->getVerbose()) printf("Done!\n"); return result; }
status_t writeAPK(Bundle* bundle, const String8& outputFile, const sp<OutputSet>& outputSet, bool isOverlay) { #if BENCHMARK fprintf(stdout, "BENCHMARK: Starting APK Bundling \n"); long startAPKTime = clock(); #endif /* BENCHMARK */ status_t result = NO_ERROR; ZipFile* zip = NULL; //bundle->setPackageCount(0); /* * Prep the Zip archive. * * If the file already exists, fail unless "update" or "force" is set. * If "update" is set, update the contents of the existing archive. * Else, if "force" is set, remove the existing archive. */ FileType fileType = getFileType(outputFile.string()); if (fileType == kFileTypeNonexistent) { // okay, create it below } else if (fileType == kFileTypeRegular) { if (bundle->getUpdate()) { // okay, open it below } else if (bundle->getForce()) { if (unlink(outputFile.string()) != 0) { fprintf(stderr, "ERROR: unable to remove '%s': %s\n", outputFile.string(), strerror(errno)); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists (use '-f' to force overwrite)\n", outputFile.string()); goto bail; } } else { fprintf(stderr, "ERROR: '%s' exists and is not a regular file\n", outputFile.string()); goto bail; } if (bundle->getVerbose()) { printf("%s '%s'\n", (fileType == kFileTypeNonexistent) ? "Creating" : "Opening", outputFile.string()); } status_t status; zip = new ZipFile; status = zip->open(outputFile.string(), ZipFile::kOpenReadWrite | ZipFile::kOpenCreate); if (status != NO_ERROR) { fprintf(stderr, "ERROR: unable to open '%s' as Zip file for writing\n", outputFile.string()); goto bail; } result = writeAPK(bundle, zip, outputFile.string(), outputSet, isOverlay); if (result != NO_ERROR) { fprintf(stderr, "ERROR: Writing apk failed\n"); goto bail; } /* anything here? */ if (zip->getNumEntries() == 0) { if (bundle->getVerbose()) { printf("Archive is empty -- removing %s\n", outputFile.getPathLeaf().string()); } delete zip; // close the file so we can remove it in Win32 zip = NULL; if (unlink(outputFile.string()) != 0) { fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); } } // If we've been asked to generate a dependency file for the .ap_ package, // do so here if (bundle->getGenDependencies()) { // The dependency file gets output to the same directory // as the specified output file with an additional .d extension. // e.g. bin/resources.ap_.d String8 dependencyFile = outputFile; dependencyFile.append(".d"); FILE* fp = fopen(dependencyFile.string(), "a"); // Add this file to the dependency file fprintf(fp, "%s \\\n", outputFile.string()); fclose(fp); } assert(result == NO_ERROR); bail: delete zip; // must close before remove in Win32 if (result != NO_ERROR) { if (bundle->getVerbose()) { printf("Removing %s due to earlier failures\n", outputFile.string()); } if (unlink(outputFile.string()) != 0) { fprintf(stderr, "warning: could not unlink '%s'\n", outputFile.string()); } } if (result == NO_ERROR && bundle->getVerbose()) printf("Done!\n"); #if BENCHMARK fprintf(stdout, "BENCHMARK: End APK Bundling. Time Elapsed: %f ms \n",(clock() - startAPKTime)/1000.0); #endif /* BENCHMARK */ return result; }
//============================================================================== PreferencesPane::PreferencesPane (const Value& loudnessBarWidth, const Value& loudnessBarMinValue, const Value& loudnessBarMaxValue, const Value& showIntegratedLoudnessHistoryValue, const Value& showLoudnessRangeHistoryValue, const Value& showShortTermLoudnessHistoryValue, const Value& showMomentaryLoudnessHistoryValue) : loudnessHistoryGroup (String::empty, "History Graph"), showIntegratedLoudnessHistory ("I"), showLoudnessRangeHistory("LRA"), showShortTimeLoudnessHistory ("S"), showMomentaryLoudnessHistory ("M") { // Get the icons from the embedded zip. // ------------------------------------ // Source: JuceDemo WidgetsDemo.cpp:616 StringArray iconNames; OwnedArray<Drawable> iconsFromZipFile; const bool dontKeepInternalCopyOfData = false; MemoryInputStream iconsFileStream (BinaryData::icons_zip, BinaryData::icons_zipSize, dontKeepInternalCopyOfData); const bool dontDeleteStreamWhenDestroyed = false; ZipFile icons (&iconsFileStream, dontDeleteStreamWhenDestroyed); for (int i = 0; i < icons.getNumEntries(); ++i) { ScopedPointer<InputStream> svgFileStream (icons.createStreamForEntry (i)); if (svgFileStream != 0) { // DBG(icons.getEntry(i)->filename); iconNames.add (icons.getEntry(i)->filename); iconsFromZipFile.add (Drawable::createFromImageDataStream (*svgFileStream)); } } ScopedPointer<DrawableComposite> wrench = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("wrenchByIonicons.svg")]->createCopy()); AnimatedSidePanel::setCaptionAndIcon("Preferences", wrench); loudnessBarSizeLeftIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("barsWide.svg")]->createCopy()); addAndMakeVisible (loudnessBarSizeLeftIcon); loudnessBarSizeRightIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("barsNarrow.svg")]->createCopy()); addAndMakeVisible (loudnessBarSizeRightIcon); loudnessBarRangeLeftIcon = dynamic_cast <DrawableComposite*> (iconsFromZipFile [iconNames.indexOf ("rangeArrow.svg")]->createCopy()); addAndMakeVisible (loudnessBarRangeLeftIcon); resized(); const bool isReadOnly = false; const int textEntryBoxWidth = 0; const int textEntryBoxHeight = 0; loudnessBarSize.setRange (-300.0, -5.0, 1.0); // This value multiplied by -1 results in the used with // for each loudness bar. Negative values have been chosen to invert the behaviour of the slider // (left side: big bars, right side: small bars). loudnessBarSize.getValueObject().referTo(loudnessBarWidth); loudnessBarSize.setTextBoxStyle(Slider::NoTextBox, isReadOnly, textEntryBoxWidth, textEntryBoxHeight); loudnessBarSize.setColour(Slider::trackColourId, Colours::black); addAndMakeVisible (&loudnessBarSize); loudnessBarRange.setRange (-100, 0.0, 1.0); loudnessBarRange.getMinValueObject().referTo (loudnessBarMinValue); loudnessBarRange.getMaxValueObject().referTo (loudnessBarMaxValue); loudnessBarRange.setTextBoxStyle (Slider::NoTextBox, isReadOnly, textEntryBoxWidth, textEntryBoxHeight); loudnessBarRange.setPopupDisplayEnabled (true, this); loudnessBarRange.setTextValueSuffix (" LUFS"); addAndMakeVisible (&loudnessBarRange); addAndMakeVisible (&loudnessHistoryGroup); showIntegratedLoudnessHistory.setClickingTogglesState (true); showIntegratedLoudnessHistory.getToggleStateValue().referTo (showIntegratedLoudnessHistoryValue); showIntegratedLoudnessHistory.setWantsKeyboardFocus (false); loudnessHistoryGroup.addAndMakeVisible (&showIntegratedLoudnessHistory); showLoudnessRangeHistory.setClickingTogglesState (true); showLoudnessRangeHistory.getToggleStateValue().referTo (showLoudnessRangeHistoryValue); showLoudnessRangeHistory.setWantsKeyboardFocus (false); loudnessHistoryGroup.addAndMakeVisible (&showLoudnessRangeHistory); showShortTimeLoudnessHistory.setClickingTogglesState (true); showShortTimeLoudnessHistory.getToggleStateValue().referTo (showShortTermLoudnessHistoryValue); showShortTimeLoudnessHistory.setWantsKeyboardFocus (false); loudnessHistoryGroup.addAndMakeVisible (&showShortTimeLoudnessHistory); showMomentaryLoudnessHistory.setClickingTogglesState (true); showMomentaryLoudnessHistory.getToggleStateValue().referTo (showMomentaryLoudnessHistoryValue); showMomentaryLoudnessHistory.setWantsKeyboardFocus (false); loudnessHistoryGroup.addAndMakeVisible (&showMomentaryLoudnessHistory); // Colours // ------- setBackgroundColour (Colours::white.withAlpha (0.5f)); loudnessBarSize.setColour (Slider::thumbColourId, Colours::black); loudnessBarRange.setColour (Slider::thumbColourId, Colours::black); loudnessBarRange.setColour (Slider::trackColourId, Colours::black); Colour loudnessHistoryGroupColour = Colour (0xff000000); // (Colour (0xff00ad00)); //Colour (0xff7f7f7f); loudnessHistoryGroup.setColour (GroupComponent::outlineColourId, loudnessHistoryGroupColour); loudnessHistoryGroup.setColour (GroupComponent::textColourId, loudnessHistoryGroupColour); Colour textColourOn = Colours::black; Colour buttonOnColour = Colour (0xffffff00); Colour textColourOff = Colour (0xff9a9a9a); Colour buttonOffColour = Colour (0xff383838); showIntegratedLoudnessHistory.setColour (TextButton::buttonOnColourId, Colours::yellow.darker ().darker ()); showIntegratedLoudnessHistory.setColour (TextButton::textColourOnId, textColourOn); showIntegratedLoudnessHistory.setColour (TextButton::buttonColourId, buttonOffColour); showIntegratedLoudnessHistory.setColour (TextButton::textColourOffId, textColourOff); showLoudnessRangeHistory.setColour (TextButton::buttonOnColourId, Colours::blue.darker ()); showLoudnessRangeHistory.setColour (TextButton::textColourOnId, textColourOn); showLoudnessRangeHistory.setColour (TextButton::buttonColourId, buttonOffColour); showLoudnessRangeHistory.setColour (TextButton::textColourOffId, textColourOff); showShortTimeLoudnessHistory.setColour (TextButton::buttonOnColourId, Colours::green); showShortTimeLoudnessHistory.setColour (TextButton::textColourOnId, textColourOn); showShortTimeLoudnessHistory.setColour (TextButton::buttonColourId, buttonOffColour); showShortTimeLoudnessHistory.setColour (TextButton::textColourOffId, textColourOff); showMomentaryLoudnessHistory.setColour (TextButton::buttonOnColourId, Colours::darkgreen); showMomentaryLoudnessHistory.setColour (TextButton::textColourOnId, textColourOn); showMomentaryLoudnessHistory.setColour (TextButton::buttonColourId, buttonOffColour); showMomentaryLoudnessHistory.setColour (TextButton::textColourOffId, textColourOff); }