BsDockManagerLayout.cpp 2.0 KB

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