Exemple #1
0
//==============================================================================
void CtrlrGroup::paint (Graphics& g)
{
    //[UserPrePaint] Add your own custom painting code here..
    //[/UserPrePaint]

    //[UserPaint] Add your own custom painting code here..
	Rectangle<int> r = getUsableRect();

	gradientFromProperty(g, getBounds(), getObjectTree(), Ids::uiGroupOutlineGradientType, Ids::uiGroupOutlineColour1, Ids::uiGroupOutlineColour2);
	g.drawRoundedRectangle (r.toFloat().reduced((float)getProperty(Ids::uiGroupOutlineThickness)/2.0f), getProperty(Ids::uiGroupOutlineRoundAngle), getProperty(Ids::uiGroupOutlineThickness));

	gradientFromProperty(g, getBounds(), getObjectTree(), Ids::uiGroupBackgroundGradientType, Ids::uiGroupBackgroundColour1, Ids::uiGroupBackgroundColour2);
	g.fillRoundedRectangle (r.toFloat().reduced((float)getProperty(Ids::uiGroupOutlineThickness)/2.0f), getProperty(Ids::uiGroupOutlineRoundAngle));

	if (groupBackgroundImage.isValid())
	{
		if ((int)getProperty (Ids::uiGroupBackgroundImageLayout) == 8192)
		{
			g.setTiledImageFill (groupBackgroundImage, 0, 0, (float)getProperty (Ids::uiGroupBackgroundImageAlpha)/255.0f);
			g.fillRect(r);
		}
		else
		{
			g.setColour (Colours::black.withAlpha ((float)getProperty (Ids::uiGroupBackgroundImageAlpha)/255.0f));
			g.drawImageWithin (groupBackgroundImage,
								r.getX(),
								r.getY(),
								r.getWidth(),
								r.getHeight(),
								RectanglePlacement(getProperty (Ids::uiGroupBackgroundImageLayout)));
		}
	}
    //[/UserPaint]
}
//==============================================================================
void CtrlrXYSurface::paint (Graphics& g)
{
    //[UserPrePaint] Add your own custom painting code here..
    //[/UserPrePaint]

    //[UserPaint] Add your own custom painting code here..
	gradientFromProperty (g, usableRectangle.getSmallestIntegerContainer(), getObjectTree(), Ids::uiXYSurfaceBgGradientType, Ids::uiXYSurfaceBackgroundColour1, Ids::uiXYSurfaceBackgroundColour2);
	g.fillRoundedRectangle ((float)usableRectangle.getTopLeft().getX(), (float)usableRectangle.getTopLeft().getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize));

	gradientFromProperty (g, usableRectangle.getSmallestIntegerContainer(), getObjectTree(), Ids::uiXYSurfaceOutlineGradientType, Ids::uiXYSurfaceOutlineColour1, Ids::uiXYSurfaceOutlineColour2);
    g.drawRoundedRectangle ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize), getProperty(Ids::uiXYSurfaceOutlineThickness));

	const int snapSize	= (int)getProperty (Ids::uiXYSurfaceGradientGrain, 8);
	Colour colour		= VAR2COLOUR(getProperty(Ids::uiXYSurfaceGradientColour));

	if (snapSize > 0)
	{
		Image backgroundFill(Image::ARGB, snapSize, snapSize, true);
		Graphics g1(backgroundFill);

		if (snapSize > 2)
		{
			g1.setColour (colour);
			g1.drawRect (0, 0, snapSize + 1, snapSize + 1);
		}

		g.setTiledImageFill (backgroundFill, 0, 0, 1.0f);
		g.fillRoundedRectangle ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight(), getProperty(Ids::uiXYSurfaceCornerSize));
	}

	if (backgroundImage.isValid())
	{
		if ((int)getProperty (Ids::uiXYSurfaceBgImageLayout) == 8192)
		{
			g.setTiledImageFill (backgroundImage, 0, 0, (float)getProperty (Ids::uiXYSurfaceBgImageAlpha)/255.0f);
			g.fillRect ((float)usableRectangle.getX(), (float)usableRectangle.getY(), (float)usableRectangle.getWidth(), (float)usableRectangle.getHeight());
		}
		else
		{
			g.setColour (Colours::black.withAlpha ((float)getProperty (Ids::uiXYSurfaceBgImageAlpha)/255.0f));
			g.drawImageWithin (backgroundImage,
								usableRectangle.getX(),
								usableRectangle.getX(),
								usableRectangle.getWidth(),
								usableRectangle.getHeight(),
								RectanglePlacement(getProperty (Ids::uiXYSurfaceBgImageLayout)));
		}
	}

	if (getProperty (Ids::uiXYSurfaceXTrackEnabled))
	{
		const Point<int> c = surfaceModulator->getBounds().getCentre();

		g.setColour (VAR2COLOUR(getProperty(Ids::uiXYSurfaceYTrackColour)));
		g.drawLine ((float)c.getX(), (float)usableRectangle.getY(), (float)c.getX(), (float)usableRectangle.getBottom(), getProperty(Ids::uiXYSurfaceYTrackThickness));

		g.setColour (VAR2COLOUR(getProperty(Ids::uiXYSurfaceXTrackColour)));
		g.drawLine ((float)usableRectangle.getX(), (float)c.getY(), (float)usableRectangle.getWidth(), (float)c.getY(), getProperty(Ids::uiXYSurfaceXTrackThickness));
	}

	if ((bool)getProperty(Ids::uiXYSurfaceInfoLabelVisible))
	{
		// const int xScale = (int)getProperty(Ids::uiXYSurfaceMaxX);
		// const int yScale = (int)getProperty(Ids::uiXYSurfaceMaxY);

		const Point<int> c = surfaceModulator->getBounds().getCentre();
		g.setColour (VAR2COLOUR(getProperty (Ids::uiXYSurfaceInfoLabelColour)));
		g.setFont (STR2FONT(getProperty(Ids::uiXYSurfaceInfoLabelFont)));
		g.drawText ("X="+String(getValueForPosition(c.getX(), true))+" Y="+String(getValueForPosition(c.getY(), false)),
					usableRectangle.getX() + 8,
					usableRectangle.getY() + 8,
					usableRectangle.getWidth()-16,
					usableRectangle.getHeight()-16,
					justificationFromProperty(getProperty (Ids::uiXYSurfaceInfoLabelLocation)),
					true);
	}

    //[/UserPaint]
}