display selection image using brush - help required
Posted: Tue Mar 01, 2005 08:28
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
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