BsGUITreeView.cpp 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  1. #include "BsGUITreeView.h"
  2. #include "BsGUILayout.h"
  3. #include "BsGUITexture.h"
  4. #include "BsGUIButton.h"
  5. #include "BsGUILabel.h"
  6. #include "BsGUISpace.h"
  7. #include "BsCGUIWidget.h"
  8. #include "BsGUIToggle.h"
  9. #include "BsGUITreeViewEditBox.h"
  10. #include "BsGUIMouseEvent.h"
  11. #include "BsGUISkin.h"
  12. #include "BsGUICommandEvent.h"
  13. #include "BsGUIVirtualButtonEvent.h"
  14. #include "BsGUIScrollArea.h"
  15. #include "BsDragAndDropManager.h"
  16. #include "BsTime.h"
  17. using namespace std::placeholders;
  18. namespace BansheeEngine
  19. {
  20. const UINT32 GUITreeView::ELEMENT_EXTRA_SPACING = 3;
  21. const UINT32 GUITreeView::INDENT_SIZE = 10;
  22. const UINT32 GUITreeView::INITIAL_INDENT_OFFSET = 16;
  23. const UINT32 GUITreeView::DRAG_MIN_DISTANCE = 3;
  24. const float GUITreeView::AUTO_EXPAND_DELAY_SEC = 0.5f;
  25. const float GUITreeView::SCROLL_AREA_HEIGHT_PCT = 0.1f;
  26. const UINT32 GUITreeView::SCROLL_SPEED_PX_PER_SEC = 100;
  27. const Color GUITreeView::CUT_COLOR = Color(1.0f, 1.0f, 1.0f, 0.3f);
  28. const Color GUITreeView::DISABLED_COLOR = Color(1.0f, 1.0f, 1.0f, 0.6f);
  29. VirtualButton GUITreeView::mRenameVB = VirtualButton("Rename");
  30. VirtualButton GUITreeView::mDeleteVB = VirtualButton("Delete");
  31. VirtualButton GUITreeView::mDuplicateVB = VirtualButton("Duplicate");
  32. VirtualButton GUITreeView::mCutVB = VirtualButton("Cut");
  33. VirtualButton GUITreeView::mCopyVB = VirtualButton("Copy");
  34. VirtualButton GUITreeView::mPasteVB = VirtualButton("Paste");
  35. GUITreeView::TreeElement::TreeElement()
  36. :mParent(nullptr), mFoldoutBtn(nullptr), mElement(nullptr), mIsSelected(false),
  37. mIsExpanded(false), mSortedIdx(0), mIsVisible(true), mIsHighlighted(false), mIsCut(false), mIsDisabled(false)
  38. { }
  39. GUITreeView::TreeElement::~TreeElement()
  40. {
  41. for(auto& child : mChildren)
  42. bs_delete(child);
  43. if(mFoldoutBtn != nullptr)
  44. GUIElement::destroy(mFoldoutBtn);
  45. if(mElement != nullptr)
  46. GUIElement::destroy(mElement);
  47. mChildren.clear();
  48. }
  49. bool GUITreeView::TreeElement::isParentRec(TreeElement* element) const
  50. {
  51. TreeElement* curParent = mParent;
  52. while(curParent != nullptr)
  53. {
  54. if(curParent == element)
  55. return true;
  56. curParent = curParent->mParent;
  57. }
  58. return false;
  59. }
  60. GUITreeView::TreeElement* GUITreeView::InteractableElement::getTreeElement() const
  61. {
  62. if(!isTreeElement())
  63. return nullptr;
  64. UINT32 sortedIdx = (index - 1) / 2;
  65. auto findIter = std::find_if(parent->mChildren.begin(), parent->mChildren.end(),
  66. [&](const TreeElement* x) { return x->mSortedIdx == sortedIdx; });
  67. if(findIter != parent->mChildren.end())
  68. return *findIter;
  69. return nullptr;
  70. }
  71. GUITreeView::GUITreeView(const String& backgroundStyle, const String& elementBtnStyle,
  72. const String& foldoutBtnStyle, const String& selectionBackgroundStyle, const String& highlightBackgroundStyle,
  73. const String& editBoxStyle, const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUIDimensions& dimensions)
  74. :GUIElementContainer(dimensions), mBackgroundStyle(backgroundStyle),
  75. mElementBtnStyle(elementBtnStyle), mFoldoutBtnStyle(foldoutBtnStyle), mEditBoxStyle(editBoxStyle), mEditElement(nullptr), mIsElementSelected(false),
  76. mNameEditBox(nullptr), mHighlightBackgroundStyle(highlightBackgroundStyle), mSelectionBackgroundStyle(selectionBackgroundStyle), mDragInProgress(nullptr),
  77. mDragHighlightStyle(dragHighlightStyle), mDragSepHighlightStyle(dragSepHighlightStyle), mDragHighlight(nullptr), mDragSepHighlight(nullptr), mMouseOverDragElement(nullptr),
  78. mMouseOverDragElementTime(0.0f), mScrollState(ScrollState::None), mLastScrollTime(0.0f), mIsElementHighlighted(false)
  79. {
  80. if(mBackgroundStyle == StringUtil::BLANK)
  81. mBackgroundStyle = "TreeViewBackground";
  82. if(mElementBtnStyle == StringUtil::BLANK)
  83. mElementBtnStyle = "TreeViewElementBtn";
  84. if(mFoldoutBtnStyle == StringUtil::BLANK)
  85. mFoldoutBtnStyle = "TreeViewFoldoutBtn";
  86. if(mSelectionBackgroundStyle == StringUtil::BLANK)
  87. mSelectionBackgroundStyle = "TreeViewSelectionBackground";
  88. if (mHighlightBackgroundStyle == StringUtil::BLANK)
  89. mHighlightBackgroundStyle = "TreeViewHighlightBackground";
  90. if(mEditBoxStyle == StringUtil::BLANK)
  91. mEditBoxStyle = "TreeViewEditBox";
  92. if(mDragHighlightStyle == StringUtil::BLANK)
  93. mDragHighlightStyle = "TreeViewElementHighlight";
  94. if(mDragSepHighlightStyle == StringUtil::BLANK)
  95. mDragSepHighlightStyle = "TreeViewElementSepHighlight";
  96. mBackgroundImage = GUITexture::create(mBackgroundStyle);
  97. mNameEditBox = GUITreeViewEditBox::create(mEditBoxStyle);
  98. mNameEditBox->setVisible(false);
  99. mNameEditBox->onInputConfirmed.connect(std::bind(&GUITreeView::onEditAccepted, this));
  100. mNameEditBox->onInputCanceled.connect(std::bind(&GUITreeView::onEditCanceled, this));
  101. mNameEditBox->onFocusLost.connect(std::bind(&GUITreeView::onEditFocusLost, this));
  102. mDragHighlight = GUITexture::create(mDragHighlightStyle);
  103. mDragSepHighlight = GUITexture::create(mDragSepHighlightStyle);
  104. mDragHighlight->setVisible(false);
  105. mDragSepHighlight->setVisible(false);
  106. mDragHighlight->_setElementDepth(2);
  107. mDragSepHighlight->_setElementDepth(2);
  108. _registerChildElement(mBackgroundImage);
  109. _registerChildElement(mNameEditBox);
  110. _registerChildElement(mDragHighlight);
  111. _registerChildElement(mDragSepHighlight);
  112. }
  113. GUITreeView::~GUITreeView()
  114. {
  115. }
  116. void GUITreeView::_update()
  117. {
  118. // Attempt to auto-expand elements we are dragging over
  119. if(acceptDragAndDrop())
  120. {
  121. const GUITreeView::InteractableElement* element = findElementUnderCoord(mDragPosition);
  122. temporarilyExpandElement(element);
  123. }
  124. // NOTE - Instead of iterating through every visible element and comparing it with internal values,
  125. // I might just want to add callbacks to SceneManager that notify me of any changes and then only perform
  126. // update if anything is actually dirty
  127. updateTreeElementHierarchy();
  128. // Attempt to scroll if needed
  129. if(mScrollState != ScrollState::None)
  130. {
  131. GUIScrollArea* scrollArea = findParentScrollArea();
  132. if(scrollArea != nullptr)
  133. {
  134. float curTime = gTime().getTime();
  135. float timeDiff = curTime - mLastScrollTime;
  136. float secondsPerPixel = 1.0f / SCROLL_SPEED_PX_PER_SEC;
  137. switch(mScrollState)
  138. {
  139. case ScrollState::TransitioningUp:
  140. mScrollState = ScrollState::Up;
  141. mLastScrollTime = curTime;
  142. break;
  143. case ScrollState::TransitioningDown:
  144. mScrollState = ScrollState::Down;
  145. mLastScrollTime = curTime;
  146. break;
  147. case ScrollState::Up:
  148. {
  149. UINT32 scrollAmount = (UINT32)Math::floorToInt(timeDiff / secondsPerPixel);
  150. mLastScrollTime += scrollAmount * secondsPerPixel;
  151. scrollArea->scrollUpPx(scrollAmount);
  152. }
  153. break;
  154. case ScrollState::Down:
  155. {
  156. UINT32 scrollAmount = (UINT32)Math::floorToInt(timeDiff / secondsPerPixel);
  157. mLastScrollTime += scrollAmount * secondsPerPixel;
  158. scrollArea->scrollDownPx(scrollAmount);
  159. }
  160. break;
  161. }
  162. }
  163. }
  164. }
  165. bool GUITreeView::_mouseEvent(const GUIMouseEvent& event)
  166. {
  167. if(event.getType() == GUIMouseEventType::MouseUp)
  168. {
  169. if(DragAndDropManager::instance().isDragInProgress())
  170. return false;
  171. const GUITreeView::InteractableElement* element = findElementUnderCoord(event.getPosition());
  172. TreeElement* treeElement = nullptr;
  173. if(element != nullptr && element->isTreeElement())
  174. {
  175. treeElement = element->getTreeElement();
  176. }
  177. if (treeElement != nullptr)
  178. {
  179. bool onFoldout = false;
  180. if (treeElement->mFoldoutBtn != nullptr)
  181. onFoldout = treeElement->mFoldoutBtn->_getClippedBounds().contains(event.getPosition());
  182. bool onEditElement = false;
  183. if (mEditElement != nullptr)
  184. onEditElement = treeElement == mEditElement;
  185. if (!onFoldout && !onEditElement)
  186. {
  187. if (event.getButton() == GUIMouseButton::Left)
  188. {
  189. if (event.isCtrlDown())
  190. {
  191. selectElement(treeElement);
  192. }
  193. else if (event.isShiftDown())
  194. {
  195. if (isSelectionActive())
  196. {
  197. TreeElement* selectionRoot = mSelectedElements[0].element;
  198. unselectAll();
  199. auto iterStartFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  200. [&](const InteractableElement& x) { return x.parent == selectionRoot->mParent; });
  201. bool foundStart = false;
  202. bool foundEnd = false;
  203. for (; iterStartFind != mVisibleElements.end(); ++iterStartFind)
  204. {
  205. if (!iterStartFind->isTreeElement())
  206. continue;
  207. TreeElement* curElem = iterStartFind->getTreeElement();
  208. if (curElem == selectionRoot)
  209. {
  210. foundStart = true;
  211. break;
  212. }
  213. }
  214. auto iterEndFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  215. [&](const InteractableElement& x) { return &x == element; });
  216. if (iterEndFind != mVisibleElements.end())
  217. foundEnd = true;
  218. if (foundStart && foundEnd)
  219. {
  220. if (iterStartFind < iterEndFind)
  221. {
  222. for (; iterStartFind != (iterEndFind + 1); ++iterStartFind)
  223. {
  224. if (iterStartFind->isTreeElement())
  225. selectElement(iterStartFind->getTreeElement());
  226. }
  227. }
  228. else if (iterEndFind < iterStartFind)
  229. {
  230. for (; iterEndFind != (iterStartFind + 1); ++iterEndFind)
  231. {
  232. if (iterEndFind->isTreeElement())
  233. selectElement(iterEndFind->getTreeElement());
  234. }
  235. }
  236. else
  237. selectElement(treeElement);
  238. }
  239. if (!foundStart || !foundEnd)
  240. selectElement(treeElement);
  241. }
  242. else
  243. {
  244. selectElement(treeElement);
  245. }
  246. }
  247. else
  248. {
  249. bool doRename = false;
  250. if (isSelectionActive())
  251. {
  252. for (auto& selectedElem : mSelectedElements)
  253. {
  254. if (selectedElem.element == treeElement)
  255. {
  256. doRename = true;
  257. break;
  258. }
  259. }
  260. }
  261. unselectAll();
  262. selectElement(treeElement);
  263. if (doRename)
  264. renameSelected();
  265. }
  266. _markLayoutAsDirty();
  267. return true;
  268. }
  269. else if (event.getButton() == GUIMouseButton::Right)
  270. {
  271. unselectAll();
  272. selectElement(treeElement);
  273. _markLayoutAsDirty();
  274. return true;
  275. }
  276. }
  277. }
  278. else
  279. {
  280. unselectAll();
  281. return true;
  282. }
  283. }
  284. else if(event.getType() == GUIMouseEventType::MouseDragStart)
  285. {
  286. clearPing();
  287. mDragStartPosition = event.getPosition();
  288. }
  289. else if(event.getType() == GUIMouseEventType::MouseDrag)
  290. {
  291. UINT32 dist = mDragStartPosition.manhattanDist(event.getPosition());
  292. if(!DragAndDropManager::instance().isDragInProgress())
  293. {
  294. if(dist > DRAG_MIN_DISTANCE && mEditElement == nullptr)
  295. {
  296. const GUITreeView::InteractableElement* element = findElementUnderCoord(mDragStartPosition);
  297. TreeElement* treeElement = nullptr;
  298. if(element != nullptr && element->isTreeElement())
  299. {
  300. // If element we are trying to drag isn't selected, select it
  301. TreeElement* treeElement = element->getTreeElement();
  302. auto iterFind = std::find_if(mSelectedElements.begin(), mSelectedElements.end(),
  303. [&] (const SelectedElement& x) { return x.element == treeElement; });
  304. if(iterFind == mSelectedElements.end())
  305. {
  306. unselectAll();
  307. selectElement(element->getTreeElement());
  308. }
  309. }
  310. dragAndDropStart();
  311. mDragPosition = event.getPosition();
  312. mDragInProgress = true;
  313. mScrollState = ScrollState::None;
  314. _markLayoutAsDirty();
  315. }
  316. }
  317. }
  318. else if(event.getType() == GUIMouseEventType::MouseDragAndDropDragged)
  319. {
  320. if(acceptDragAndDrop())
  321. {
  322. clearPing();
  323. mDragPosition = event.getPosition();
  324. mDragInProgress = true;
  325. _markLayoutAsDirty();
  326. if(mBottomScrollBounds.contains(mDragPosition))
  327. {
  328. if(mScrollState != ScrollState::Down)
  329. mScrollState = ScrollState::TransitioningDown;
  330. }
  331. else if(mTopScrollBounds.contains(mDragPosition))
  332. {
  333. if(mScrollState != ScrollState::Up)
  334. mScrollState = ScrollState::TransitioningUp;
  335. }
  336. else
  337. mScrollState = ScrollState::None;
  338. return true;
  339. }
  340. }
  341. else if(event.getType() == GUIMouseEventType::MouseDragAndDropDropped)
  342. {
  343. if(acceptDragAndDrop())
  344. {
  345. const GUITreeView::InteractableElement* element = findElementUnderCoord(event.getPosition());
  346. TreeElement* treeElement = nullptr;
  347. if(element != nullptr)
  348. {
  349. if(element->isTreeElement())
  350. treeElement = element->getTreeElement();
  351. else
  352. treeElement = element->parent;
  353. }
  354. dragAndDropEnded(treeElement);
  355. unselectAll();
  356. return true;
  357. }
  358. }
  359. else if(event.getType() == GUIMouseEventType::MouseOut)
  360. {
  361. mDragInProgress = false;
  362. _markLayoutAsDirty();
  363. }
  364. return false;
  365. }
  366. bool GUITreeView::_commandEvent(const GUICommandEvent& ev)
  367. {
  368. if(ev.getType() == GUICommandEventType::MoveUp || ev.getType() == GUICommandEventType::SelectUp)
  369. {
  370. TreeElement* topMostElement = getTopMostSelectedElement();
  371. auto topMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  372. [&] (const InteractableElement& x) { return x.getTreeElement() == topMostElement; });
  373. if(topMostIter != mVisibleElements.end() && topMostIter != mVisibleElements.begin())
  374. {
  375. do
  376. {
  377. topMostIter--;
  378. } while (!topMostIter->isTreeElement() && topMostIter != mVisibleElements.begin());
  379. if(topMostIter->isTreeElement())
  380. {
  381. if(ev.getType() == GUICommandEventType::MoveUp)
  382. unselectAll();
  383. TreeElement* treeElement = topMostIter->getTreeElement();
  384. selectElement(treeElement);
  385. scrollToElement(treeElement, false);
  386. }
  387. }
  388. }
  389. else if(ev.getType() == GUICommandEventType::MoveDown || ev.getType() == GUICommandEventType::SelectDown)
  390. {
  391. TreeElement* bottoMostElement = getBottomMostSelectedElement();
  392. auto bottomMostIter = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  393. [&] (const InteractableElement& x) { return x.getTreeElement() == bottoMostElement; });
  394. if(bottomMostIter != mVisibleElements.end())
  395. {
  396. do
  397. {
  398. bottomMostIter++;
  399. } while (bottomMostIter != mVisibleElements.end() && !bottomMostIter->isTreeElement());
  400. if(bottomMostIter != mVisibleElements.end() && bottomMostIter->isTreeElement())
  401. {
  402. if(ev.getType() == GUICommandEventType::MoveDown)
  403. unselectAll();
  404. TreeElement* treeElement = bottomMostIter->getTreeElement();
  405. selectElement(treeElement);
  406. scrollToElement(treeElement, false);
  407. }
  408. }
  409. }
  410. return GUIElementContainer::_commandEvent(ev);
  411. }
  412. bool GUITreeView::_virtualButtonEvent(const GUIVirtualButtonEvent& ev)
  413. {
  414. if(ev.getButton() == mRenameVB)
  415. {
  416. renameSelected();
  417. return true;
  418. }
  419. else if(ev.getButton() == mDeleteVB)
  420. {
  421. deleteSelection();
  422. }
  423. else if (ev.getButton() == mDuplicateVB)
  424. {
  425. duplicateSelection();
  426. return true;
  427. }
  428. else if (ev.getButton() == mCutVB)
  429. {
  430. cutSelection();
  431. return true;
  432. }
  433. else if (ev.getButton() == mCopyVB)
  434. {
  435. copySelection();
  436. return true;
  437. }
  438. else if (ev.getButton() == mPasteVB)
  439. {
  440. paste();
  441. return true;
  442. }
  443. return false;
  444. }
  445. bool GUITreeView::isSelectionActive() const
  446. {
  447. return mIsElementSelected && mSelectedElements.size() > 0;
  448. }
  449. void GUITreeView::selectElement(TreeElement* element)
  450. {
  451. clearPing();
  452. auto iterFind = std::find_if(mSelectedElements.begin(), mSelectedElements.end(),
  453. [&] (const SelectedElement& x) { return x.element == element; });
  454. if(iterFind == mSelectedElements.end())
  455. {
  456. GUITexture* background = GUITexture::create(mSelectionBackgroundStyle);
  457. background->_setElementDepth(3);
  458. _registerChildElement(background);
  459. element->mIsSelected = true;
  460. mSelectedElements.push_back(SelectedElement(element, background));
  461. mIsElementSelected = true;
  462. selectionChanged();
  463. }
  464. }
  465. void GUITreeView::unselectElement(TreeElement* element)
  466. {
  467. clearPing();
  468. auto iterFind = std::find_if(mSelectedElements.begin(), mSelectedElements.end(),
  469. [&] (const SelectedElement& x) { return x.element == element; });
  470. if(iterFind != mSelectedElements.end())
  471. {
  472. iterFind->element->mIsSelected = false;
  473. GUIElement::destroy(iterFind->background);
  474. mSelectedElements.erase(iterFind);
  475. _markLayoutAsDirty();
  476. selectionChanged();
  477. }
  478. mIsElementSelected = mSelectedElements.size() > 0;
  479. }
  480. void GUITreeView::unselectAll(bool sendEvent)
  481. {
  482. clearPing();
  483. for(auto& selectedElem : mSelectedElements)
  484. {
  485. selectedElem.element->mIsSelected = false;
  486. GUIElement::destroy(selectedElem.background);
  487. }
  488. mSelectedElements.clear();
  489. mIsElementSelected = false;
  490. _markLayoutAsDirty();
  491. if (sendEvent)
  492. selectionChanged();
  493. }
  494. void GUITreeView::renameSelected()
  495. {
  496. if (isSelectionActive() && mEditElement == nullptr)
  497. {
  498. clearPing();
  499. enableEdit(mSelectedElements[0].element);
  500. unselectAll();
  501. }
  502. }
  503. void GUITreeView::deleteSelection()
  504. {
  505. if (isSelectionActive())
  506. {
  507. auto isChildOf = [&](const TreeElement* parent, const TreeElement* child)
  508. {
  509. const TreeElement* elem = child;
  510. while (elem != nullptr && elem != parent)
  511. elem = elem->mParent;
  512. return elem == parent;
  513. };
  514. // Ensure we don't unnecessarily try to delete children if their
  515. // parent is getting deleted anyway
  516. Vector<TreeElement*> elementsToDelete;
  517. for (UINT32 i = 0; i < (UINT32)mSelectedElements.size(); i++)
  518. {
  519. bool hasDeletedParent = false;
  520. for (UINT32 j = 0; j < (UINT32)mSelectedElements.size(); j++)
  521. {
  522. if (i == j)
  523. continue;
  524. if (isChildOf(mSelectedElements[j].element, mSelectedElements[i].element))
  525. {
  526. hasDeletedParent = true;
  527. break;
  528. }
  529. }
  530. if (!hasDeletedParent)
  531. elementsToDelete.push_back(mSelectedElements[i].element);
  532. }
  533. clearPing();
  534. unselectAll();
  535. for (auto& elem : elementsToDelete)
  536. deleteTreeElement(elem);
  537. }
  538. }
  539. void GUITreeView::ping(TreeElement* element)
  540. {
  541. clearPing();
  542. expandToElement(element);
  543. scrollToElement(element, true);
  544. GUITexture* background = GUITexture::create(mHighlightBackgroundStyle);
  545. background->_setElementDepth(2);
  546. _registerChildElement(background);
  547. element->mIsHighlighted = true;
  548. mHighlightedElement.element = element;
  549. mHighlightedElement.background = background;
  550. mIsElementHighlighted = true;
  551. _markLayoutAsDirty();
  552. }
  553. void GUITreeView::clearPing()
  554. {
  555. if (!mIsElementHighlighted)
  556. return;
  557. mHighlightedElement.element->mIsHighlighted = false;
  558. GUIElement::destroy(mHighlightedElement.background);
  559. mHighlightedElement.element = nullptr;
  560. mHighlightedElement.background = nullptr;
  561. mIsElementHighlighted = false;
  562. _markLayoutAsDirty();
  563. }
  564. void GUITreeView::expandToElement(TreeElement* element)
  565. {
  566. if (element->mIsVisible || element->mParent == nullptr)
  567. return;
  568. Stack<TreeElement*> todo;
  569. TreeElement* parent = element->mParent;
  570. while (parent != nullptr)
  571. {
  572. if (!parent->mIsExpanded)
  573. todo.push(parent);
  574. if (parent->mIsVisible)
  575. break;
  576. parent = parent->mParent;
  577. }
  578. while (!todo.empty())
  579. {
  580. TreeElement* curElement = todo.top();
  581. todo.pop();
  582. expandElement(curElement);
  583. }
  584. }
  585. void GUITreeView::expandElement(TreeElement* element)
  586. {
  587. if(element->mIsExpanded)
  588. return;
  589. element->mIsExpanded = true;
  590. if(element->mParent == nullptr || (element->mParent->mIsVisible && element->mParent->mIsExpanded))
  591. {
  592. Stack<TreeElement*> todo;
  593. todo.push(element);
  594. while(!todo.empty())
  595. {
  596. TreeElement* curElem = todo.top();
  597. todo.pop();
  598. curElem->mIsVisible = true;
  599. updateElementGUI(curElem);
  600. if(curElem->mIsExpanded)
  601. {
  602. for(auto& child : curElem->mChildren)
  603. todo.push(child);
  604. }
  605. }
  606. }
  607. }
  608. void GUITreeView::collapseElement(TreeElement* element)
  609. {
  610. if(!element->mIsExpanded)
  611. return;
  612. element->mIsExpanded = false;
  613. updateElementGUI(element);
  614. if(element->mParent == nullptr || (element->mParent->mIsVisible && element->mParent->mIsExpanded))
  615. {
  616. Stack<TreeElement*> todo;
  617. for(auto& child : element->mChildren)
  618. todo.push(child);
  619. while(!todo.empty())
  620. {
  621. TreeElement* curElem = todo.top();
  622. todo.pop();
  623. curElem->mIsVisible = false;
  624. if(curElem->mIsSelected)
  625. unselectElement(curElem);
  626. updateElementGUI(curElem);
  627. if(curElem->mIsExpanded)
  628. {
  629. for(auto& child : curElem->mChildren)
  630. todo.push(child);
  631. }
  632. }
  633. }
  634. }
  635. void GUITreeView::updateElementGUI(TreeElement* element)
  636. {
  637. if(element == &getRootElement())
  638. return;
  639. if(element->mIsVisible)
  640. {
  641. HString name(toWString(element->mName));
  642. if(element->mElement == nullptr)
  643. {
  644. element->mElement = GUILabel::create(name, mElementBtnStyle);
  645. _registerChildElement(element->mElement);
  646. }
  647. if (element->mIsCut)
  648. {
  649. Color cutTint = element->mTint;
  650. cutTint.a = CUT_COLOR.a;
  651. element->mElement->setTint(cutTint);
  652. }
  653. else if(element->mIsDisabled)
  654. {
  655. Color disabledTint = element->mTint;
  656. disabledTint.a = DISABLED_COLOR.a;
  657. element->mElement->setTint(disabledTint);
  658. }
  659. else
  660. element->mElement->setTint(element->mTint);
  661. if(element->mChildren.size() > 0)
  662. {
  663. if(element->mFoldoutBtn == nullptr)
  664. {
  665. element->mFoldoutBtn = GUIToggle::create(GUIContent(HString(L"")), mFoldoutBtnStyle);
  666. _registerChildElement(element->mFoldoutBtn);
  667. element->mFoldoutBtn->onToggled.connect(std::bind(&GUITreeView::elementToggled, this, element, _1));
  668. if(element->mIsExpanded)
  669. element->mFoldoutBtn->toggleOn();
  670. }
  671. }
  672. else
  673. {
  674. if(element->mFoldoutBtn != nullptr)
  675. {
  676. GUIElement::destroy(element->mFoldoutBtn);
  677. element->mFoldoutBtn = nullptr;
  678. }
  679. }
  680. element->mElement->setContent(GUIContent(name));
  681. }
  682. else
  683. {
  684. if(element->mElement != nullptr)
  685. {
  686. GUIElement::destroy(element->mElement);
  687. element->mElement = nullptr;
  688. }
  689. if(element->mFoldoutBtn != nullptr)
  690. {
  691. GUIElement::destroy(element->mFoldoutBtn);
  692. element->mFoldoutBtn = nullptr;
  693. }
  694. if(element->mIsSelected && element->mIsExpanded)
  695. unselectElement(element);
  696. }
  697. _markLayoutAsDirty();
  698. }
  699. void GUITreeView::elementToggled(TreeElement* element, bool toggled)
  700. {
  701. clearPing();
  702. if(toggled)
  703. expandElement(element);
  704. else
  705. collapseElement(element);
  706. }
  707. void GUITreeView::onEditAccepted()
  708. {
  709. TreeElement* elem = mEditElement;
  710. disableEdit(true);
  711. selectElement(elem);
  712. }
  713. void GUITreeView::onEditCanceled()
  714. {
  715. if (mEditElement != nullptr)
  716. {
  717. TreeElement* elem = mEditElement;
  718. disableEdit(false);
  719. selectElement(elem);
  720. }
  721. }
  722. void GUITreeView::onEditFocusLost()
  723. {
  724. if (mEditElement != nullptr)
  725. disableEdit(false);
  726. }
  727. void GUITreeView::enableEdit(TreeElement* element)
  728. {
  729. assert(mEditElement == nullptr);
  730. mEditElement = element;
  731. mNameEditBox->setVisible(true);
  732. mNameEditBox->setText(toWString(element->mName));
  733. mNameEditBox->setFocus(true);
  734. if(element->mElement != nullptr)
  735. element->mElement->setVisible(false);
  736. }
  737. void GUITreeView::disableEdit(bool applyChanges)
  738. {
  739. assert(mEditElement != nullptr);
  740. if(mEditElement->mElement != nullptr)
  741. mEditElement->mElement->setVisible(true);
  742. if(applyChanges)
  743. {
  744. WString newName = mNameEditBox->getText();
  745. renameTreeElement(mEditElement, newName);
  746. }
  747. mNameEditBox->setFocus(false);
  748. mNameEditBox->setVisible(false);
  749. mEditElement = nullptr;
  750. }
  751. Vector2I GUITreeView::_getOptimalSize() const
  752. {
  753. struct UpdateTreeElement
  754. {
  755. UpdateTreeElement(const TreeElement* element, UINT32 indent)
  756. :element(element), indent(indent)
  757. { }
  758. const TreeElement* element;
  759. UINT32 indent;
  760. };
  761. Vector2I optimalSize;
  762. if (_getDimensions().fixedWidth() && _getDimensions().fixedHeight())
  763. {
  764. optimalSize.x = _getDimensions().minWidth;
  765. optimalSize.y = _getDimensions().minHeight;
  766. }
  767. else
  768. {
  769. Stack<UpdateTreeElement> todo;
  770. todo.push(UpdateTreeElement(&getRootElementConst(), 0));
  771. while(!todo.empty())
  772. {
  773. UpdateTreeElement currentUpdateElement = todo.top();
  774. const TreeElement* current = currentUpdateElement.element;
  775. todo.pop();
  776. INT32 yOffset = 0;
  777. if(current->mElement != nullptr)
  778. {
  779. Vector2I curOptimalSize = current->mElement->_getOptimalSize();
  780. optimalSize.x = std::max(optimalSize.x,
  781. (INT32)(INITIAL_INDENT_OFFSET + curOptimalSize.x + currentUpdateElement.indent * INDENT_SIZE));
  782. yOffset = curOptimalSize.y + ELEMENT_EXTRA_SPACING;
  783. }
  784. optimalSize.y += yOffset;
  785. for(auto& child : current->mChildren)
  786. {
  787. if(!child->mIsVisible)
  788. continue;
  789. todo.push(UpdateTreeElement(child, currentUpdateElement.indent + 1));
  790. }
  791. }
  792. if(_getDimensions().fixedWidth())
  793. optimalSize.x = _getDimensions().minWidth;
  794. else
  795. {
  796. if(_getDimensions().minWidth > 0)
  797. optimalSize.x = std::max((INT32)_getDimensions().minWidth, optimalSize.x);
  798. if(_getDimensions().maxWidth > 0)
  799. optimalSize.x = std::min((INT32)_getDimensions().maxWidth, optimalSize.x);
  800. }
  801. if (_getDimensions().fixedHeight())
  802. optimalSize.y = _getDimensions().minHeight;
  803. else
  804. {
  805. if(_getDimensions().minHeight > 0)
  806. optimalSize.y = std::max((INT32)_getDimensions().minHeight, optimalSize.y);
  807. if(_getDimensions().maxHeight > 0)
  808. optimalSize.y = std::min((INT32)_getDimensions().maxHeight, optimalSize.y);
  809. }
  810. }
  811. return optimalSize;
  812. }
  813. void GUITreeView::updateClippedBounds()
  814. {
  815. mClippedBounds = mLayoutData.area;
  816. mClippedBounds.clip(mLayoutData.clipRect);
  817. }
  818. void GUITreeView::_updateLayoutInternal(const GUILayoutData& data)
  819. {
  820. struct UpdateTreeElement
  821. {
  822. UpdateTreeElement(TreeElement* element, UINT32 indent)
  823. :element(element), indent(indent)
  824. { }
  825. TreeElement* element;
  826. UINT32 indent;
  827. };
  828. mVisibleElements.clear();
  829. Stack<UpdateTreeElement> todo;
  830. todo.push(UpdateTreeElement(&getRootElement(), 0));
  831. // NOTE - Instead of iterating through all elements, try to find those within the clip rect
  832. // and only iterate through those. Others should somehow be marked in-active (similar to GUIElement::isDisabled()?)
  833. Vector<TreeElement*> tempOrderedElements;
  834. Vector2I offset(data.area.x, data.area.y);
  835. while(!todo.empty())
  836. {
  837. UpdateTreeElement currentUpdateElement = todo.top();
  838. TreeElement* current = currentUpdateElement.element;
  839. UINT32 indent = currentUpdateElement.indent;
  840. todo.pop();
  841. INT32 btnHeight = 0;
  842. INT32 yOffset = 0;
  843. if(current->mElement != nullptr)
  844. {
  845. Vector2I elementSize = current->mElement->_getOptimalSize();
  846. btnHeight = elementSize.y;
  847. mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 0, Rect2I(data.area.x, offset.y, data.area.width, ELEMENT_EXTRA_SPACING)));
  848. mVisibleElements.push_back(InteractableElement(current->mParent, current->mSortedIdx * 2 + 1, Rect2I(data.area.x, offset.y + ELEMENT_EXTRA_SPACING, data.area.width, btnHeight)));
  849. offset.x = data.area.x + INITIAL_INDENT_OFFSET + indent * INDENT_SIZE;
  850. offset.y += ELEMENT_EXTRA_SPACING;
  851. GUILayoutData childData = data;
  852. childData.area.x = offset.x;
  853. childData.area.y = offset.y;
  854. childData.area.width = elementSize.x;
  855. childData.area.height = elementSize.y;
  856. current->mElement->_setLayoutData(childData);
  857. yOffset = btnHeight;
  858. }
  859. if(current->mFoldoutBtn != nullptr)
  860. {
  861. Vector2I elementSize = current->mFoldoutBtn->_getOptimalSize();
  862. offset.x -= std::min((INT32)INITIAL_INDENT_OFFSET, elementSize.x + 2);
  863. Vector2I myOffset = offset;
  864. myOffset.y += 1;
  865. if(elementSize.y > btnHeight)
  866. {
  867. UINT32 diff = elementSize.y - btnHeight;
  868. float half = diff * 0.5f;
  869. myOffset.y -= Math::floorToInt(half);
  870. }
  871. GUILayoutData childData = data;
  872. childData.area.x = myOffset.x;
  873. childData.area.y = myOffset.y;
  874. childData.area.width = elementSize.x;
  875. childData.area.height = elementSize.y;
  876. current->mFoldoutBtn->_setLayoutData(childData);
  877. }
  878. offset.y += yOffset;
  879. tempOrderedElements.resize(current->mChildren.size(), nullptr);
  880. for(auto& child : current->mChildren)
  881. {
  882. tempOrderedElements[child->mSortedIdx] = child;
  883. }
  884. for(auto iter = tempOrderedElements.rbegin(); iter != tempOrderedElements.rend(); ++iter)
  885. {
  886. TreeElement* child = *iter;
  887. if(!child->mIsVisible)
  888. continue;
  889. todo.push(UpdateTreeElement(child, indent + 1));
  890. }
  891. }
  892. UINT32 remainingHeight = (UINT32)std::max(0, (INT32)data.area.height - (offset.y - data.area.y));
  893. if(remainingHeight > 0)
  894. mVisibleElements.push_back(InteractableElement(&getRootElement(), (UINT32)getRootElement().mChildren.size() * 2, Rect2I(data.area.x, offset.y, data.area.width, remainingHeight)));
  895. for(auto selectedElem : mSelectedElements)
  896. {
  897. GUILabel* targetElement = selectedElem.element->mElement;
  898. GUILayoutData childData = data;
  899. childData.area.y = targetElement->_getLayoutData().area.y;
  900. childData.area.height = targetElement->_getLayoutData().area.height;
  901. selectedElem.background->_setLayoutData(childData);
  902. }
  903. if (mIsElementHighlighted)
  904. {
  905. GUILabel* targetElement = mHighlightedElement.element->mElement;
  906. GUILayoutData childData = data;
  907. childData.area.y = targetElement->_getLayoutData().area.y;
  908. childData.area.height = targetElement->_getLayoutData().area.height;
  909. mHighlightedElement.background->_setLayoutData(childData);
  910. }
  911. if(mEditElement != nullptr)
  912. {
  913. GUILabel* targetElement = mEditElement->mElement;
  914. UINT32 remainingWidth = (UINT32)std::max(0, (((INT32)data.area.width) - (offset.x - data.area.x)));
  915. GUILayoutData childData = data;
  916. childData.area = targetElement->_getLayoutData().area;
  917. childData.area.width = remainingWidth;
  918. mNameEditBox->_setLayoutData(childData);
  919. }
  920. if(mDragInProgress)
  921. {
  922. const InteractableElement* interactableElement = findElementUnderCoord(mDragPosition);
  923. if(interactableElement == nullptr)
  924. {
  925. mDragHighlight->setVisible(false);
  926. mDragSepHighlight->setVisible(false);
  927. }
  928. else
  929. {
  930. if(interactableElement->isTreeElement())
  931. {
  932. mDragSepHighlight->setVisible(false);
  933. mDragHighlight->setVisible(true);
  934. GUILayoutData childData = data;
  935. childData.area = interactableElement->bounds;
  936. mDragHighlight->_setLayoutData(childData);
  937. }
  938. else
  939. {
  940. mDragHighlight->setVisible(false);
  941. mDragSepHighlight->setVisible(true);
  942. GUILayoutData childData = data;
  943. childData.area = interactableElement->bounds;
  944. mDragSepHighlight->_setLayoutData(childData);
  945. }
  946. }
  947. }
  948. else
  949. {
  950. mDragHighlight->setVisible(false);
  951. mDragSepHighlight->setVisible(false);
  952. }
  953. // Update scroll bounds
  954. UINT32 scrollHeight = (UINT32)Math::roundToInt(data.clipRect.height * SCROLL_AREA_HEIGHT_PCT);
  955. mTopScrollBounds.x = data.clipRect.x;
  956. mTopScrollBounds.y = data.clipRect.y;
  957. mTopScrollBounds.width = data.clipRect.width;
  958. mTopScrollBounds.height = scrollHeight;
  959. mBottomScrollBounds.x = data.clipRect.x;
  960. mBottomScrollBounds.y = data.clipRect.y + data.clipRect.height - scrollHeight;
  961. mBottomScrollBounds.width = data.clipRect.width;
  962. mBottomScrollBounds.height = scrollHeight;
  963. }
  964. const GUITreeView::InteractableElement* GUITreeView::findElementUnderCoord(const Vector2I& coord) const
  965. {
  966. for(auto& element : mVisibleElements)
  967. {
  968. if(element.bounds.contains(coord))
  969. {
  970. return &element;
  971. }
  972. }
  973. return nullptr;
  974. }
  975. GUITreeView::TreeElement* GUITreeView::getTopMostSelectedElement() const
  976. {
  977. auto topMostElement = mVisibleElements.end();
  978. for(auto& selectedElement : mSelectedElements)
  979. {
  980. auto iterFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  981. [&] (const InteractableElement& x) { return x.getTreeElement() == selectedElement.element; });
  982. if(iterFind != mVisibleElements.end())
  983. {
  984. if(topMostElement == mVisibleElements.end())
  985. topMostElement = iterFind;
  986. else
  987. {
  988. if(iterFind->bounds.y < topMostElement->bounds.y)
  989. topMostElement = iterFind;
  990. }
  991. }
  992. }
  993. if(topMostElement != mVisibleElements.end())
  994. return topMostElement->getTreeElement();
  995. else
  996. return nullptr;
  997. }
  998. GUITreeView::TreeElement* GUITreeView::getBottomMostSelectedElement() const
  999. {
  1000. auto& botMostElement = mVisibleElements.end();
  1001. for(auto& selectedElement : mSelectedElements)
  1002. {
  1003. auto iterFind = std::find_if(mVisibleElements.begin(), mVisibleElements.end(),
  1004. [&] (const InteractableElement& x) { return x.getTreeElement() == selectedElement.element; });
  1005. if(iterFind != mVisibleElements.end())
  1006. {
  1007. if(botMostElement == mVisibleElements.end())
  1008. botMostElement = iterFind;
  1009. else
  1010. {
  1011. if((iterFind->bounds.y + iterFind->bounds.height) > (botMostElement->bounds.y + botMostElement->bounds.height))
  1012. botMostElement = iterFind;
  1013. }
  1014. }
  1015. }
  1016. if(botMostElement != mVisibleElements.end())
  1017. return botMostElement->getTreeElement();
  1018. else
  1019. return nullptr;
  1020. }
  1021. void GUITreeView::closeTemporarilyExpandedElements()
  1022. {
  1023. temporarilyExpandElement(nullptr);
  1024. }
  1025. void GUITreeView::temporarilyExpandElement(const GUITreeView::InteractableElement* mouseOverElement)
  1026. {
  1027. TreeElement* treeElement = nullptr;
  1028. if(mouseOverElement != nullptr && mouseOverElement->isTreeElement())
  1029. treeElement = mouseOverElement->getTreeElement();
  1030. if(treeElement == nullptr || treeElement != mMouseOverDragElement)
  1031. {
  1032. while(!mAutoExpandedElements.empty())
  1033. {
  1034. TreeElement* autoExpandedElement = mAutoExpandedElements.top();
  1035. bool unexpandElement = false;
  1036. if(mouseOverElement != nullptr && mouseOverElement->parent != nullptr)
  1037. {
  1038. if(mouseOverElement->parent != autoExpandedElement && !mouseOverElement->parent->isParentRec(autoExpandedElement))
  1039. unexpandElement = true;
  1040. else
  1041. break;
  1042. }
  1043. else
  1044. unexpandElement = true;
  1045. if(unexpandElement)
  1046. {
  1047. collapseElement(autoExpandedElement);
  1048. if(autoExpandedElement->mFoldoutBtn != nullptr)
  1049. autoExpandedElement->mFoldoutBtn->toggleOff();
  1050. mAutoExpandedElements.pop();
  1051. }
  1052. }
  1053. mMouseOverDragElement = treeElement;
  1054. mMouseOverDragElementTime = gTime().getTime();
  1055. }
  1056. else
  1057. {
  1058. if(mMouseOverDragElement != nullptr && !mMouseOverDragElement->mIsExpanded)
  1059. {
  1060. float timeDiff = gTime().getTime() - mMouseOverDragElementTime;
  1061. if(timeDiff >= AUTO_EXPAND_DELAY_SEC)
  1062. {
  1063. mAutoExpandedElements.push(mMouseOverDragElement);
  1064. expandElement(mMouseOverDragElement);
  1065. if(mMouseOverDragElement->mFoldoutBtn != nullptr)
  1066. mMouseOverDragElement->mFoldoutBtn->toggleOn();
  1067. }
  1068. }
  1069. }
  1070. }
  1071. void GUITreeView::scrollToElement(TreeElement* element, bool center)
  1072. {
  1073. if(element->mElement == nullptr)
  1074. return;
  1075. GUIScrollArea* scrollArea = findParentScrollArea();
  1076. if(scrollArea == nullptr)
  1077. return;
  1078. if(center)
  1079. {
  1080. Rect2I myBounds = _getClippedBounds();
  1081. INT32 clipVertCenter = myBounds.y + (INT32)Math::roundToInt(myBounds.height * 0.5f);
  1082. INT32 elemVertCenter = element->mElement->_getLayoutData().area.y + (INT32)Math::roundToInt(element->mElement->_getLayoutData().area.height * 0.5f);
  1083. if(elemVertCenter > clipVertCenter)
  1084. scrollArea->scrollDownPx(elemVertCenter - clipVertCenter);
  1085. else
  1086. scrollArea->scrollUpPx(clipVertCenter - elemVertCenter);
  1087. }
  1088. else
  1089. {
  1090. Rect2I myBounds = _getClippedBounds();
  1091. INT32 elemVertTop = element->mElement->_getLayoutData().area.y;
  1092. INT32 elemVertBottom = element->mElement->_getLayoutData().area.y + element->mElement->_getLayoutData().area.height;
  1093. INT32 top = myBounds.y;
  1094. INT32 bottom = myBounds.y + myBounds.height;
  1095. INT32 offset = 0;
  1096. if(elemVertTop < top)
  1097. scrollArea->scrollUpPx(top - elemVertTop);
  1098. else if(elemVertBottom > bottom)
  1099. scrollArea->scrollDownPx(elemVertBottom - bottom);
  1100. }
  1101. }
  1102. GUIScrollArea* GUITreeView::findParentScrollArea() const
  1103. {
  1104. GUIElementBase* parent = _getParent();
  1105. while(parent != nullptr)
  1106. {
  1107. if(parent->_getType() == GUIElementBase::Type::Element)
  1108. {
  1109. GUIElement* parentElement = static_cast<GUIElement*>(parent);
  1110. if(parentElement->_getElementType() == GUIElement::ElementType::ScrollArea)
  1111. {
  1112. GUIScrollArea* scrollArea = static_cast<GUIScrollArea*>(parentElement);
  1113. return scrollArea;
  1114. }
  1115. }
  1116. parent = parent->_getParent();
  1117. }
  1118. return nullptr;
  1119. }
  1120. const String& GUITreeView::getGUITypeName()
  1121. {
  1122. static String typeName = "SceneTreeView";
  1123. return typeName;
  1124. }
  1125. }