Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
d7a429759b
7 changed files with 85 additions and 7 deletions
  1. +5
    -4
      src/juce_appframework/gui/components/controls/juce_ListBox.h
  2. +3
    -2
      src/juce_appframework/gui/components/controls/juce_Slider.cpp
  3. +1
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp
  4. +1
    -1
      src/juce_appframework/gui/components/special/juce_AudioDeviceSelectorComponent.cpp
  5. +45
    -0
      src/juce_appframework/gui/graphics/contexts/juce_Graphics.cpp
  6. +16
    -0
      src/juce_appframework/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp
  7. +14
    -0
      src/juce_appframework/gui/graphics/geometry/juce_Path.cpp

+ 5
- 4
src/juce_appframework/gui/components/controls/juce_ListBox.h View File

@@ -431,10 +431,11 @@ public:
*/ */
enum ColourIds enum ColourIds
{ {
backgroundColourId = 0x1002800, /**< The background colour to fill the list with.
Make this transparent if you don't want the background to be filled. */
outlineColourId = 0x1002810 /**< An optional colour to use to draw a border around the list.
Make this transparent to not have an outline. */
backgroundColourId = 0x1002800, /**< The background colour to fill the list with.
Make this transparent if you don't want the background to be filled. */
outlineColourId = 0x1002810, /**< An optional colour to use to draw a border around the list.
Make this transparent to not have an outline. */
textColourId = 0x1002820 /**< The preferred colour to use for drawing text in the listbox. */
}; };
/** Sets the thickness of a border that will be drawn around the box. /** Sets the thickness of a border that will be drawn around the box.


+ 3
- 2
src/juce_appframework/gui/components/controls/juce_Slider.cpp View File

@@ -1281,9 +1281,10 @@ void Slider::mouseWheelMove (const MouseEvent&, float wheelIncrementX, float whe
const double currentPos = valueToProportionOfLength (currentValue); const double currentPos = valueToProportionOfLength (currentValue);
const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)); const double newValue = proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta));
double delta = jmax (fabs (newValue - currentValue), interval);
double delta = (newValue != currentValue)
? jmax (fabs (newValue - currentValue), interval) : 0;
if (proportionDelta < 0)
if (currentValue > newValue)
delta = -delta; delta = -delta;
sendDragStart(); sendDragStart();


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

@@ -142,6 +142,7 @@ LookAndFeel::LookAndFeel()
ListBox::backgroundColourId, 0xffffffff, ListBox::backgroundColourId, 0xffffffff,
ListBox::outlineColourId, standardOutlineColour, ListBox::outlineColourId, standardOutlineColour,
ListBox::textColourId, 0xff000000,
Slider::backgroundColourId, 0x00000000, Slider::backgroundColourId, 0x00000000,
Slider::thumbColourId, textButtonColour, Slider::thumbColourId, textButtonColour,


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

@@ -132,7 +132,7 @@ public:
enabled, true, true, false); enabled, true, true, false);
g.setFont (height * 0.6f); g.setFont (height * 0.6f);
g.setColour (Colours::black.withAlpha (enabled ? 1.0f : 0.6f));
g.setColour (findColour (ListBox::textColourId, true).withMultipliedAlpha (enabled ? 1.0f : 0.6f));
g.drawText (item, x, 0, width - x - 2, height, Justification::centredLeft, true); g.drawText (item, x, 0, width - x - 2, height, Justification::centredLeft, true);
} }
} }


+ 45
- 0
src/juce_appframework/gui/graphics/contexts/juce_Graphics.cpp View File

@@ -42,6 +42,20 @@ BEGIN_JUCE_NAMESPACE
static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality; static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality;
//==============================================================================
#define MINIMUM_COORD -0x3fffffff
#define MAXIMUM_COORD 0x3fffffff
#define ASSERT_COORDS_ARE_SENSIBLE_NUMBERS(x, y, w, h) \
jassert ((int) x >= MINIMUM_COORD \
&& (int) x <= MAXIMUM_COORD \
&& (int) y >= MINIMUM_COORD \
&& (int) y <= MAXIMUM_COORD \
&& (int) w >= 0 \
&& (int) w < MAXIMUM_COORD \
&& (int) h >= 0 \
&& (int) h < MAXIMUM_COORD);
//============================================================================== //==============================================================================
LowLevelGraphicsContext::LowLevelGraphicsContext() LowLevelGraphicsContext::LowLevelGraphicsContext()
@@ -345,6 +359,9 @@ void Graphics::fillRect (int x,
int width, int width,
int height) const throw() int height) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
SolidColourBrush colourBrush (state->colour); SolidColourBrush colourBrush (state->colour);
(state->brush != 0 ? *(state->brush) : (Brush&) colourBrush).paintRectangle (*context, x, y, width, height); (state->brush != 0 ? *(state->brush) : (Brush&) colourBrush).paintRectangle (*context, x, y, width, height);
} }
@@ -362,6 +379,9 @@ void Graphics::fillRect (const float x,
const float width, const float width,
const float height) const throw() const float height) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
Path p; Path p;
p.addRectangle (x, y, width, height); p.addRectangle (x, y, width, height);
fillPath (p); fillPath (p);
@@ -423,6 +443,9 @@ void Graphics::drawRect (const int x,
const int height, const int height,
const int lineThickness) const throw() const int lineThickness) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
SolidColourBrush colourBrush (state->colour); SolidColourBrush colourBrush (state->colour);
Brush& b = (state->brush != 0 ? *(state->brush) : (Brush&) colourBrush); Brush& b = (state->brush != 0 ? *(state->brush) : (Brush&) colourBrush);
@@ -441,6 +464,9 @@ void Graphics::drawBevel (const int x,
const Colour& bottomRightColour, const Colour& bottomRightColour,
const bool useGradient) const throw() const bool useGradient) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
if (clipRegionIntersects (x, y, width, height)) if (clipRegionIntersects (x, y, width, height))
{ {
const float oldOpacity = state->colour.getFloatAlpha(); const float oldOpacity = state->colour.getFloatAlpha();
@@ -465,6 +491,9 @@ void Graphics::fillEllipse (const float x,
const float width, const float width,
const float height) const throw() const float height) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
Path p; Path p;
p.addEllipse (x, y, width, height); p.addEllipse (x, y, width, height);
fillPath (p); fillPath (p);
@@ -476,6 +505,9 @@ void Graphics::drawEllipse (const float x,
const float height, const float height,
const float lineThickness) const throw() const float lineThickness) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
Path p; Path p;
p.addEllipse (x, y, width, height); p.addEllipse (x, y, width, height);
strokePath (p, PathStrokeType (lineThickness)); strokePath (p, PathStrokeType (lineThickness));
@@ -487,6 +519,9 @@ void Graphics::fillRoundedRectangle (const float x,
const float height, const float height,
const float cornerSize) const throw() const float cornerSize) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
Path p; Path p;
p.addRoundedRectangle (x, y, width, height, cornerSize); p.addRoundedRectangle (x, y, width, height, cornerSize);
fillPath (p); fillPath (p);
@@ -499,6 +534,9 @@ void Graphics::drawRoundedRectangle (const float x,
const float cornerSize, const float cornerSize,
const float lineThickness) const throw() const float lineThickness) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
Path p; Path p;
p.addRoundedRectangle (x, y, width, height, cornerSize); p.addRoundedRectangle (x, y, width, height, cornerSize);
strokePath (p, PathStrokeType (lineThickness)); strokePath (p, PathStrokeType (lineThickness));
@@ -680,6 +718,9 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
const RectanglePlacement& placementWithinTarget, const RectanglePlacement& placementWithinTarget,
const bool fillAlphaChannelWithCurrentBrush) const throw() const bool fillAlphaChannelWithCurrentBrush) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (destX, destY, destW, destH);
if (imageToDraw != 0) if (imageToDraw != 0)
{ {
const int imageW = imageToDraw->getWidth(); const int imageW = imageToDraw->getWidth();
@@ -711,6 +752,10 @@ void Graphics::drawImage (const Image* const imageToDraw,
int sx, int sy, int sw, int sh, int sx, int sy, int sw, int sh,
const bool fillAlphaChannelWithCurrentBrush) const throw() const bool fillAlphaChannelWithCurrentBrush) const throw()
{ {
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (dx, dy, dw, dh);
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (sx, sy, sw, sh);
if (imageToDraw == 0 || ! context->clipRegionIntersects (dx, dy, dw, dh)) if (imageToDraw == 0 || ! context->clipRegionIntersects (dx, dy, dw, dh))
return; return;


+ 16
- 0
src/juce_appframework/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp View File

@@ -49,6 +49,19 @@ BEGIN_JUCE_NAMESPACE
#pragma warning (disable: 4714) #pragma warning (disable: 4714)
#endif #endif
#define MINIMUM_COORD -0x3fffffff
#define MAXIMUM_COORD 0x3fffffff
#define ASSERT_COORDS_ARE_SENSIBLE_NUMBERS(x, y, w, h) \
jassert ((int) x >= MINIMUM_COORD \
&& (int) x <= MAXIMUM_COORD \
&& (int) y >= MINIMUM_COORD \
&& (int) y <= MAXIMUM_COORD \
&& (int) w >= 0 \
&& (int) w < MAXIMUM_COORD \
&& (int) h >= 0 \
&& (int) h < MAXIMUM_COORD);
//============================================================================== //==============================================================================
static void replaceRectRGB (uint8* pixels, const int w, int h, const int stride, const Colour& colour) throw() static void replaceRectRGB (uint8* pixels, const int w, int h, const int stride, const Colour& colour) throw()
{ {
@@ -1177,6 +1190,9 @@ bool LowLevelGraphicsSoftwareRenderer::getPathBounds (int clipX, int clipY, int
w = roundDoubleToInt (tw) + 2; w = roundDoubleToInt (tw) + 2;
h = roundDoubleToInt (th) + 2; h = roundDoubleToInt (th) + 2;
// seems like this operation is using some crazy out-of-range numbers..
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, w, h);
return Rectangle::intersectRectangles (x, y, w, h, clipX, clipY, clipW, clipH); return Rectangle::intersectRectangles (x, y, w, h, clipX, clipY, clipW, clipH);
} }


+ 14
- 0
src/juce_appframework/gui/graphics/geometry/juce_Path.cpp View File

@@ -38,6 +38,9 @@ BEGIN_JUCE_NAMESPACE
#include "juce_Line.h" #include "juce_Line.h"
#include "../../../../juce_core/io/streams/juce_MemoryInputStream.h" #include "../../../../juce_core/io/streams/juce_MemoryInputStream.h"
// tests that some co-ords aren't NaNs
#define CHECK_COORDS_ARE_VALID(x, y) \
jassert (x == x && y == y);
//============================================================================== //==============================================================================
static const float lineMarker = 100001.0f; static const float lineMarker = 100001.0f;
@@ -197,6 +200,8 @@ void Path::getBoundsTransformed (const AffineTransform& transform,
void Path::startNewSubPath (const float x, void Path::startNewSubPath (const float x,
const float y) throw() const float y) throw()
{ {
CHECK_COORDS_ARE_VALID (x, y);
if (numElements == 0) if (numElements == 0)
{ {
pathXMin = pathXMax = x; pathXMin = pathXMax = x;
@@ -219,6 +224,8 @@ void Path::startNewSubPath (const float x,
void Path::lineTo (const float x, const float y) throw() void Path::lineTo (const float x, const float y) throw()
{ {
CHECK_COORDS_ARE_VALID (x, y);
if (numElements == 0) if (numElements == 0)
startNewSubPath (0, 0); startNewSubPath (0, 0);
@@ -237,6 +244,9 @@ void Path::lineTo (const float x, const float y) throw()
void Path::quadraticTo (const float x1, const float y1, void Path::quadraticTo (const float x1, const float y1,
const float x2, const float y2) throw() const float x2, const float y2) throw()
{ {
CHECK_COORDS_ARE_VALID (x1, y1);
CHECK_COORDS_ARE_VALID (x2, y2);
if (numElements == 0) if (numElements == 0)
startNewSubPath (0, 0); startNewSubPath (0, 0);
@@ -258,6 +268,10 @@ void Path::cubicTo (const float x1, const float y1,
const float x2, const float y2, const float x2, const float y2,
const float x3, const float y3) throw() const float x3, const float y3) throw()
{ {
CHECK_COORDS_ARE_VALID (x1, y1);
CHECK_COORDS_ARE_VALID (x2, y2);
CHECK_COORDS_ARE_VALID (x3, y3);
if (numElements == 0) if (numElements == 0)
startNewSubPath (0, 0); startNewSubPath (0, 0);


Loading…
Cancel
Save