Fixed skin glitch with list selection rendering : clip the selection image when drawing it very near the edge and half the image is outside the list

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5268 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-04-25 18:22:53 +00:00
parent 1ced2b17cd
commit 702934c50e
2 changed files with 27 additions and 16 deletions

View File

@ -326,7 +326,8 @@ void Skin::drawBgImage()
}
void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const core::rect< s32 > &dest,
BoxRenderParams& params, bool deactivated)
BoxRenderParams& params, bool deactivated,
const core::rect<s32>* clipRect)
{
// check if widget moved. if so, recalculate coords
if (w->x != dest.UpperLeftCorner.X || w->y != dest.UpperLeftCorner.Y ||
@ -539,51 +540,51 @@ X##_yflip.LowerRightCorner.Y = w->dest_y + (w->dest_y2 - w->dest_y) - y1;}
if ((areas & BoxRenderParams::LEFT) != 0)
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_left, source_area_left,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ((areas & BoxRenderParams::BODY) != 0)
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_center, source_area_center,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ((areas & BoxRenderParams::RIGHT) != 0)
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_right, source_area_right,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ((areas & BoxRenderParams::TOP) != 0)
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_top, source_area_top,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ((areas & BoxRenderParams::BOTTOM) != 0)
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_bottom, source_area_bottom,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ( ((areas & BoxRenderParams::LEFT) != 0) && ((areas & BoxRenderParams::TOP) != 0) )
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_top_left, source_area_top_left,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ( ((areas & BoxRenderParams::RIGHT) != 0) && ((areas & BoxRenderParams::TOP) != 0) )
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_top_right, source_area_top_right,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ( ((areas & BoxRenderParams::LEFT) != 0) && ((areas & BoxRenderParams::BOTTOM) != 0) )
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_bottom_left, source_area_bottom_left,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if ( ((areas & BoxRenderParams::RIGHT) != 0) && ((areas & BoxRenderParams::BOTTOM) != 0) )
{
GUIEngine::getDriver()->draw2DImage(source, dest_area_bottom_right, source_area_bottom_right,
0 /* no clipping */, colorptr, true /* alpha */);
clipRect, colorptr, true /* alpha */);
}
if (colorptr != NULL)
@ -1090,15 +1091,22 @@ void Skin::drawList(const core::rect< s32 > &rect, Widget* widget, bool focused)
/**
* @param focused whether this element is focus by the master player (focus for other players is not supported)
*/
void Skin::drawListSelection(const core::rect< s32 > &rect, Widget* widget, bool focused)
void Skin::drawListSelection(const core::rect< s32 > &rect, Widget* widget, bool focused,
const core::rect< s32 > *clip)
{
ListWidget* list = dynamic_cast<ListWidget*>(widget);
assert(list != NULL);
if (focused)
drawBoxFromStretchableTexture(&list->m_selection_skin_info, rect, SkinConfig::m_render_params["listitem::focused"]);
{
drawBoxFromStretchableTexture(&list->m_selection_skin_info, rect,
SkinConfig::m_render_params["listitem::focused"], false, clip);
}
else
drawBoxFromStretchableTexture(&list->m_selection_skin_info, rect, SkinConfig::m_render_params["listitem::down"]);
{
drawBoxFromStretchableTexture(&list->m_selection_skin_info, rect,
SkinConfig::m_render_params["listitem::down"], false, clip);
}
}
/** recursive function to render all sections (recursion allows to easily traverse the tree of children
@ -1235,7 +1243,7 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, co
// lists not supported in multiplayer screens
const bool focused = GUIEngine::isFocusedForPlayer(widget, PLAYER_ID_GAME_MASTER);
drawListSelection(rect, widget, focused);
drawListSelection(rect, widget, focused, clip);
}
}

View File

@ -172,6 +172,7 @@ namespace GUIEngine
/**
* \brief class containing render params for the 'drawBoxFromStretchableTexture' function
* see \ref skin for more information about skinning in STK
* \ingroup guiengine
*/
class BoxRenderParams
@ -231,6 +232,7 @@ namespace GUIEngine
/**
* \brief Object used to render the GUI widgets
* see \ref skin for more information about skinning in STK
* \ingroup guiengine
*/
class Skin : public irr::gui::IGUISkin
@ -242,7 +244,8 @@ namespace GUIEngine
void drawBoxFromStretchableTexture(SkinWidgetContainer* w, const irr::core::rect< irr::s32 > &dest,
BoxRenderParams& params, bool deactivated=false);
BoxRenderParams& params, bool deactivated=false,
const irr::core::rect<irr::s32>* clipRect=NULL);
// my utility methods, to work around irrlicht's very Windows-95-like-look-enforcing skin system
void process3DPane(irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const bool pressed);
@ -255,7 +258,7 @@ namespace GUIEngine
void drawGaugeFill(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused);
void drawCheckBox(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused);
void drawList(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused);
void drawListSelection(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused);
void drawListSelection(const irr::core::rect< irr::s32 > &rect, Widget* widget, bool focused, const irr::core::rect< irr::s32 > *clip);
void drawIconButton(const irr::core::rect< irr::s32 > &rect, Widget* widget, const bool pressed, bool focused);
void drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect);