Browse Source

Minor clean-ups. Jucer development.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
1ef2087154
10 changed files with 429 additions and 592 deletions
  1. +15
    -0
      extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp
  2. +51
    -27
      extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp
  3. +98
    -184
      juce_amalgamated.cpp
  4. +83
    -97
      juce_amalgamated.h
  5. +1
    -4
      src/gui/components/mouse/juce_LassoComponent.h
  6. +92
    -179
      src/gui/graphics/contexts/juce_Graphics.cpp
  7. +72
    -95
      src/gui/graphics/contexts/juce_Graphics.h
  8. +5
    -5
      src/gui/graphics/drawables/juce_DrawablePath.cpp
  9. +1
    -1
      src/gui/graphics/drawables/juce_SVGParser.cpp
  10. +11
    -0
      src/gui/graphics/geometry/juce_Rectangle.h

+ 15
- 0
extras/Jucer (experimental)/Source/model/jucer_ComponentDocument.cpp View File

@@ -364,6 +364,21 @@ public:
void resize (ValueTree& v, const Point<int>& distance, const Rectangle<int>& originalPos)
{
Rectangle<int> r (originalPos);
if ((zones & zoneL) != 0)
r.setLeft (r.getX() + distance.getX());
if ((zones & zoneT) != 0)
r.setTop (r.getY() + distance.getY());
if ((zones & zoneR) != 0)
r.setWidth (r.getWidth() + distance.getX());
if ((zones & zoneB) != 0)
r.setHeight (r.getHeight() + distance.getY());
v.setProperty (compBoundsProperty, componentBoundsToString (r), document.getUndoManager());
}
private:


+ 51
- 27
extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditor.cpp View File

@@ -153,12 +153,12 @@ private:
ComponentEditor& editor;
//==============================================================================
class ComponentSelectorFrame : public Component,
public ComponentListener
class ComponentResizeFrame : public Component,
public ComponentListener
{
public:
ComponentSelectorFrame (ComponentCanvas& canvas_,
Component* componentToAttachTo)
ComponentResizeFrame (ComponentCanvas& canvas_,
Component* componentToAttachTo)
: canvas (canvas_),
component (componentToAttachTo),
borderThickness (4)
@@ -167,7 +167,7 @@ private:
componentToAttachTo->addComponentListener (this);
}
~ComponentSelectorFrame()
~ComponentResizeFrame()
{
if (component != 0)
component->removeComponentListener (this);
@@ -181,13 +181,13 @@ private:
void mouseEnter (const MouseEvent& e)
{
repaint();
//repaint();
updateDragZone (e.getPosition());
}
void mouseExit (const MouseEvent& e)
{
repaint();
//repaint();
updateDragZone (e.getPosition());
}
@@ -227,8 +227,9 @@ private:
setBounds (component->getBounds().expanded (borderThickness, borderThickness));
}
void resized()
bool hitTest (int x, int y)
{
return ! getCentreArea().contains (x, y);
}
uint32 getTargetComponentUID() const { return component == 0 ? 0 : component->getComponentUID(); }
@@ -239,14 +240,16 @@ private:
int dragZone;
const int borderThickness;
const Rectangle<int> getCentreArea() const
{
return Rectangle<int> (0, 0, getWidth(), getHeight()).reduced (borderThickness, borderThickness);
}
void updateDragZone (const Point<int>& p)
{
int newZone = 0;
Rectangle<int> r (0, 0, getWidth(), getHeight());
r = r.reduced (borderThickness, borderThickness);
if (! r.contains (p))
if (! getCentreArea().contains (p))
{
const int bw = jmax (borderThickness, proportionOfWidth (0.1f), jmin (10, proportionOfWidth (0.33f)));
const int bh = jmax (borderThickness, proportionOfHeight (0.1f), jmin (10, proportionOfHeight (0.33f)));
@@ -311,6 +314,8 @@ private:
void mouseDown (const MouseEvent& e)
{
lasso = 0;
mouseDownCompUID = 0;
isDraggingClickedComp = false;
if (e.mods.isPopupMenu())
{
@@ -343,7 +348,20 @@ private:
void mouseDrag (const MouseEvent& e)
{
if (lasso != 0)
{
lasso->dragLasso (e);
}
else if (mouseDownCompUID != 0 && (! e.mouseWasClicked()) && (! e.mods.isPopupMenu()))
{
if (! isDraggingClickedComp)
{
isDraggingClickedComp = true;
canvas.getSelection().addToSelectionOnMouseUp (mouseDownCompUID, e.mods, true, mouseDownResult);
canvas.getDocument().beginDrag (canvas.getSelectedComps(), e, 0);
}
canvas.getDocument().continueDrag (e);
}
}
void mouseUp (const MouseEvent& e)
@@ -356,9 +374,10 @@ private:
if (e.mouseWasClicked())
canvas.getSelection().deselectAll();
}
else
else if (! e.mods.isPopupMenu())
{
canvas.getSelection().addToSelectionOnMouseUp (mouseDownCompUID, e.mods, ! e.mouseWasClicked(), mouseDownResult);
if (! isDraggingClickedComp)
canvas.getSelection().addToSelectionOnMouseUp (mouseDownCompUID, e.mods, ! e.mouseWasClicked(), mouseDownResult);
}
}
@@ -369,7 +388,7 @@ private:
for (int i = canvas.getComponentHolder()->getNumChildComponents(); --i >= 0;)
{
Component* c = canvas.getComponentHolder()->getChildComponent(i);
if (c != this && c->getBounds().intersects (lassoArea))
if (c->getBounds().intersects (lassoArea))
itemsFound.add (c->getComponentUID());
}
}
@@ -378,38 +397,43 @@ private:
void changeListenerCallback (void*)
{
updateSelectedComponentOverlays();
updateSelectedComponentResizeFrames();
}
void modifierKeysChanged (const ModifierKeys&)
{
Desktop::getInstance().getMainMouseSource().triggerFakeMove();
}
private:
ComponentCanvas& canvas;
ScopedPointer <LassoComponent <ComponentDocument::SelectedItems::ItemType> > lasso;
bool mouseDownResult;
bool mouseDownResult, isDraggingClickedComp;
uint32 mouseDownCompUID;
ComponentSelectorFrame* getSelectorFrameFor (Component* c) const
ComponentResizeFrame* getSelectorFrameFor (Component* c) const
{
for (int i = getNumChildComponents(); --i >= 0;)
{
ComponentSelectorFrame* overlay = dynamic_cast <ComponentSelectorFrame*> (getChildComponent(i));
if (overlay != 0 && overlay->getTargetComponentUID() == c->getComponentUID())
return overlay;
ComponentResizeFrame* resizer = dynamic_cast <ComponentResizeFrame*> (getChildComponent(i));
if (resizer != 0 && resizer->getTargetComponentUID() == c->getComponentUID())
return resizer;
}
return 0;
}
void updateSelectedComponentOverlays()
void updateSelectedComponentResizeFrames()
{
ComponentDocument::SelectedItems& selection = canvas.getSelection();
int i;
for (i = getNumChildComponents(); --i >= 0;)
{
ComponentSelectorFrame* overlay = dynamic_cast <ComponentSelectorFrame*> (getChildComponent(i));
ComponentResizeFrame* resizer = dynamic_cast <ComponentResizeFrame*> (getChildComponent(i));
if (overlay != 0 && ! selection.isSelected (overlay->getTargetComponentUID()))
delete overlay;
if (resizer != 0 && ! selection.isSelected (resizer->getTargetComponentUID()))
delete resizer;
}
for (i = canvas.getComponentHolder()->getNumChildComponents(); --i >= 0;)
@@ -417,7 +441,7 @@ private:
Component* c = canvas.getComponentHolder()->getChildComponent(i);
if (c != this && selection.isSelected (c->getComponentUID()) && getSelectorFrameFor (c) == 0)
addAndMakeVisible (new ComponentSelectorFrame (canvas, c));
addAndMakeVisible (new ComponentResizeFrame (canvas, c));
}
}
};
@@ -428,7 +452,7 @@ private:
Component* getComponentForUID (const uint32 uid) const
{
for (int i = getNumChildComponents(); --i >= 0;)
for (int i = componentHolder->getNumChildComponents(); --i >= 0;)
if (componentHolder->getChildComponent (i)->getComponentUID() == uid)
return componentHolder->getChildComponent (i);


+ 98
- 184
juce_amalgamated.cpp View File

@@ -79614,7 +79614,7 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext()
{
}

Graphics::Graphics (Image& imageToDrawOnto) throw()
Graphics::Graphics (Image& imageToDrawOnto)
: context (imageToDrawOnto.createLowLevelContext()),
contextToDelete (context),
saveStatePending (false)
@@ -79627,11 +79627,11 @@ Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw()
{
}

Graphics::~Graphics() throw()
Graphics::~Graphics()
{
}

void Graphics::resetToDefaultState() throw()
void Graphics::resetToDefaultState()
{
saveStateIfPending();
context->setFill (FillType());
@@ -79639,61 +79639,60 @@ void Graphics::resetToDefaultState() throw()
context->setInterpolationQuality (defaultQuality);
}

bool Graphics::isVectorDevice() const throw()
bool Graphics::isVectorDevice() const
{
return context->isVectorDevice();
}

bool Graphics::reduceClipRegion (const int x, const int y,
const int w, const int h) throw()
bool Graphics::reduceClipRegion (const int x, const int y, const int w, const int h)
{
saveStateIfPending();
return context->clipToRectangle (Rectangle<int> (x, y, w, h));
}

bool Graphics::reduceClipRegion (const RectangleList& clipRegion) throw()
bool Graphics::reduceClipRegion (const RectangleList& clipRegion)
{
saveStateIfPending();
return context->clipToRectangleList (clipRegion);
}

bool Graphics::reduceClipRegion (const Path& path, const AffineTransform& transform) throw()
bool Graphics::reduceClipRegion (const Path& path, const AffineTransform& transform)
{
saveStateIfPending();
context->clipToPath (path, transform);
return ! context->isClipEmpty();
}

bool Graphics::reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion, const AffineTransform& transform) throw()
bool Graphics::reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion, const AffineTransform& transform)
{
saveStateIfPending();
context->clipToImageAlpha (image, sourceClipRegion, transform);
return ! context->isClipEmpty();
}

