diff --git a/modules/juce_core/network/juce_URL.cpp b/modules/juce_core/network/juce_URL.cpp index f4dbe4a51d..f74cd19d8a 100644 --- a/modules/juce_core/network/juce_URL.cpp +++ b/modules/juce_core/network/juce_URL.cpp @@ -121,7 +121,7 @@ namespace URLHelpers return p; } - int findStartOfDomain (const String& url) + int findEndOfScheme (const String& url) { int i = 0; @@ -132,6 +132,20 @@ namespace URLHelpers return url[i] == ':' ? i + 1 : 0; } + int findStartOfNetLocation (const String& url) + { + int start = findEndOfScheme (url); + while (url[start] == '/') + ++start; + + return start; + } + + int findStartOfPath (const String& url) + { + return url.indexOfChar (findStartOfNetLocation (url), '/') + 1; + } + void createHeadersAndPostData (const URL& url, String& headers, MemoryBlock& postData) { MemoryOutputStream data (postData, false); @@ -214,10 +228,7 @@ bool URL::isWellFormed() const String URL::getDomain() const { - int start = URLHelpers::findStartOfDomain (url); - while (url[start] == '/') - ++start; - + const int start = URLHelpers::findStartOfNetLocation (url); const int end1 = url.indexOfChar (start, '/'); const int end2 = url.indexOfChar (start, ':'); @@ -229,11 +240,7 @@ String URL::getDomain() const String URL::getSubPath() const { - int start = URLHelpers::findStartOfDomain (url); - while (url[start] == '/') - ++start; - - const int startOfPath = url.indexOfChar (start, '/') + 1; + const int startOfPath = URLHelpers::findStartOfPath (url); return startOfPath <= 0 ? String::empty : url.substring (startOfPath); @@ -241,16 +248,19 @@ String URL::getSubPath() const String URL::getScheme() const { - return url.substring (0, URLHelpers::findStartOfDomain (url) - 1); + return url.substring (0, URLHelpers::findEndOfScheme (url) - 1); +} + +int URL::getPort() const +{ + const int colonPos = url.indexOfChar (URLHelpers::findStartOfNetLocation (url), ':'); + + return colonPos > 0 ? url.substring (colonPos + 1).getIntValue() : 0; } URL URL::withNewSubPath (const String& newPath) const { - int start = URLHelpers::findStartOfDomain (url); - while (url[start] == '/') - ++start; - - const int startOfPath = url.indexOfChar (start, '/') + 1; + const int startOfPath = URLHelpers::findStartOfPath (url); URL u (*this); diff --git a/modules/juce_core/network/juce_URL.h b/modules/juce_core/network/juce_URL.h index c4fad9edd0..67f1743d82 100644 --- a/modules/juce_core/network/juce_URL.h +++ b/modules/juce_core/network/juce_URL.h @@ -96,6 +96,11 @@ public: */ String getScheme() const; + /** Attempts to read a port number from the URL. + @returns the port number, or 0 if none is explicitly specified. + */ + int getPort() const; + /** Returns a new version of this URL that uses a different sub-path. E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with diff --git a/modules/juce_graphics/images/juce_Image.cpp b/modules/juce_graphics/images/juce_Image.cpp index 77ceead2f9..39958d4ed2 100644 --- a/modules/juce_graphics/images/juce_Image.cpp +++ b/modules/juce_graphics/images/juce_Image.cpp @@ -176,10 +176,7 @@ Image Image::getClippedImage (const Rectangle& area) const return *this; const Rectangle validArea (area.getIntersection (getBounds())); - if (validArea.isEmpty()) - return Image::null; - - return Image (new SubsectionPixelData (image, validArea)); + return Image (validArea.isEmpty() ? nullptr : new SubsectionPixelData (image, validArea)); } @@ -254,6 +251,11 @@ void Image::duplicateIfShared() image = image->clone(); } +Image Image::createCopy() const +{ + return Image (image != nullptr ? image->clone() : nullptr); +} + Image Image::rescaled (const int newWidth, const int newHeight, const Graphics::ResamplingQuality quality) const { if (image == nullptr || (image->width == newWidth && image->height == newHeight)) diff --git a/modules/juce_graphics/images/juce_Image.h b/modules/juce_graphics/images/juce_Image.h index ca97f8c95e..bc989c2937 100644 --- a/modules/juce_graphics/images/juce_Image.h +++ b/modules/juce_graphics/images/juce_Image.h @@ -200,6 +200,13 @@ public: Image rescaled (int newWidth, int newHeight, Graphics::ResamplingQuality quality = Graphics::mediumResamplingQuality) const; + /** Creates a copy of this image. + Note that it's usually more efficient to use duplicateIfShared(), because it may not be necessary + to copy an image if nothing else is using it. + @see getReferenceCount + */ + Image createCopy() const; + /** Returns a version of this image with a different image format. A new image is returned which has been converted to the specified format. diff --git a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp index b28c01a56b..41331b1aba 100644 --- a/modules/juce_gui_basics/windows/juce_AlertWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_AlertWindow.cpp @@ -400,6 +400,8 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) const int labelHeight = 18; int iconSpace = 0; + attributedText.setColour (findColour (textColourId)); + if (alertIconType == NoIcon) { attributedText.setJustification (Justification::centredTop); @@ -590,6 +592,7 @@ void AlertWindow::lookAndFeelChanged() setUsingNativeTitleBar ((newFlags & ComponentPeer::windowHasTitleBar) != 0); setDropShadowEnabled (isOpaque() && (newFlags & ComponentPeer::windowHasDropShadow) != 0); + updateLayout (false); } int AlertWindow::getDesktopWindowStyleFlags() const