Simplify code (no need to keep scroll-bar width in extra variable here).
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5621 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
2246895ae1
commit
7442e24ded
|
@ -25,7 +25,7 @@ CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
|||
bool drawBack, bool moveOverSelect)
|
||||
: IGUIListBox(environment, parent, id, rectangle), Selected(-1),
|
||||
ItemHeight(0),ItemHeightOverride(0),
|
||||
TotalItemHeight(0), ItemsIconWidth(0), ScrollBarSize(0), Font(0), IconBank(0),
|
||||
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
|
||||
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
|
||||
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
|
||||
{
|
||||
|
@ -34,10 +34,9 @@ CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
|||
#endif
|
||||
|
||||
IGUISkin* skin = Environment->getSkin();
|
||||
ScrollBarSize = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||
|
||||
ScrollBar = new CGUIScrollBar(false, Environment, this, -1,
|
||||
core::rect<s32>(RelativeRect.getWidth() - ScrollBarSize, 0, RelativeRect.getWidth(), RelativeRect.getHeight()),
|
||||
ScrollBar = new CGUIScrollBar(false, Environment, this, -1,
|
||||
core::recti(0, 0, 1, 1),
|
||||
!clip);
|
||||
ScrollBar->setSubElement(true);
|
||||
ScrollBar->setTabStop(false);
|
||||
|
@ -45,6 +44,8 @@ CGUIListBox::CGUIListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
|||
ScrollBar->setVisible(false);
|
||||
ScrollBar->setPos(0);
|
||||
|
||||
updateScrollBarSize(skin->getSize(EGDS_SCROLLBAR_SIZE));
|
||||
|
||||
setNotClipped(!clip);
|
||||
|
||||
// this element can be tabbed to
|
||||
|
@ -149,8 +150,7 @@ void CGUIListBox::clear()
|
|||
ItemsIconWidth = 0;
|
||||
Selected = -1;
|
||||
|
||||
if (ScrollBar)
|
||||
ScrollBar->setPos(0);
|
||||
ScrollBar->setPos(0);
|
||||
|
||||
recalculateItemHeight();
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ void CGUIListBox::draw()
|
|||
clientClip.UpperLeftCorner.Y += 1;
|
||||
clientClip.UpperLeftCorner.X += 1;
|
||||
if (ScrollBar->isVisible())
|
||||
clientClip.LowerRightCorner.X -= ScrollBarSize;
|
||||
clientClip.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth();
|
||||
clientClip.LowerRightCorner.Y -= 1;
|
||||
clientClip.clipAgainst(AbsoluteClippingRect);
|
||||
|
||||
|
@ -523,7 +523,7 @@ void CGUIListBox::draw()
|
|||
frameRect = AbsoluteRect;
|
||||
frameRect.UpperLeftCorner.X += 1;
|
||||
if (ScrollBar->isVisible())
|
||||
frameRect.LowerRightCorner.X -= ScrollBarSize;
|
||||
frameRect.LowerRightCorner.X -= ScrollBar->getRelativePosition().getWidth();
|
||||
|
||||
frameRect.LowerRightCorner.Y = AbsoluteRect.UpperLeftCorner.Y + ItemHeight;
|
||||
|
||||
|
@ -642,10 +642,9 @@ void CGUIListBox::recalculateScrollPos()
|
|||
|
||||
void CGUIListBox::updateScrollBarSize(s32 size)
|
||||
{
|
||||
if ( size != ScrollBarSize )
|
||||
if ( size != ScrollBar->getRelativePosition().getWidth() )
|
||||
{
|
||||
ScrollBarSize = size;
|
||||
core::recti r(RelativeRect.getWidth() - ScrollBarSize, 0, RelativeRect.getWidth(), RelativeRect.getHeight());
|
||||
core::recti r(RelativeRect.getWidth() - size, 0, RelativeRect.getWidth(), RelativeRect.getHeight());
|
||||
ScrollBar->setRelativePosition(r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,6 @@ namespace gui
|
|||
s32 ItemHeightOverride;
|
||||
s32 TotalItemHeight;
|
||||
s32 ItemsIconWidth;
|
||||
s32 ScrollBarSize;
|
||||
gui::IGUIFont* Font;
|
||||
gui::IGUISpriteBank* IconBank;
|
||||
gui::IGUIScrollBar* ScrollBar;
|
||||
|
|
Loading…
Reference in New Issue