I am trying to highlight a date button in my control using the drawpushed() function given below.
The position of the brush image is not getting properly and hence the selection image is shifted upwards.
FInd the code bewlow used to draw the date button string and pushed image.
void TLDateButton::drawPushed(float z)
{
Rect clipper(getPixelRect());
// get the destination screen rect for this window
Rect absrect(getUnclippedPixelRect());
// do nothing if the widget is totally clipped.
if (clipper.getWidth() == 0)
{
return;
}
Size dateSize(0,0);
dateSize.d_width = absrect.getWidth();
dateSize.d_height = absrect.getHeight();
float alpha_comp = getEffectiveAlpha();
ColourRect selectColour(colour(0, 0, 1, alpha_comp));
Vector3 imgpos;
imgpos.d_x = absrect.d_left;
imgpos.d_y = absrect.d_top;
imgpos.d_z = z;
d_selectBrush->draw(imgpos, dateSize, clipper, getModulateAlphaColourRect(selectColour, alpha_comp));
}
void TLDateButton::drawDate(float z, ColourRect colours)
{
Rect clipper(getPixelRect());
// do nothing if the widget is totally clipped.
if (clipper.getWidth() == 0)
{
return;
}
float width = clipper.getWidth();
float height = clipper.getHeight();
// get the destination screen rect for this window
Rect absrect(getUnclippedPixelRect());
const Font* font = getFont();
if (font != NULL)
{
float height = font->getBaseline();
absrect.d_top += (height / 2);
}
getFont()->drawText((utf8*)(dateTable[d_date - 1].dateString), absrect,
System::getSingleton().getRenderer()->getZLayer(2), clipper, Centred, colours);
}
Pl. let me know the correction to do such that the highlighted image is set proper.
thanks in advance
krithiga
display selection image using brush - help required
Moderators: CEGUI MVP, CEGUI Team
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: display selection image using brush - help required
If you're using >= 0.2.0 then you might try the PixelAligned macro to ensure any sub-pixel positioning errors are eliminated.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 8 guests