void fillRect (const Rectangle<int>& r, bool /*replaceExistingContents*/)
 {
     fillRect (r.toFloat());
 }
Example #2
0
double getTotalAreas(Rectangle &r1, Rectangle &r2)
{
	return r1.getArea()+r2.getArea();
}
 bool clipRegionIntersects (const Rectangle<int>& r)
 {
     return currentState->clipRect.intersects (r.toFloat().transformed (currentState->transform).getSmallestIntegerContainer());
 }
//==============================================================================
void DrawablePad::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
{
    const int insetX = getWidth() / 4;
    const int insetY = getHeight() / 4;

    Rectangle imageSpace;
    imageSpace.setBounds (insetX, insetY, getWidth() - insetX * 2, getHeight() - insetY * 2);
 
    drawButtonBackground (g,
                          *this,
                          getBackgroundColour(),
                          isMouseOverButton,
                          isButtonDown);

    g.setOpacity (1.0f);

    const Drawable* imageToDraw = 0;

    if (isEnabled())
    {
        imageToDraw = getCurrentImage();
    }
    else
    {
        imageToDraw = getToggleState() ? disabledImageOn
                                       : disabledImage;

        if (imageToDraw == 0)
        {
            g.setOpacity (0.4f);
            imageToDraw = getNormalImage();
        }
    }

    if (imageToDraw != 0)
    {
        g.setImageResamplingQuality (Graphics::highResamplingQuality);

        imageToDraw->drawWithin (g,
                                 imageSpace.getX(),
                                 imageSpace.getY(),
                                 imageSpace.getWidth(),
                                 imageSpace.getHeight(),
                                 RectanglePlacement::centred,
                                 1.0f);
    }

    float fontsize = jmin ((float)(proportionOfWidth(0.2f)),(float)(proportionOfHeight(0.15f)));
    if (fontsize < 5.0) fontsize=5.0;

    g.setFont (Font (fontsize, Font::bold));
    g.setColour (getBackgroundColour().contrasting(0.8f));
    g.drawText (Label,
                proportionOfWidth (0.0447f),
                proportionOfHeight (0.0499f),
                proportionOfWidth (0.9137f),
                proportionOfHeight (0.1355f),
                Justification::centred, true);

    if (showdot && ! hex)
    {
        g.setFont (Font (fontsize*0.9f, Font::plain));

        String xy;
        if (showx && showy) xy = T("x:") + String((int)(x*127.1)) + T(" y:") + String((int)(y*127.1));
        else if (showx)     xy = T("x:") + String((int)(x*127.1));
        else if (showy)     xy = T("y:") + String((int)(y*127.1));

        g.drawText (xy,
                    proportionOfWidth (0.0447f),
                    proportionOfHeight (0.8057f),
                    proportionOfWidth (0.9137f),
                    proportionOfHeight (0.1355f),
                    Justification::centred, true);

        float diameter = jmin ((float)(proportionOfHeight(0.125f)), (float)(proportionOfWidth(0.5f)));

        g.setColour (Colour (0x88faa52a));
        g.fillEllipse ((float)(proportionOfWidth(x)) - diameter*0.5f, 
                       (float)(proportionOfHeight(1.0f-y)) - diameter*0.5f, 
                       diameter, 
                       diameter);

        g.setColour (Colour (0x99a52a88));
        g.drawEllipse ((float)(proportionOfWidth(x)) - diameter*0.5f, 
                       (float)(proportionOfHeight(1.0f-y)) - diameter*0.5f, 
                       diameter, 
                       diameter, 
                       diameter*0.1f);
    }

}