Hi,
Because my english is poor and a image is sometimes better than words. This is 2 pictures to explain my problem.
void fillBackground (Graphics& g,
bool isMouseOverButton,
bool isButtonDown)
{
const int width = getWidth();
const int height = getHeight();
const int hh = (height-2) / 2;
Colour color11 = buttonColor.brighter (0.40f);
Colour color12 = buttonColor.brighter (0.05f);
Colour color21 = buttonColor.darker (0.05f);
Colour color22 = buttonColor.darker (0.40f);
// Generate color scenario
if (!isEnabled())
{
color11 = color11.darker (0.6f);
color12 = color12.darker (0.6f);
color21 = color21.darker (0.6f);
color22 = color22.darker (0.6f);
}
else
{
if (isMouseOverButton)
{
color11 = color11.brighter (0.4f);
color12 = color12.brighter (0.4f);
color21 = color21.brighter (0.4f);
color22 = color22.brighter (0.4f);
}
// cumuled
if (isButtonDown)
{
color11 = color11.brighter (0.2f);
color12 = color12.brighter (0.2f);
color21 = color21.brighter (0.2f);
color22 = color22.brighter (0.2f);
}
}
FillType brush1 (ColourGradient (color11, 0, 2, color12, 0, hh, false));
FillType brush2 (ColourGradient (color21, 0, 2+hh, color22, 0, 2+hh+hh, false));
g.setFillType (brush1);
g.fillRect (1, 1, width-2, hh);
g.setFillType (brush2);
g.fillRect (1, 1+hh, width-2, hh);
if (isEnabled())
{
// Bump Approximation (light/shadow)
// White (light from top left)
g.setColour (Colours::white.withAlpha (0.25f));
g.drawHorizontalLine (1, 1, width-3);
g.drawVerticalLine (1, 1, height-3);
// Black (shadow on bottom right)
g.setColour (Colours::black.withAlpha (0.25f));
g.drawHorizontalLine (height-1, 1, width);
g.drawVerticalLine (width-1, 2, height-1);
}
// Main black border
g.setColour (Colours::black);
g.drawRect (0, 0, width-1, height-1, 1);
}
Maybe the solution is simple. I really hope and just want to keep the idea simple and clean, so just providing shapes like :
Path item;
if (name == "add") // cross shape
{
item.startNewSubPath (0.00f, 0.30f);
item.lineTo (0.00f, 0.70f);
item.lineTo (0.30f, 0.70f);
item.lineTo (0.30f, 1.00f);
item.lineTo (0.70f, 1.00f);
item.lineTo (0.70f, 0.70f);
item.lineTo (1.00f, 0.70f);
item.lineTo (1.00f, 0.30f);
item.lineTo (0.70f, 0.30f);
item.lineTo (0.70f, 0.00f);
item.lineTo (0.30f, 0.00f);
item.lineTo (0.30f, 0.30f);
item.closeSubPath ();
}
else
if (name == "remove") // minus
{
item.startNewSubPath (0.00f, 0.30f);
item.lineTo (0.00f, 0.70f);
item.lineTo (1.00f, 0.70f);
item.lineTo (1.00f, 0.30f);
item.closeSubPath ();
}
return item;
Or maybe by a external xml description.
All ideas are welcome.
Thks.
Max