1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

New class: DropShadow, and a complete refactoring of the way shadows are rendered. The DropShadowEffect and DropShadower classes now take a DropShadow object to describe their shadow parameters, instead of the raw numbers.

This commit is contained in:
jules 2012-07-11 21:07:47 +01:00
parent 591ce2a396
commit 3ddc6dd43d
16 changed files with 286 additions and 248 deletions

View file

@ -23,49 +23,24 @@
==============================================================================
*/
ArrowButton::ArrowButton (const String& name,
float arrowDirectionInRadians,
const Colour& arrowColour)
: Button (name),
colour (arrowColour)
ArrowButton::ArrowButton (const String& name, float arrowDirectionInRadians, const Colour& arrowColour)
: Button (name), colour (arrowColour)
{
path.lineTo (0.0f, 1.0f);
path.lineTo (1.0f, 0.5f);
path.closeSubPath();
path.applyTransform (AffineTransform::rotation (float_Pi * 2.0f * arrowDirectionInRadians,
0.5f, 0.5f));
setComponentEffect (&shadow);
updateShadowAndOffset();
path.addTriangle (0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
path.applyTransform (AffineTransform::rotation (float_Pi * 2.0f * arrowDirectionInRadians, 0.5f, 0.5f));
}
ArrowButton::~ArrowButton()
{
}
ArrowButton::~ArrowButton() {}
void ArrowButton::paintButton (Graphics& g,
bool /*isMouseOverButton*/,
bool /*isButtonDown*/)
void ArrowButton::paintButton (Graphics& g, bool /*isMouseOverButton*/, bool isButtonDown)
{
Path p (path);
const float offset = isButtonDown ? 1.0f : 0.0f;
p.applyTransform (path.getTransformToScaleToFit (offset, offset, getWidth() - 3.0f, getHeight() - 3.0f, false));
DropShadow (Colours::black.withAlpha (0.3f), isButtonDown ? 2 : 4, Point<int>()).drawForPath (g, p);
g.setColour (colour);
g.fillPath (path, path.getTransformToScaleToFit ((float) offset,
(float) offset,
(float) (getWidth() - 3),
(float) (getHeight() - 3),
false));
}
void ArrowButton::buttonStateChanged()
{
updateShadowAndOffset();
}
void ArrowButton::updateShadowAndOffset()
{
offset = (isDown()) ? 1 : 0;
shadow.setShadowProperties ((isDown()) ? 1.2f : 3.0f,
0.3f, -1, 0);
g.fillPath (p);
}