Hi CE,
I'm in love with ItemListBox but for my own purposes I was after a bit of extra functionality. I added these and I was wondering if you would like them (in one form or another) for the main source.
I added the following properties:
"Orientation" (set to "Vertical" or "Horizontal") - Modifies the orientation of the listbox between vertical (like it is now) and horizontal.
"FixedItemSize" (a UVector2 value) - Overwrites the size of all ItemEntry items (as defined per ItemEntry by the "ContentSize" named area from the looknfeel) to your own preference. It takes a standard UVector2 string, ie: {{relative_width, offset_width},{relative_height, offset_height}}. If you only want to fix the width or hight and not both, set the other to {0,0}.
"MultiItemPerLine" (a bool value) - If this is set to Yes/True, then it will pack multiple ItemEntry items into each "row" for a vertical orientation, or each "column" for a horizontal orientation. Similar to how Windows Explorer works in "Icons" or "Thumbnails" view modes. This isn't really like a MultiColumnList, even if is sounds and in some ways looks like one.
This has so far meant updating CEGUIItemListbox.h/.cpp, CEGUIItemListboxProperties.h/.cpp and a small change in CEGUIScrolledItemListBase.cpp.
I originally faked some of this using regular lua, but it added a bit of overhead to what I was doing and using properties in a layout file is just so much nicer.
I'd also like to expand on the sorting so you can tell it to sort on properties other than the "text" value, as well as UserTextStrings, and to also have the option of sorting numbers as numbers rather than as strings.
A screen shot with a vertical list on the left, horizontal on the right, both with MultiItemPerLine turned on along with a FixedItemSize:
(I need to get a more interesting screenshot.)
Cheers.
PS: Thanks for providing such a wonderful library . So many times I've gone to code something only to find that I can just modify or add to the .looknfeel and .scheme files.
Extending ItemListBox
Moderators: CEGUI MVP, CEGUI Team
- Jabberwocky
- Quite a regular
- Posts: 86
- Joined: Wed Oct 31, 2007 18:16
- Location: Canada
- Contact:
Re: Extending ItemListBox
Horizontal ItemListBoxes would be awesome.
The Salvation Prophecy
Space Combat. Planet Exploration. Strategic Domination.
Space Combat. Planet Exploration. Strategic Domination.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Extending ItemListBox
Yeah, I think pretty much all these changes sound interesting, so I'm certainly for having such facilities rolled in to the CEGUI core
Before submitting anything, you should definitely have read this page: http://www.cegui.org.uk/docs/current/devel.html in order that changes can be integrated quickly and cleanly, and without me getting all upset
CE
Before submitting anything, you should definitely have read this page: http://www.cegui.org.uk/docs/current/devel.html in order that changes can be integrated quickly and cleanly, and without me getting all upset
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Extending ItemListBox
Thanks for the link. I'll modify my code to match the CEGUI formatting and give it a few more comments before I submit the patch.
Most probably will take me a day or two.
Cheers.
Most probably will take me a day or two.
Cheers.
Re: Extending ItemListBox
Hi CE,
I've cleaned up the code but I'm unable to logon to your mantis system with my forum account - do I need to be granted access to this?
Also, would you like a sample/demo app that shows some of the features? I could do one that uses Lua and drag and drop between ItemListboxes if you would like one.
Cheers.
I've cleaned up the code but I'm unable to logon to your mantis system with my forum account - do I need to be granted access to this?
Also, would you like a sample/demo app that shows some of the features? I could do one that uses Lua and drag and drop between ItemListboxes if you would like one.
Cheers.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Extending ItemListBox
Hmmm. Strange that mantis is not working for you, though it's not the first time I've had people tell me this. I looked up your user name on there but it does not exist, the entry there should automatically get added when you try and log on for the first time using your forum credentials. What error do you get?
I like the proposal of a new demo - especially a lua based one
If by the time you're done, we have not resolved the mantis log-in issue, you may send me the patch(es) via email, while we work to resolve that
CE.
I like the proposal of a new demo - especially a lua based one
If by the time you're done, we have not resolved the mantis log-in issue, you may send me the patch(es) via email, while we work to resolve that
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Extending ItemListBox
Hi CE,
I'm still working on this - it's been a bit slooow with work and stuff. (and most of the effort has been with the Sample.)
Are you adverse to me including some public domain graphics in the Sample? I'm looking at having three different windows within the single sample to show some of the things you could use it for - one with fantasy pixel art in an rpg "inventory" type system, one with "files and folders" like a simple Windows Explorer and a final window with lists of countries and tanks and the like for a strategy game kind of look.
Cheers.
Most probably will take me a day or two.
I'm still working on this - it's been a bit slooow with work and stuff. (and most of the effort has been with the Sample.)
Are you adverse to me including some public domain graphics in the Sample? I'm looking at having three different windows within the single sample to show some of the things you could use it for - one with fantasy pixel art in an rpg "inventory" type system, one with "files and folders" like a simple Windows Explorer and a final window with lists of countries and tanks and the like for a strategy game kind of look.
Cheers.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Extending ItemListBox
Additional, free, assets for the samples is fine, though please include a reference to some place where we can verify it's status and also to include a credit in the docs
Cheers,
CE.
Cheers,
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Extending ItemListBox
I wanted to sort a column as numbers, so I created a derived class from ListboxTextItem. I've had to resort to a dynamic_cast which I don't like, but it seems to do the job:
Has anyone got a nicer way of doing this?
Code: Select all
class ListboxNumberItem : public ListboxTextItem
{
int value;
public:
ListboxNumberItem(int value, CEGUI::uint item_id = 0, void* item_data = 0, bool disabled = false, bool auto_delete = true);
void setText(int value);
virtual ~ListboxNumberItem(void) {}
virtual bool operator<(const ListboxItem &rhs) const;
virtual bool operator>(const ListboxItem &rhs) const;
};
ListboxNumberItem::ListboxNumberItem(int value, uint item_id, void* item_data, bool disabled, bool auto_delete) :
ListboxTextItem(boost::lexical_cast<std::string>(value), item_id, item_data, disabled, auto_delete),
value(value)
{
}
void ListboxNumberItem::setText(int value)
{
this->value = value;
ListboxItem::setText(boost::lexical_cast<std::string>(value));
}
bool ListboxNumberItem::operator<(const ListboxItem &rhs) const
{
const ListboxNumberItem *number=dynamic_cast<const ListboxNumberItem*>(&rhs);
if (number)
return value<number->value;
return ListboxItem::operator<(rhs);
}
bool ListboxNumberItem::operator>(const ListboxItem &rhs) const
{
const ListboxNumberItem *number=dynamic_cast<const ListboxNumberItem*>(&rhs);
if (number)
return value>number->value;
return ListboxItem::operator>(rhs);
}
Has anyone got a nicer way of doing this?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Extending ItemListBox
The use of the dynamic_cast in situations such as this is technically correct. Just because C++ is strongly statically typed does not mean that there will not be situations where you need to identify types at runtime. IMO the solution is fine, the alternatives would surely involve making assumptions about types and then suffering the consequences.
CE.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Bug Reports, Suggestions, Feature Requests”
Who is online
Users browsing this forum: No registered users and 13 guests