Browse Source

tags/2021-05-28
jules 17 years ago
parent
commit
934f1c1c1d
14 changed files with 415 additions and 113 deletions
  1. +24
    -6
      build/macosx/platform_specific_code/juce_mac_HTTPStream.h
  2. +9
    -1
      build/win32/platform_specific_code/juce_win32_Network.cpp
  3. +5
    -3
      build/win32/platform_specific_code/juce_win32_WebBrowserComponent.cpp
  4. +16
    -11
      build/win32/platform_specific_code/juce_win32_Windowing.cpp
  5. +172
    -53
      juce_amalgamated.cpp
  6. +40
    -2
      juce_amalgamated.h
  7. +24
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp
  8. +3
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h
  9. +38
    -28
      src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.cpp
  10. +5
    -1
      src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.h
  11. +31
    -0
      src/juce_appframework/gui/graphics/colour/juce_Colour.cpp
  12. +28
    -0
      src/juce_appframework/gui/graphics/colour/juce_Colour.h
  13. +15
    -7
      src/juce_core/io/network/juce_URL.cpp
  14. +5
    -1
      src/juce_core/io/network/juce_URL.h

+ 24
- 6
build/macosx/platform_specific_code/juce_mac_HTTPStream.h View File

@@ -57,10 +57,20 @@ public:
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
closeSocket();
uint32 timeOutTime = Time::getMillisecondCounter();
if (timeOutMs == 0)
timeOutTime += 60000;
else if (timeOutMs < 0)
timeOutTime = 0xffffffff;
else
timeOutTime += timeOutMs;
String hostName, hostPath;
int hostPort;
@@ -125,6 +135,12 @@ public:
while (totalHeaderSent < requestHeader.getSize())
{
if (Time::getMillisecondCounter() > timeOutTime)
{
closeSocket();
return false;
}
const int numToSend = jmin (1024, requestHeader.getSize() - totalHeaderSent);
if (send (socketHandle,
@@ -145,7 +161,7 @@ public:
}
}
const String responseHeader (readResponse());
const String responseHeader (readResponse (timeOutTime));
if (responseHeader.isNotEmpty())
{
@@ -259,12 +275,13 @@ private:
return mb;
}
const String readResponse()
const String readResponse (const uint32 timeOutTime)
{
int bytesRead = 0, numConsecutiveLFs = 0;
MemoryBlock buffer (1024, true);
while (numConsecutiveLFs < 2 && bytesRead < 32768)
while (numConsecutiveLFs < 2 && bytesRead < 32768
&& Time::getMillisecondCounter() <= timeOutTime)
{
fd_set readbits;
FD_ZERO (&readbits);
@@ -361,12 +378,13 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
JUCE_HTTPSocketStream* const s = new JUCE_HTTPSocketStream();
if (s->open (url, headers, postData, isPost,
callback, callbackContext))
callback, callbackContext, timeOutMs))
return s;
delete s;


+ 9
- 1
build/win32/platform_specific_code/juce_win32_Network.cpp View File

@@ -79,7 +79,8 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
if (sessionHandle == 0)
sessionHandle = InternetOpen (_T("juce"),
@@ -102,6 +103,13 @@ void* juce_openInternetFile (const String& url,
if (InternetCrackUrl (url, 0, 0, &uc))
{
if (timeOutMs == 0)
timeOutMs = 30000;
else if (timeOutMs < 0)
timeOutMs = -1;
InternetSetOption (sessionHandle, INTERNET_OPTION_CONNECT_TIMEOUT, &timeOutMs, sizeof (timeOutMs));
const bool isFtp = url.startsWithIgnoreCase (T("ftp:"));
HINTERNET connection = InternetConnect (sessionHandle,


+ 5
- 3
build/win32/platform_specific_code/juce_win32_WebBrowserComponent.cpp View File

@@ -303,14 +303,16 @@ void WebBrowserComponent::checkWindowAssociation()
{
if (isShowing())
{
if (blankPageShown)
goBack();
if (browser->browser == 0 && getPeer() != 0)
{
browser->createBrowser();
reloadLastURL();
}
else
{
if (blankPageShown)
goBack();
}
}
else
{


+ 16
- 11
build/win32/platform_specific_code/juce_win32_Windowing.cpp View File

@@ -820,7 +820,7 @@ public:
shouldDeactivateTitleBar = oldDeactivate;
}
void textInputRequired (int x, int y)
void textInputRequired (int /*x*/, int /*y*/)
{
if (! hasCreatedCaret)
{
@@ -829,7 +829,7 @@ public:
}
ShowCaret (hwnd);
SetCaretPos (x, y);
SetCaretPos (-1, -1);
}
void repaint (int x, int y, int w, int h)
@@ -3738,6 +3738,7 @@ class ActiveXControlData : public ComponentMovementWatcher
bool wasShowing;
public:
HWND controlHWND;
IStorage* storage;
IOleClientSite* clientSite;
IOleObject* control;
@@ -3748,6 +3749,7 @@ public:
: ComponentMovementWatcher (owner_),
owner (owner_),
wasShowing (owner_ != 0 && owner_->isShowing()),
controlHWND (0),
storage (new JuceIStorage()),
clientSite (new JuceIOleClientSite (hwnd)),
control (0)
@@ -3796,6 +3798,11 @@ public:
{
componentPeerChanged();
}
static bool doesWindowMatch (const ActiveXControlComponent* const ax, HWND hwnd)
{
return ((ActiveXControlData*) ax->control)->controlHWND == hwnd;
}
};
//==============================================================================
@@ -3863,9 +3870,7 @@ static LRESULT CALLBACK activeXHookWndProc (HWND hwnd, UINT message, WPARAM wPar
{
const ActiveXControlComponent* const ax = (const ActiveXControlComponent*) activeXComps.getUnchecked(i);
HWND controlHWND = getHWND (ax);
if (controlHWND == hwnd)
if (ActiveXControlData::doesWindowMatch (ax, hwnd))
{
switch (message)
{
@@ -3961,12 +3966,12 @@ bool ActiveXControlComponent::createControl (const void* controlIID)
control = info;
setControlBounds (Rectangle (x, y, getWidth(), getHeight()));
HWND controlHWND = getHWND (this);
info->controlHWND = getHWND (this);
if (controlHWND != 0)
if (info->controlHWND != 0)
{
originalWndProc = (void*) GetWindowLongPtr (controlHWND, GWLP_WNDPROC);
SetWindowLongPtr (controlHWND, GWLP_WNDPROC, (LONG_PTR) activeXHookWndProc);
originalWndProc = (void*) GetWindowLongPtr ((HWND) info->controlHWND, GWLP_WNDPROC);
SetWindowLongPtr ((HWND) info->controlHWND, GWLP_WNDPROC, (LONG_PTR) activeXHookWndProc);
}
return true;
@@ -4007,7 +4012,7 @@ void* ActiveXControlComponent::queryInterface (const void* iid) const
void ActiveXControlComponent::setControlBounds (const Rectangle& newBounds) const
{
HWND hwnd = getHWND (this);
HWND hwnd = ((ActiveXControlData*) control)->controlHWND;
if (hwnd != 0)
MoveWindow (hwnd, newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight(), TRUE);
@@ -4015,7 +4020,7 @@ void ActiveXControlComponent::setControlBounds (const Rectangle& newBounds) cons
void ActiveXControlComponent::setControlVisible (const bool shouldBeVisible) const
{
HWND hwnd = getHWND (this);
HWND hwnd = ((ActiveXControlData*) control)->controlHWND;
if (hwnd != 0)
ShowWindow (hwnd, shouldBeVisible ? SW_SHOWNA : SW_HIDE);


+ 172
- 53
juce_amalgamated.cpp View File

@@ -6683,7 +6683,8 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& optionalPostData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext);
void* callbackContext,
int timeOutMs);

void juce_closeInternetFile (void* handle);
int juce_readFromInternetFile (void* handle, void* dest, int bytesToRead);
@@ -6697,12 +6698,14 @@ public:
const bool isPost_,
URL::OpenStreamProgressCallback* const progressCallback_,
void* const progressCallbackContext_,
const String& extraHeaders)
const String& extraHeaders,
int timeOutMs_)
: position (0),
finished (false),
isPost (isPost_),
progressCallback (progressCallback_),
progressCallbackContext (progressCallbackContext_)
progressCallbackContext (progressCallbackContext_),
timeOutMs (timeOutMs_)
{
server = url.toString (! isPost);

@@ -6715,7 +6718,8 @@ public:
headers << "\r\n";

handle = juce_openInternetFile (server, headers, postData, isPost,
progressCallback_, progressCallbackContext_);
progressCallback_, progressCallbackContext_,
timeOutMs);
}

~WebInputStream()
@@ -6783,7 +6787,8 @@ public:
finished = false;

handle = juce_openInternetFile (server, headers, postData, isPost,
progressCallback, progressCallbackContext);
progressCallback, progressCallbackContext,
timeOutMs);
}

skipNextBytes (wantedPos - position);
@@ -6804,6 +6809,7 @@ private:
void* handle;
URL::OpenStreamProgressCallback* const progressCallback;
void* const progressCallbackContext;
const int timeOutMs;

void createHeadersAndPostData (const URL& url)
{
@@ -6887,11 +6893,13 @@ private:
InputStream* URL::createInputStream (const bool usePostCommand,
OpenStreamProgressCallback* const progressCallback,
void* const progressCallbackContext,
const String& extraHeaders) const
const String& extraHeaders,
const int timeOutMs) const
{
WebInputStream* wi = new WebInputStream (*this, usePostCommand,
progressCallback, progressCallbackContext,
extraHeaders);
extraHeaders,
timeOutMs);

if (wi->isError())
{
@@ -59846,6 +59854,29 @@ void LookAndFeel::playAlertSound()
PlatformUtilities::beep();
}

void LookAndFeel::drawLevelMeter (Graphics& g, int width, int height, float level)
{
g.setColour (Colours::white.withAlpha (0.7f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) width, (float) height, 3.0f);
g.setColour (Colours::black.withAlpha (0.2f));
g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f);

const int totalBlocks = 7;
const int numBlocks = roundDoubleToInt (totalBlocks * level);
const float w = (width - 6.0f) / (float) totalBlocks;

for (int i = 0; i < totalBlocks; ++i)
{
if (i >= numBlocks)
g.setColour (Colours::lightblue.withAlpha (0.6f));
else
g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
: Colours::red);

g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, height - 6.0f, w * 0.4f);
}
}

static void createRoundedPath (Path& p,
const float x, const float y,
const float w, const float h,
@@ -64649,9 +64680,8 @@ class SimpleDeviceManagerInputLevelMeter : public Component,
public:
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager* const manager_)
: manager (manager_),
totalBlocks (7)
level (0)
{
numBlocks = 0;
startTimer (50);
manager->enableInputLevelMeasurement (true);
}
@@ -64663,39 +64693,23 @@ public:

void timerCallback()
{
const int newNumBlocks = roundDoubleToInt (manager->getCurrentInputLevel() * totalBlocks);
if (newNumBlocks != numBlocks)
const float newLevel = (float) manager->getCurrentInputLevel();

if (fabsf (level - newLevel) > 0.005f)
{
numBlocks = newNumBlocks;
level = newLevel;
repaint();
}
}

void paint (Graphics& g)
{
g.setColour (Colours::white.withAlpha (0.8f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 3.0f);
g.setColour (Colours::black.withAlpha (0.2f));
g.drawRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 3.0f, 1.0f);

const float w = (getWidth() - 6.0f) / (float) totalBlocks;

for (int i = 0; i < totalBlocks; ++i)
{
if (i >= numBlocks)
g.setColour (Colours::lightblue.withAlpha (0.6f));
else
g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
: Colours::red);

g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, getHeight() - 6.0f, w * 0.4f);
}
getLookAndFeel().drawLevelMeter (g, getWidth(), getHeight(), level);
}