void Graphics::excludeClipRegion (const Rectangle<int>& rectangleToExclude) throw()
void Graphics::excludeClipRegion (const Rectangle<int>& rectangleToExclude)
{
saveStateIfPending();
context->excludeClipRectangle (rectangleToExclude);
}

bool Graphics::isClipEmpty() const throw()
bool Graphics::isClipEmpty() const
{
return context->isClipEmpty();
}

const Rectangle<int> Graphics::getClipBounds() const throw()
const Rectangle<int> Graphics::getClipBounds() const
{
return context->getClipBounds();
}

void Graphics::saveState() throw()
void Graphics::saveState()
{
saveStateIfPending();
saveStatePending = true;
}

void Graphics::restoreState() throw()
void Graphics::restoreState()
{
if (saveStatePending)
saveStatePending = false;
@@ -79701,7 +79700,7 @@ void Graphics::restoreState() throw()
context->restoreState();
}

void Graphics::saveStateIfPending() throw()
void Graphics::saveStateIfPending()
{
if (saveStatePending)
{
@@ -79710,61 +79709,54 @@ void Graphics::saveStateIfPending() throw()
}
}

void Graphics::setOrigin (const int newOriginX,
const int newOriginY) throw()
void Graphics::setOrigin (const int newOriginX, const int newOriginY)
{
saveStateIfPending();
context->setOrigin (newOriginX, newOriginY);
}

bool Graphics::clipRegionIntersects (const int x, const int y,
const int w, const int h) const throw()
bool Graphics::clipRegionIntersects (const int x, const int y, const int w, const int h) const
{
return context->clipRegionIntersects (Rectangle<int> (x, y, w, h));
}

void Graphics::setColour (const Colour& newColour) throw()
void Graphics::setColour (const Colour& newColour)
{
saveStateIfPending();
context->setFill (FillType (newColour));
context->setFill (newColour);
}

void Graphics::setOpacity (const float newOpacity) throw()
void Graphics::setOpacity (const float newOpacity)
{
saveStateIfPending();
context->setOpacity (newOpacity);
}

void Graphics::setGradientFill (const ColourGradient& gradient) throw()
void Graphics::setGradientFill (const ColourGradient& gradient)
{
saveStateIfPending();
context->setFill (FillType (gradient));
setFillType (gradient);
}

void Graphics::setTiledImageFill (const Image& imageToUse,
const int anchorX,
const int anchorY,
const float opacity) throw()
void Graphics::setTiledImageFill (const Image& imageToUse, const int anchorX, const int anchorY, const float opacity)
{
saveStateIfPending();
context->setFill (FillType (imageToUse, AffineTransform::translation ((float) anchorX, (float) anchorY)));
context->setOpacity (opacity);
}

void Graphics::setFillType (const FillType& newFill) throw()
void Graphics::setFillType (const FillType& newFill)
{
saveStateIfPending();
context->setFill (newFill);
}

void Graphics::setFont (const Font& newFont) throw()
void Graphics::setFont (const Font& newFont)
{
saveStateIfPending();
context->setFont (newFont);
}

void Graphics::setFont (const float newFontHeight,
const int newFontStyleFlags) throw()
void Graphics::setFont (const float newFontHeight, const int newFontStyleFlags)
{
saveStateIfPending();
Font f (context->getFont());
@@ -79772,9 +79764,7 @@ void Graphics::setFont (const float newFontHeight,
context->setFont (f);
}

void Graphics::drawSingleLineText (const String& text,
const int startX,
const int baselineY) const throw()
void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY) const
{
if (text.isNotEmpty()
&& startX < context->getClipBounds().getRight())
@@ -79785,8 +79775,7 @@ void Graphics::drawSingleLineText (const String& text,
}
}

