Backport irrlicht changes to CGUISTKListBox
This commit is contained in:
parent
2a60d6508b
commit
af1238d688
@ -40,11 +40,8 @@ CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent
|
||||
#endif
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
|
||||
ScrollBar = Environment->addScrollBar(false,
|
||||
core::rect<s32>(RelativeRect.getWidth() - s, 0,
|
||||
RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1);
|
||||
ScrollBar = Environment->addScrollBar(false, core::recti(0, 0, 1, 1), this, -1);
|
||||
ScrollBar->grab();
|
||||
ScrollBar->setSubElement(true);
|
||||
ScrollBar->setTabStop(false);
|
||||
@ -52,6 +49,8 @@ CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent
|
||||
ScrollBar->setVisible(false);
|
||||
ScrollBar->setPos(0);
|
||||
|
||||
updateScrollBarSize(skin->getSize(EGDS_SCROLLBAR_SIZE));
|
||||
|
||||
setNotClipped(!clip);
|
||||
|
||||
// this element can be tabbed to
|
||||
@ -478,6 +477,7 @@ void CGUISTKListBox::draw()
|
||||
recalculateItemHeight(); // if the font changed
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
updateScrollBarSize(skin->getSize(EGDS_SCROLLBAR_SIZE));
|
||||
|
||||
core::rect<s32>* clipRect = 0;
|
||||
|
||||
@ -489,7 +489,7 @@ void CGUISTKListBox::draw()
|
||||
core::rect<s32> clientClip(AbsoluteRect);
|
||||
clientClip.UpperLeftCorner.Y += 1;
|
||||
if (ScrollBar->isVisible())
|
||||
clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
clientClip.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth();
|
||||
clientClip.LowerRightCorner.Y -= 1;
|
||||
clientClip.clipAgainst(AbsoluteClippingRect);
|
||||
|
||||
@ -501,7 +501,7 @@ void CGUISTKListBox::draw()
|
||||
|
||||
frameRect = AbsoluteRect;
|
||||
if (ScrollBar->isVisible())
|
||||
frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
frameRect.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth();
|
||||
|
||||
frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight;
|
||||
|
||||
@ -817,6 +817,16 @@ void CGUISTKListBox::setDrawBackground(bool draw)
|
||||
}
|
||||
|
||||
|
||||
void CGUISTKListBox::updateScrollBarSize(s32 size)
|
||||
{
|
||||
if (size != ScrollBar->getRelativePosition().getWidth())
|
||||
{
|
||||
core::recti r(RelativeRect.getWidth() - size, 0, RelativeRect.getWidth(), RelativeRect.getHeight());
|
||||
ScrollBar->setRelativePosition(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace gui
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -183,6 +183,7 @@ namespace irr
|
||||
void recalculateItemHeight();
|
||||
void selectNew(s32 ypos, bool onlyHover=false);
|
||||
void recalculateScrollPos();
|
||||
void updateScrollBarSize(s32 size);
|
||||
|
||||
// extracted that function to avoid copy&paste code
|
||||
void recalculateIconWidth();
|
||||
|
Loading…
Reference in New Issue
Block a user