private:
AudioDeviceManager* const manager;
const int totalBlocks;
int numBlocks;
float level;
};

class MidiInputSelectorComponentListBox : public ListBox,
@@ -64828,7 +64842,8 @@ class AudioDeviceSettingsPanel : public Component,
{
public:
AudioDeviceSettingsPanel (AudioIODeviceType* type_,
AudioIODeviceType::DeviceSetupDetails& setup_)
AudioIODeviceType::DeviceSetupDetails& setup_,
const bool hideAdvancedOptionsWithButton)
: type (type_),
setup (setup_)
{
@@ -64847,6 +64862,13 @@ public:
outputChanList = 0;
inputChanLabel = 0;
outputChanLabel = 0;
showAdvancedSettingsButton = 0;

if (hideAdvancedOptionsWithButton)
{
addAndMakeVisible (showAdvancedSettingsButton = new TextButton (TRANS("Show advanced settings...")));
showAdvancedSettingsButton->addButtonListener (this);
}

type->scanForDevices();

@@ -64865,6 +64887,7 @@ public:
deleteAndZero (showUIButton);
deleteAndZero (inputChanLabel);
deleteAndZero (outputChanLabel);
deleteAndZero (showAdvancedSettingsButton);

deleteAllChildren();
}
@@ -64917,20 +64940,30 @@ public:

y += space * 2;

if (showAdvancedSettingsButton != 0)
{
showAdvancedSettingsButton->changeWidthToFitText (h);
showAdvancedSettingsButton->setTopLeftPosition (lx, y);
}

if (sampleRateDropDown != 0)
{
sampleRateDropDown->setVisible (! showAdvancedSettingsButton->isVisible());

sampleRateDropDown->setBounds (lx, y, w, h);
y += dh;
}

if (bufferSizeDropDown != 0)
{
bufferSizeDropDown->setVisible (! showAdvancedSettingsButton->isVisible());
bufferSizeDropDown->setBounds (lx, y, w, h);
y += dh;
}

if (showUIButton != 0)
{
showUIButton->setVisible (! showAdvancedSettingsButton->isVisible());
showUIButton->changeWidthToFitText (h);
showUIButton->setTopLeftPosition (lx, y);
}
@@ -64999,7 +65032,12 @@ public:

void buttonClicked (Button* button)
{
if (button == showUIButton)
if (button == showAdvancedSettingsButton)
{
showAdvancedSettingsButton->setVisible (false);
resized();
}
else if (button == showUIButton)
{
AudioIODevice* const device = setup.manager->getCurrentAudioDevice();

@@ -65220,6 +65258,7 @@ private:
TextButton* testButton;
Component* inputLevelMeter;
TextButton* showUIButton;
TextButton* showAdvancedSettingsButton;

void showCorrectDeviceName (ComboBox* const box, const bool isInput)
{
@@ -65526,13 +65565,15 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
const int maxOutputChannels_,
const bool showMidiInputOptions,
const bool showMidiOutputSelector,
const bool showChannelsAsStereoPairs_)
const bool showChannelsAsStereoPairs_,
const bool hideAdvancedOptionsWithButton_)
: deviceManager (deviceManager_),
minOutputChannels (minOutputChannels_),
maxOutputChannels (maxOutputChannels_),
minInputChannels (minInputChannels_),
maxInputChannels (maxInputChannels_),
showChannelsAsStereoPairs (showChannelsAsStereoPairs_),
hideAdvancedOptionsWithButton (hideAdvancedOptionsWithButton_),
deviceTypeDropDown (0),
deviceTypeDropDownLabel (0),
audioDeviceSettingsComp (0)
@@ -65694,7 +65735,7 @@ void AudioDeviceSelectorComponent::changeListenerCallback (void*)
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;

audioDeviceSettingsComp = new AudioDeviceSettingsPanel (type, details);
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (type, details, hideAdvancedOptionsWithButton);

if (audioDeviceSettingsComp != 0)
{
@@ -72950,6 +72991,13 @@ Colour::Colour (const uint8 red,
argb.setARGB (0xff, red, green, blue);
}

const Colour Colour::fromRGB (const uint8 red,
const uint8 green,
const uint8 blue) throw()
{
return Colour (red, green, blue);
}

Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
@@ -72958,6 +73006,14 @@ Colour::Colour (const uint8 red,
argb.setARGB (alpha, red, green, blue);
}

const Colour Colour::fromRGBA (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw()
{
return Colour (red, green, blue, alpha);
}

Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
@@ -72966,6 +73022,14 @@ Colour::Colour (const uint8 red,
argb.setARGB (floatAlphaToInt (alpha), red, green, blue);
}

const Colour Colour::fromRGBAFloat (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) throw()
{
return Colour (red, green, blue, alpha);
}

static void convertHSBtoRGB (float h, const float s, float v,
uint8& r, uint8& g, uint8& b) throw()
{
@@ -73043,6 +73107,14 @@ Colour::Colour (const float hue,
argb.setARGB (floatAlphaToInt (alpha), r, g, b);
}

const Colour Colour::fromHSV (const float hue,
const float saturation,
const float brightness,
const float alpha) throw()
{
return Colour (hue, saturation, brightness, alpha);
}

Colour::Colour (const float hue,
const float saturation,
const float brightness,
@@ -230358,7 +230430,8 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
if (sessionHandle == 0)
sessionHandle = InternetOpen (_T("juce"),
@@ -230381,6 +230454,13 @@ void* juce_openInternetFile (const String& url,

if (InternetCrackUrl (url, 0, 0, &uc))
{
if (timeOutMs == 0)
timeOutMs = 30000;
else if (timeOutMs < 0)
timeOutMs = -1;

InternetSetOption (sessionHandle, INTERNET_OPTION_CONNECT_TIMEOUT, &timeOutMs, sizeof (timeOutMs));

const bool isFtp = url.startsWithIgnoreCase (T("ftp:"));

HINTERNET connection = InternetConnect (sessionHandle,
@@ -239575,14 +239655,16 @@ void WebBrowserComponent::checkWindowAssociation()
{
if (isShowing())
{
if (blankPageShown)
goBack();

if (browser->browser == 0 && getPeer() != 0)
{
browser->createBrowser();
reloadLastURL();
}
else
{
if (blankPageShown)
goBack();
}
}
else
{
@@ -244675,10 +244757,20 @@ public:
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
closeSocket();

uint32 timeOutTime = Time::getMillisecondCounter();

if (timeOutMs == 0)
timeOutTime += 60000;
else if (timeOutMs < 0)
timeOutTime = 0xffffffff;
else
timeOutTime += timeOutMs;

String hostName, hostPath;
int hostPort;

@@ -244743,6 +244835,12 @@ public:

while (totalHeaderSent < requestHeader.getSize())
{
if (Time::getMillisecondCounter() > timeOutTime)
{
closeSocket();
return false;
}

const int numToSend = jmin (1024, requestHeader.getSize() - totalHeaderSent);

if (send (socketHandle,
@@ -244763,7 +244861,7 @@ public:
}
}

const String responseHeader (readResponse());
const String responseHeader (readResponse (timeOutTime));

if (responseHeader.isNotEmpty())
{
@@ -244873,12 +244971,13 @@ private:
return mb;
}

const String readResponse()
const String readResponse (const uint32 timeOutTime)
{
int bytesRead = 0, numConsecutiveLFs = 0;
MemoryBlock buffer (1024, true);

while (numConsecutiveLFs < 2 && bytesRead < 32768)
while (numConsecutiveLFs < 2 && bytesRead < 32768
&& Time::getMillisecondCounter() <= timeOutTime)
{
fd_set readbits;
FD_ZERO (&readbits);
@@ -244972,12 +245071,13 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
JUCE_HTTPSocketStream* const s = new JUCE_HTTPSocketStream();

if (s->open (url, headers, postData, isPost,
callback, callbackContext))
callback, callbackContext, timeOutMs))
return s;

delete s;
@@ -251301,6 +251401,7 @@ END_JUCE_NAMESPACE

/********* Start of inlined file: juce_mac_Files.cpp *********/

#include <ApplicationServices/ApplicationServices.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <sys/param.h>
@@ -252853,7 +252954,7 @@ void SystemStats::initialiseStats() throw()
initialised = true;

[NSApplication sharedApplication];
// NSApplicationLoad();
NSApplicationLoad();

#if JUCE_INTEL
{
@@ -253194,10 +253295,20 @@ public:
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
closeSocket();

uint32 timeOutTime = Time::getMillisecondCounter();

if (timeOutMs == 0)
timeOutTime += 60000;
else if (timeOutMs < 0)
timeOutTime = 0xffffffff;
else
timeOutTime += timeOutMs;

String hostName, hostPath;
int hostPort;

@@ -253262,6 +253373,12 @@ public:

while (totalHeaderSent < requestHeader.getSize())
{
if (Time::getMillisecondCounter() > timeOutTime)
{
closeSocket();
return false;
}

const int numToSend = jmin (1024, requestHeader.getSize() - totalHeaderSent);

if (send (socketHandle,
@@ -253282,7 +253399,7 @@ public:
}
}

const String responseHeader (readResponse());
const String responseHeader (readResponse (timeOutTime));

if (responseHeader.isNotEmpty())
{
@@ -253392,12 +253509,13 @@ private:
return mb;
}

const String readResponse()
const String readResponse (const uint32 timeOutTime)
{
int bytesRead = 0, numConsecutiveLFs = 0;
MemoryBlock buffer (1024, true);

while (numConsecutiveLFs < 2 && bytesRead < 32768)
while (numConsecutiveLFs < 2 && bytesRead < 32768
&& Time::getMillisecondCounter() <= timeOutTime)
{
fd_set readbits;
FD_ZERO (&readbits);
@@ -253491,12 +253609,13 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& postData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext)
void* callbackContext,
int timeOutMs)
{
JUCE_HTTPSocketStream* const s = new JUCE_HTTPSocketStream();

if (s->open (url, headers, postData, isPost,
callback, callbackContext))
callback, callbackContext, timeOutMs))
return s;

delete s;
@@ -259422,7 +259541,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages)
return true;
}

return true;
return false;
}

ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo)


+ 40
- 2
juce_amalgamated.h View File

@@ -12279,11 +12279,15 @@ public:
@param extraHeaders if not empty, this string is appended onto the headers that
are used for the request. It must therefore be a valid set of HTML
header directives, separated by newlines.
@param connectionTimeOutMs if 0, this will use whatever default setting the OS chooses. If
a negative number, it will be infinite. Otherwise it specifies a
time in milliseconds.
*/
InputStream* createInputStream (const bool usePostCommand,
OpenStreamProgressCallback* const progressCallback = 0,
void* const progressCallbackContext = 0,
const String& extraHeaders = String::empty) const;
const String& extraHeaders = String::empty,
const int connectionTimeOutMs = 0) const;

/** Tries to download the entire contents of this URL into a binary data block.

@@ -18377,12 +18381,23 @@ public:
const uint8 green,
const uint8 blue) throw();

/** Creates an opaque colour using 8-bit red, green and blue values */
static const Colour fromRGB (const uint8 red,
const uint8 green,
const uint8 blue) throw();

/** Creates a colour using 8-bit red, green, blue and alpha values. */
Colour (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw();

/** Creates a colour using 8-bit red, green, blue and alpha values. */
static const Colour fromRGBA (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw();

/** Creates a colour from 8-bit red, green, and blue values, and a floating-point alpha.

Alpha of 0.0 is transparent, alpha of 1.0f is opaque.
@@ -18393,6 +18408,12 @@ public:
const uint8 blue,
const float alpha) throw();

/** Creates a colour using 8-bit red, green, blue and float alpha values. */
static const Colour fromRGBAFloat (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) throw();

/** Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.

The floating point values must be between 0.0 and 1.0.
@@ -18414,6 +18435,17 @@ public:
const float brightness,
const float alpha) throw();

/** Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.

The floating point values must be between 0.0 and 1.0.
An alpha of 0x00 is completely transparent, alpha of 0xff is opaque.
Values outside the valid range will be clipped.
*/
static const Colour fromHSV (const float hue,
const float saturation,
const float brightness,
const float alpha) throw();

/** Destructor. */
~Colour() throw();

@@ -50477,6 +50509,8 @@ public:
@param showMidiOutputSelector if true, the component will let the user choose a default midi output device
@param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
treated as a set of separate mono channels.
@param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
are shown, with an "advanced" button that shows the rest of them
*/
AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
const int minAudioInputChannels,
@@ -50485,7 +50519,8 @@ public:
const int maxAudioOutputChannels,
const bool showMidiInputOptions,
const bool showMidiOutputSelector,
const bool showChannelsAsStereoPairs);
const bool showChannelsAsStereoPairs,
const bool hideAdvancedOptionsWithButton);

/** Destructor */
~AudioDeviceSelectorComponent();
@@ -50509,6 +50544,7 @@ private:
String audioDeviceSettingsCompType;
const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
const bool showChannelsAsStereoPairs;
const bool hideAdvancedOptionsWithButton;

MidiInputSelectorComponentListBox* midiInputsList;
Label* midiInputsLabel;
@@ -52629,6 +52665,8 @@ public:

virtual const Rectangle getPropertyComponentContentPosition (PropertyComponent& component);

virtual void drawLevelMeter (Graphics& g, int width, int height, float level);

/**
*/
virtual void playAlertSound();


+ 24
- 0
src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -2553,6 +2553,30 @@ void LookAndFeel::playAlertSound()
PlatformUtilities::beep();
}
//==============================================================================
void LookAndFeel::drawLevelMeter (Graphics& g, int width, int height, float level)
{
g.setColour (Colours::white.withAlpha (0.7f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) width, (float) height, 3.0f);
g.setColour (Colours::black.withAlpha (0.2f));
g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f);
const int totalBlocks = 7;
const int numBlocks = roundDoubleToInt (totalBlocks * level);
const float w = (width - 6.0f) / (float) totalBlocks;
for (int i = 0; i < totalBlocks; ++i)
{
if (i >= numBlocks)
g.setColour (Colours::lightblue.withAlpha (0.6f));
else
g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
: Colours::red);
g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, height - 6.0f, w * 0.4f);
}
}
//==============================================================================
static void createRoundedPath (Path& p,
const float x, const float y,


+ 3
- 0
src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h View File

@@ -542,6 +542,9 @@ public:
virtual const Rectangle getPropertyComponentContentPosition (PropertyComponent& component);
//==============================================================================
virtual void drawLevelMeter (Graphics& g, int width, int height, float level);
//==============================================================================
/**
*/


+ 38
- 28
src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.cpp View File

@@ -48,9 +48,8 @@ class SimpleDeviceManagerInputLevelMeter : public Component,
public:
SimpleDeviceManagerInputLevelMeter (AudioDeviceManager* const manager_)
: manager (manager_),
totalBlocks (7)
level (0)
{
numBlocks = 0;
startTimer (50);
manager->enableInputLevelMeasurement (true);
}
@@ -62,39 +61,23 @@ public:
void timerCallback()
{
const int newNumBlocks = roundDoubleToInt (manager->getCurrentInputLevel() * totalBlocks);
if (newNumBlocks != numBlocks)
const float newLevel = (float) manager->getCurrentInputLevel();
if (fabsf (level - newLevel) > 0.005f)
{
numBlocks = newNumBlocks;
level = newLevel;
repaint();
}
}
void paint (Graphics& g)
{
g.setColour (Colours::white.withAlpha (0.8f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 3.0f);
g.setColour (Colours::black.withAlpha (0.2f));
g.drawRoundedRectangle (1.0f, 1.0f, getWidth() - 2.0f, getHeight() - 2.0f, 3.0f, 1.0f);
const float w = (getWidth() - 6.0f) / (float) totalBlocks;
for (int i = 0; i < totalBlocks; ++i)
{
if (i >= numBlocks)
g.setColour (Colours::lightblue.withAlpha (0.6f));
else
g.setColour (i < totalBlocks - 1 ? Colours::blue.withAlpha (0.5f)
: Colours::red);
g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, getHeight() - 6.0f, w * 0.4f);
}
getLookAndFeel().drawLevelMeter (g, getWidth(), getHeight(), level);
}
private:
AudioDeviceManager* const manager;
const int totalBlocks;
int numBlocks;
float level;
};
@@ -232,7 +215,8 @@ class AudioDeviceSettingsPanel : public Component,
{
public:
AudioDeviceSettingsPanel (AudioIODeviceType* type_,
AudioIODeviceType::DeviceSetupDetails& setup_)
AudioIODeviceType::DeviceSetupDetails& setup_,
const bool hideAdvancedOptionsWithButton)
: type (type_),
setup (setup_)
{
@@ -251,6 +235,13 @@ public:
outputChanList = 0;
inputChanLabel = 0;
outputChanLabel = 0;
showAdvancedSettingsButton = 0;
if (hideAdvancedOptionsWithButton)
{
addAndMakeVisible (showAdvancedSettingsButton = new TextButton (TRANS("Show advanced settings...")));
showAdvancedSettingsButton->addButtonListener (this);
}
type->scanForDevices();
@@ -269,6 +260,7 @@ public:
deleteAndZero (showUIButton);
deleteAndZero (inputChanLabel);
deleteAndZero (outputChanLabel);
deleteAndZero (showAdvancedSettingsButton);
deleteAllChildren();
}
@@ -321,20 +313,30 @@ public:
y += space * 2;
if (showAdvancedSettingsButton != 0)
{
showAdvancedSettingsButton->changeWidthToFitText (h);
showAdvancedSettingsButton->setTopLeftPosition (lx, y);
}
if (sampleRateDropDown != 0)
{
sampleRateDropDown->setVisible (! showAdvancedSettingsButton->isVisible());
sampleRateDropDown->setBounds (lx, y, w, h);
y += dh;
}
if (bufferSizeDropDown != 0)
{
bufferSizeDropDown->setVisible (! showAdvancedSettingsButton->isVisible());
bufferSizeDropDown->setBounds (lx, y, w, h);
y += dh;
}
if (showUIButton != 0)
{
showUIButton->setVisible (! showAdvancedSettingsButton->isVisible());
showUIButton->changeWidthToFitText (h);
showUIButton->setTopLeftPosition (lx, y);
}
@@ -403,7 +405,12 @@ public:
void buttonClicked (Button* button)
{
if (button == showUIButton)
if (button == showAdvancedSettingsButton)
{
showAdvancedSettingsButton->setVisible (false);
resized();
}
else if (button == showUIButton)
{
AudioIODevice* const device = setup.manager->getCurrentAudioDevice();
@@ -624,6 +631,7 @@ private:
TextButton* testButton;
Component* inputLevelMeter;
TextButton* showUIButton;
TextButton* showAdvancedSettingsButton;
void showCorrectDeviceName (ComboBox* const box, const bool isInput)
{
@@ -935,13 +943,15 @@ AudioDeviceSelectorComponent::AudioDeviceSelectorComponent (AudioDeviceManager&
const int maxOutputChannels_,
const bool showMidiInputOptions,
const bool showMidiOutputSelector,
const bool showChannelsAsStereoPairs_)
const bool showChannelsAsStereoPairs_,
const bool hideAdvancedOptionsWithButton_)
: deviceManager (deviceManager_),
minOutputChannels (minOutputChannels_),
maxOutputChannels (maxOutputChannels_),
minInputChannels (minInputChannels_),
maxInputChannels (maxInputChannels_),
showChannelsAsStereoPairs (showChannelsAsStereoPairs_),
hideAdvancedOptionsWithButton (hideAdvancedOptionsWithButton_),
deviceTypeDropDown (0),
deviceTypeDropDownLabel (0),
audioDeviceSettingsComp (0)
@@ -1103,7 +1113,7 @@ void AudioDeviceSelectorComponent::changeListenerCallback (void*)
details.maxNumOutputChannels = maxOutputChannels;
details.useStereoPairs = showChannelsAsStereoPairs;
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (type, details);
audioDeviceSettingsComp = new AudioDeviceSettingsPanel (type, details, hideAdvancedOptionsWithButton);
if (audioDeviceSettingsComp != 0)
{


+ 5
- 1
src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.h View File

@@ -68,6 +68,8 @@ public:
@param showMidiOutputSelector if true, the component will let the user choose a default midi output device
@param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be
treated as a set of separate mono channels.
@param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components
are shown, with an "advanced" button that shows the rest of them
*/
AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager,
const int minAudioInputChannels,
@@ -76,7 +78,8 @@ public:
const int maxAudioOutputChannels,
const bool showMidiInputOptions,
const bool showMidiOutputSelector,
const bool showChannelsAsStereoPairs);
const bool showChannelsAsStereoPairs,
const bool hideAdvancedOptionsWithButton);
/** Destructor */
~AudioDeviceSelectorComponent();
@@ -103,6 +106,7 @@ private:
String audioDeviceSettingsCompType;
const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels;
const bool showChannelsAsStereoPairs;
const bool hideAdvancedOptionsWithButton;
MidiInputSelectorComponentListBox* midiInputsList;
Label* midiInputsLabel;


+ 31
- 0
src/juce_appframework/gui/graphics/colour/juce_Colour.cpp View File

@@ -85,6 +85,13 @@ Colour::Colour (const uint8 red,
argb.setARGB (0xff, red, green, blue);
}
const Colour Colour::fromRGB (const uint8 red,
const uint8 green,
const uint8 blue) throw()
{
return Colour (red, green, blue);
}
Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
@@ -93,6 +100,14 @@ Colour::Colour (const uint8 red,
argb.setARGB (alpha, red, green, blue);
}
const Colour Colour::fromRGBA (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw()
{
return Colour (red, green, blue, alpha);
}
Colour::Colour (const uint8 red,
const uint8 green,
const uint8 blue,
@@ -101,6 +116,14 @@ Colour::Colour (const uint8 red,
argb.setARGB (floatAlphaToInt (alpha), red, green, blue);
}
const Colour Colour::fromRGBAFloat (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) throw()
{
return Colour (red, green, blue, alpha);
}
//==============================================================================
static void convertHSBtoRGB (float h, const float s, float v,
uint8& r, uint8& g, uint8& b) throw()
@@ -179,6 +202,14 @@ Colour::Colour (const float hue,
argb.setARGB (floatAlphaToInt (alpha), r, g, b);
}
const Colour Colour::fromHSV (const float hue,
const float saturation,
const float brightness,
const float alpha) throw()
{
return Colour (hue, saturation, brightness, alpha);
}
Colour::Colour (const float hue,
const float saturation,
const float brightness,


+ 28
- 0
src/juce_appframework/gui/graphics/colour/juce_Colour.h View File

@@ -68,12 +68,23 @@ public:
const uint8 green,
const uint8 blue) throw();
/** Creates an opaque colour using 8-bit red, green and blue values */
static const Colour fromRGB (const uint8 red,
const uint8 green,
const uint8 blue) throw();
/** Creates a colour using 8-bit red, green, blue and alpha values. */
Colour (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw();
/** Creates a colour using 8-bit red, green, blue and alpha values. */
static const Colour fromRGBA (const uint8 red,
const uint8 green,
const uint8 blue,
const uint8 alpha) throw();
/** Creates a colour from 8-bit red, green, and blue values, and a floating-point alpha.
Alpha of 0.0 is transparent, alpha of 1.0f is opaque.
@@ -84,6 +95,12 @@ public:
const uint8 blue,
const float alpha) throw();
/** Creates a colour using 8-bit red, green, blue and float alpha values. */
static const Colour fromRGBAFloat (const uint8 red,
const uint8 green,
const uint8 blue,
const float alpha) throw();
/** Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.
The floating point values must be between 0.0 and 1.0.
@@ -105,6 +122,17 @@ public:
const float brightness,
const float alpha) throw();
/** Creates a colour using floating point hue, saturation and brightness values, and an 8-bit alpha.
The floating point values must be between 0.0 and 1.0.
An alpha of 0x00 is completely transparent, alpha of 0xff is opaque.
Values outside the valid range will be clipped.
*/
static const Colour fromHSV (const float hue,
const float saturation,
const float brightness,
const float alpha) throw();
/** Destructor. */
~Colour() throw();


+ 15
- 7
src/juce_core/io/network/juce_URL.cpp View File

@@ -162,7 +162,8 @@ void* juce_openInternetFile (const String& url,
const MemoryBlock& optionalPostData,
const bool isPost,
URL::OpenStreamProgressCallback* callback,
void* callbackContext);
void* callbackContext,
int timeOutMs);
void juce_closeInternetFile (void* handle);
int juce_readFromInternetFile (void* handle, void* dest, int bytesToRead);
@@ -178,12 +179,14 @@ public:
const bool isPost_,
URL::OpenStreamProgressCallback* const progressCallback_,
void* const progressCallbackContext_,
const String& extraHeaders)
const String& extraHeaders,
int timeOutMs_)
: position (0),
finished (false),
isPost (isPost_),
progressCallback (progressCallback_),
progressCallbackContext (progressCallbackContext_)
progressCallbackContext (progressCallbackContext_),
timeOutMs (timeOutMs_)
{
server = url.toString (! isPost);
@@ -196,7 +199,8 @@ public:
headers << "\r\n";
handle = juce_openInternetFile (server, headers, postData, isPost,
progressCallback_, progressCallbackContext_);
progressCallback_, progressCallbackContext_,
timeOutMs);
}
~WebInputStream()
@@ -265,7 +269,8 @@ public:
finished = false;
handle = juce_openInternetFile (server, headers, postData, isPost,
progressCallback, progressCallbackContext);
progressCallback, progressCallbackContext,
timeOutMs);
}
skipNextBytes (wantedPos - position);
@@ -287,6 +292,7 @@ private:
void* handle;
URL::OpenStreamProgressCallback* const progressCallback;
void* const progressCallbackContext;
const int timeOutMs;
void createHeadersAndPostData (const URL& url)
{
@@ -370,11 +376,13 @@ private:
InputStream* URL::createInputStream (const bool usePostCommand,
OpenStreamProgressCallback* const progressCallback,
void* const progressCallbackContext,
const String& extraHeaders) const
const String& extraHeaders,
const int timeOutMs) const
{
WebInputStream* wi = new WebInputStream (*this, usePostCommand,
progressCallback, progressCallbackContext,
extraHeaders);
extraHeaders,
timeOutMs);
if (wi->isError())
{


+ 5
- 1
src/juce_core/io/network/juce_URL.h View File

@@ -162,11 +162,15 @@ public:
@param extraHeaders if not empty, this string is appended onto the headers that
are used for the request. It must therefore be a valid set of HTML
header directives, separated by newlines.
@param connectionTimeOutMs if 0, this will use whatever default setting the OS chooses. If
a negative number, it will be infinite. Otherwise it specifies a
time in milliseconds.
*/
InputStream* createInputStream (const bool usePostCommand,
OpenStreamProgressCallback* const progressCallback = 0,
void* const progressCallbackContext = 0,
const String& extraHeaders = String::empty) const;
const String& extraHeaders = String::empty,
const int connectionTimeOutMs = 0) const;
//==============================================================================


Loading…
Cancel
Save