void Graphics::drawTextAsPath (const String& text,
const AffineTransform& transform) const throw()
void Graphics::drawTextAsPath (const String& text, const AffineTransform& transform) const
{
if (text.isNotEmpty())
{
@@ -79796,10 +79785,7 @@ void Graphics::drawTextAsPath (const String& text,
}
}

void Graphics::drawMultiLineText (const String& text,
const int startX,
const int baselineY,
const int maximumLineWidth) const throw()
void Graphics::drawMultiLineText (const String& text, const int startX, const int baselineY, const int maximumLineWidth) const
{
if (text.isNotEmpty()
&& startX < context->getClipBounds().getRight())
@@ -79813,37 +79799,30 @@ void Graphics::drawMultiLineText (const String& text,
}

void Graphics::drawText (const String& text,
const int x,
const int y,
const int width,
const int height,
const int x, const int y, const int width, const int height,
const Justification& justificationType,
const bool useEllipsesIfTooBig) const throw()
const bool useEllipsesIfTooBig) const
{
if (text.isNotEmpty() && context->clipRegionIntersects (Rectangle<int> (x, y, width, height)))
{
GlyphArrangement arr;

arr.addCurtailedLineOfText (context->getFont(), text,
0.0f, 0.0f, (float)width,
0.0f, 0.0f, (float) width,
useEllipsesIfTooBig);

arr.justifyGlyphs (0, arr.getNumGlyphs(),
(float) x, (float) y,
(float) width, (float) height,
(float) x, (float) y, (float) width, (float) height,
justificationType);
arr.draw (*this);
}
}

void Graphics::drawFittedText (const String& text,
const int x,
const int y,
const int width,
const int height,
const int x, const int y, const int width, const int height,
const Justification& justification,
const int maximumNumberOfLines,
const float minimumHorizontalScale) const throw()
const float minimumHorizontalScale) const
{
if (text.isNotEmpty()
&& width > 0 && height > 0
@@ -79852,8 +79831,7 @@ void Graphics::drawFittedText (const String& text,
GlyphArrangement arr;

arr.addFittedText (context->getFont(), text,
(float) x, (float) y,
(float) width, (float) height,
(float) x, (float) y, (float) width, (float) height,
justification,
maximumNumberOfLines,
minimumHorizontalScale);
@@ -79862,10 +79840,7 @@ void Graphics::drawFittedText (const String& text,
}
}

void Graphics::fillRect (int x,
int y,
int width,
int height) const throw()
void Graphics::fillRect (int x, int y, int width, int height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -79873,15 +79848,12 @@ void Graphics::fillRect (int x,
context->fillRect (Rectangle<int> (x, y, width, height), false);
}

void Graphics::fillRect (const Rectangle<int>& r) const throw()
void Graphics::fillRect (const Rectangle<int>& r) const
{
context->fillRect (r, false);
}

void Graphics::fillRect (const float x,
const float y,
const float width,
const float height) const throw()
void Graphics::fillRect (const float x, const float y, const float width, const float height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -79891,31 +79863,30 @@ void Graphics::fillRect (const float x,
fillPath (p);
}

void Graphics::setPixel (int x, int y) const throw()
void Graphics::setPixel (int x, int y) const
{
context->fillRect (Rectangle<int> (x, y, 1, 1), false);
}

void Graphics::fillAll() const throw()
void Graphics::fillAll() const
{
fillRect (context->getClipBounds());
}

void Graphics::fillAll (const Colour& colourToUse) const throw()
void Graphics::fillAll (const Colour& colourToUse) const
{
if (! colourToUse.isTransparent())
{
const Rectangle<int> clip (context->getClipBounds());

context->saveState();
context->setFill (FillType (colourToUse));
context->setFill (colourToUse);
context->fillRect (clip, false);
context->restoreState();
}
}

void Graphics::fillPath (const Path& path,
const AffineTransform& transform) const throw()
void Graphics::fillPath (const Path& path, const AffineTransform& transform) const
{
if ((! context->isClipEmpty()) && ! path.isEmpty())
context->fillPath (path, transform);
@@ -79923,18 +79894,15 @@ void Graphics::fillPath (const Path& path,

void Graphics::strokePath (const Path& path,
const PathStrokeType& strokeType,
const AffineTransform& transform) const throw()
const AffineTransform& transform) const
{
Path stroke;
strokeType.createStrokedPath (stroke, path, transform);
fillPath (stroke);
}

void Graphics::drawRect (const int x,
const int y,
const int width,
const int height,
const int lineThickness) const throw()
void Graphics::drawRect (const int x, const int y, const int width, const int height,
const int lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -79945,11 +79913,7 @@ void Graphics::drawRect (const int x,
context->fillRect (Rectangle<int> (x, y + height - lineThickness, width, lineThickness), false);
}

void Graphics::drawRect (const float x,
const float y,
const float width,
const float height,
const float lineThickness) const throw()
void Graphics::drawRect (const float x, const float y, const float width, const float height, const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -79962,23 +79926,14 @@ void Graphics::drawRect (const float x,
fillPath (p);
}

void Graphics::drawRect (const Rectangle<int>& r,
const int lineThickness) const throw()
void Graphics::drawRect (const Rectangle<int>& r, const int lineThickness) const
{
drawRect (r.getX(), r.getY(),
r.getWidth(), r.getHeight(),
lineThickness);
drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness);
}

void Graphics::drawBevel (const int x,
const int y,
const int width,
const int height,
const int bevelThickness,
const Colour& topLeftColour,
const Colour& bottomRightColour,
const bool useGradient,
const bool sharpEdgeOnOutside) const throw()
void Graphics::drawBevel (const int x, const int y, const int width, const int height,
const int bevelThickness, const Colour& topLeftColour, const Colour& bottomRightColour,
const bool useGradient, const bool sharpEdgeOnOutside) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -79995,13 +79950,13 @@ void Graphics::drawBevel (const int x,
const float op = useGradient ? ramp * (sharpEdgeOnOutside ? bevelThickness - i : i)
: oldOpacity;

context->setFill (FillType (topLeftColour.withMultipliedAlpha (op)));
context->setFill (topLeftColour.withMultipliedAlpha (op));
context->fillRect (Rectangle<int> (x + i, y + i, width - i * 2, 1), false);
context->setFill (FillType (topLeftColour.withMultipliedAlpha (op * 0.75f)));
context->setFill (topLeftColour.withMultipliedAlpha (op * 0.75f));
context->fillRect (Rectangle<int> (x + i, y + i + 1, 1, height - i * 2 - 2), false);
context->setFill (FillType (bottomRightColour.withMultipliedAlpha (op)));
context->setFill (bottomRightColour.withMultipliedAlpha (op));
context->fillRect (Rectangle<int> (x + i, y + height - i - 1, width - i * 2, 1), false);
context->setFill (FillType (bottomRightColour.withMultipliedAlpha (op * 0.75f)));
context->setFill (bottomRightColour.withMultipliedAlpha (op * 0.75f));
context->fillRect (Rectangle<int> (x + width - i - 1, y + i + 1, 1, height - i * 2 - 2), false);
}

@@ -80009,10 +79964,7 @@ void Graphics::drawBevel (const int x,
}
}

void Graphics::fillEllipse (const float x,
const float y,
const float width,
const float height) const throw()
void Graphics::fillEllipse (const float x, const float y, const float width, const float height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -80022,11 +79974,8 @@ void Graphics::fillEllipse (const float x,
fillPath (p);
}

void Graphics::drawEllipse (const float x,
const float y,
const float width,
const float height,
const float lineThickness) const throw()
void Graphics::drawEllipse (const float x, const float y, const float width, const float height,
const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -80036,11 +79985,7 @@ void Graphics::drawEllipse (const float x,
strokePath (p, PathStrokeType (lineThickness));
}

void Graphics::fillRoundedRectangle (const float x,
const float y,
const float width,
const float height,
const float cornerSize) const throw()
void Graphics::fillRoundedRectangle (const float x, const float y, const float width, const float height, const float cornerSize) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -80050,22 +79995,13 @@ void Graphics::fillRoundedRectangle (const float x,
fillPath (p);
}

void Graphics::fillRoundedRectangle (const Rectangle<int>& r,
const float cornerSize) const throw()
void Graphics::fillRoundedRectangle (const Rectangle<float>& r, const float cornerSize) const
{
fillRoundedRectangle ((float) r.getX(),
(float) r.getY(),
(float) r.getWidth(),
(float) r.getHeight(),
cornerSize);
fillRoundedRectangle (r.getX(), r.getY(), r.getWidth(), r.getHeight(), cornerSize);
}

void Graphics::drawRoundedRectangle (const float x,
const float y,
const float width,
const float height,
const float cornerSize,
const float lineThickness) const throw()
void Graphics::drawRoundedRectangle (const float x, const float y, const float width, const float height,
const float cornerSize, const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -80075,24 +80011,13 @@ void Graphics::drawRoundedRectangle (const float x,
strokePath (p, PathStrokeType (lineThickness));
}

void Graphics::drawRoundedRectangle (const Rectangle<int>& r,
const float cornerSize,
const float lineThickness) const throw()
void Graphics::drawRoundedRectangle (const Rectangle<float>& r, const float cornerSize, const float lineThickness) const
{
drawRoundedRectangle ((float) r.getX(),
(float) r.getY(),
(float) r.getWidth(),
(float) r.getHeight(),
cornerSize, lineThickness);
drawRoundedRectangle (r.getX(), r.getY(), r.getWidth(), r.getHeight(), cornerSize, lineThickness);
}

void Graphics::drawArrow (const float startX,
const float startY,
const float endX,
const float endY,
const float lineThickness,
const float arrowheadWidth,
const float arrowheadLength) const throw()
void Graphics::drawArrow (const float startX, const float startY, const float endX, const float endY,
const float lineThickness, const float arrowheadWidth, const float arrowheadLength) const
{
Path p;
p.addArrow (startX, startY, endX, endY,
@@ -80100,12 +80025,9 @@ void Graphics::drawArrow (const float startX,
fillPath (p);
}

void Graphics::fillCheckerBoard (int x, int y,
int width, int height,
const int checkWidth,
const int checkHeight,
const Colour& colour1,
const Colour& colour2) const throw()
void Graphics::fillCheckerBoard (int x, int y, int width, int height,
const int checkWidth, const int checkHeight,
const Colour& colour1, const Colour& colour2) const
{
jassert (checkWidth > 0 && checkHeight > 0); // can't be zero or less!

@@ -80115,7 +80037,7 @@ void Graphics::fillCheckerBoard (int x, int y,

if (colour1 == colour2)
{
context->setFill (FillType (colour1));
context->setFill (colour1);
context->fillRect (Rectangle<int> (x, y, width, height), false);
}
else
@@ -80132,7 +80054,7 @@ void Graphics::fillCheckerBoard (int x, int y,

for (int xx = x; xx < right; xx += checkWidth)
{
context->setFill (FillType (((cx++ & 1) == 0) ? colour1 : colour2));
context->setFill (((cx++ & 1) == 0) ? colour1 : colour2);
context->fillRect (Rectangle<int> (xx, y, jmin (checkWidth, right - xx), jmin (checkHeight, bottom - y)),
false);
}
@@ -80146,50 +80068,45 @@ void Graphics::fillCheckerBoard (int x, int y,
}
}

void Graphics::drawVerticalLine (const int x, float top, float bottom) const throw()
void Graphics::drawVerticalLine (const int x, float top, float bottom) const
{
context->drawVerticalLine (x, top, bottom);
}

void Graphics::drawHorizontalLine (const int y, float left, float right) const throw()
void Graphics::drawHorizontalLine (const int y, float left, float right) const
{
context->drawHorizontalLine (y, left, right);
}

void Graphics::drawLine (float x1, float y1, float x2, float y2) const throw()
void Graphics::drawLine (float x1, float y1, float x2, float y2) const
{
context->drawLine (x1, y1, x2, y2);
}

void Graphics::drawLine (const float startX,
const float startY,
const float endX,
const float endY,
const float lineThickness) const throw()
void Graphics::drawLine (const float startX, const float startY,
const float endX, const float endY,
const float lineThickness) const
{
Path p;
p.addLineSegment (startX, startY, endX, endY, lineThickness);
fillPath (p);
}

void Graphics::drawLine (const Line& line) const throw()
void Graphics::drawLine (const Line& line) const
{
drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY());
}

void Graphics::drawLine (const Line& line,
const float lineThickness) const throw()
void Graphics::drawLine (const Line& line, const float lineThickness) const
{
drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY(), lineThickness);
}

void Graphics::drawDashedLine (const float startX,
const float startY,
const float endX,
const float endY,
void Graphics::drawDashedLine (const float startX, const float startY,
const float endX, const float endY,
const float* const dashLengths,
const int numDashLengths,
const float lineThickness) const throw()
const float lineThickness) const
{
const double dx = endX - startX;
const double dy = endY - startY;
@@ -80226,16 +80143,15 @@ void Graphics::drawDashedLine (const float startX,
}
}

void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQuality) throw()
void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQuality)
{
saveStateIfPending();
context->setInterpolationQuality (newQuality);
}

void Graphics::drawImageAt (const Image* const imageToDraw,
const int topLeftX,
const int topLeftY,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const int topLeftX, const int topLeftY,
const bool fillAlphaChannelWithCurrentBrush) const
{
if (imageToDraw != 0)
{
@@ -80250,12 +80166,10 @@ void Graphics::drawImageAt (const Image* const imageToDraw,
}

void Graphics::drawImageWithin (const Image* const imageToDraw,
const int destX,
const int destY,
const int destW,
const int destH,
const int destX, const int destY,
const int destW, const int destH,
const RectanglePlacement& placementWithinTarget,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH));
@@ -80289,7 +80203,7 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
void Graphics::drawImage (const Image* const imageToDraw,
int dx, int dy, int dw, int dh,
int sx, int sy, int sw, int sh,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (dx, dy, dw, dh));
@@ -80307,7 +80221,7 @@ void Graphics::drawImage (const Image* const imageToDraw,
void Graphics::drawImageTransformed (const Image* const imageToDraw,
const Rectangle<int>& imageSubRegion,
const AffineTransform& transform,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
if (imageToDraw != 0 && ! context->isClipEmpty())
{
@@ -83105,8 +83019,8 @@ END_JUCE_NAMESPACE
BEGIN_JUCE_NAMESPACE

DrawablePath::DrawablePath()
: mainFill (FillType (Colours::black)),
strokeFill (FillType (Colours::transparentBlack)),
: mainFill (Colours::black),
strokeFill (Colours::transparentBlack),
strokeType (0.0f)
{
}
@@ -83205,8 +83119,8 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
if (type.equalsIgnoreCase ("solid"))
{
const String colour (v ["colour"].toString());
return FillType (Colour (colour.isEmpty() ? (uint32) 0xff000000
: (uint32) colour.getHexValue32()));
return Colour (colour.isEmpty() ? (uint32) 0xff000000
: (uint32) colour.getHexValue32());
}
else if (type.equalsIgnoreCase ("gradient"))
{
@@ -83224,7 +83138,7 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
g.addColour (colours[i * 2].getDoubleValue(),
Colour ((uint32) colours[i * 2 + 1].getHexValue32()));

return FillType (g);
return g;
}

jassertfalse
@@ -83977,7 +83891,7 @@ private:

DrawablePath* dp = new DrawablePath();
dp->setName (xml.getStringAttribute ("id"));
dp->setFill (FillType (Colours::transparentBlack));
dp->setFill (Colours::transparentBlack);

path.applyTransform (transform);
dp->setPath (path);


+ 83
- 97
juce_amalgamated.h View File

@@ -9945,6 +9945,16 @@ public:
{
}

Rectangle (const Point<ValueType>& corner1, const Point<ValueType>& corner2) throw()
: x (jmin (corner1.getX(), corner2.getX())),
y (jmin (corner1.getY(), corner2.getY())),
w (corner1.getX() - corner2.getX()),
h (corner1.getY() - corner2.getY())
{
if (w < 0) w = -w;
if (h < 0) h = -h;
}

Rectangle& operator= (const Rectangle& other) throw()
{
x = other.x; y = other.y;
@@ -11911,140 +11921,126 @@ class JUCE_API Graphics
{
public:

explicit Graphics (Image& imageToDrawOnto) throw();
explicit Graphics (Image& imageToDrawOnto);

~Graphics() throw();
~Graphics();

void setColour (const Colour& newColour) throw();
void setColour (const Colour& newColour);

void setOpacity (const float newOpacity) throw();
void setOpacity (const float newOpacity);

void setGradientFill (const ColourGradient& gradient) throw();
void setGradientFill (const ColourGradient& gradient);

void setTiledImageFill (const Image& imageToUse,
int anchorX,
int anchorY,
float opacity) throw();
int anchorX, int anchorY,
float opacity);

void setFillType (const FillType& newFill) throw();
void setFillType (const FillType& newFill);

void setFont (const Font& newFont) throw();
void setFont (const Font& newFont);

void setFont (float newFontHeight,
int fontStyleFlags = Font::plain) throw();
void setFont (float newFontHeight, int fontStyleFlags = Font::plain);

void drawSingleLineText (const String& text,
int startX, int baselineY) const throw();
int startX, int baselineY) const;

void drawMultiLineText (const String& text,
int startX, int baselineY,
int maximumLineWidth) const throw();
int maximumLineWidth) const;

void drawTextAsPath (const String& text,
const AffineTransform& transform) const throw();
const AffineTransform& transform) const;

void drawText (const String& text,
int x, int y, int width, int height,
const Justification& justificationType,
bool useEllipsesIfTooBig) const throw();
bool useEllipsesIfTooBig) const;

void drawFittedText (const String& text,
int x, int y, int width, int height,
const Justification& justificationFlags,
int maximumNumberOfLines,
float minimumHorizontalScale = 0.7f) const throw();
float minimumHorizontalScale = 0.7f) const;

void fillAll() const throw();
void fillAll() const;

void fillAll (const Colour& colourToUse) const throw();
void fillAll (const Colour& colourToUse) const;

void fillRect (int x, int y, int width, int height) const throw();
void fillRect (int x, int y, int width, int height) const;

void fillRect (const Rectangle<int>& rectangle) const throw();
void fillRect (const Rectangle<int>& rectangle) const;

void fillRect (float x, float y, float width, float height) const throw();
void fillRect (float x, float y, float width, float height) const;

void fillRoundedRectangle (float x, float y, float width, float height,
float cornerSize) const throw();
float cornerSize) const;

void fillRoundedRectangle (const Rectangle<int>& rectangle,
float cornerSize) const throw();
void fillRoundedRectangle (const Rectangle<float>& rectangle,
float cornerSize) const;

void fillCheckerBoard (int x, int y, int width, int height,
int checkWidth, int checkHeight,
const Colour& colour1, const Colour& colour2) const throw();
const Colour& colour1, const Colour& colour2) const;

void drawRect (int x, int y, int width, int height,
int lineThickness = 1) const throw();
int lineThickness = 1) const;

void drawRect (float x, float y, float width, float height,
float lineThickness = 1.0f) const throw();
float lineThickness = 1.0f) const;

void drawRect (const Rectangle<int>& rectangle,
int lineThickness = 1) const throw();
int lineThickness = 1) const;

void drawRoundedRectangle (float x, float y, float width, float height,
float cornerSize, float lineThickness) const throw();
float cornerSize, float lineThickness) const;

void drawRoundedRectangle (const Rectangle<int>& rectangle,
float cornerSize, float lineThickness) const throw();
void drawRoundedRectangle (const Rectangle<float>& rectangle,
float cornerSize, float lineThickness) const;

void drawBevel (int x, int y, int width, int height,
int bevelThickness,
const Colour& topLeftColour = Colours::white,
const Colour& bottomRightColour = Colours::black,
bool useGradient = true,
bool sharpEdgeOnOutside = true) const throw();
bool sharpEdgeOnOutside = true) const;

void setPixel (int x, int y) const throw();
void setPixel (int x, int y) const;

void fillEllipse (float x, float y, float width, float height) const throw();
void fillEllipse (float x, float y, float width, float height) const;

void drawEllipse (float x, float y, float width, float height,
float lineThickness) const throw();
float lineThickness) const;

