mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
Removed methods Graphics::getCurrentFont and Graphics::getCurrentColour, because these methods will become impossible for future native drawing contexts. This required a couple of minor tweaks to LookAndFeel and Drawable methods. Also fixed native CoreGraphics drawing of transparent windows.
This commit is contained in:
parent
3c32eda726
commit
1e1c9944c9
18 changed files with 114 additions and 343 deletions
|
|
@ -213,25 +213,23 @@ public:
|
|||
}
|
||||
else if (type == 10)
|
||||
{
|
||||
g.setOpacity ((float) opacitySlider->getValue());
|
||||
|
||||
float x, y, w, h;
|
||||
drawable->getBounds (x, y, w, h);
|
||||
|
||||
drawable->draw (g, AffineTransform::translation (-x - 0.5f * w,
|
||||
-y - 0.5f * h)
|
||||
.followedBy (getTransform()));
|
||||
drawable->draw (g, (float) opacitySlider->getValue(),
|
||||
AffineTransform::translation (-x - 0.5f * w,
|
||||
-y - 0.5f * h)
|
||||
.followedBy (getTransform()));
|
||||
}
|
||||
else if (type == 11)
|
||||
{
|
||||
g.setOpacity ((float) opacitySlider->getValue());
|
||||
|
||||
float x, y, w, h;
|
||||
svgDrawable->getBounds (x, y, w, h);
|
||||
|
||||
svgDrawable->draw (g, AffineTransform::translation (-x - 0.5f * w,
|
||||
-y - 0.5f * h)
|
||||
.followedBy (getTransform()));
|
||||
svgDrawable->draw (g, (float) opacitySlider->getValue(),
|
||||
AffineTransform::translation (-x - 0.5f * w,
|
||||
-y - 0.5f * h)
|
||||
.followedBy (getTransform()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42656,7 +42656,7 @@ void DrawableButton::paintButton (Graphics& g,
|
|||
{
|
||||
if (style == ImageRaw)
|
||||
{
|
||||
imageToDraw->draw (g);
|
||||
imageToDraw->draw (g, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -42665,7 +42665,8 @@ void DrawableButton::paintButton (Graphics& g,
|
|||
imageSpace.getY(),
|
||||
imageSpace.getWidth(),
|
||||
imageSpace.getHeight(),
|
||||
RectanglePlacement::centred);
|
||||
RectanglePlacement::centred,
|
||||
1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43268,14 +43269,14 @@ void ToolbarButton::paintButtonArea (Graphics& g,
|
|||
{
|
||||
Image im (Image::ARGB, width, height, true);
|
||||
Graphics g2 (im);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
im.desaturate();
|
||||
|
||||
g.drawImageAt (&im, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
d->drawWithin (g, 0, 0, width, height, RectanglePlacement::centred);
|
||||
d->drawWithin (g, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60719,14 +60720,15 @@ const Font LookAndFeel::getFontForTextButton (TextButton& button)
|
|||
void LookAndFeel::drawButtonText (Graphics& g, TextButton& button,
|
||||
bool /*isMouseOverButton*/, bool /*isButtonDown*/)
|
||||
{
|
||||
g.setFont (getFontForTextButton (button));
|
||||
Font font (getFontForTextButton (button));
|
||||
g.setFont (font);
|
||||
g.setColour (button.findColour (TextButton::textColourId)
|
||||
.withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
|
||||
|
||||
const int yIndent = jmin (4, button.proportionOfHeight (0.3f));
|
||||
const int cornerSize = jmin (button.getHeight(), button.getWidth()) / 2;
|
||||
|
||||
const int fontHeight = roundFloatToInt (g.getCurrentFont().getHeight() * 0.6f);
|
||||
const int fontHeight = roundFloatToInt (font.getHeight() * 0.6f);
|
||||
const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2));
|
||||
const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2));
|
||||
|
||||
|
|
@ -61005,7 +61007,7 @@ void LookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
|||
}
|
||||
}
|
||||
|
||||
void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, int h)
|
||||
void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, const Colour& colour, int x, int y, int w, int h)
|
||||
{
|
||||
const float radius = jmin (w, h) * 0.4f;
|
||||
const float thickness = radius * 0.15f;
|
||||
|
|
@ -61018,12 +61020,11 @@ void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, i
|
|||
const float cy = y + h * 0.5f;
|
||||
|
||||
const uint32 animationIndex = (Time::getMillisecondCounter() / (1000 / 10)) % 12;
|
||||
const Colour col (g.getCurrentColour());
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
const int n = (i + 12 - animationIndex) % 12;
|
||||
g.setColour (col.withMultipliedAlpha ((n + 1) / 12.0f));
|
||||
g.setColour (colour.withMultipliedAlpha ((n + 1) / 12.0f));
|
||||
|
||||
g.fillPath (p, AffineTransform::rotation (i * (float_Pi / 6.0f))
|
||||
.translated (cx, cy));
|
||||
|
|
@ -61444,7 +61445,7 @@ void LookAndFeel::drawPopupMenuItem (Graphics& g,
|
|||
|
||||
if (shortcutKeyText.isNotEmpty())
|
||||
{
|
||||
Font f2 (g.getCurrentFont());
|
||||
Font f2 (font);
|
||||
f2.setHeight (f2.getHeight() * 0.75f);
|
||||
f2.setHorizontalScale (0.95f);
|
||||
g.setFont (f2);
|
||||
|
|
@ -62111,15 +62112,16 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window,
|
|||
g.setBrush (&gb);
|
||||
g.fillAll();
|
||||
|
||||
g.setFont (h * 0.65f, Font::bold);
|
||||
Font font (h * 0.65f, Font::bold);
|
||||
g.setFont (font);
|
||||
|
||||
int textW = g.getCurrentFont().getStringWidth (window.getName());
|
||||
int textW = font.getStringWidth (window.getName());
|
||||
int iconW = 0;
|
||||
int iconH = 0;
|
||||
|
||||
if (icon != 0)
|
||||
{
|
||||
iconH = (int) g.getCurrentFont().getHeight();
|
||||
iconH = (int) font.getHeight();
|
||||
iconW = icon->getWidth() * iconH / icon->getHeight() + 4;
|
||||
}
|
||||
|
||||
|
|
@ -62836,7 +62838,7 @@ void LookAndFeel::drawPropertyComponentLabel (Graphics& g, int, int height,
|
|||
g.setColour (Colours::black);
|
||||
|
||||
if (! component.isEnabled())
|
||||
g.setOpacity (g.getCurrentColour().getFloatAlpha() * 0.6f);
|
||||
g.setOpacity (0.6f);
|
||||
|
||||
g.setFont (jmin (height, 24) * 0.65f);
|
||||
|
||||
|
|
@ -76588,11 +76590,6 @@ void Graphics::setColour (const Colour& newColour) throw()
|
|||
deleteAndZero (state->brush);
|
||||
}
|
||||
|
||||
const Colour& Graphics::getCurrentColour() const throw()
|
||||
{
|
||||
return state->colour;
|
||||
}
|
||||
|
||||
void Graphics::setOpacity (const float newOpacity) throw()
|
||||
{
|
||||
saveStateIfPending();
|
||||
|
|
@ -76643,11 +76640,6 @@ void Graphics::setFont (const float newFontHeight,
|
|||
state->font.setSizeAndStyle (newFontHeight, newFontStyleFlags, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
const Font& Graphics::getCurrentFont() const throw()
|
||||
{
|
||||
return state->font;
|
||||
}
|
||||
|
||||
void Graphics::drawSingleLineText (const String& text,
|
||||
const int startX,
|
||||
const int baselineY) const throw()
|
||||
|
|
@ -77272,11 +77264,16 @@ void Graphics::drawImage (const Image* const imageToDraw,
|
|||
}
|
||||
else
|
||||
{
|
||||
context->blendImageRescaling (*imageToDraw,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, sw, sh,
|
||||
state->colour.getFloatAlpha(),
|
||||
state->quality);
|
||||
context->blendImageWarping (*imageToDraw,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
state->colour.getFloatAlpha(),
|
||||
state->quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -77816,37 +77813,6 @@ void LowLevelGraphicsPostScriptRenderer::fillAlphaChannelWithImage (const Image&
|
|||
notPossibleInPostscriptAssert // you can disable this warning by setting the WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS flag at the top of this file
|
||||
}
|
||||
|
||||
void LowLevelGraphicsPostScriptRenderer::blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha,
|
||||
const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
jassert (sx >= 0 && sx + sw <= sourceImage.getWidth());
|
||||
jassert (sy >= 0 && sy + sh <= sourceImage.getHeight());
|
||||
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::scale (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) (dx - sx),
|
||||
(float) (dy - sy)),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LowLevelGraphicsPostScriptRenderer::blendImage (const Image& sourceImage, int dx, int dy, int dw, int dh, int sx, int sy, float opacity)
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
|
|
@ -79698,36 +79664,6 @@ void LowLevelGraphicsSoftwareRenderer::clippedBlendImage (int clipX, int clipY,
|
|||
sourceImage.releasePixelDataReadOnly (srcPixels);
|
||||
}
|
||||
|
||||
void LowLevelGraphicsSoftwareRenderer::blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha,
|
||||
const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LowLevelGraphicsSoftwareRenderer::blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& t,
|
||||
|
|
@ -80326,16 +80262,15 @@ Drawable::~Drawable()
|
|||
{
|
||||
}
|
||||
|
||||
void Drawable::draw (Graphics& g,
|
||||
void Drawable::draw (Graphics& g, const float opacity,
|
||||
const AffineTransform& transform) const
|
||||
{
|
||||
const RenderingContext context (g, transform, g.getCurrentColour().getFloatAlpha());
|
||||
render (context);
|
||||
render (RenderingContext (g, transform, opacity));
|
||||
}
|
||||
|
||||
void Drawable::drawAt (Graphics& g, const float x, const float y) const
|
||||
void Drawable::drawAt (Graphics& g, const float x, const float y, const float opacity) const
|
||||
{
|
||||
draw (g, AffineTransform::translation (x, y));
|
||||
draw (g, opacity, AffineTransform::translation (x, y));
|
||||
}
|
||||
|
||||
void Drawable::drawWithin (Graphics& g,
|
||||
|
|
@ -80343,16 +80278,18 @@ void Drawable::drawWithin (Graphics& g,
|
|||
const int destY,
|
||||
const int destW,
|
||||
const int destH,
|
||||
const RectanglePlacement& placement) const
|
||||
const RectanglePlacement& placement,
|
||||
const float opacity) const
|
||||
{
|
||||
if (destW > 0 && destH > 0)
|
||||
{
|
||||
float x, y, w, h;
|
||||
getBounds (x, y, w, h);
|
||||
|
||||
draw (g, placement.getTransformToFit (x, y, w, h,
|
||||
(float) destX, (float) destY,
|
||||
(float) destW, (float) destH));
|
||||
draw (g, opacity,
|
||||
placement.getTransformToFit (x, y, w, h,
|
||||
(float) destX, (float) destY,
|
||||
(float) destW, (float) destH));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -263283,35 +263220,6 @@ public:
|
|||
CGImageRelease (image);
|
||||
}
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha, const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
|
|
@ -264946,8 +264854,12 @@ void NSViewComponentPeer::drawRect (NSRect r)
|
|||
return;
|
||||
|
||||
#if USE_COREGRAPHICS_RENDERING
|
||||
CoreGraphicsContext context ((CGContextRef) [[NSGraphicsContext currentContext] graphicsPort],
|
||||
[view frame].size.height);
|
||||
CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
if (! component->isOpaque())
|
||||
CGContextClearRect (cg, CGContextGetClipBoundingBox (cg));
|
||||
|
||||
CoreGraphicsContext context (cg, [view frame].size.height);
|
||||
handlePaint (context);
|
||||
#else
|
||||
const float y = [view frame].size.height - (r.origin.y + r.size.height);
|
||||
|
|
|
|||
|
|
@ -19695,23 +19695,14 @@ public:
|
|||
If a brush is being used when this method is called, the brush will be deselected,
|
||||
and any subsequent drawing will be done with a solid colour brush instead.
|
||||
|
||||
@see setOpacity, setBrush, getColour
|
||||
@see setOpacity, setBrush
|
||||
*/
|
||||
void setColour (const Colour& newColour) throw();
|
||||
|
||||
/** Returns the colour that's currently being used.
|
||||
|
||||
This will return the last colour set by setColour(), even if the colour's not
|
||||
currently being used for drawing because a brush has been selected instead.
|
||||
|
||||
@see setColour
|
||||
*/
|
||||
const Colour& getCurrentColour() const throw();
|
||||
|
||||
/** Changes the opacity to use with the current colour.
|
||||
|
||||
If a solid colour is being used for drawing, this changes its opacity (and this
|
||||
will be reflected by calls to the getColour() method).
|
||||
If a solid colour is being used for drawing, this changes its opacity
|
||||
to this new value (i.e. it doesn't multiply the colour's opacity by this amount).
|
||||
|
||||
A value of 0.0 is completely transparent, 1.0 is completely opaque.
|
||||
*/
|
||||
|
|
@ -19748,12 +19739,6 @@ public:
|
|||
void setFont (const float newFontHeight,
|
||||
const int fontStyleFlags = Font::plain) throw();
|
||||
|
||||
/** Returns the font that's currently being used for text operations.
|
||||
|
||||
@see setFont
|
||||
*/
|
||||
const Font& getCurrentFont() const throw();
|
||||
|
||||
/** Draws a one-line text string.
|
||||
|
||||
This will use the current colour (or brush) to fill the text. The font is the last
|
||||
|
|
@ -39997,11 +39982,6 @@ public:
|
|||
int destX, int destY, int destW, int destH, int sourceX, int sourceY,
|
||||
float alpha) = 0;
|
||||
|
||||
virtual void blendImageRescaling (const Image& sourceImage,
|
||||
int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality) = 0;
|
||||
|
||||
virtual void blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
|
|
@ -40069,10 +40049,6 @@ public:
|
|||
void blendImage (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, float alpha);
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
||||
void blendImageWarping (const Image& sourceImage, int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
|
@ -40173,10 +40149,6 @@ public:
|
|||
void blendImage (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, float alpha);
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
||||
void blendImageWarping (const Image& sourceImage, int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
|
@ -41264,7 +41236,7 @@ public:
|
|||
/** Renders this Drawable object.
|
||||
@see drawWithin
|
||||
*/
|
||||
void draw (Graphics& g,
|
||||
void draw (Graphics& g, const float opacity,
|
||||
const AffineTransform& transform = AffineTransform::identity) const;
|
||||
|
||||
/** Renders the Drawable at a given offset within the Graphics context.
|
||||
|
|
@ -41278,7 +41250,8 @@ public:
|
|||
*/
|
||||
void drawAt (Graphics& g,
|
||||
const float x,
|
||||
const float y) const;
|
||||
const float y,
|
||||
const float opacity) const;
|
||||
|
||||
/** Renders the Drawable within a rectangle, scaling it to fit neatly inside without
|
||||
changing its aspect-ratio.
|
||||
|
|
@ -41293,13 +41266,15 @@ public:
|
|||
@param destHeight size of the target rectangle to fit the image into
|
||||
@param placement defines the alignment and rescaling to use to fit
|
||||
this object within the target rectangle.
|
||||
@param opacity the opacity to use, in the range 0 to 1.0
|
||||
*/
|
||||
void drawWithin (Graphics& g,
|
||||
const int destX,
|
||||
const int destY,
|
||||
const int destWidth,
|
||||
const int destHeight,
|
||||
const RectanglePlacement& placement) const;
|
||||
const RectanglePlacement& placement,
|
||||
const float opacity) const;
|
||||
|
||||
/** Holds the information needed when telling a drawable to render itself.
|
||||
@see Drawable::draw
|
||||
|
|
@ -54088,7 +54063,8 @@ public:
|
|||
// Draws a small image that spins to indicate that something's happening..
|
||||
// This method should use the current time to animate itself, so just keep
|
||||
// repainting it every so often.
|
||||
virtual void drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, int h);
|
||||
virtual void drawSpinningWaitAnimation (Graphics& g, const Colour& colour,
|
||||
int x, int y, int w, int h);
|
||||
|
||||
/** Draws one of the buttons on a scrollbar.
|
||||
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ void DrawableButton::paintButton (Graphics& g,
|
|||
{
|
||||
if (style == ImageRaw)
|
||||
{
|
||||
imageToDraw->draw (g);
|
||||
imageToDraw->draw (g, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -231,7 +231,8 @@ void DrawableButton::paintButton (Graphics& g,
|
|||
imageSpace.getY(),
|
||||
imageSpace.getWidth(),
|
||||
imageSpace.getHeight(),
|
||||
RectanglePlacement::centred);
|
||||
RectanglePlacement::centred,
|
||||
1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ void ToolbarButton::paintButtonArea (Graphics& g,
|
|||
{
|
||||
Image im (Image::ARGB, width, height, true);
|
||||
Graphics g2 (im);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
im.desaturate();
|
||||
|
||||
g.drawImageAt (&im, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
d->drawWithin (g, 0, 0, width, height, RectanglePlacement::centred);
|
||||
d->drawWithin (g, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,14 +367,15 @@ const Font LookAndFeel::getFontForTextButton (TextButton& button)
|
|||
void LookAndFeel::drawButtonText (Graphics& g, TextButton& button,
|
||||
bool /*isMouseOverButton*/, bool /*isButtonDown*/)
|
||||
{
|
||||
g.setFont (getFontForTextButton (button));
|
||||
Font font (getFontForTextButton (button));
|
||||
g.setFont (font);
|
||||
g.setColour (button.findColour (TextButton::textColourId)
|
||||
.withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f));
|
||||
|
||||
const int yIndent = jmin (4, button.proportionOfHeight (0.3f));
|
||||
const int cornerSize = jmin (button.getHeight(), button.getWidth()) / 2;
|
||||
|
||||
const int fontHeight = roundFloatToInt (g.getCurrentFont().getHeight() * 0.6f);
|
||||
const int fontHeight = roundFloatToInt (font.getHeight() * 0.6f);
|
||||
const int leftIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnLeft() ? 4 : 2));
|
||||
const int rightIndent = jmin (fontHeight, 2 + cornerSize / (button.isConnectedOnRight() ? 4 : 2));
|
||||
|
||||
|
|
@ -655,7 +656,7 @@ void LookAndFeel::drawProgressBar (Graphics& g, ProgressBar& progressBar,
|
|||
}
|
||||
}
|
||||
|
||||
void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, int h)
|
||||
void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, const Colour& colour, int x, int y, int w, int h)
|
||||
{
|
||||
const float radius = jmin (w, h) * 0.4f;
|
||||
const float thickness = radius * 0.15f;
|
||||
|
|
@ -668,12 +669,11 @@ void LookAndFeel::drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, i
|
|||
const float cy = y + h * 0.5f;
|
||||
|
||||
const uint32 animationIndex = (Time::getMillisecondCounter() / (1000 / 10)) % 12;
|
||||
const Colour col (g.getCurrentColour());
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
const int n = (i + 12 - animationIndex) % 12;
|
||||
g.setColour (col.withMultipliedAlpha ((n + 1) / 12.0f));
|
||||
g.setColour (colour.withMultipliedAlpha ((n + 1) / 12.0f));
|
||||
|
||||
g.fillPath (p, AffineTransform::rotation (i * (float_Pi / 6.0f))
|
||||
.translated (cx, cy));
|
||||
|
|
@ -1099,7 +1099,7 @@ void LookAndFeel::drawPopupMenuItem (Graphics& g,
|
|||
|
||||
if (shortcutKeyText.isNotEmpty())
|
||||
{
|
||||
Font f2 (g.getCurrentFont());
|
||||
Font f2 (font);
|
||||
f2.setHeight (f2.getHeight() * 0.75f);
|
||||
f2.setHorizontalScale (0.95f);
|
||||
g.setFont (f2);
|
||||
|
|
@ -1777,15 +1777,16 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window,
|
|||
g.setBrush (&gb);
|
||||
g.fillAll();
|
||||
|
||||
g.setFont (h * 0.65f, Font::bold);
|
||||
Font font (h * 0.65f, Font::bold);
|
||||
g.setFont (font);
|
||||
|
||||
int textW = g.getCurrentFont().getStringWidth (window.getName());
|
||||
int textW = font.getStringWidth (window.getName());
|
||||
int iconW = 0;
|
||||
int iconH = 0;
|
||||
|
||||
if (icon != 0)
|
||||
{
|
||||
iconH = (int) g.getCurrentFont().getHeight();
|
||||
iconH = (int) font.getHeight();
|
||||
iconW = icon->getWidth() * iconH / icon->getHeight() + 4;
|
||||
}
|
||||
|
||||
|
|
@ -2515,7 +2516,7 @@ void LookAndFeel::drawPropertyComponentLabel (Graphics& g, int, int height,
|
|||
g.setColour (Colours::black);
|
||||
|
||||
if (! component.isEnabled())
|
||||
g.setOpacity (g.getCurrentColour().getFloatAlpha() * 0.6f);
|
||||
g.setOpacity (0.6f);
|
||||
|
||||
g.setFont (jmin (height, 24) * 0.65f);
|
||||
|
||||
|
|
|
|||
|
|
@ -210,7 +210,8 @@ public:
|
|||
// Draws a small image that spins to indicate that something's happening..
|
||||
// This method should use the current time to animate itself, so just keep
|
||||
// repainting it every so often.
|
||||
virtual void drawSpinningWaitAnimation (Graphics& g, int x, int y, int w, int h);
|
||||
virtual void drawSpinningWaitAnimation (Graphics& g, const Colour& colour,
|
||||
int x, int y, int w, int h);
|
||||
|
||||
//==============================================================================
|
||||
/** Draws one of the buttons on a scrollbar.
|
||||
|
|
|
|||
|
|
@ -195,11 +195,6 @@ void Graphics::setColour (const Colour& newColour) throw()
|
|||
deleteAndZero (state->brush);
|
||||
}
|
||||
|
||||
const Colour& Graphics::getCurrentColour() const throw()
|
||||
{
|
||||
return state->colour;
|
||||
}
|
||||
|
||||
void Graphics::setOpacity (const float newOpacity) throw()
|
||||
{
|
||||
saveStateIfPending();
|
||||
|
|
@ -252,11 +247,6 @@ void Graphics::setFont (const float newFontHeight,
|
|||
state->font.setSizeAndStyle (newFontHeight, newFontStyleFlags, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
const Font& Graphics::getCurrentFont() const throw()
|
||||
{
|
||||
return state->font;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void Graphics::drawSingleLineText (const String& text,
|
||||
const int startX,
|
||||
|
|
@ -891,11 +881,16 @@ void Graphics::drawImage (const Image* const imageToDraw,
|
|||
}
|
||||
else
|
||||
{
|
||||
context->blendImageRescaling (*imageToDraw,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, sw, sh,
|
||||
state->colour.getFloatAlpha(),
|
||||
state->quality);
|
||||
context->blendImageWarping (*imageToDraw,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
state->colour.getFloatAlpha(),
|
||||
state->quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,23 +78,14 @@ public:
|
|||
If a brush is being used when this method is called, the brush will be deselected,
|
||||
and any subsequent drawing will be done with a solid colour brush instead.
|
||||
|
||||
@see setOpacity, setBrush, getColour
|
||||
@see setOpacity, setBrush
|
||||
*/
|
||||
void setColour (const Colour& newColour) throw();
|
||||
|
||||
/** Returns the colour that's currently being used.
|
||||
|
||||
This will return the last colour set by setColour(), even if the colour's not
|
||||
currently being used for drawing because a brush has been selected instead.
|
||||
|
||||
@see setColour
|
||||
*/
|
||||
const Colour& getCurrentColour() const throw();
|
||||
|
||||
/** Changes the opacity to use with the current colour.
|
||||
|
||||
If a solid colour is being used for drawing, this changes its opacity (and this
|
||||
will be reflected by calls to the getColour() method).
|
||||
If a solid colour is being used for drawing, this changes its opacity
|
||||
to this new value (i.e. it doesn't multiply the colour's opacity by this amount).
|
||||
|
||||
A value of 0.0 is completely transparent, 1.0 is completely opaque.
|
||||
*/
|
||||
|
|
@ -132,12 +123,6 @@ public:
|
|||
void setFont (const float newFontHeight,
|
||||
const int fontStyleFlags = Font::plain) throw();
|
||||
|
||||
/** Returns the font that's currently being used for text operations.
|
||||
|
||||
@see setFont
|
||||
*/
|
||||
const Font& getCurrentFont() const throw();
|
||||
|
||||
/** Draws a one-line text string.
|
||||
|
||||
This will use the current colour (or brush) to fill the text. The font is the last
|
||||
|
|
|
|||
|
|
@ -102,11 +102,6 @@ public:
|
|||
int destX, int destY, int destW, int destH, int sourceX, int sourceY,
|
||||
float alpha) = 0;
|
||||
|
||||
virtual void blendImageRescaling (const Image& sourceImage,
|
||||
int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality) = 0;
|
||||
|
||||
virtual void blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
|
|
|
|||
|
|
@ -449,39 +449,6 @@ void LowLevelGraphicsPostScriptRenderer::fillAlphaChannelWithImage (const Image&
|
|||
notPossibleInPostscriptAssert // you can disable this warning by setting the WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS flag at the top of this file
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
void LowLevelGraphicsPostScriptRenderer::blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha,
|
||||
const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
jassert (sx >= 0 && sx + sw <= sourceImage.getWidth());
|
||||
jassert (sy >= 0 && sy + sh <= sourceImage.getHeight());
|
||||
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::scale (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) (dx - sx),
|
||||
(float) (dy - sy)),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LowLevelGraphicsPostScriptRenderer::blendImage (const Image& sourceImage, int dx, int dy, int dw, int dh, int sx, int sy, float opacity)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,10 +79,6 @@ public:
|
|||
void blendImage (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, float alpha);
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
||||
void blendImageWarping (const Image& sourceImage, int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
|
|
|||
|
|
@ -1757,37 +1757,6 @@ void LowLevelGraphicsSoftwareRenderer::clippedBlendImage (int clipX, int clipY,
|
|||
sourceImage.releasePixelDataReadOnly (srcPixels);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LowLevelGraphicsSoftwareRenderer::blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha,
|
||||
const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void LowLevelGraphicsSoftwareRenderer::blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
|
|
|
|||
|
|
@ -78,10 +78,6 @@ public:
|
|||
void blendImage (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, float alpha);
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage, int destX, int destY, int destW, int destH,
|
||||
int sourceX, int sourceY, int sourceW, int sourceH,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
||||
void blendImageWarping (const Image& sourceImage, int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
float alpha, const Graphics::ResamplingQuality quality);
|
||||
|
|
|
|||
|
|
@ -53,16 +53,15 @@ Drawable::~Drawable()
|
|||
{
|
||||
}
|
||||
|
||||
void Drawable::draw (Graphics& g,
|
||||
void Drawable::draw (Graphics& g, const float opacity,
|
||||
const AffineTransform& transform) const
|
||||
{
|
||||
const RenderingContext context (g, transform, g.getCurrentColour().getFloatAlpha());
|
||||
render (context);
|
||||
render (RenderingContext (g, transform, opacity));
|
||||
}
|
||||
|
||||
void Drawable::drawAt (Graphics& g, const float x, const float y) const
|
||||
void Drawable::drawAt (Graphics& g, const float x, const float y, const float opacity) const
|
||||
{
|
||||
draw (g, AffineTransform::translation (x, y));
|
||||
draw (g, opacity, AffineTransform::translation (x, y));
|
||||
}
|
||||
|
||||
void Drawable::drawWithin (Graphics& g,
|
||||
|
|
@ -70,16 +69,18 @@ void Drawable::drawWithin (Graphics& g,
|
|||
const int destY,
|
||||
const int destW,
|
||||
const int destH,
|
||||
const RectanglePlacement& placement) const
|
||||
const RectanglePlacement& placement,
|
||||
const float opacity) const
|
||||
{
|
||||
if (destW > 0 && destH > 0)
|
||||
{
|
||||
float x, y, w, h;
|
||||
getBounds (x, y, w, h);
|
||||
|
||||
draw (g, placement.getTransformToFit (x, y, w, h,
|
||||
(float) destX, (float) destY,
|
||||
(float) destW, (float) destH));
|
||||
draw (g, opacity,
|
||||
placement.getTransformToFit (x, y, w, h,
|
||||
(float) destX, (float) destY,
|
||||
(float) destW, (float) destH));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public:
|
|||
/** Renders this Drawable object.
|
||||
@see drawWithin
|
||||
*/
|
||||
void draw (Graphics& g,
|
||||
void draw (Graphics& g, const float opacity,
|
||||
const AffineTransform& transform = AffineTransform::identity) const;
|
||||
|
||||
/** Renders the Drawable at a given offset within the Graphics context.
|
||||
|
|
@ -75,7 +75,8 @@ public:
|
|||
*/
|
||||
void drawAt (Graphics& g,
|
||||
const float x,
|
||||
const float y) const;
|
||||
const float y,
|
||||
const float opacity) const;
|
||||
|
||||
/** Renders the Drawable within a rectangle, scaling it to fit neatly inside without
|
||||
changing its aspect-ratio.
|
||||
|
|
@ -90,13 +91,15 @@ public:
|
|||
@param destHeight size of the target rectangle to fit the image into
|
||||
@param placement defines the alignment and rescaling to use to fit
|
||||
this object within the target rectangle.
|
||||
@param opacity the opacity to use, in the range 0 to 1.0
|
||||
*/
|
||||
void drawWithin (Graphics& g,
|
||||
const int destX,
|
||||
const int destY,
|
||||
const int destWidth,
|
||||
const int destHeight,
|
||||
const RectanglePlacement& placement) const;
|
||||
const RectanglePlacement& placement,
|
||||
const float opacity) const;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -240,35 +240,6 @@ public:
|
|||
CGImageRelease (image);
|
||||
}
|
||||
|
||||
void blendImageRescaling (const Image& sourceImage,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
float alpha, const Graphics::ResamplingQuality quality)
|
||||
{
|
||||
if (sw > 0 && sh > 0)
|
||||
{
|
||||
if (sw == dw && sh == dh)
|
||||
{
|
||||
blendImage (sourceImage,
|
||||
dx, dy, dw, dh,
|
||||
sx, sy, alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
blendImageWarping (sourceImage,
|
||||
sx, sy, sw, sh,
|
||||
AffineTransform::translation ((float) -sx,
|
||||
(float) -sy)
|
||||
.scaled (dw / (float) sw,
|
||||
dh / (float) sh)
|
||||
.translated ((float) dx,
|
||||
(float) dy),
|
||||
alpha,
|
||||
quality);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blendImageWarping (const Image& sourceImage,
|
||||
int srcClipX, int srcClipY, int srcClipW, int srcClipH,
|
||||
const AffineTransform& transform,
|
||||
|
|
|
|||
|
|
@ -1436,8 +1436,12 @@ void NSViewComponentPeer::drawRect (NSRect r)
|
|||
return;
|
||||
|
||||
#if USE_COREGRAPHICS_RENDERING
|
||||
CoreGraphicsContext context ((CGContextRef) [[NSGraphicsContext currentContext] graphicsPort],
|
||||
[view frame].size.height);
|
||||
CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
||||
|
||||
if (! component->isOpaque())
|
||||
CGContextClearRect (cg, CGContextGetClipBoundingBox (cg));
|
||||
|
||||
CoreGraphicsContext context (cg, [view frame].size.height);
|
||||
handlePaint (context);
|
||||
#else
|
||||
const float y = [view frame].size.height - (r.origin.y + r.size.height);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue