New Widget : Tree

zolt4n

08-12-2007 10:38:02

Hello every body!!!
I'm working on a new widget, tree : public List

You can:
- add a thumbtails before each item.
- add/del item everywhere in tree.
- add branch

- minimize/maximize branch.



zolt4n

08-12-2007 12:28:02

voici une demo
http://bordet.b.free.fr/dl/tree%20demo.avi

zolt4n

08-12-2007 17:26:35

How use tree widget ?

You have to add these lines:
in file QuickGuiPanel.h
#include "QuickGUITree.h"
Tree* createTree();
Tree* createTree(const Ogre::String& name);


in file QuickGuiPanel.cpp

// in enum Type add
TYPE_TREE ,

Tree *Panel::createTree()
{
return createTree(mGUIManager->generateName(TYPE_TREE));
}
Tree *Panel::createTree(const Ogre::String& name)
{
if(mGUIManager->isNameUnique(name))
{
mGUIManager->notifyNameUsed(name);
return dynamic_cast<Tree*>(_createChild(name,TYPE_TREE));
}
else
{
Ogre::String name = mGUIManager->generateName(TYPE_TREE);
mGUIManager->notifyNameUsed(name);
return dynamic_cast<Tree*>(_createChild(name,TYPE_TREE));
}
}



in file QuickGuiPrecompileHeader.h
#include "QuickGuiTree.h"


i think that's all you need to use the Tree Widget

Usage :

_widget = mSheet->createTree(name);
_widget->addInList("name of item", "text of item", "parent's name of item", "add after this");
// 3, 4em param are not compulsory.

//small tools
_widget->setThumbtails("item's name", "pic.png");
_widget->setTitle("title");


If you have any question ... I'm here !
Download QuickGuiTree.cpp and QuickGuiTree.h
http://bordet.b.free.fr/dl/tree

zolt4n

08-12-2007 17:34:34

Now I only have two bugs.


1 / You can see that the title does not inherit from parent.

2 / And scrollbar are not updated when we minimize the tree....
i think i have to call a method from list but i don't know the name
ps : If i call tree->setSize(_tree->getSize());
it's working but it's very slow...

Qbound

08-12-2007 20:24:57

wow looks sweet... great work :)
i will use it in the further progress of the game :D

kungfoomasta

08-12-2007 21:01:37

Wow, thats awesome!

I was going to work on this in the future, you beat me to it. To get scrollbar's working properly, you will have to make use of the following functions:

ScrollPane::manageWidget(...);
ScrollPane::unmanageWidget(...);

Basically, the ScrollPane will adjust the sizes of the scroll bars, and handle repositioning of the widgets it manages. The size of the ScrollPane is determined by the total bounds of the managed widgets (since they can go outside the list bounds).

When you collapse a branch, you need to tell the ScrollPane to unmanage those widgets. (And when you expand, need to manage them)

I should probably make a function "unmanageWidgets(vector<Widget*> widgets)" and "manageWidgets(vector<Widget*> widgets)" for efficiency.

zolt4n

08-12-2007 22:09:07

OK thx U I will see it tomorow or monday,
Any idea for the title ???

kungfoomasta

08-12-2007 22:45:38

Is the title a label, or the text of an invisible title bar? What kind of Widget is it?

zolt4n

08-12-2007 22:47:26

in fact it is a MenuLabel like the others

zolt4n

09-12-2007 13:58:39

The segfault is when I delete an item from the list.
segfault appear when I pass mouse over tree.

WidgetArray::iterator it;
for( it = mItems.begin(); it != mItems.end(); ++it )
{
if( (*it)== me->getItem()// return list's item )
{
mGUIManager->destroyWidget((*it));
mItems.erase(it);
break;
}
}


but if I use this
removeItem(getItemIndex(me->getItem()));
it's working but the code is the same ??? wtf ??

zolt4n

10-12-2007 11:45:56

Stable version tree 0.1

now tree are stable.

download files:
http://bordet.b.free.fr/dl/tree

I allready have two problem. ( result of segfault )...

1 / Resize scroll bar I do a setSize(getSize); // very slow but manageWidgets() segfault ...

2 / I can't do destroy MenulLabel of list.
I had comment this mGUIManager->destroyWidget((*it));

If you want to see why I 'll enjoy it ^^

kungfoomasta

10-12-2007 17:36:10

I would investigate and help you out with this, but I can't do it currently, my code base isn't working due to my current task. I'll make a thread so its more obvious.

tdev

02-06-2008 14:19:26

what is the status of the tree widgets in the latest release?
why is everything commented out?

kungfoomasta

02-06-2008 18:41:39

Its not working. The 0.9.7 design made it hard for users to create Custom Widgets, and the clipping/drawing is not as robust as it is in the latest developments.

With the next release I will create a wiki entry that covers how to create custom widgets, it should be pretty straightforward and defined.

tdev

03-06-2008 08:12:44

Its not working. The 0.9.7 design made it hard for users to create Custom Widgets, and the clipping/drawing is not as robust as it is in the latest developments.

With the next release I will create a wiki entry that covers how to create custom widgets, it should be pretty straightforward and defined.

ok, thanks for your reply and your support
keep up the good work! :)