Added IGUIListBox::getItemAt
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3723 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
52f84ab7e9
commit
4f990e2084
|
@ -1,5 +1,7 @@
|
|||
Changes in 1.8 (??.??.2011)
|
||||
|
||||
- Added IGUIListBox::getItemAt
|
||||
|
||||
- Added IGUITable::getColumnWidth
|
||||
|
||||
- Added the ability to open an archive from an IReadFile*, added a FileToHeader tool with instructions of how to make a portable app that consists of a single executable file.
|
||||
|
|
|
@ -56,6 +56,10 @@ namespace gui
|
|||
//! Removes an item from the list
|
||||
virtual void removeItem(u32 index) = 0;
|
||||
|
||||
//! get the the id of the item at the given absolute coordinates
|
||||
/** \return The id of the listitem or -1 when no item is at those coordinates*/
|
||||
virtual s32 getItemAt(s32 xpos, s32 ypos) const = 0;
|
||||
|
||||
//! Returns the icon of an item
|
||||
virtual s32 getIcon(u32 index) const = 0;
|
||||
|
||||
|
|
|
@ -125,6 +125,23 @@ void CGUIListBox::removeItem(u32 id)
|
|||
}
|
||||
|
||||
|
||||
s32 CGUIListBox::getItemAt(s32 xpos, s32 ypos) const
|
||||
{
|
||||
if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X
|
||||
|| ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y
|
||||
)
|
||||
return -1;
|
||||
|
||||
if ( ItemHeight == 0 )
|
||||
return -1;
|
||||
|
||||
s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
||||
if ( item < 0 || item >= (s32)Items.size())
|
||||
return -1;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
//! clears the list
|
||||
void CGUIListBox::clear()
|
||||
{
|
||||
|
@ -438,15 +455,9 @@ void CGUIListBox::selectNew(s32 ypos, bool onlyHover)
|
|||
u32 now = os::Timer::getTime();
|
||||
s32 oldSelected = Selected;
|
||||
|
||||
// find new selected item.
|
||||
if (ItemHeight!=0)
|
||||
Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
||||
|
||||
if (Selected<0)
|
||||
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
|
||||
if (Selected<0 && !Items.empty())
|
||||
Selected = 0;
|
||||
else
|
||||
if ((u32)Selected >= Items.size())
|
||||
Selected = Items.size() - 1;
|
||||
|
||||
recalculateScrollPos();
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ namespace gui
|
|||
//! removes an item from the list
|
||||
virtual void removeItem(u32 id);
|
||||
|
||||
//! get the the id of the item at the given absolute coordinates
|
||||
virtual s32 getItemAt(s32 xpos, s32 ypos) const;
|
||||
|
||||
//! Sets the sprite bank which should be used to draw list icons. This font is set to the sprite bank of
|
||||
//! the built-in-font by default. A sprite can be displayed in front of every list item.
|
||||
//! An icon is an index within the icon sprite bank. Several default icons are available in the
|
||||
|
|
Loading…
Reference in New Issue