diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 3f7a0e0d35..db6f8defaf 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -64262,7 +64262,7 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button, void LookAndFeel::drawTickBox (Graphics& g, Component& component, - int x, int y, int w, int h, + float x, float y, float w, float h, const bool ticked, const bool isEnabled, const bool isMouseOverButton, @@ -64270,7 +64270,7 @@ void LookAndFeel::drawTickBox (Graphics& g, { const float boxSize = w * 0.7f; - drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize, + drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, createBaseColour (component.findColour (TextButton::buttonColourId) .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), true, @@ -64288,7 +64288,7 @@ void LookAndFeel::drawTickBox (Graphics& g, g.setColour (isEnabled ? Colours::black : Colours::grey); const AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f) - .translated ((float) x, (float) y)); + .translated (x, y)); g.strokePath (tick, PathStrokeType (2.5f), trans); } @@ -64305,9 +64305,10 @@ void LookAndFeel::drawToggleButton (Graphics& g, g.drawRect (0, 0, button.getWidth(), button.getHeight()); } - const int tickWidth = jmin (20, button.getHeight() - 4); + float fontSize = jmin (15.0f, button.getHeight() * 0.75f); + const float tickWidth = fontSize * 1.1f; - drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2, + drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), @@ -64315,7 +64316,7 @@ void LookAndFeel::drawToggleButton (Graphics& g, isButtonDown); g.setColour (button.findColour (ToggleButton::textColourId)); - g.setFont (jmin (15.0f, button.getHeight() * 0.6f)); + g.setFont (fontSize); if (! button.isEnabled()) g.setOpacity (0.5f); @@ -64323,8 +64324,8 @@ void LookAndFeel::drawToggleButton (Graphics& g, const int textX = tickWidth + 5; g.drawFittedText (button.getButtonText(), - textX, 4, - button.getWidth() - textX - 2, button.getHeight() - 8, + textX, 0, + button.getWidth() - textX - 2, button.getHeight(), Justification::centredLeft, 10); } @@ -75760,28 +75761,32 @@ void AlertWindow::paint (Graphics& g) int i; for (i = textBoxes.size(); --i >= 0;) { - if (textboxNames[i].isNotEmpty()) - { - const TextEditor* const te = (TextEditor*) textBoxes[i]; + const TextEditor* const te = (TextEditor*) textBoxes[i]; - g.drawFittedText (textboxNames[i], - te->getX(), te->getY() - 14, - te->getWidth(), 14, - Justification::centredLeft, 1); - } + g.drawFittedText (textboxNames[i], + te->getX(), te->getY() - 14, + te->getWidth(), 14, + Justification::centredLeft, 1); } for (i = comboBoxNames.size(); --i >= 0;) { - if (comboBoxNames[i].isNotEmpty()) - { - const ComboBox* const cb = (ComboBox*) comboBoxes[i]; + const ComboBox* const cb = (ComboBox*) comboBoxes[i]; - g.drawFittedText (comboBoxNames[i], - cb->getX(), cb->getY() - 14, - cb->getWidth(), 14, - Justification::centredLeft, 1); - } + g.drawFittedText (comboBoxNames[i], + cb->getX(), cb->getY() - 14, + cb->getWidth(), 14, + Justification::centredLeft, 1); + } + + for (i = customComps.size(); --i >= 0;) + { + const Component* const c = (Component*) customComps[i]; + + g.drawFittedText (c->getName(), + c->getX(), c->getY() - 14, + c->getWidth(), 14, + Justification::centredLeft, 1); } } @@ -75793,6 +75798,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) const int sw = (int) sqrt (font.getHeight() * wid); int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f)); const int edgeGap = 10; + const int labelHeight = 18; int iconSpace; if (alertIconType == NoIcon) @@ -75827,8 +75833,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (i = customComps.size(); --i >= 0;) { - w = jmax (w, ((Component*) customComps[i])->getWidth() + 40); - h += 10 + ((Component*) customComps[i])->getHeight(); + Component* c = (Component*) customComps[i]; + w = jmax (w, (c->getWidth() * 100) / 80); + h += 10 + c->getHeight(); + + if (c->getName().isNotEmpty()) + h += labelHeight; } for (i = textBlocks.size(); --i >= 0;) @@ -75897,27 +75907,35 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (i = 0; i < allComps.size(); ++i) { Component* const c = (Component*) allComps[i]; - - const int h = 22; + int h = 22; const int comboIndex = comboBoxes.indexOf (c); if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty()) - y += 18; + y += labelHeight; const int tbIndex = textBoxes.indexOf (c); if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty()) - y += 18; + y += labelHeight; - if (customComps.contains (c) || textBlocks.contains (c)) + if (customComps.contains (c)) + { + if (c->getName().isNotEmpty()) + y += labelHeight; + + c->setTopLeftPosition (proportionOfWidth (0.1f), y); + h = c->getHeight(); + } + else if (textBlocks.contains (c)) { c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y); - y += c->getHeight() + 10; + h = c->getHeight(); } else { c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h); - y += h + 10; } + + y += h + 10; } setWantsKeyboardFocus (getNumChildComponents() == 0); @@ -213632,6 +213650,48 @@ struct ConnectionAndRequestStruct static HINTERNET sessionHandle = 0; +#ifndef WORKAROUND_TIMEOUT_BUG + //#define WORKAROUND_TIMEOUT_BUG 1 +#endif + +#if WORKAROUND_TIMEOUT_BUG +// Required because of a Microsoft bug in setting a timeout +class InternetConnectThread : public Thread +{ +public: + InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_) + : Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_) + { + startThread(); + } + + ~InternetConnectThread() + { + stopThread (60000); + } + + void run() + { + connection = InternetConnect (sessionHandle, uc.lpszHostName, + uc.nPort, _T(""), _T(""), + isFtp ? INTERNET_SERVICE_FTP + : INTERNET_SERVICE_HTTP, + 0, 0); + notify(); + } + + juce_UseDebuggingNewOperator + +private: + URL_COMPONENTS& uc; + HINTERNET& connection; + const bool isFtp; + + InternetConnectThread (const InternetConnectThread&); + InternetConnectThread& operator= (const InternetConnectThread&); +}; +#endif + void* juce_openInternetFile (const String& url, const String& headers, const MemoryBlock& postData, @@ -213661,6 +213721,9 @@ void* juce_openInternetFile (const String& url, if (InternetCrackUrl (url, 0, 0, &uc)) { + int disable = 1; + InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable)); + if (timeOutMs == 0) timeOutMs = 30000; else if (timeOutMs < 0) @@ -213670,6 +213733,20 @@ void* juce_openInternetFile (const String& url, const bool isFtp = url.startsWithIgnoreCase (T("ftp:")); +#if WORKAROUND_TIMEOUT_BUG + HINTERNET connection = 0; + + { + InternetConnectThread connectThread (uc, connection, isFtp); + connectThread.wait (timeOutMs); + + if (connection == 0) + { + InternetCloseHandle (sessionHandle); + sessionHandle = 0; + } + } +#else HINTERNET connection = InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort, @@ -213677,6 +213754,7 @@ void* juce_openInternetFile (const String& url, isFtp ? INTERNET_SERVICE_FTP : INTERNET_SERVICE_HTTP, 0, 0); +#endif if (connection != 0) { @@ -246393,6 +246471,9 @@ bool NSViewComponentPeer::redirectKeyUp (NSEvent* ev) void NSViewComponentPeer::redirectModKeyChange (NSEvent* ev) { + keysCurrentlyDown.clear(); + handleKeyUpOrDown (true); + updateModifiers (ev); handleModifierKeysChange(); } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 973aaaa05a..d4149d04c2 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -18413,6 +18413,8 @@ public: int getPreferredHeight() const throw() { return preferredHeight; } + void setPreferredHeight (int newHeight) throw() { preferredHeight = newHeight; } + virtual void refresh() = 0; void paint (Graphics& g); @@ -24096,7 +24098,7 @@ public: virtual void drawTickBox (Graphics& g, Component& component, - int x, int y, int w, int h, + float x, float y, float w, float h, const bool ticked, const bool isEnabled, const bool isMouseOverButton, @@ -24477,16 +24479,6 @@ public: juce_UseDebuggingNewOperator -protected: - // xxx the following methods are only here to cause a compiler error, because they've been - // deprecated or their parameters have changed. Hopefully these definitions should cause an - // error if you try to build a subclass with the old versions. - virtual int drawTickBox (Graphics&, int, int, int, int, bool, const bool, const bool, const bool) { return 0; } - virtual int drawProgressBar (Graphics&, int, int, int, int, float) { return 0; } - virtual int drawProgressBar (Graphics&, ProgressBar&, int, int, int, int, float) { return 0; } - virtual void getTabButtonBestWidth (int, const String&, int) {} - virtual int drawTreeviewPlusMinusBox (Graphics&, int, int, int, int, bool) { return 0; } - private: friend void JUCE_PUBLIC_FUNCTION shutdownJuce_GUI(); static void clearDefaultLookAndFeel() throw(); // called at shutdown diff --git a/src/audio/devices/juce_AudioIODeviceType.h b/src/audio/devices/juce_AudioIODeviceType.h index c518eecae3..0debb1ed0d 100644 --- a/src/audio/devices/juce_AudioIODeviceType.h +++ b/src/audio/devices/juce_AudioIODeviceType.h @@ -34,12 +34,12 @@ class Component; /** Represents a type of audio driver, such as DirectSound, ASIO, CoreAudio, etc. - To get a list of available audio driver types, use the createDeviceTypes() + To get a list of available audio driver types, use the AudioDeviceManager::createAudioDeviceTypes() method. Each of the objects returned can then be used to list the available devices of that type. E.g. @code OwnedArray types; - AudioIODeviceType::createDeviceTypes (types); + myAudioDeviceManager.createAudioDeviceTypes (types); for (int i = 0; i < types.size(); ++i) { diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index d0cb5b92b8..9e9dbd34df 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -411,7 +411,7 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button, void LookAndFeel::drawTickBox (Graphics& g, Component& component, - int x, int y, int w, int h, + float x, float y, float w, float h, const bool ticked, const bool isEnabled, const bool isMouseOverButton, @@ -419,7 +419,7 @@ void LookAndFeel::drawTickBox (Graphics& g, { const float boxSize = w * 0.7f; - drawGlassSphere (g, (float) x, y + (h - boxSize) * 0.5f, boxSize, + drawGlassSphere (g, x, y + (h - boxSize) * 0.5f, boxSize, createBaseColour (component.findColour (TextButton::buttonColourId) .withMultipliedAlpha (isEnabled ? 1.0f : 0.5f), true, @@ -437,7 +437,7 @@ void LookAndFeel::drawTickBox (Graphics& g, g.setColour (isEnabled ? Colours::black : Colours::grey); const AffineTransform trans (AffineTransform::scale (w / 9.0f, h / 9.0f) - .translated ((float) x, (float) y)); + .translated (x, y)); g.strokePath (tick, PathStrokeType (2.5f), trans); } @@ -454,9 +454,10 @@ void LookAndFeel::drawToggleButton (Graphics& g, g.drawRect (0, 0, button.getWidth(), button.getHeight()); } - const int tickWidth = jmin (20, button.getHeight() - 4); + float fontSize = jmin (15.0f, button.getHeight() * 0.75f); + const float tickWidth = fontSize * 1.1f; - drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2, + drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), @@ -464,7 +465,7 @@ void LookAndFeel::drawToggleButton (Graphics& g, isButtonDown); g.setColour (button.findColour (ToggleButton::textColourId)); - g.setFont (jmin (15.0f, button.getHeight() * 0.6f)); + g.setFont (fontSize); if (! button.isEnabled()) g.setOpacity (0.5f); @@ -472,8 +473,8 @@ void LookAndFeel::drawToggleButton (Graphics& g, const int textX = tickWidth + 5; g.drawFittedText (button.getButtonText(), - textX, 4, - button.getWidth() - textX - 2, button.getHeight() - 8, + textX, 0, + button.getWidth() - textX - 2, button.getHeight(), Justification::centredLeft, 10); } diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.h b/src/gui/components/lookandfeel/juce_LookAndFeel.h index 73a48b0b51..029556256a 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.h @@ -171,7 +171,7 @@ public: virtual void drawTickBox (Graphics& g, Component& component, - int x, int y, int w, int h, + float x, float y, float w, float h, const bool ticked, const bool isEnabled, const bool isMouseOverButton, @@ -635,16 +635,6 @@ public: juce_UseDebuggingNewOperator -protected: - // xxx the following methods are only here to cause a compiler error, because they've been - // deprecated or their parameters have changed. Hopefully these definitions should cause an - // error if you try to build a subclass with the old versions. - virtual int drawTickBox (Graphics&, int, int, int, int, bool, const bool, const bool, const bool) { return 0; } - virtual int drawProgressBar (Graphics&, int, int, int, int, float) { return 0; } - virtual int drawProgressBar (Graphics&, ProgressBar&, int, int, int, int, float) { return 0; } - virtual void getTabButtonBestWidth (int, const String&, int) {} - virtual int drawTreeviewPlusMinusBox (Graphics&, int, int, int, int, bool) { return 0; } - private: friend void JUCE_PUBLIC_FUNCTION shutdownJuce_GUI(); static void clearDefaultLookAndFeel() throw(); // called at shutdown diff --git a/src/gui/components/properties/juce_PropertyComponent.h b/src/gui/components/properties/juce_PropertyComponent.h index 92dd8fed28..a161544847 100644 --- a/src/gui/components/properties/juce_PropertyComponent.h +++ b/src/gui/components/properties/juce_PropertyComponent.h @@ -76,6 +76,7 @@ public: */ int getPreferredHeight() const throw() { return preferredHeight; } + void setPreferredHeight (int newHeight) throw() { preferredHeight = newHeight; } //============================================================================== /** Updates the property component if the item it refers to has changed. diff --git a/src/gui/components/windows/juce_AlertWindow.cpp b/src/gui/components/windows/juce_AlertWindow.cpp index 45ed3fcb54..1471f737fe 100644 --- a/src/gui/components/windows/juce_AlertWindow.cpp +++ b/src/gui/components/windows/juce_AlertWindow.cpp @@ -369,28 +369,32 @@ void AlertWindow::paint (Graphics& g) int i; for (i = textBoxes.size(); --i >= 0;) { - if (textboxNames[i].isNotEmpty()) - { - const TextEditor* const te = (TextEditor*) textBoxes[i]; + const TextEditor* const te = (TextEditor*) textBoxes[i]; - g.drawFittedText (textboxNames[i], - te->getX(), te->getY() - 14, - te->getWidth(), 14, - Justification::centredLeft, 1); - } + g.drawFittedText (textboxNames[i], + te->getX(), te->getY() - 14, + te->getWidth(), 14, + Justification::centredLeft, 1); } for (i = comboBoxNames.size(); --i >= 0;) { - if (comboBoxNames[i].isNotEmpty()) - { - const ComboBox* const cb = (ComboBox*) comboBoxes[i]; + const ComboBox* const cb = (ComboBox*) comboBoxes[i]; - g.drawFittedText (comboBoxNames[i], - cb->getX(), cb->getY() - 14, - cb->getWidth(), 14, - Justification::centredLeft, 1); - } + g.drawFittedText (comboBoxNames[i], + cb->getX(), cb->getY() - 14, + cb->getWidth(), 14, + Justification::centredLeft, 1); + } + + for (i = customComps.size(); --i >= 0;) + { + const Component* const c = (Component*) customComps[i]; + + g.drawFittedText (c->getName(), + c->getX(), c->getY() - 14, + c->getWidth(), 14, + Justification::centredLeft, 1); } } @@ -402,6 +406,7 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) const int sw = (int) sqrt (font.getHeight() * wid); int w = jmin (300 + sw * 2, (int) (getParentWidth() * 0.7f)); const int edgeGap = 10; + const int labelHeight = 18; int iconSpace; if (alertIconType == NoIcon) @@ -436,8 +441,12 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (i = customComps.size(); --i >= 0;) { - w = jmax (w, ((Component*) customComps[i])->getWidth() + 40); - h += 10 + ((Component*) customComps[i])->getHeight(); + Component* c = (Component*) customComps[i]; + w = jmax (w, (c->getWidth() * 100) / 80); + h += 10 + c->getHeight(); + + if (c->getName().isNotEmpty()) + h += labelHeight; } for (i = textBlocks.size(); --i >= 0;) @@ -506,27 +515,35 @@ void AlertWindow::updateLayout (const bool onlyIncreaseSize) for (i = 0; i < allComps.size(); ++i) { Component* const c = (Component*) allComps[i]; - - const int h = 22; + int h = 22; const int comboIndex = comboBoxes.indexOf (c); if (comboIndex >= 0 && comboBoxNames [comboIndex].isNotEmpty()) - y += 18; + y += labelHeight; const int tbIndex = textBoxes.indexOf (c); if (tbIndex >= 0 && textboxNames[tbIndex].isNotEmpty()) - y += 18; + y += labelHeight; - if (customComps.contains (c) || textBlocks.contains (c)) + if (customComps.contains (c)) + { + if (c->getName().isNotEmpty()) + y += labelHeight; + + c->setTopLeftPosition (proportionOfWidth (0.1f), y); + h = c->getHeight(); + } + else if (textBlocks.contains (c)) { c->setTopLeftPosition ((getWidth() - c->getWidth()) / 2, y); - y += c->getHeight() + 10; + h = c->getHeight(); } else { c->setBounds (proportionOfWidth (0.1f), y, proportionOfWidth (0.8f), h); - y += h + 10; } + + y += h + 10; } setWantsKeyboardFocus (getNumChildComponents() == 0); diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 058f8fac34..b2df739639 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -1200,6 +1200,9 @@ bool NSViewComponentPeer::redirectKeyUp (NSEvent* ev) void NSViewComponentPeer::redirectModKeyChange (NSEvent* ev) { + keysCurrentlyDown.clear(); + handleKeyUpOrDown (true); + updateModifiers (ev); handleModifierKeysChange(); } diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index f70639c527..e80d641a19 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -48,6 +48,48 @@ struct ConnectionAndRequestStruct static HINTERNET sessionHandle = 0; +#ifndef WORKAROUND_TIMEOUT_BUG + //#define WORKAROUND_TIMEOUT_BUG 1 +#endif + +#if WORKAROUND_TIMEOUT_BUG +// Required because of a Microsoft bug in setting a timeout +class InternetConnectThread : public Thread +{ +public: + InternetConnectThread (URL_COMPONENTS& uc_, HINTERNET& connection_, const bool isFtp_) + : Thread ("Internet"), uc (uc_), connection (connection_), isFtp (isFtp_) + { + startThread(); + } + + ~InternetConnectThread() + { + stopThread (60000); + } + + void run() + { + connection = InternetConnect (sessionHandle, uc.lpszHostName, + uc.nPort, _T(""), _T(""), + isFtp ? INTERNET_SERVICE_FTP + : INTERNET_SERVICE_HTTP, + 0, 0); + notify(); + } + + juce_UseDebuggingNewOperator + +private: + URL_COMPONENTS& uc; + HINTERNET& connection; + const bool isFtp; + + InternetConnectThread (const InternetConnectThread&); + InternetConnectThread& operator= (const InternetConnectThread&); +}; +#endif + void* juce_openInternetFile (const String& url, const String& headers, const MemoryBlock& postData, @@ -77,6 +119,9 @@ void* juce_openInternetFile (const String& url, if (InternetCrackUrl (url, 0, 0, &uc)) { + int disable = 1; + InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable)); + if (timeOutMs == 0) timeOutMs = 30000; else if (timeOutMs < 0) @@ -86,6 +131,20 @@ void* juce_openInternetFile (const String& url, const bool isFtp = url.startsWithIgnoreCase (T("ftp:")); +#if WORKAROUND_TIMEOUT_BUG + HINTERNET connection = 0; + + { + InternetConnectThread connectThread (uc, connection, isFtp); + connectThread.wait (timeOutMs); + + if (connection == 0) + { + InternetCloseHandle (sessionHandle); + sessionHandle = 0; + } + } +#else HINTERNET connection = InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort, @@ -93,6 +152,7 @@ void* juce_openInternetFile (const String& url, isFtp ? INTERNET_SERVICE_FTP : INTERNET_SERVICE_HTTP, 0, 0); +#endif if (connection != 0) {