void drawLine (float startX,
float startY,
float endX,
float endY) const throw();
void drawLine (float startX, float startY, float endX, float endY) const;

void drawLine (float startX,
float startY,
float endX,
float endY,
float lineThickness) const throw();
void drawLine (float startX, float startY, float endX, float endY,
float lineThickness) const;

void drawLine (const Line& line) const throw();
void drawLine (const Line& line) const;

void drawLine (const Line& line,
float lineThickness) const throw();
void drawLine (const Line& line, float lineThickness) const;

void drawDashedLine (float startX,
float startY,
float endX,
float endY,
const float* dashLengths,
int numDashLengths,
float lineThickness = 1.0f) const throw();
void drawDashedLine (float startX, float startY,
float endX, float endY,
const float* dashLengths, int numDashLengths,
float lineThickness = 1.0f) const;

void drawVerticalLine (int x, float top, float bottom) const throw();
void drawVerticalLine (int x, float top, float bottom) const;

void drawHorizontalLine (int y, float left, float right) const throw();
void drawHorizontalLine (int y, float left, float right) const;

void fillPath (const Path& path,
const AffineTransform& transform = AffineTransform::identity) const throw();
const AffineTransform& transform = AffineTransform::identity) const;

void strokePath (const Path& path,
const PathStrokeType& strokeType,
const AffineTransform& transform = AffineTransform::identity) const throw();
const AffineTransform& transform = AffineTransform::identity) const;

void drawArrow (float startX,
float startY,
float endX,
float endY,
void drawArrow (float startX, float startY,
float endX, float endY,
float lineThickness,
float arrowheadWidth,
float arrowheadLength) const throw();
float arrowheadLength) const;

enum ResamplingQuality
{
@@ -12053,59 +12049,52 @@ public:
highResamplingQuality = 2 /**< Uses bicubic interpolation for upsampling and area-averaging for downsampling. */
};

void setImageResamplingQuality (const ResamplingQuality newQuality) throw();
void setImageResamplingQuality (const ResamplingQuality newQuality);

void drawImageAt (const Image* const imageToDraw,
int topLeftX, int topLeftY,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
void drawImageAt (const Image* const imageToDraw, int topLeftX, int topLeftY,
bool fillAlphaChannelWithCurrentBrush = false) const;

void drawImage (const Image* const imageToDraw,
int destX,
int destY,
int destWidth,
int destHeight,
int sourceX,
int sourceY,
int sourceWidth,
int sourceHeight,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
int destX, int destY, int destWidth, int destHeight,
int sourceX, int sourceY, int sourceWidth, int sourceHeight,
bool fillAlphaChannelWithCurrentBrush = false) const;

void drawImageTransformed (const Image* imageToDraw,
const Rectangle<int>& imageSubRegion,
const AffineTransform& transform,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
bool fillAlphaChannelWithCurrentBrush = false) const;

void drawImageWithin (const Image* imageToDraw,
int destX, int destY, int destWidth, int destHeight,
const RectanglePlacement& placementWithinTarget,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
bool fillAlphaChannelWithCurrentBrush = false) const;

const Rectangle<int> getClipBounds() const throw();
const Rectangle<int> getClipBounds() const;

bool clipRegionIntersects (int x, int y, int width, int height) const throw();
bool clipRegionIntersects (int x, int y, int width, int height) const;

bool reduceClipRegion (int x, int y, int width, int height) throw();
bool reduceClipRegion (int x, int y, int width, int height);

bool reduceClipRegion (const RectangleList& clipRegion) throw();
bool reduceClipRegion (const RectangleList& clipRegion);

bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity) throw();
bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity);

bool reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion,
const AffineTransform& transform) throw();
const AffineTransform& transform);

void excludeClipRegion (const Rectangle<int>& rectangleToExclude) throw();
void excludeClipRegion (const Rectangle<int>& rectangleToExclude);

bool isClipEmpty() const throw();
bool isClipEmpty() const;

void saveState() throw();
void saveState();

void restoreState() throw();
void restoreState();

void setOrigin (int newOriginX, int newOriginY) throw();
void setOrigin (int newOriginX, int newOriginY);

void resetToDefaultState() throw();
void resetToDefaultState();

bool isVectorDevice() const throw();
bool isVectorDevice() const;

juce_UseDebuggingNewOperator

@@ -12119,7 +12108,7 @@ private:
ScopedPointer <LowLevelGraphicsContext> contextToDelete;

bool saveStatePending;
void saveStateIfPending() throw();
void saveStateIfPending();

