Beispiel #1
0
void TCATLookAndFeel::drawShinyButtonShape (Graphics& g,
                                             float x, float y, float w, float h,
                                             float maxCornerSize,
                                             const Colour& baseColour,
                                             const float strokeWidth,
                                             const bool flatOnLeft,
                                             const bool flatOnRight,
                                             const bool flatOnTop,
                                             const bool flatOnBottom)
{
    if (w <= strokeWidth * 1.1f || h <= strokeWidth * 1.1f)
        return;

    const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f);

    Path outline;
    createRoundedPath (outline, x, y, w, h, cs,
                        ! (flatOnLeft || flatOnTop),
                        ! (flatOnRight || flatOnTop),
                        ! (flatOnLeft || flatOnBottom),
                        ! (flatOnRight || flatOnBottom));

    ColourGradient cg (baseColour.overlaidWith (Colours::white.withAlpha (0.0f)), 0.0f, y,
                       baseColour.overlaidWith (Colours::blue.withAlpha (0.03f)), 0.0f, y + h,
                       false);

    cg.addColour (0.5, baseColour.overlaidWith (Colours::white.withAlpha (0.2f)));
    cg.addColour (0.51, baseColour.overlaidWith (Colours::blue.withAlpha (0.07f)));
    g.setGradientFill(cg);
    g.fillPath (outline);

    g.setColour (Colours::black.withAlpha (0.5f));
    g.strokePath (outline, PathStrokeType (strokeWidth));
}
Beispiel #2
0
//==============================================================================
void NonShinyLookAndFeel::drawShinyButtonShape (Graphics& g,
                                        float x, float y, float w, float h,
                                        float maxCornerSize,
                                        const Colour& baseColour,
                                        const float strokeWidth,
                                        const bool flatOnLeft,
                                        const bool flatOnRight,
                                        const bool flatOnTop,
                                        const bool flatOnBottom) throw()
{
    if (w <= strokeWidth * 1.1f || h <= strokeWidth * 1.1f)
        return;

    const float cs = jmin (maxCornerSize, w * 0.5f, h * 0.5f);

    Path outline;
    createRoundedPath (outline, x, y, w, h, cs,
                        ! (flatOnLeft || flatOnTop),
                        ! (flatOnRight || flatOnTop),
                        ! (flatOnLeft || flatOnBottom),
                        ! (flatOnRight || flatOnBottom));

    ColourGradient cg (baseColour, 0.0f, y,
                       baseColour.overlaidWith (Colour (0x070000ff)), 0.0f, y + h,
                       false);

    cg.addColour (0.5, baseColour.overlaidWith (Colour (0x25ffffff)));
    cg.addColour (0.51, baseColour.overlaidWith (Colour (0x110000ff)));

    //g.setGradientFill (cg);
	g.setColour(baseColour);
    g.fillPath (outline);

    g.setColour (Colour (0x80000000));
    g.strokePath (outline, PathStrokeType (strokeWidth));
}
Beispiel #3
0
//==============================================================================
void NonShinyLookAndFeel::drawGlassLozenge (Graphics& g,
                                    const float x, const float y,
                                    const float width, const float height,
                                    const Colour& colour,
                                    const float outlineThickness,
                                    const float cornerSize,
                                    const bool flatOnLeft,
                                    const bool flatOnRight,
                                    const bool flatOnTop,
                                    const bool flatOnBottom) throw()
{
    if (width <= outlineThickness || height <= outlineThickness)
        return;

    const int intX = (int) x;
    const int intY = (int) y;
    const int intW = (int) width;
    const int intH = (int) height;

    const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize;
    const float edgeBlurRadius = height * 0.75f + (height - cs * 2.0f);
    const int intEdge = (int) edgeBlurRadius;

    Path outline;
    createRoundedPath (outline, x, y, width, height, cs,
                        ! (flatOnLeft || flatOnTop),
                        ! (flatOnRight || flatOnTop),
                        ! (flatOnLeft || flatOnBottom),
                        ! (flatOnRight || flatOnBottom));

    {
        ColourGradient cg (colour.darker (0.1f), 0, y,
                           colour.darker (0.1f), 0, y + height, false);

        cg.addColour (0.03, colour.withMultipliedAlpha (0.3f));
        cg.addColour (0.4, colour);
        cg.addColour (0.97, colour.withMultipliedAlpha (0.3f));

        //g.setGradientFill (cg);
		g.setColour(colour);
        g.fillPath (outline);
    }

    //ColourGradient cg (Colours::transparentBlack, x + edgeBlurRadius, y + height * 0.5f,
    //                   colour.darker (0.1f), x, y + height * 0.5f, true);

    //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.5f) / edgeBlurRadius), Colours::transparentBlack);
    //cg.addColour (jlimit (0.0, 1.0, 1.0 - (cs * 0.25f) / edgeBlurRadius), colour.darker (0.2f).withMultipliedAlpha (0.3f));

    if (! (flatOnLeft || flatOnTop || flatOnBottom))
    {
        g.saveState();
//        g.setGradientFill (cg);
		g.setColour(colour);
        g.reduceClipRegion (intX, intY, intEdge, intH);
        g.fillPath (outline);
        g.restoreState();
    }

    if (! (flatOnRight || flatOnTop || flatOnBottom))
    {
        //cg.point1.setX (x + width - edgeBlurRadius);
        //cg.point2.setX (x + width);

        g.saveState();
        //g.setGradientFill (cg);
		g.setColour(colour);
        g.reduceClipRegion (intX + intW - intEdge, intY, 2 + intEdge, intH);
        g.fillPath (outline);
        g.restoreState();
    }

    //{
    //    const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f;
    //    const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f;

    //    Path highlight;
    //    createRoundedPath (highlight,
    //                       x + leftIndent,
    //                       y + cs * 0.1f,
    //                       width - (leftIndent + rightIndent),
    //                       height * 0.4f, cs * 0.4f,
    //                       ! (flatOnLeft || flatOnTop),
    //                       ! (flatOnRight || flatOnTop),
    //                       ! (flatOnLeft || flatOnBottom),
    //                       ! (flatOnRight || flatOnBottom));

    //    g.setGradientFill (ColourGradient (colour.brighter (10.0f), 0, y + height * 0.06f,
    //                                       Colours::transparentWhite, 0, y + height * 0.4f, false));
    //    g.fillPath (highlight);
    //}

	g.setColour (colour.darker(10.f).withMultipliedAlpha (1.5f));
    g.strokePath (outline, PathStrokeType (outlineThickness));
}
void NewLookAndFeel::drawGlassLozenge (Graphics& g,
									   const float x, const float y,
									   const float width, const float height,
									   const Colour& colour,
									   const float outlineThickness,
									   const float cornerSize,
									   const bool flatOnLeft,
									   const bool flatOnRight,
									   const bool flatOnTop,
									   const bool flatOnBottom,
									   const bool isMouseOverButton,
									   const bool isButtonDown) throw()
{
    if (width <= outlineThickness || height <= outlineThickness)
        return;
	
    const float cs = cornerSize < 0 ? jmin (width * 0.5f, height * 0.5f) : cornerSize;
	
    Path outline;
    createRoundedPath (outline, x, y, width, height, cs,
					   ! (flatOnLeft || flatOnTop),
					   ! (flatOnRight || flatOnTop),
					   ! (flatOnLeft || flatOnBottom),
					   ! (flatOnRight || flatOnBottom));

    {
		ColourGradient cg;
		if (isButtonDown) {
			cg  = ColourGradient(colour, 0, y,
				 			     colour.darker (0.1f), 0, y + height, false);
		} else { 
			cg  = ColourGradient(colour.darker(0.1f), 0, y,
							     colour, 0, y + height, false);
		}

		
        g.setGradientFill (cg);
        g.fillPath (outline);
    }
 
    {
        const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f;
        const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f;
		
        Path highlight;
        createRoundedPath (highlight,
                           x + leftIndent,
                           y + cs * 0.1f,
                           width - (leftIndent + rightIndent),
                           height * 0.2f, cs * 0.2f,
                           ! (flatOnLeft || flatOnTop),
                           ! (flatOnRight || flatOnTop),
                           ! (flatOnLeft || flatOnBottom),
                           ! (flatOnRight || flatOnBottom));
		
		if (!isButtonDown) {
			g.setGradientFill (ColourGradient (colour.brighter (2.0f), 0, y + height * 0.06f,
											   Colours::transparentWhite, 0, y + height * 0.2f, false));
		} else {
			g.setGradientFill (ColourGradient (colour.darker (0.3f), 0, y + height * 0.06f,
											   Colours::transparentBlack, 0, y + height * 0.2f, false));
		}
		g.fillPath (highlight);
    }
	
    {
        const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f;
        const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f;
		
        Path shadow;
        createRoundedPath (shadow,
                           x + leftIndent,
                           y + height * 0.85f + cs * 0.1f,
                           width - (leftIndent + rightIndent),
                           height * 0.2f, cs * 0.2f,
                           ! (flatOnLeft || flatOnTop),
                           ! (flatOnRight || flatOnTop),
                           ! (flatOnLeft || flatOnBottom),
                           ! (flatOnRight || flatOnBottom));
		
		if (!isButtonDown) {
			g.setGradientFill (ColourGradient (Colours::transparentWhite, 0, y + height * 0.85f,
											   colour.darker (0.4f), 0, y + height, false));
		} 
		g.fillPath (shadow);
    }
    
	g.setColour(Colour::fromRGBA(0, 0, 0, 150));
    g.strokePath (outline, PathStrokeType (outlineThickness));
}