Newer
Older
invertedlogic / InvertedLogic / iLFramework / toolkit / include / GL / TreeView.inl
@John Ryland John Ryland on 10 Nov 2019 996 bytes rename
#include "GL/TextView.h"
#include "GL/Font.h"
#include "GL/ImmediateMode.h"


BEGIN_NAMESPACE


template <typename T>
void TreeView<T>::draw()
{
	drawPanel();
	const int fontSize = 14;
	int row = 1;
	int xOff = 0;
	std::vector<std::pair<int,const std::vector<const T*> > > objectTreeStack;
	objectTreeStack.push_back(std::pair<int,const std::vector<const T*> >(0, m_root->children()));
	while (objectTreeStack.size())
	{
		int i = objectTreeStack.back().first;
		std::vector<const T*> childList = objectTreeStack.back().second;
		if ( i == childList.size() ) {
			objectTreeStack.pop_back();
			xOff -= 10;
		} else {
			glDrawText(xOff+x+8+1, y+30+row*20, childList[i]->text(), 0xff000000, 0xffffffff, fontSize);
			objectTreeStack.back().first = i + 1;
			if ( childList[i]->hasChildren() ) {
				objectTreeStack.push_back(std::pair<int,const std::vector<const T*> >(0, childList[i]->children()));
				xOff += 10;
			}
			row++;
		}
	}

}


END_NAMESPACE