|
Post by rohmer on Jun 2, 2017 10:11:43 GMT -8
I am trying to create a button type object with an image over it.
I draw my rectangle, then text, but when I try and put the image over it, it doesn't appear.
I would assume the zStack is last in on top, but that's fairly immaterial as I have tried to adjust this and it still doesn't appear.
Rectangle r; if (is3D)
{
if (sunken)
{
r = UIPrimitives::SunkenPanel(tft, x, y, width, height, cornerRadius, buttonColor, alpha);
}
else
{
r = UIPrimitives::RaisedPanel(tft, x, y, width, height, cornerRadius, buttonColor, alpha);
}
}
else
{
r = UIPrimitives::FlatPanel(tft, x, y, width, height, cornerRadius, buttonColor, alpha);
}
r.update();
// Now we need to center the text
Logger::Trace("Button (%d,%d,%d,%d) text(%d,%d)", r.x1, r.y1, r.x2, r.y2, x + width / 2, y + height / 2);
uint8_t tHeight = FontHelper::GetTextRect(tft, text, font, Point(0, 0)).height;
uint16_t yText = y + height / 2 - tHeight / 2;
if (vertAlign == eVertAlign::Top)
yText = y + 3;
if (vertAlign == eVertAlign::Bottom)
{
yText = y + height - 3 - tHeight;
}
#ifdef RA8875
UIPrimitives::Text(tft, textColor, alpha, x + width / 4, yText, font,
is3D, text, UIPrimitives::Center);
#endif
#ifdef FT8XX
UIPrimitives::Text(tft, textColor, alpha, x + width / 2, yText, font,
is3D, text, UIPrimitives::Center);
#endif
#ifdef FT8XX
GD.Begin(BITMAPS);
GD.Vertex2ii(r.center().x - iconSize.width / 2, r.center().y - iconSize.height / 2,iconHandle);
#endif
The Bolded section is where I actually put the image. The odd thing is if I put said image somewhere else on the screen it appears. SO its being loaded correctly.
|
|
|
Post by jamesbowman on Jun 2, 2017 18:26:20 GMT -8
Yes, the draw order is always from back to front.
This ought to work. You can definitely draw an image on top of a button. Could there be a problem with the coordinates?
|
|