| @@ -172,7 +172,7 @@ private: | |||||
| for (int i = 10; --i >= 0;) | for (int i = 10; --i >= 0;) | ||||
| { | { | ||||
| Path pp; | Path pp; | ||||
| pp.addStar (Point<float> (r.nextInt (w), r.nextInt (h)), r.nextInt (8) + 3, 10, 20, 0); | |||||
| pp.addStar (Point<float> (r.nextFloat() * w, r.nextFloat() * h, r.nextFloat() * 8 + 3, 10.0f, 20.0f, 0.0f); | |||||
| g.setColour (Colours::pink.withAlpha (0.4f)); | g.setColour (Colours::pink.withAlpha (0.4f)); | ||||
| g.fillPath (pp); | g.fillPath (pp); | ||||
| } | } | ||||
| @@ -42,7 +42,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat, const bool make | |||||
| if (newFormat != nullptr) | if (newFormat != nullptr) | ||||
| { | { | ||||
| #if JUCE_DEBUG | |||||
| #if JUCE_DEBUG | |||||
| for (int i = getNumKnownFormats(); --i >= 0;) | for (int i = getNumKnownFormats(); --i >= 0;) | ||||
| { | { | ||||
| if (getKnownFormat (i)->getFormatName() == newFormat->getFormatName()) | if (getKnownFormat (i)->getFormatName() == newFormat->getFormatName()) | ||||
| @@ -50,7 +50,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat, const bool make | |||||
| jassertfalse; // trying to add the same format twice! | jassertfalse; // trying to add the same format twice! | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| #endif | |||||
| if (makeThisTheDefaultFormat) | if (makeThisTheDefaultFormat) | ||||
| defaultFormatIndex = getNumKnownFormats(); | defaultFormatIndex = getNumKnownFormats(); | ||||
| @@ -61,22 +61,20 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat, const bool make | |||||
| void AudioFormatManager::registerBasicFormats() | void AudioFormatManager::registerBasicFormats() | ||||
| { | { | ||||
| #if JUCE_MAC | |||||
| registerFormat (new AiffAudioFormat(), true); | |||||
| registerFormat (new WavAudioFormat(), false); | |||||
| registerFormat (new CoreAudioFormat(), false); | |||||
| #else | |||||
| registerFormat (new WavAudioFormat(), true); | registerFormat (new WavAudioFormat(), true); | ||||
| registerFormat (new AiffAudioFormat(), false); | registerFormat (new AiffAudioFormat(), false); | ||||
| #endif | |||||
| #if JUCE_USE_FLAC | |||||
| #if JUCE_MAC || JUCE_IOS | |||||
| registerFormat (new CoreAudioFormat(), false); | |||||
| #endif | |||||
| #if JUCE_USE_FLAC | |||||
| registerFormat (new FlacAudioFormat(), false); | registerFormat (new FlacAudioFormat(), false); | ||||
| #endif | |||||
| #endif | |||||
| #if JUCE_USE_OGGVORBIS | |||||
| #if JUCE_USE_OGGVORBIS | |||||
| registerFormat (new OggVorbisAudioFormat(), false); | registerFormat (new OggVorbisAudioFormat(), false); | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| void AudioFormatManager::clearFormats() | void AudioFormatManager::clearFormats() | ||||
| @@ -102,12 +100,11 @@ AudioFormat* AudioFormatManager::getDefaultFormat() const | |||||
| AudioFormat* AudioFormatManager::findFormatForFileExtension (const String& fileExtension) const | AudioFormat* AudioFormatManager::findFormatForFileExtension (const String& fileExtension) const | ||||
| { | { | ||||
| String e (fileExtension); | |||||
| if (! e.startsWithChar ('.')) | |||||
| e = "." + e; | |||||
| if (! fileExtension.startsWithChar ('.')) | |||||
| return findFormatForFileExtension ("." + fileExtension); | |||||
| for (int i = 0; i < getNumKnownFormats(); ++i) | for (int i = 0; i < getNumKnownFormats(); ++i) | ||||
| if (getKnownFormat(i)->getFileExtensions().contains (e, true)) | |||||
| if (getKnownFormat(i)->getFileExtensions().contains (fileExtension, true)) | |||||
| return getKnownFormat(i); | return getKnownFormat(i); | ||||
| return nullptr; | return nullptr; | ||||
| @@ -115,30 +112,20 @@ AudioFormat* AudioFormatManager::findFormatForFileExtension (const String& fileE | |||||
| String AudioFormatManager::getWildcardForAllFormats() const | String AudioFormatManager::getWildcardForAllFormats() const | ||||
| { | { | ||||
| StringArray allExtensions; | |||||
| StringArray extensions; | |||||
| int i; | int i; | ||||
| for (i = 0; i < getNumKnownFormats(); ++i) | for (i = 0; i < getNumKnownFormats(); ++i) | ||||
| allExtensions.addArray (getKnownFormat (i)->getFileExtensions()); | |||||
| allExtensions.trim(); | |||||
| allExtensions.removeEmptyStrings(); | |||||
| extensions.addArray (getKnownFormat(i)->getFileExtensions()); | |||||
| String s; | |||||
| for (i = 0; i < allExtensions.size(); ++i) | |||||
| { | |||||
| s << '*'; | |||||
| if (! allExtensions[i].startsWithChar ('.')) | |||||
| s << '.'; | |||||
| extensions.trim(); | |||||
| extensions.removeEmptyStrings(); | |||||
| s << allExtensions[i]; | |||||
| if (i < allExtensions.size() - 1) | |||||
| s << ';'; | |||||
| } | |||||
| for (i = 0; i < extensions.size(); ++i) | |||||
| extensions.set (i, (extensions[i].startsWithChar ('.') ? "*" : "*.") + extensions[i]); | |||||
| return s; | |||||
| extensions.removeDuplicates (true); | |||||
| return extensions.joinIntoString (";"); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -87,12 +87,10 @@ public: | |||||
| LinkedListPointer& operator= (LinkedListPointer&& other) noexcept | LinkedListPointer& operator= (LinkedListPointer&& other) noexcept | ||||
| { | { | ||||
| if (this != &other) | |||||
| { | |||||
| item = other.item; | |||||
| other.item = nullptr; | |||||
| } | |||||
| jassert (this != &other); // hopefully the compiler should make this situation impossible! | |||||
| item = other.item; | |||||
| other.item = nullptr; | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -2382,8 +2382,8 @@ public: | |||||
| beginTest ("StringArray"); | beginTest ("StringArray"); | ||||
| StringArray s; | StringArray s; | ||||
| for (int i = 5; --i >= 0;) | |||||
| s.add (String (i)); | |||||
| s.addTokens ("4,3,2,1,0", ";,", "x"); | |||||
| expectEquals (s.size(), 5); | |||||
| expectEquals (s.joinIntoString ("-"), String ("4-3-2-1-0")); | expectEquals (s.joinIntoString ("-"), String ("4-3-2-1-0")); | ||||
| s.remove (2); | s.remove (2); | ||||
| @@ -2391,6 +2391,21 @@ public: | |||||
| expectEquals (s.joinIntoString (String::empty), String ("4310")); | expectEquals (s.joinIntoString (String::empty), String ("4310")); | ||||
| s.clear(); | s.clear(); | ||||
| expectEquals (s.joinIntoString ("x"), String::empty); | expectEquals (s.joinIntoString ("x"), String::empty); | ||||
| StringArray toks; | |||||
| toks.addTokens ("x,,", ";,", ""); | |||||
| expectEquals (toks.size(), 3); | |||||
| expectEquals (toks.joinIntoString ("-"), String ("x--")); | |||||
| toks.clear(); | |||||
| toks.addTokens (",x,", ";,", ""); | |||||
| expectEquals (toks.size(), 3); | |||||
| expectEquals (toks.joinIntoString ("-"), String ("-x-")); | |||||
| toks.clear(); | |||||
| toks.addTokens ("x,'y,z',", ";,", "'"); | |||||
| expectEquals (toks.size(), 3); | |||||
| expectEquals (toks.joinIntoString ("-"), String ("x-'y,z'-")); | |||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -279,15 +279,13 @@ void StringArray::trim() | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| class InternalStringArrayComparator_CaseSensitive | |||||
| struct InternalStringArrayComparator_CaseSensitive | |||||
| { | { | ||||
| public: | |||||
| static int compareElements (String& first, String& second) { return first.compare (second); } | static int compareElements (String& first, String& second) { return first.compare (second); } | ||||
| }; | }; | ||||
| class InternalStringArrayComparator_CaseInsensitive | |||||
| struct InternalStringArrayComparator_CaseInsensitive | |||||
| { | { | ||||
| public: | |||||
| static int compareElements (String& first, String& second) { return first.compareIgnoreCase (second); } | static int compareElements (String& first, String& second) { return first.compareIgnoreCase (second); } | ||||
| }; | }; | ||||
| @@ -363,18 +361,21 @@ int StringArray::addTokens (const String& text, const String& breakCharacters, c | |||||
| int num = 0; | int num = 0; | ||||
| String::CharPointerType t (text.getCharPointer()); | String::CharPointerType t (text.getCharPointer()); | ||||
| while (! t.isEmpty()) | |||||
| if (! t.isEmpty()) | |||||
| { | { | ||||
| String::CharPointerType tokenEnd (CharacterFunctions::findEndOfToken (t, | |||||
| breakCharacters.getCharPointer(), | |||||
| quoteCharacters.getCharPointer())); | |||||
| add (String (t, tokenEnd)); | |||||
| ++num; | |||||
| for (;;) | |||||
| { | |||||
| String::CharPointerType tokenEnd (CharacterFunctions::findEndOfToken (t, | |||||
| breakCharacters.getCharPointer(), | |||||
| quoteCharacters.getCharPointer())); | |||||
| add (String (t, tokenEnd)); | |||||
| ++num; | |||||
| if (tokenEnd.isEmpty()) | |||||
| break; | |||||
| if (tokenEnd.isEmpty()) | |||||
| break; | |||||
| t = ++tokenEnd; | |||||
| t = ++tokenEnd; | |||||
| } | |||||
| } | } | ||||
| return num; | return num; | ||||
| @@ -95,16 +95,15 @@ XmlElement::XmlElement (XmlElement&& other) noexcept | |||||
| XmlElement& XmlElement::operator= (XmlElement&& other) noexcept | XmlElement& XmlElement::operator= (XmlElement&& other) noexcept | ||||
| { | { | ||||
| if (this != &other) | |||||
| { | |||||
| removeAllAttributes(); | |||||
| deleteAllChildElements(); | |||||
| jassert (this != &other); // hopefully the compiler should make this situation impossible! | |||||
| nextListItem = static_cast <LinkedListPointer <XmlElement>&&> (other.nextListItem); | |||||
| firstChildElement = static_cast <LinkedListPointer <XmlElement>&&> (other.firstChildElement); | |||||
| attributes = static_cast <LinkedListPointer <XmlAttributeNode>&&> (other.attributes); | |||||
| tagName = static_cast <String&&> (other.tagName); | |||||
| } | |||||
| removeAllAttributes(); | |||||
| deleteAllChildElements(); | |||||
| nextListItem = static_cast <LinkedListPointer <XmlElement>&&> (other.nextListItem); | |||||
| firstChildElement = static_cast <LinkedListPointer <XmlElement>&&> (other.firstChildElement); | |||||
| attributes = static_cast <LinkedListPointer <XmlAttributeNode>&&> (other.attributes); | |||||
| tagName = static_cast <String&&> (other.tagName); | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -26,7 +26,7 @@ | |||||
| BEGIN_JUCE_NAMESPACE | BEGIN_JUCE_NAMESPACE | ||||
| //============================================================================== | //============================================================================== | ||||
| class AsyncUpdaterMessage : public CallbackMessage | |||||
| class AsyncUpdater::AsyncUpdaterMessage : public CallbackMessage | |||||
| { | { | ||||
| public: | public: | ||||
| AsyncUpdaterMessage (AsyncUpdater& owner_) | AsyncUpdaterMessage (AsyncUpdater& owner_) | ||||
| @@ -52,11 +52,6 @@ AsyncUpdater::AsyncUpdater() | |||||
| message = new AsyncUpdaterMessage (*this); | message = new AsyncUpdaterMessage (*this); | ||||
| } | } | ||||
| inline Atomic<int>& AsyncUpdater::getDeliveryFlag() const noexcept | |||||
| { | |||||
| return static_cast <AsyncUpdaterMessage*> (message.getObject())->shouldDeliver; | |||||
| } | |||||
| AsyncUpdater::~AsyncUpdater() | AsyncUpdater::~AsyncUpdater() | ||||
| { | { | ||||
| // You're deleting this object with a background thread while there's an update | // You're deleting this object with a background thread while there's an update | ||||
| @@ -65,18 +60,18 @@ AsyncUpdater::~AsyncUpdater() | |||||
| // deleting this object, or find some other way to avoid such a race condition. | // deleting this object, or find some other way to avoid such a race condition. | ||||
| jassert ((! isUpdatePending()) || MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | jassert ((! isUpdatePending()) || MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | ||||
| getDeliveryFlag().set (0); | |||||
| message->shouldDeliver.set (0); | |||||
| } | } | ||||
| void AsyncUpdater::triggerAsyncUpdate() | void AsyncUpdater::triggerAsyncUpdate() | ||||
| { | { | ||||
| if (getDeliveryFlag().compareAndSetBool (1, 0)) | |||||
| if (message->shouldDeliver.compareAndSetBool (1, 0)) | |||||
| message->post(); | message->post(); | ||||
| } | } | ||||
| void AsyncUpdater::cancelPendingUpdate() noexcept | void AsyncUpdater::cancelPendingUpdate() noexcept | ||||
| { | { | ||||
| getDeliveryFlag().set (0); | |||||
| message->shouldDeliver.set (0); | |||||
| } | } | ||||
| void AsyncUpdater::handleUpdateNowIfNeeded() | void AsyncUpdater::handleUpdateNowIfNeeded() | ||||
| @@ -84,13 +79,13 @@ void AsyncUpdater::handleUpdateNowIfNeeded() | |||||
| // This can only be called by the event thread. | // This can only be called by the event thread. | ||||
| jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | ||||
| if (getDeliveryFlag().exchange (0) != 0) | |||||
| if (message->shouldDeliver.exchange (0) != 0) | |||||
| handleAsyncUpdate(); | handleAsyncUpdate(); | ||||
| } | } | ||||
| bool AsyncUpdater::isUpdatePending() const noexcept | bool AsyncUpdater::isUpdatePending() const noexcept | ||||
| { | { | ||||
| return getDeliveryFlag().value != 0; | |||||
| return message->shouldDeliver.value != 0; | |||||
| } | } | ||||
| @@ -26,8 +26,6 @@ | |||||
| #ifndef __JUCE_ASYNCUPDATER_JUCEHEADER__ | #ifndef __JUCE_ASYNCUPDATER_JUCEHEADER__ | ||||
| #define __JUCE_ASYNCUPDATER_JUCEHEADER__ | #define __JUCE_ASYNCUPDATER_JUCEHEADER__ | ||||
| #include "../messages/juce_CallbackMessage.h" | |||||
| //============================================================================== | //============================================================================== | ||||
| /** | /** | ||||
| @@ -102,8 +100,9 @@ public: | |||||
| private: | private: | ||||
| //============================================================================== | //============================================================================== | ||||
| ReferenceCountedObjectPtr<CallbackMessage> message; | |||||
| Atomic<int>& getDeliveryFlag() const noexcept; | |||||
| class AsyncUpdaterMessage; | |||||
| friend class ReferenceCountedObjectPtr<AsyncUpdaterMessage>; | |||||
| ReferenceCountedObjectPtr<AsyncUpdaterMessage> message; | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncUpdater); | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AsyncUpdater); | ||||
| }; | }; | ||||
| @@ -281,14 +281,14 @@ public: | |||||
| { | { | ||||
| public: | public: | ||||
| //============================================================================== | //============================================================================== | ||||
| Iterator (const ListType& list_) | |||||
| Iterator (const ListType& list_) noexcept | |||||
| : list (list_), index (list_.size()) | : list (list_), index (list_.size()) | ||||
| {} | {} | ||||
| ~Iterator() {} | |||||
| ~Iterator() noexcept {} | |||||
| //============================================================================== | //============================================================================== | ||||
| bool next() | |||||
| bool next() noexcept | |||||
| { | { | ||||
| if (index <= 0) | if (index <= 0) | ||||
| return false; | return false; | ||||
| @@ -302,7 +302,7 @@ public: | |||||
| return index >= 0; | return index >= 0; | ||||
| } | } | ||||
| bool next (const BailOutCheckerType& bailOutChecker) | |||||
| bool next (const BailOutCheckerType& bailOutChecker) noexcept | |||||
| { | { | ||||
| return (! bailOutChecker.shouldBailOut()) && next(); | return (! bailOutChecker.shouldBailOut()) && next(); | ||||
| } | } | ||||
| @@ -97,7 +97,7 @@ struct HSB | |||||
| return Colour (hue, saturation, brightness, original.getAlpha()); | return Colour (hue, saturation, brightness, original.getAlpha()); | ||||
| } | } | ||||
| static PixelARGB convertHSBtoRGB (float h, float s, float v, const uint8 alpha) noexcept | |||||
| static PixelARGB toRGB (float h, float s, float v, const uint8 alpha) noexcept | |||||
| { | { | ||||
| v = jlimit (0.0f, 255.0f, v * 255.0f); | v = jlimit (0.0f, 255.0f, v * 255.0f); | ||||
| const uint8 intV = (uint8) roundToInt (v); | const uint8 intV = (uint8) roundToInt (v); | ||||
| @@ -178,7 +178,7 @@ Colour Colour::fromRGBAFloat (const uint8 red, const uint8 green, const uint8 bl | |||||
| } | } | ||||
| Colour::Colour (const float hue, const float saturation, const float brightness, const float alpha) noexcept | Colour::Colour (const float hue, const float saturation, const float brightness, const float alpha) noexcept | ||||
| : argb (HSB::convertHSBtoRGB (hue, saturation, brightness, ColourHelpers::floatToUInt8 (alpha))) | |||||
| : argb (HSB::toRGB (hue, saturation, brightness, ColourHelpers::floatToUInt8 (alpha))) | |||||
| { | { | ||||
| } | } | ||||
| @@ -188,7 +188,7 @@ Colour Colour::fromHSV (const float hue, const float saturation, const float bri | |||||
| } | } | ||||
| Colour::Colour (const float hue, const float saturation, const float brightness, const uint8 alpha) noexcept | Colour::Colour (const float hue, const float saturation, const float brightness, const uint8 alpha) noexcept | ||||
| : argb (HSB::convertHSBtoRGB (hue, saturation, brightness, alpha)) | |||||
| : argb (HSB::toRGB (hue, saturation, brightness, alpha)) | |||||
| { | { | ||||
| } | } | ||||
| @@ -78,14 +78,12 @@ FillType::FillType (FillType&& other) noexcept | |||||
| FillType& FillType::operator= (FillType&& other) noexcept | FillType& FillType::operator= (FillType&& other) noexcept | ||||
| { | { | ||||
| if (this != &other) | |||||
| { | |||||
| colour = other.colour; | |||||
| gradient = other.gradient.release(); | |||||
| image = static_cast <Image&&> (other.image); | |||||
| transform = other.transform; | |||||
| } | |||||
| jassert (this != &other); // hopefully the compiler should make this situation impossible! | |||||
| colour = other.colour; | |||||
| gradient = other.gradient.release(); | |||||
| image = static_cast <Image&&> (other.image); | |||||
| transform = other.transform; | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -79,11 +79,11 @@ public: | |||||
| or saveMode, and canSelectFiles and/or canSelectDirectories. | or saveMode, and canSelectFiles and/or canSelectDirectories. | ||||
| @param initialFileOrDirectory The file or directory that should be selected when the component begins. | @param initialFileOrDirectory The file or directory that should be selected when the component begins. | ||||
| If this is File::nonexistent, a default directory will be chosen. | If this is File::nonexistent, a default directory will be chosen. | ||||
| @param fileFilter an optional filter to use to determine which files are shown. | |||||
| @param fileFilter an optional filter to use to determine which files are shown. | |||||
| If this is nullptr then all files are displayed. Note that a pointer | If this is nullptr then all files are displayed. Note that a pointer | ||||
| is kept internally to this object, so make sure that it is not deleted | is kept internally to this object, so make sure that it is not deleted | ||||
| before the FileBrowserComponent object is deleted. | before the FileBrowserComponent object is deleted. | ||||
| @param previewComp an optional preview component that will be used to show previews of | |||||
| @param previewComp an optional preview component that will be used to show previews of | |||||
| files that the user selects | files that the user selects | ||||
| */ | */ | ||||
| FileBrowserComponent (int flags, | FileBrowserComponent (int flags, | ||||
| @@ -1169,12 +1169,10 @@ PopupMenu::PopupMenu (PopupMenu&& other) noexcept | |||||
| PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept | PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept | ||||
| { | { | ||||
| if (this != &other) | |||||
| { | |||||
| items.swapWithArray (other.items); | |||||
| lookAndFeel = other.lookAndFeel; | |||||
| } | |||||
| jassert (this != &other); // hopefully the compiler should make this situation impossible! | |||||
| items.swapWithArray (other.items); | |||||
| lookAndFeel = other.lookAndFeel; | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -108,7 +108,7 @@ public: | |||||
| The item ID of each item will be its index in the StringArray + firstItemIdOffset. | The item ID of each item will be its index in the StringArray + firstItemIdOffset. | ||||
| */ | */ | ||||
| void addItemList (const StringArray& items, int firstItemIdOffset); | void addItemList (const StringArray& items, int firstItemIdOffset); | ||||
| /** Adds a separator line to the drop-down list. | /** Adds a separator line to the drop-down list. | ||||
| This is like adding a separator to a popup menu. See PopupMenu::addSeparator(). | This is like adding a separator to a popup menu. See PopupMenu::addSeparator(). | ||||