BsDockManagerLayout.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "BsDockManagerLayout.h"
  2. #include "BsDockManagerLayoutRTTI.h"
  3. namespace BansheeEngine
  4. {
  5. DockManagerLayout::Entry::Entry()
  6. :isLeaf(true), splitPosition(0), horizontalSplit(false),
  7. parent(nullptr)
  8. {
  9. children[0] = nullptr;
  10. children[1] = nullptr;
  11. }
  12. DockManagerLayout::Entry::~Entry()
  13. { }
  14. DockManagerLayout::Entry* DockManagerLayout::Entry::createLeaf(Entry* parent, UINT32 childIdx,
  15. const Vector<String>::type& widgetNames)
  16. {
  17. Entry* newEntry = cm_new<Entry>();
  18. newEntry->isLeaf = true;
  19. newEntry->parent = parent;
  20. if(parent != nullptr)
  21. parent->children[childIdx] = newEntry;
  22. newEntry->widgetNames = widgetNames;
  23. return newEntry;
  24. }
  25. DockManagerLayout::Entry* DockManagerLayout::Entry::createContainer(Entry* parent, UINT32 childIdx,
  26. float splitPosition, bool horizontalSplit)
  27. {
  28. Entry* newEntry = cm_new<Entry>();
  29. newEntry->isLeaf = false;
  30. newEntry->parent = parent;
  31. if(parent != nullptr)
  32. parent->children[childIdx] = newEntry;
  33. newEntry->horizontalSplit = horizontalSplit;
  34. newEntry->splitPosition = splitPosition;
  35. return newEntry;
  36. }
  37. DockManagerLayout::~DockManagerLayout()
  38. {
  39. Stack<Entry*>::type todo;
  40. if(!mRootEntry.isLeaf)
  41. {
  42. todo.push(mRootEntry.children[0]);
  43. todo.push(mRootEntry.children[1]);
  44. }
  45. while(!todo.empty())
  46. {
  47. Entry* current = todo.top();
  48. todo.pop();
  49. if(!current->isLeaf)
  50. {
  51. todo.push(current->children[0]);
  52. todo.push(current->children[1]);
  53. }
  54. cm_delete(current);
  55. }
  56. }
  57. /************************************************************************/
  58. /* RTTI */
  59. /************************************************************************/
  60. RTTITypeBase* DockManagerLayout::getRTTIStatic()
  61. {
  62. return DockManagerLayoutRTTI::instance();
  63. }
  64. RTTITypeBase* DockManagerLayout::getRTTI() const
  65. {
  66. return DockManagerLayout::getRTTIStatic();
  67. }
  68. }