Graphics (const Graphics&);
Graphics& operator= (const Graphics& other);
@@ -25630,10 +25619,7 @@ public:
{
if (source != 0)
{
const int x1 = e.getMouseDownX();
const int y1 = e.getMouseDownY();

setBounds (jmin (x1, e.x), jmin (y1, e.y), abs (e.x - x1), abs (e.y - y1));
setBounds (Rectangle<int> (e.getMouseDownPosition(), e.getPosition()));
setVisible (true);

Array <SelectableItemType> itemsInLasso;


+ 1
- 4
src/gui/components/mouse/juce_LassoComponent.h View File

@@ -159,10 +159,7 @@ public:
{
if (source != 0)
{
const int x1 = e.getMouseDownX();
const int y1 = e.getMouseDownY();
setBounds (jmin (x1, e.x), jmin (y1, e.y), abs (e.x - x1), abs (e.y - y1));
setBounds (Rectangle<int> (e.getMouseDownPosition(), e.getPosition()));
setVisible (true);
Array <SelectableItemType> itemsInLasso;


+ 92
- 179
src/gui/graphics/contexts/juce_Graphics.cpp View File

@@ -56,7 +56,7 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext()
}
//==============================================================================
Graphics::Graphics (Image& imageToDrawOnto) throw()
Graphics::Graphics (Image& imageToDrawOnto)
: context (imageToDrawOnto.createLowLevelContext()),
contextToDelete (context),
saveStatePending (false)
@@ -69,12 +69,12 @@ Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw()
{
}
Graphics::~Graphics() throw()
Graphics::~Graphics()
{
}
//==============================================================================
void Graphics::resetToDefaultState() throw()
void Graphics::resetToDefaultState()
{
saveStateIfPending();
context->setFill (FillType());
@@ -82,61 +82,60 @@ void Graphics::resetToDefaultState() throw()
context->setInterpolationQuality (defaultQuality);
}
bool Graphics::isVectorDevice() const throw()
bool Graphics::isVectorDevice() const
{
return context->isVectorDevice();
}
bool Graphics::reduceClipRegion (const int x, const int y,
const int w, const int h) throw()
bool Graphics::reduceClipRegion (const int x, const int y, const int w, const int h)
{
saveStateIfPending();
return context->clipToRectangle (Rectangle<int> (x, y, w, h));
}
bool Graphics::reduceClipRegion (const RectangleList& clipRegion) throw()
bool Graphics::reduceClipRegion (const RectangleList& clipRegion)
{
saveStateIfPending();
return context->clipToRectangleList (clipRegion);
}
bool Graphics::reduceClipRegion (const Path& path, const AffineTransform& transform) throw()
bool Graphics::reduceClipRegion (const Path& path, const AffineTransform& transform)
{
saveStateIfPending();
context->clipToPath (path, transform);
return ! context->isClipEmpty();
}
bool Graphics::reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion, const AffineTransform& transform) throw()
bool Graphics::reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion, const AffineTransform& transform)
{
saveStateIfPending();
context->clipToImageAlpha (image, sourceClipRegion, transform);
return ! context->isClipEmpty();
}
void Graphics::excludeClipRegion (const Rectangle<int>& rectangleToExclude) throw()
void Graphics::excludeClipRegion (const Rectangle<int>& rectangleToExclude)
{
saveStateIfPending();
context->excludeClipRectangle (rectangleToExclude);
}
bool Graphics::isClipEmpty() const throw()
bool Graphics::isClipEmpty() const
{
return context->isClipEmpty();
}
const Rectangle<int> Graphics::getClipBounds() const throw()
const Rectangle<int> Graphics::getClipBounds() const
{
return context->getClipBounds();
}
void Graphics::saveState() throw()
void Graphics::saveState()
{
saveStateIfPending();
saveStatePending = true;
}
void Graphics::restoreState() throw()
void Graphics::restoreState()
{
if (saveStatePending)
saveStatePending = false;
@@ -144,7 +143,7 @@ void Graphics::restoreState() throw()
context->restoreState();
}
void Graphics::saveStateIfPending() throw()
void Graphics::saveStateIfPending()
{
if (saveStatePending)
{
@@ -153,63 +152,56 @@ void Graphics::saveStateIfPending() throw()
}
}
void Graphics::setOrigin (const int newOriginX,
const int newOriginY) throw()
void Graphics::setOrigin (const int newOriginX, const int newOriginY)
{
saveStateIfPending();
context->setOrigin (newOriginX, newOriginY);
}
bool Graphics::clipRegionIntersects (const int x, const int y,
const int w, const int h) const throw()
bool Graphics::clipRegionIntersects (const int x, const int y, const int w, const int h) const
{
return context->clipRegionIntersects (Rectangle<int> (x, y, w, h));
}
//==============================================================================
void Graphics::setColour (const Colour& newColour) throw()
void Graphics::setColour (const Colour& newColour)
{
saveStateIfPending();
context->setFill (FillType (newColour));
context->setFill (newColour);
}
void Graphics::setOpacity (const float newOpacity) throw()
void Graphics::setOpacity (const float newOpacity)
{
saveStateIfPending();
context->setOpacity (newOpacity);
}
void Graphics::setGradientFill (const ColourGradient& gradient) throw()
void Graphics::setGradientFill (const ColourGradient& gradient)
{
saveStateIfPending();
context->setFill (FillType (gradient));
setFillType (gradient);
}
void Graphics::setTiledImageFill (const Image& imageToUse,
const int anchorX,
const int anchorY,
const float opacity) throw()
void Graphics::setTiledImageFill (const Image& imageToUse, const int anchorX, const int anchorY, const float opacity)
{
saveStateIfPending();
context->setFill (FillType (imageToUse, AffineTransform::translation ((float) anchorX, (float) anchorY)));
context->setOpacity (opacity);
}
void Graphics::setFillType (const FillType& newFill) throw()
void Graphics::setFillType (const FillType& newFill)
{
saveStateIfPending();
context->setFill (newFill);
}
//==============================================================================
void Graphics::setFont (const Font& newFont) throw()
void Graphics::setFont (const Font& newFont)
{
saveStateIfPending();
context->setFont (newFont);
}
void Graphics::setFont (const float newFontHeight,
const int newFontStyleFlags) throw()
void Graphics::setFont (const float newFontHeight, const int newFontStyleFlags)
{
saveStateIfPending();
Font f (context->getFont());
@@ -218,9 +210,7 @@ void Graphics::setFont (const float newFontHeight,
}
//==============================================================================
void Graphics::drawSingleLineText (const String& text,
const int startX,
const int baselineY) const throw()
void Graphics::drawSingleLineText (const String& text, const int startX, const int baselineY) const
{
if (text.isNotEmpty()
&& startX < context->getClipBounds().getRight())
@@ -231,8 +221,7 @@ void Graphics::drawSingleLineText (const String& text,
}
}
void Graphics::drawTextAsPath (const String& text,
const AffineTransform& transform) const throw()
void Graphics::drawTextAsPath (const String& text, const AffineTransform& transform) const
{
if (text.isNotEmpty())
{
@@ -242,10 +231,7 @@ void Graphics::drawTextAsPath (const String& text,
}
}
void Graphics::drawMultiLineText (const String& text,
const int startX,
const int baselineY,
const int maximumLineWidth) const throw()
void Graphics::drawMultiLineText (const String& text, const int startX, const int baselineY, const int maximumLineWidth) const
{
if (text.isNotEmpty()
&& startX < context->getClipBounds().getRight())
@@ -259,37 +245,30 @@ void Graphics::drawMultiLineText (const String& text,
}
void Graphics::drawText (const String& text,
const int x,
const int y,
const int width,
const int height,
const int x, const int y, const int width, const int height,
const Justification& justificationType,
const bool useEllipsesIfTooBig) const throw()
const bool useEllipsesIfTooBig) const
{
if (text.isNotEmpty() && context->clipRegionIntersects (Rectangle<int> (x, y, width, height)))
{
GlyphArrangement arr;
arr.addCurtailedLineOfText (context->getFont(), text,
0.0f, 0.0f, (float)width,
0.0f, 0.0f, (float) width,
useEllipsesIfTooBig);
arr.justifyGlyphs (0, arr.getNumGlyphs(),
(float) x, (float) y,
(float) width, (float) height,
(float) x, (float) y, (float) width, (float) height,
justificationType);
arr.draw (*this);
}
}
void Graphics::drawFittedText (const String& text,
const int x,
const int y,
const int width,
const int height,
const int x, const int y, const int width, const int height,
const Justification& justification,
const int maximumNumberOfLines,
const float minimumHorizontalScale) const throw()
const float minimumHorizontalScale) const
{
if (text.isNotEmpty()
&& width > 0 && height > 0
@@ -298,8 +277,7 @@ void Graphics::drawFittedText (const String& text,
GlyphArrangement arr;
arr.addFittedText (context->getFont(), text,
(float) x, (float) y,
(float) width, (float) height,
(float) x, (float) y, (float) width, (float) height,
justification,
maximumNumberOfLines,
minimumHorizontalScale);
@@ -309,10 +287,7 @@ void Graphics::drawFittedText (const String& text,
}
//==============================================================================
void Graphics::fillRect (int x,
int y,
int width,
int height) const throw()
void Graphics::fillRect (int x, int y, int width, int height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -320,15 +295,12 @@ void Graphics::fillRect (int x,
context->fillRect (Rectangle<int> (x, y, width, height), false);
}
void Graphics::fillRect (const Rectangle<int>& r) const throw()
void Graphics::fillRect (const Rectangle<int>& r) const
{
context->fillRect (r, false);
}
void Graphics::fillRect (const float x,
const float y,
const float width,
const float height) const throw()
void Graphics::fillRect (const float x, const float y, const float width, const float height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -338,24 +310,24 @@ void Graphics::fillRect (const float x,
fillPath (p);
}
void Graphics::setPixel (int x, int y) const throw()
void Graphics::setPixel (int x, int y) const
{
context->fillRect (Rectangle<int> (x, y, 1, 1), false);
}
void Graphics::fillAll() const throw()
void Graphics::fillAll() const
{
fillRect (context->getClipBounds());
}
void Graphics::fillAll (const Colour& colourToUse) const throw()
void Graphics::fillAll (const Colour& colourToUse) const
{
if (! colourToUse.isTransparent())
{
const Rectangle<int> clip (context->getClipBounds());
context->saveState();
context->setFill (FillType (colourToUse));
context->setFill (colourToUse);
context->fillRect (clip, false);
context->restoreState();
}
@@ -363,8 +335,7 @@ void Graphics::fillAll (const Colour& colourToUse) const throw()
//==============================================================================
void Graphics::fillPath (const Path& path,
const AffineTransform& transform) const throw()
void Graphics::fillPath (const Path& path, const AffineTransform& transform) const
{
if ((! context->isClipEmpty()) && ! path.isEmpty())
context->fillPath (path, transform);
@@ -372,7 +343,7 @@ void Graphics::fillPath (const Path& path,
void Graphics::strokePath (const Path& path,
const PathStrokeType& strokeType,
const AffineTransform& transform) const throw()
const AffineTransform& transform) const
{
Path stroke;
strokeType.createStrokedPath (stroke, path, transform);
@@ -380,11 +351,8 @@ void Graphics::strokePath (const Path& path,
}
//==============================================================================
void Graphics::drawRect (const int x,
const int y,
const int width,
const int height,
const int lineThickness) const throw()
void Graphics::drawRect (const int x, const int y, const int width, const int height,
const int lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -395,11 +363,7 @@ void Graphics::drawRect (const int x,
context->fillRect (Rectangle<int> (x, y + height - lineThickness, width, lineThickness), false);
}
void Graphics::drawRect (const float x,
const float y,
const float width,
const float height,
const float lineThickness) const throw()
void Graphics::drawRect (const float x, const float y, const float width, const float height, const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -412,23 +376,14 @@ void Graphics::drawRect (const float x,
fillPath (p);
}
void Graphics::drawRect (const Rectangle<int>& r,
const int lineThickness) const throw()
void Graphics::drawRect (const Rectangle<int>& r, const int lineThickness) const
{
drawRect (r.getX(), r.getY(),
r.getWidth(), r.getHeight(),
lineThickness);
drawRect (r.getX(), r.getY(), r.getWidth(), r.getHeight(), lineThickness);
}
void Graphics::drawBevel (const int x,
const int y,
const int width,
const int height,
const int bevelThickness,
const Colour& topLeftColour,
const Colour& bottomRightColour,
const bool useGradient,
const bool sharpEdgeOnOutside) const throw()
void Graphics::drawBevel (const int x, const int y, const int width, const int height,
const int bevelThickness, const Colour& topLeftColour, const Colour& bottomRightColour,
const bool useGradient, const bool sharpEdgeOnOutside) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -445,13 +400,13 @@ void Graphics::drawBevel (const int x,
const float op = useGradient ? ramp * (sharpEdgeOnOutside ? bevelThickness - i : i)
: oldOpacity;
context->setFill (FillType (topLeftColour.withMultipliedAlpha (op)));
context->setFill (topLeftColour.withMultipliedAlpha (op));
context->fillRect (Rectangle<int> (x + i, y + i, width - i * 2, 1), false);
context->setFill (FillType (topLeftColour.withMultipliedAlpha (op * 0.75f)));
context->setFill (topLeftColour.withMultipliedAlpha (op * 0.75f));
context->fillRect (Rectangle<int> (x + i, y + i + 1, 1, height - i * 2 - 2), false);
context->setFill (FillType (bottomRightColour.withMultipliedAlpha (op)));
context->setFill (bottomRightColour.withMultipliedAlpha (op));
context->fillRect (Rectangle<int> (x + i, y + height - i - 1, width - i * 2, 1), false);
context->setFill (FillType (bottomRightColour.withMultipliedAlpha (op * 0.75f)));
context->setFill (bottomRightColour.withMultipliedAlpha (op * 0.75f));
context->fillRect (Rectangle<int> (x + width - i - 1, y + i + 1, 1, height - i * 2 - 2), false);
}
@@ -460,10 +415,7 @@ void Graphics::drawBevel (const int x,
}
//==============================================================================
void Graphics::fillEllipse (const float x,
const float y,
const float width,
const float height) const throw()
void Graphics::fillEllipse (const float x, const float y, const float width, const float height) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -473,11 +425,8 @@ void Graphics::fillEllipse (const float x,
fillPath (p);
}
void Graphics::drawEllipse (const float x,
const float y,
const float width,
const float height,
const float lineThickness) const throw()
void Graphics::drawEllipse (const float x, const float y, const float width, const float height,
const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -487,11 +436,7 @@ void Graphics::drawEllipse (const float x,
strokePath (p, PathStrokeType (lineThickness));
}
void Graphics::fillRoundedRectangle (const float x,
const float y,
const float width,
const float height,
const float cornerSize) const throw()
void Graphics::fillRoundedRectangle (const float x, const float y, const float width, const float height, const float cornerSize) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -501,22 +446,13 @@ void Graphics::fillRoundedRectangle (const float x,
fillPath (p);
}
void Graphics::fillRoundedRectangle (const Rectangle<int>& r,
const float cornerSize) const throw()
void Graphics::fillRoundedRectangle (const Rectangle<float>& r, const float cornerSize) const
{
fillRoundedRectangle ((float) r.getX(),
(float) r.getY(),
(float) r.getWidth(),
(float) r.getHeight(),
cornerSize);
fillRoundedRectangle (r.getX(), r.getY(), r.getWidth(), r.getHeight(), cornerSize);
}
void Graphics::drawRoundedRectangle (const float x,
const float y,
const float width,
const float height,
const float cornerSize,
const float lineThickness) const throw()
void Graphics::drawRoundedRectangle (const float x, const float y, const float width, const float height,
const float cornerSize, const float lineThickness) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (x, y, width, height));
@@ -526,25 +462,13 @@ void Graphics::drawRoundedRectangle (const float x,
strokePath (p, PathStrokeType (lineThickness));
}
void Graphics::drawRoundedRectangle (const Rectangle<int>& r,
const float cornerSize,
const float lineThickness) const throw()
void Graphics::drawRoundedRectangle (const Rectangle<float>& r, const float cornerSize, const float lineThickness) const
{
drawRoundedRectangle ((float) r.getX(),
(float) r.getY(),
(float) r.getWidth(),
(float) r.getHeight(),
cornerSize, lineThickness);
drawRoundedRectangle (r.getX(), r.getY(), r.getWidth(), r.getHeight(), cornerSize, lineThickness);
}
void Graphics::drawArrow (const float startX,
const float startY,
const float endX,
const float endY,
const float lineThickness,
const float arrowheadWidth,
const float arrowheadLength) const throw()
void Graphics::drawArrow (const float startX, const float startY, const float endX, const float endY,
const float lineThickness, const float arrowheadWidth, const float arrowheadLength) const
{
Path p;
p.addArrow (startX, startY, endX, endY,
@@ -552,12 +476,9 @@ void Graphics::drawArrow (const float startX,
fillPath (p);
}
void Graphics::fillCheckerBoard (int x, int y,
int width, int height,
const int checkWidth,
const int checkHeight,
const Colour& colour1,
const Colour& colour2) const throw()
void Graphics::fillCheckerBoard (int x, int y, int width, int height,
const int checkWidth, const int checkHeight,
const Colour& colour1, const Colour& colour2) const
{
jassert (checkWidth > 0 && checkHeight > 0); // can't be zero or less!
@@ -567,7 +488,7 @@ void Graphics::fillCheckerBoard (int x, int y,
if (colour1 == colour2)
{
context->setFill (FillType (colour1));
context->setFill (colour1);
context->fillRect (Rectangle<int> (x, y, width, height), false);
}
else
@@ -584,7 +505,7 @@ void Graphics::fillCheckerBoard (int x, int y,
for (int xx = x; xx < right; xx += checkWidth)
{
context->setFill (FillType (((cx++ & 1) == 0) ? colour1 : colour2));
context->setFill (((cx++ & 1) == 0) ? colour1 : colour2);
context->fillRect (Rectangle<int> (xx, y, jmin (checkWidth, right - xx), jmin (checkHeight, bottom - y)),
false);
}
@@ -599,50 +520,45 @@ void Graphics::fillCheckerBoard (int x, int y,
}
//==============================================================================
void Graphics::drawVerticalLine (const int x, float top, float bottom) const throw()
void Graphics::drawVerticalLine (const int x, float top, float bottom) const
{
context->drawVerticalLine (x, top, bottom);
}
void Graphics::drawHorizontalLine (const int y, float left, float right) const throw()
void Graphics::drawHorizontalLine (const int y, float left, float right) const
{
context->drawHorizontalLine (y, left, right);
}
void Graphics::drawLine (float x1, float y1, float x2, float y2) const throw()
void Graphics::drawLine (float x1, float y1, float x2, float y2) const
{
context->drawLine (x1, y1, x2, y2);
}
void Graphics::drawLine (const float startX,
const float startY,
const float endX,
const float endY,
const float lineThickness) const throw()
void Graphics::drawLine (const float startX, const float startY,
const float endX, const float endY,
const float lineThickness) const
{
Path p;
p.addLineSegment (startX, startY, endX, endY, lineThickness);
fillPath (p);
}
void Graphics::drawLine (const Line& line) const throw()
void Graphics::drawLine (const Line& line) const
{
drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY());
}
void Graphics::drawLine (const Line& line,
const float lineThickness) const throw()
void Graphics::drawLine (const Line& line, const float lineThickness) const
{
drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY(), lineThickness);
}
void Graphics::drawDashedLine (const float startX,
const float startY,
const float endX,
const float endY,
void Graphics::drawDashedLine (const float startX, const float startY,
const float endX, const float endY,
const float* const dashLengths,
const int numDashLengths,
const float lineThickness) const throw()
const float lineThickness) const
{
const double dx = endX - startX;
const double dy = endY - startY;
@@ -680,7 +596,7 @@ void Graphics::drawDashedLine (const float startX,
}
//==============================================================================
void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQuality) throw()
void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQuality)
{
saveStateIfPending();
context->setInterpolationQuality (newQuality);
@@ -688,9 +604,8 @@ void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQ
//==============================================================================
void Graphics::drawImageAt (const Image* const imageToDraw,
const int topLeftX,
const int topLeftY,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const int topLeftX, const int topLeftY,
const bool fillAlphaChannelWithCurrentBrush) const
{
if (imageToDraw != 0)
{
@@ -705,12 +620,10 @@ void Graphics::drawImageAt (const Image* const imageToDraw,
}
void Graphics::drawImageWithin (const Image* const imageToDraw,
const int destX,
const int destY,
const int destW,
const int destH,
const int destX, const int destY,
const int destW, const int destH,
const RectanglePlacement& placementWithinTarget,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH));
@@ -744,7 +657,7 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
void Graphics::drawImage (const Image* const imageToDraw,
int dx, int dy, int dw, int dh,
int sx, int sy, int sw, int sh,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
// passing in a silly number can cause maths problems in rendering!
jassert (areCoordsSensibleNumbers (dx, dy, dw, dh));
@@ -762,7 +675,7 @@ void Graphics::drawImage (const Image* const imageToDraw,
void Graphics::drawImageTransformed (const Image* const imageToDraw,
const Rectangle<int>& imageSubRegion,
const AffineTransform& transform,
const bool fillAlphaChannelWithCurrentBrush) const throw()
const bool fillAlphaChannelWithCurrentBrush) const
{
if (imageToDraw != 0 && ! context->isClipEmpty())
{


+ 72
- 95
src/gui/graphics/contexts/juce_Graphics.h View File

@@ -64,10 +64,10 @@ public:
Obviously you shouldn't delete the image before this context is deleted.
*/
explicit Graphics (Image& imageToDrawOnto) throw();
explicit Graphics (Image& imageToDrawOnto);
/** Destructor. */
~Graphics() throw();
~Graphics();
//==============================================================================
/** Changes the current drawing colour.
@@ -80,7 +80,7 @@ public:
@see setOpacity
*/
void setColour (const Colour& newColour) throw();
void setColour (const Colour& newColour);
/** Changes the opacity to use with the current colour.
@@ -91,25 +91,24 @@ public:
A value of 0.0 is completely transparent, 1.0 is completely opaque.
*/
void setOpacity (const float newOpacity) throw();
void setOpacity (const float newOpacity);
/** Sets the context to use a gradient for its fill pattern.
*/
void setGradientFill (const ColourGradient& gradient) throw();
void setGradientFill (const ColourGradient& gradient);
/** Sets the context to use a tiled image pattern for filling.
Make sure that you don't delete this image while it's still being used by
this context!
*/
void setTiledImageFill (const Image& imageToUse,
int anchorX,
int anchorY,
float opacity) throw();
int anchorX, int anchorY,
float opacity);
/** Changes the current fill settings.
@see setColour, setGradientFill, setTiledImageFill
*/
void setFillType (const FillType& newFill) throw();
void setFillType (const FillType& newFill);
//==============================================================================
/** Changes the font to use for subsequent text-drawing functions.
@@ -119,7 +118,7 @@ public:
@see drawSingleLineText, drawMultiLineText, drawTextAsPath, drawText, drawFittedText
*/
void setFont (const Font& newFont) throw();
void setFont (const Font& newFont);
/** Changes the size and style of the currently-selected font.
@@ -128,8 +127,7 @@ public:
@see Font
*/
void setFont (float newFontHeight,
int fontStyleFlags = Font::plain) throw();
void setFont (float newFontHeight, int fontStyleFlags = Font::plain);
/** Draws a one-line text string.
@@ -142,7 +140,7 @@ public:
@see drawMultiLineText, drawText, drawFittedText, GlyphArrangement::addLineOfText
*/
void drawSingleLineText (const String& text,
int startX, int baselineY) const throw();
int startX, int baselineY) const;
/** Draws text across multiple lines.
@@ -154,7 +152,7 @@ public:
*/
void drawMultiLineText (const String& text,
int startX, int baselineY,
int maximumLineWidth) const throw();
int maximumLineWidth) const;
/** Renders a string of text as a vector path.
@@ -165,7 +163,7 @@ public:
@see setFont
*/
void drawTextAsPath (const String& text,
const AffineTransform& transform) const throw();
const AffineTransform& transform) const;
/** Draws a line of text within a specified rectangle.
@@ -179,7 +177,7 @@ public:
void drawText (const String& text,
int x, int y, int width, int height,
const Justification& justificationType,
bool useEllipsesIfTooBig) const throw();
bool useEllipsesIfTooBig) const;
/** Tries to draw a text string inside a given space.
@@ -204,7 +202,7 @@ public:
int x, int y, int width, int height,
const Justification& justificationFlags,
int maximumNumberOfLines,
float minimumHorizontalScale = 0.7f) const throw();
float minimumHorizontalScale = 0.7f) const;
//==============================================================================
/** Fills the context's entire clip region with the current colour or brush.
@@ -212,51 +210,51 @@ public:
(See also the fillAll (const Colour&) method which is a quick way of filling
it with a given colour).
*/
void fillAll() const throw();
void fillAll() const;
/** Fills the context's entire clip region with a given colour.
This leaves the context's current colour and brush unchanged, it just
uses the specified colour temporarily.
*/
void fillAll (const Colour& colourToUse) const throw();
void fillAll (const Colour& colourToUse) const;
//==============================================================================
/** Fills a rectangle with the current colour or brush.
@see drawRect, fillRoundedRectangle
*/
void fillRect (int x, int y, int width, int height) const throw();
void fillRect (int x, int y, int width, int height) const;
/** Fills a rectangle with the current colour or brush. */
void fillRect (const Rectangle<int>& rectangle) const throw();
void fillRect (const Rectangle<int>& rectangle) const;
/** Fills a rectangle with the current colour or brush.
This uses sub-pixel positioning so is slower than the fillRect method which
takes integer co-ordinates.
*/
void fillRect (float x, float y, float width, float height) const throw();
void fillRect (float x, float y, float width, float height) const;
/** Uses the current colour or brush to fill a rectangle with rounded corners.
@see drawRoundedRectangle, Path::addRoundedRectangle
*/
void fillRoundedRectangle (float x, float y, float width, float height,
float cornerSize) const throw();
float cornerSize) const;
/** Uses the current colour or brush to fill a rectangle with rounded corners.
@see drawRoundedRectangle, Path::addRoundedRectangle
*/
void fillRoundedRectangle (const Rectangle<int>& rectangle,
float cornerSize) const throw();
void fillRoundedRectangle (const Rectangle<float>& rectangle,
float cornerSize) const;
/** Fills a rectangle with a checkerboard pattern, alternating between two colours.
*/
void fillCheckerBoard (int x, int y, int width, int height,
int checkWidth, int checkHeight,
const Colour& colour1, const Colour& colour2) const throw();
const Colour& colour1, const Colour& colour2) const;
/** Draws four lines to form a rectangular outline, using the current colour or brush.
@@ -266,7 +264,7 @@ public:
@see fillRect
*/
void drawRect (int x, int y, int width, int height,
int lineThickness = 1) const throw();
int lineThickness = 1) const;
/** Draws four lines to form a rectangular outline, using the current colour or brush.
@@ -276,7 +274,7 @@ public:
@see fillRect
*/
void drawRect (float x, float y, float width, float height,
float lineThickness = 1.0f) const throw();
float lineThickness = 1.0f) const;
/** Draws four lines to form a rectangular outline, using the current colour or brush.
@@ -286,21 +284,21 @@ public:
@see fillRect
*/
void drawRect (const Rectangle<int>& rectangle,
int lineThickness = 1) const throw();
int lineThickness = 1) const;
/** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.
@see fillRoundedRectangle, Path::addRoundedRectangle
*/
void drawRoundedRectangle (float x, float y, float width, float height,
float cornerSize, float lineThickness) const throw();
float cornerSize, float lineThickness) const;
/** Uses the current colour or brush to draw the outline of a rectangle with rounded corners.
@see fillRoundedRectangle, Path::addRoundedRectangle
*/
void drawRoundedRectangle (const Rectangle<int>& rectangle,
float cornerSize, float lineThickness) const throw();
void drawRoundedRectangle (const Rectangle<float>& rectangle,
float cornerSize, float lineThickness) const;
/** Draws a 3D raised (or indented) bevel using two colours.
@@ -321,11 +319,11 @@ public:
const Colour& topLeftColour = Colours::white,
const Colour& bottomRightColour = Colours::black,
bool useGradient = true,
bool sharpEdgeOnOutside = true) const throw();
bool sharpEdgeOnOutside = true) const;
/** Draws a pixel using the current colour or brush.
*/
void setPixel (int x, int y) const throw();
void setPixel (int x, int y) const;
//==============================================================================
/** Fills an ellipse with the current colour or brush.
@@ -334,47 +332,40 @@ public:
@see drawEllipse, Path::addEllipse
*/
void fillEllipse (float x, float y, float width, float height) const throw();
void fillEllipse (float x, float y, float width, float height) const;
/** Draws an elliptical stroke using the current colour or brush.
@see fillEllipse, Path::addEllipse
*/
void drawEllipse (float x, float y, float width, float height,
float lineThickness) const throw();
float lineThickness) const;
//==============================================================================
/** Draws a line between two points.
The line is 1 pixel wide and drawn with the current colour or brush.
*/
void drawLine (float startX,
float startY,
float endX,
float endY) const throw();
void drawLine (float startX, float startY, float endX, float endY) const;
/** Draws a line between two points with a given thickness.
@see Path::addLineSegment
*/
void drawLine (float startX,
float startY,
float endX,
float endY,
float lineThickness) const throw();
void drawLine (float startX, float startY, float endX, float endY,
float lineThickness) const;
/** Draws a line between two points.
The line is 1 pixel wide and drawn with the current colour or brush.
*/
void drawLine (const Line& line) const throw();
void drawLine (const Line& line) const;
/** Draws a line between two points with a given thickness.
@see Path::addLineSegment
*/
void drawLine (const Line& line,
float lineThickness) const throw();
void drawLine (const Line& line, float lineThickness) const;
/** Draws a dashed line using a custom set of dash-lengths.
@@ -389,39 +380,36 @@ public:
@param lineThickness the thickness of the line to draw
@see PathStrokeType::createDashedStroke
*/
void drawDashedLine (float startX,
float startY,
float endX,
float endY,
const float* dashLengths,
int numDashLengths,
float lineThickness = 1.0f) const throw();
void drawDashedLine (float startX, float startY,
float endX, float endY,
const float* dashLengths, int numDashLengths,
float lineThickness = 1.0f) const;
/** Draws a vertical line of pixels at a given x position.
The x position is an integer, but the top and bottom of the line can be sub-pixel
positions, and these will be anti-aliased if necessary.
*/
void drawVerticalLine (int x, float top, float bottom) const throw();
void drawVerticalLine (int x, float top, float bottom) const;
/** Draws a horizontal line of pixels at a given y position.
The y position is an integer, but the left and right ends of the line can be sub-pixel
positions, and these will be anti-aliased if necessary.
*/
void drawHorizontalLine (int y, float left, float right) const throw();
void drawHorizontalLine (int y, float left, float right) const;
//==============================================================================
/** Fills a path using the currently selected colour or brush.
*/
void fillPath (const Path& path,
const AffineTransform& transform = AffineTransform::identity) const throw();
const AffineTransform& transform = AffineTransform::identity) const;
/** Draws a path's outline using the currently selected colour or brush.
*/
void strokePath (const Path& path,
const PathStrokeType& strokeType,
const AffineTransform& transform = AffineTransform::identity) const throw();
const AffineTransform& transform = AffineTransform::identity) const;
/** Draws a line with an arrowhead.
@@ -433,13 +421,11 @@ public:
@param arrowheadWidth the width of the arrow head (perpendicular to the line)
@param arrowheadLength the length of the arrow head (along the length of the line)
*/
void drawArrow (float startX,
float startY,
float endX,
float endY,
void drawArrow (float startX, float startY,
float endX, float endY,
float lineThickness,
float arrowheadWidth,
float arrowheadLength) const throw();
float arrowheadLength) const;
//==============================================================================
@@ -460,7 +446,7 @@ public:
@see Graphics::drawImage, Graphics::drawImageTransformed, Graphics::drawImageWithin
*/
void setImageResamplingQuality (const ResamplingQuality newQuality) throw();
void setImageResamplingQuality (const ResamplingQuality newQuality);
/** Draws an image.
@@ -473,9 +459,8 @@ public:
don't want it to be drawn semi-transparently, be sure to call setOpacity (1.0f)
(or setColour() with an opaque colour) before drawing images.
*/
void drawImageAt (const Image* const imageToDraw,
int topLeftX, int topLeftY,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
void drawImageAt (const Image* const imageToDraw, int topLeftX, int topLeftY,
bool fillAlphaChannelWithCurrentBrush = false) const;
/** Draws part of an image, rescaling it to fit in a given target region.
@@ -503,15 +488,9 @@ public:
@see setImageResamplingQuality, drawImageAt, drawImageWithin, fillAlphaMap
*/
void drawImage (const Image* const imageToDraw,
int destX,
int destY,
int destWidth,
int destHeight,
int sourceX,
int sourceY,
int sourceWidth,
int sourceHeight,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
int destX, int destY, int destWidth, int destHeight,
int sourceX, int sourceY, int sourceWidth, int sourceHeight,
bool fillAlphaChannelWithCurrentBrush = false) const;
/** Draws part of an image, having applied an affine transform to it.
@@ -537,7 +516,7 @@ public:
void drawImageTransformed (const Image* imageToDraw,
const Rectangle<int>& imageSubRegion,
const AffineTransform& transform,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
bool fillAlphaChannelWithCurrentBrush = false) const;
/** Draws an image to fit within a designated rectangle.
@@ -563,7 +542,7 @@ public:
void drawImageWithin (const Image* imageToDraw,
int destX, int destY, int destWidth, int destHeight,
const RectanglePlacement& placementWithinTarget,
bool fillAlphaChannelWithCurrentBrush = false) const throw();
bool fillAlphaChannelWithCurrentBrush = false) const;
//==============================================================================
@@ -571,7 +550,7 @@ public:
@see getClipRegion, clipRegionIntersects
*/
const Rectangle<int> getClipBounds() const throw();
const Rectangle<int> getClipBounds() const;
/** Checks whether a rectangle overlaps the context's clipping region.
@@ -579,28 +558,28 @@ public:
method can be used to optimise a component's paint() method, by letting it
avoid drawing complex objects that aren't within the region being repainted.
*/
bool clipRegionIntersects (int x, int y, int width, int height) const throw();
bool clipRegionIntersects (int x, int y, int width, int height) const;
/** Intersects the current clipping region with another region.
@returns true if the resulting clipping region is non-zero in size
@see setOrigin, clipRegionIntersects
*/
bool reduceClipRegion (int x, int y, int width, int height) throw();
bool reduceClipRegion (int x, int y, int width, int height);
/** Intersects the current clipping region with a rectangle list region.
@returns true if the resulting clipping region is non-zero in size
@see setOrigin, clipRegionIntersects
*/
bool reduceClipRegion (const RectangleList& clipRegion) throw();
bool reduceClipRegion (const RectangleList& clipRegion);
/** Intersects the current clipping region with a path.
@returns true if the resulting clipping region is non-zero in size
@see reduceClipRegion
*/
bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity) throw();
bool reduceClipRegion (const Path& path, const AffineTransform& transform = AffineTransform::identity);
/** Intersects the current clipping region with an image's alpha-channel.
@@ -617,23 +596,23 @@ public:
@see reduceClipRegion
*/
bool reduceClipRegion (const Image& image, const Rectangle<int>& sourceClipRegion,
const AffineTransform& transform) throw();
const AffineTransform& transform);
/** Excludes a rectangle to stop it being drawn into. */
void excludeClipRegion (const Rectangle<int>& rectangleToExclude) throw();
void excludeClipRegion (const Rectangle<int>& rectangleToExclude);
/** Returns true if no drawing can be done because the clip region is zero. */
bool isClipEmpty() const throw();
bool isClipEmpty() const;
/** Saves the current graphics state on an internal stack.
To restore the state, use restoreState().
*/
void saveState() throw();
void saveState();
/** Restores a graphics state that was previously saved with saveState().
*/
void restoreState() throw();
void restoreState();
/** Moves the position of the context's origin.
@@ -645,21 +624,19 @@ public:
@see reduceClipRegion
*/
void setOrigin (int newOriginX, int newOriginY) throw();
void setOrigin (int newOriginX, int newOriginY);
/** Resets the current colour, brush, and font to default settings. */
void resetToDefaultState() throw();
void resetToDefaultState();
/** Returns true if this context is drawing to a vector-based device, such as a printer. */
bool isVectorDevice() const throw();
bool isVectorDevice() const;
//==============================================================================
juce_UseDebuggingNewOperator
/** Create a graphics that uses a given low-level renderer.
For internal use only.
NB. The context will NOT be deleted by this object when it is deleted.
*/
Graphics (LowLevelGraphicsContext* const internalContext) throw();
@@ -673,7 +650,7 @@ private:
ScopedPointer <LowLevelGraphicsContext> contextToDelete;
bool saveStatePending;
void saveStateIfPending() throw();
void saveStateIfPending();
Graphics (const Graphics&);
Graphics& operator= (const Graphics& other);


+ 5
- 5
src/gui/graphics/drawables/juce_DrawablePath.cpp View File

@@ -33,8 +33,8 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
DrawablePath::DrawablePath()
: mainFill (FillType (Colours::black)),
strokeFill (FillType (Colours::transparentBlack)),
: mainFill (Colours::black),
strokeFill (Colours::transparentBlack),
strokeType (0.0f)
{
}
@@ -136,8 +136,8 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
if (type.equalsIgnoreCase ("solid"))
{
const String colour (v ["colour"].toString());
return FillType (Colour (colour.isEmpty() ? (uint32) 0xff000000
: (uint32) colour.getHexValue32()));
return Colour (colour.isEmpty() ? (uint32) 0xff000000
: (uint32) colour.getHexValue32());
}
else if (type.equalsIgnoreCase ("gradient"))
{
@@ -155,7 +155,7 @@ static const FillType readFillTypeFromTree (const ValueTree& v)
g.addColour (colours[i * 2].getDoubleValue(),
Colour ((uint32) colours[i * 2 + 1].getHexValue32()));
return FillType (g);
return g;
}
jassertfalse


+ 1
- 1
src/gui/graphics/drawables/juce_SVGParser.cpp View File

@@ -610,7 +610,7 @@ private:
DrawablePath* dp = new DrawablePath();
dp->setName (xml.getStringAttribute ("id"));
dp->setFill (FillType (Colours::transparentBlack));
dp->setFill (Colours::transparentBlack);
path.applyTransform (transform);
dp->setPath (path);


+ 11
- 0
src/gui/graphics/geometry/juce_Rectangle.h View File

@@ -72,6 +72,17 @@ public:
{
}
/** Creates a Rectangle from the positions of two opposite corners. */
Rectangle (const Point<ValueType>& corner1, const Point<ValueType>& corner2) throw()
: x (jmin (corner1.getX(), corner2.getX())),
y (jmin (corner1.getY(), corner2.getY())),
w (corner1.getX() - corner2.getX()),
h (corner1.getY() - corner2.getY())
{
if (w < 0) w = -w;
if (h < 0) h = -h;
}
Rectangle& operator= (const Rectangle& other) throw()
{
x = other.x; y = other.y;


Loading…
Cancel
Save