display selection image using brush - help required

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
krithigal
Not too shy to talk
Not too shy to talk
Posts: 40
Joined: Wed Jan 12, 2005 12:06

display selection image using brush - help required

Postby krithigal » 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

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: display selection image using brush - help required

Postby CrazyEddie » Tue Mar 01, 2005 14:11

If you're using >= 0.2.0 then you might try the PixelAligned macro to ensure any sub-pixel positioning errors are eliminated.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 5 guests