mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
This commit is contained in:
parent
1ca5d73733
commit
25b03b4cc1
12 changed files with 2022 additions and 1879 deletions
|
|
@ -27,6 +27,7 @@ Changelist for version 1.46
|
|||
- moved some of the posix code that was the same in the mac and linux builds into a single, shared file
|
||||
- fixed InterprocessLock on mac/linux so that it can't get stuck when an app quits unexpectedly
|
||||
- added an option to splash screens to close themselves when the mouse is clicked
|
||||
- change to ProgressBar to allow custom text and bars that are just spinning without a known progress position. This also meant a change to the params for LookAndFeel::drawProgressBar
|
||||
|
||||
==============================================================================
|
||||
Changelist for version 1.45
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,7 @@
|
|||
namespace BinaryData
|
||||
{
|
||||
extern const char* audiodemo_cpp;
|
||||
const int audiodemo_cppSize = 23529;
|
||||
const int audiodemo_cppSize = 23434;
|
||||
|
||||
extern const char* cello_wav;
|
||||
const int cello_wavSize = 46348;
|
||||
|
|
@ -42,7 +42,7 @@ namespace BinaryData
|
|||
const int readme__what_this_directory_is_for_txtSize = 259;
|
||||
|
||||
extern const char* tabledemo_cpp;
|
||||
const int tabledemo_cppSize = 12327;
|
||||
const int tabledemo_cppSize = 12381;
|
||||
|
||||
extern const char* threadingdemo_cpp;
|
||||
const int threadingdemo_cppSize = 10047;
|
||||
|
|
@ -51,10 +51,10 @@ namespace BinaryData
|
|||
const int treedemo_xmlSize = 1126;
|
||||
|
||||
extern const char* treeviewdemo_cpp;
|
||||
const int treeviewdemo_cppSize = 7534;
|
||||
const int treeviewdemo_cppSize = 7715;
|
||||
|
||||
extern const char* widgetsdemo_cpp;
|
||||
const int widgetsdemo_cppSize = 51573;
|
||||
const int widgetsdemo_cppSize = 53388;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -979,6 +979,10 @@ public:
|
|||
|
||||
void run()
|
||||
{
|
||||
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
|
||||
setStatusMessage (T("Preparing to do some stuff..."));
|
||||
wait (2000);
|
||||
|
||||
const int thingsToDo = 10;
|
||||
|
||||
for (int i = 0; i < thingsToDo; ++i)
|
||||
|
|
@ -991,10 +995,14 @@ public:
|
|||
// this will update the progress bar on the dialog box
|
||||
setProgress (i / (double) thingsToDo);
|
||||
|
||||
wait (500);
|
||||
|
||||
setStatusMessage (String (thingsToDo - i) + T(" things left to do..."));
|
||||
|
||||
wait (500);
|
||||
}
|
||||
|
||||
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
|
||||
setStatusMessage (T("Finishing off the last few bits and pieces!"));
|
||||
wait (3000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -979,6 +979,10 @@ public:
|
|||
|
||||
void run()
|
||||
{
|
||||
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
|
||||
setStatusMessage (T("Preparing to do some stuff..."));
|
||||
wait (2000);
|
||||
|
||||
const int thingsToDo = 10;
|
||||
|
||||
for (int i = 0; i < thingsToDo; ++i)
|
||||
|
|
@ -991,10 +995,14 @@ public:
|
|||
// this will update the progress bar on the dialog box
|
||||
setProgress (i / (double) thingsToDo);
|
||||
|
||||
wait (500);
|
||||
|
||||
setStatusMessage (String (thingsToDo - i) + T(" things left to do..."));
|
||||
|
||||
wait (500);
|
||||
}
|
||||
|
||||
setProgress (-1.0); // setting a value beyond the range 0 -> 1 will show a spinning bar..
|
||||
setStatusMessage (T("Finishing off the last few bits and pieces!"));
|
||||
wait (3000);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "juce_AudioThumbnail.h"
|
||||
#include "juce_AudioThumbnailCache.h"
|
||||
|
||||
const int timeBeforeDeletingReader = 1000;
|
||||
const int timeBeforeDeletingReader = 2000;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -98,30 +98,34 @@ AudioThumbnail::~AudioThumbnail()
|
|||
void AudioThumbnail::setSource (InputSource* const newSource)
|
||||
{
|
||||
cache.removeThumbnail (this);
|
||||
stopTimer();
|
||||
|
||||
{
|
||||
const ScopedLock sl (readerLock);
|
||||
deleteAndZero (reader);
|
||||
}
|
||||
|
||||
delete source;
|
||||
source = newSource;
|
||||
|
||||
{
|
||||
const ScopedLock sl (readerLock);
|
||||
|
||||
deleteAndZero (reader);
|
||||
reader = createReader();
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
if (reader != 0)
|
||||
if (! (cache.loadThumb (*this, newSource->hashCode())
|
||||
&& isFullyLoaded()))
|
||||
{
|
||||
startTimer (timeBeforeDeletingReader);
|
||||
{
|
||||
const ScopedLock sl (readerLock);
|
||||
reader = createReader();
|
||||
}
|
||||
|
||||
initialiseFromAudioFile (*reader);
|
||||
|
||||
cache.loadThumb (*this, newSource->hashCode());
|
||||
|
||||
if (! isFullyLoaded())
|
||||
if (reader != 0)
|
||||
{
|
||||
initialiseFromAudioFile (*reader);
|
||||
cache.addThumbnail (this);
|
||||
}
|
||||
}
|
||||
|
||||
sendChangeMessage (this);
|
||||
}
|
||||
|
||||
bool AudioThumbnail::useTimeSlice()
|
||||
|
|
@ -143,7 +147,7 @@ bool AudioThumbnail::useTimeSlice()
|
|||
if (reader != 0)
|
||||
{
|
||||
readNextBlockFromAudioFile (*reader);
|
||||
startTimer (timeBeforeDeletingReader);
|
||||
stopTimer();
|
||||
|
||||
sendChangeMessage (this);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@ void ProgressBar::setPercentageDisplay (const bool shouldDisplayPercentage)
|
|||
repaint();
|
||||
}
|
||||
|
||||
void ProgressBar::setTextToDisplay (const String& text)
|
||||
{
|
||||
displayPercentage = false;
|
||||
displayedMessage = text;
|
||||
}
|
||||
|
||||
void ProgressBar::lookAndFeelChanged()
|
||||
{
|
||||
setOpaque (findColour (backgroundColourId).isOpaque());
|
||||
|
|
@ -68,23 +74,21 @@ void ProgressBar::colourChanged()
|
|||
|
||||
void ProgressBar::paint (Graphics& g)
|
||||
{
|
||||
getLookAndFeel().drawProgressBar (g, *this,
|
||||
0, 0,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
(float) currentValue);
|
||||
String text;
|
||||
|
||||
if (displayPercentage)
|
||||
{
|
||||
String percent;
|
||||
percent << roundDoubleToInt (currentValue * 100.0) << T("%");
|
||||
|
||||
g.setColour (Colour::contrasting (findColour (foregroundColourId),
|
||||
findColour (backgroundColourId)));
|
||||
g.setFont (getHeight() * 0.6f);
|
||||
|
||||
g.drawText (percent, 0, 0, getWidth(), getHeight(), Justification::centred, false);
|
||||
if (currentValue >= 0 && currentValue <= 1.0)
|
||||
text << roundDoubleToInt (currentValue * 100.0) << T("%");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = displayedMessage;
|
||||
}
|
||||
|
||||
getLookAndFeel().drawProgressBar (g, *this,
|
||||
getWidth(), getHeight(),
|
||||
currentValue, text);
|
||||
}
|
||||
|
||||
void ProgressBar::visibilityChanged()
|
||||
|
|
@ -99,18 +103,19 @@ void ProgressBar::timerCallback()
|
|||
{
|
||||
double newProgress = progress;
|
||||
|
||||
if (newProgress < 0)
|
||||
newProgress = 0;
|
||||
|
||||
if (newProgress > 1.0)
|
||||
newProgress = 1.0;
|
||||
|
||||
if (currentValue != newProgress)
|
||||
if (currentValue != newProgress
|
||||
|| newProgress < 0 || newProgress >= 1.0
|
||||
|| currentMessage != displayedMessage)
|
||||
{
|
||||
if (currentValue < newProgress)
|
||||
if (currentValue < newProgress
|
||||
&& newProgress >= 0 && newProgress < 1.0
|
||||
&& currentValue >= 0 && newProgress < 1.0)
|
||||
{
|
||||
newProgress = jmin (currentValue + 0.02, newProgress);
|
||||
}
|
||||
|
||||
currentValue = newProgress;
|
||||
currentMessage = displayedMessage;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ public:
|
|||
*/
|
||||
void setPercentageDisplay (const bool shouldDisplayPercentage);
|
||||
|
||||
/** Gives the progress bar a string to display inside it.
|
||||
|
||||
If you call this, it will turn off the percentage display.
|
||||
@see setPercentageDisplay
|
||||
*/
|
||||
void setTextToDisplay (const String& text);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** A set of colour IDs to use to change the colour of various aspects of the bar.
|
||||
|
|
@ -111,6 +118,7 @@ private:
|
|||
double& progress;
|
||||
double currentValue;
|
||||
bool displayPercentage;
|
||||
String displayedMessage, currentMessage;
|
||||
|
||||
void timerCallback();
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../juce_Desktop.h"
|
||||
#include "../../graphics/imaging/juce_ImageCache.h"
|
||||
#include "../../graphics/brushes/juce_GradientBrush.h"
|
||||
#include "../../graphics/brushes/juce_ImageBrush.h"
|
||||
#include "../../graphics/fonts/juce_GlyphArrangement.h"
|
||||
#include "../../graphics/drawables/juce_DrawableComposite.h"
|
||||
#include "../../graphics/drawables/juce_DrawablePath.h"
|
||||
|
|
@ -163,7 +164,7 @@ LookAndFeel::LookAndFeel()
|
|||
AlertWindow::textColourId, 0xff000000,
|
||||
AlertWindow::outlineColourId, 0xff666666,
|
||||
|
||||
ProgressBar::backgroundColourId, 0xffffffff,
|
||||
ProgressBar::backgroundColourId, 0xffeeeeee,
|
||||
ProgressBar::foregroundColourId, 0xffaaaaee,
|
||||
|
||||
TooltipWindow::backgroundColourId, 0xffeeeebb,
|
||||
|
|
@ -509,24 +510,64 @@ int LookAndFeel::getAlertBoxWindowFlags()
|
|||
}
|
||||
|
||||
void LookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
||||
int x, int y, int w, int h,
|
||||
float progress)
|
||||
int width, int height,
|
||||
double progress, const String& textToShow)
|
||||
{
|
||||
const Colour background (progressBar.findColour (ProgressBar::backgroundColourId));
|
||||
const Colour foreground (progressBar.findColour (ProgressBar::foregroundColourId));
|
||||
|
||||
g.fillAll (background);
|
||||
|
||||
g.setColour (background.contrasting (0.2f));
|
||||
g.drawRect (x, y, w, h);
|
||||
if (progress >= 0.0f && progress < 1.0f)
|
||||
{
|
||||
drawGlassLozenge (g, 1.0f, 1.0f,
|
||||
(float) jlimit (0.0, width - 2.0, progress * (width - 2.0)),
|
||||
(float) (height - 2),
|
||||
foreground,
|
||||
0.5f, 0.0f,
|
||||
true, true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// spinning bar..
|
||||
g.setColour (foreground);
|
||||
|
||||
drawGlassLozenge (g,
|
||||
(float) (x + 1),
|
||||
(float) (y + 1),
|
||||
jlimit (0.0f, w - 2.0f, progress * (w - 2.0f)),
|
||||
(float) (h - 2),
|
||||
progressBar.findColour (ProgressBar::foregroundColourId),
|
||||
0.5f,
|
||||
0.0f,
|
||||
true, true, true, true);
|
||||
const int stripeWidth = height * 2;
|
||||
const int position = (Time::getMillisecondCounter() / 15) % stripeWidth;
|
||||
|
||||
Path p;
|
||||
|
||||
for (float x = (float) (stripeWidth - position); x < width + stripeWidth; x += stripeWidth)
|
||||
p.addQuadrilateral (x, 0.0f,
|
||||
x + stripeWidth * 0.5f, 0.0f,
|
||||
x, (float) height,
|
||||
x - stripeWidth * 0.5f, (float) height);
|
||||
|
||||
Image im (Image::ARGB, width, height, true);
|
||||
|
||||
{
|
||||
Graphics g (im);
|
||||
drawGlassLozenge (g, 1.0f, 1.0f,
|
||||
(float) (width - 2),
|
||||
(float) (height - 2),
|
||||
foreground,
|
||||
0.5f, 0.0f,
|
||||
true, true, true, true);
|
||||
}
|
||||
|
||||
ImageBrush ib (&im, 0, 0, 0.85f);
|
||||
g.setBrush (&ib);
|
||||
|
||||
g.fillPath (p);
|
||||
}
|
||||
|
||||
if (textToShow.isNotEmpty())
|
||||
{
|
||||
g.setColour (Colour::contrasting (background, foreground));
|
||||
g.setFont (height * 0.6f);
|
||||
|
||||
g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
|
||||
}
|
||||
}
|
||||
|
||||
void LookAndFeel::drawScrollbarButton (Graphics& g,
|
||||
|
|
|
|||
|
|
@ -168,11 +168,15 @@ public:
|
|||
|
||||
/** Draws a progress bar.
|
||||
|
||||
If the progress value is less than 0 or greater than 1.0, this should draw a spinning
|
||||
bar that fills the whole space (i.e. to say that the app is still busy but the progress
|
||||
isn't known). It can use the current time as a basis for playing an animation.
|
||||
|
||||
(Used by progress bars in AlertWindow).
|
||||
*/
|
||||
virtual void drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
||||
int x, int y, int w, int h,
|
||||
float progress);
|
||||
int width, int height,
|
||||
double progress, const String& textToShow);
|
||||
|
||||
//==============================================================================
|
||||
/** Draws one of the buttons on a scrollbar.
|
||||
|
|
@ -577,6 +581,7 @@ protected:
|
|||
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) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,17 +184,33 @@ void OldSchoolLookAndFeel::drawToggleButton (Graphics& g,
|
|||
}
|
||||
|
||||
void OldSchoolLookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
||||
int x, int y, int w, int h,
|
||||
float progress)
|
||||
int width, int height,
|
||||
double progress, const String& textToShow)
|
||||
{
|
||||
g.fillAll (progressBar.findColour (ProgressBar::backgroundColourId));
|
||||
if (progress < 0 || progress >= 1.0)
|
||||
{
|
||||
LookAndFeel::drawProgressBar (g, progressBar, width, height, progress, textToShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Colour background (progressBar.findColour (ProgressBar::backgroundColourId));
|
||||
const Colour foreground (progressBar.findColour (ProgressBar::foregroundColourId));
|
||||
|
||||
g.setColour (progressBar.findColour (ProgressBar::foregroundColourId));
|
||||
g.fillAll (background);
|
||||
g.setColour (foreground);
|
||||
|
||||
g.fillRect (x + 1,
|
||||
y + 1,
|
||||
jlimit (0, w - 2, roundFloatToInt (progress * (w - 2))),
|
||||
h - 2);
|
||||
g.fillRect (1, 1,
|
||||
jlimit (0, width - 2, roundDoubleToInt (progress * (width - 2))),
|
||||
height - 2);
|
||||
|
||||
if (textToShow.isNotEmpty())
|
||||
{
|
||||
g.setColour (Colour::contrasting (background, foreground));
|
||||
g.setFont (height * 0.6f);
|
||||
|
||||
g.drawText (textToShow, 0, 0, width, height, Justification::centred, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OldSchoolLookAndFeel::drawScrollbarButton (Graphics& g,
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
virtual void drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
||||
int x, int y, int w, int h,
|
||||
float progress);
|
||||
int width, int height,
|
||||
double progress, const String& textToShow);
|
||||
|
||||
//==============================================================================
|
||||
virtual void drawScrollbarButton (Graphics& g,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue