creator.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _CREATOR_H_
  23. #define _CREATOR_H_
  24. #ifndef _GUIARRAYCTRL_H_
  25. #include "gui/core/guiArrayCtrl.h"
  26. #endif
  27. /// Creator tree from old editor. Not used in current editor.
  28. class CreatorTree : public GuiArrayCtrl
  29. {
  30. typedef GuiArrayCtrl Parent;
  31. public:
  32. class Node
  33. {
  34. public:
  35. Node();
  36. ~Node();
  37. enum {
  38. Group = BIT(0),
  39. Expanded = BIT(1),
  40. Selected = BIT(2),
  41. Root = BIT(3)
  42. };
  43. BitSet32 mFlags;
  44. S32 mId;
  45. U32 mTab;
  46. Node * mParent;
  47. Vector<Node*> mChildren;
  48. StringTableEntry mName;
  49. StringTableEntry mValue;
  50. void expand(bool exp);
  51. void select(bool sel){mFlags.set(Selected, sel);}
  52. Node * find(S32 id);
  53. //
  54. bool isGroup(){return(mFlags.test(Group));}
  55. bool isExpanded(){return(mFlags.test(Expanded));}
  56. bool isSelected(){return(mFlags.test(Selected));}
  57. bool isRoot(){return(mFlags.test(Root));}
  58. S32 getId(){return(mId);}
  59. bool hasChildItem();
  60. S32 getSelected();
  61. //
  62. bool isFirst();
  63. bool isLast();
  64. };
  65. CreatorTree();
  66. ~CreatorTree();
  67. //
  68. S32 mCurId;
  69. Node * mRoot;
  70. Vector<Node*> mNodeList;
  71. //
  72. void buildNode(Node * node, U32 tab);
  73. void build();
  74. //
  75. bool addNode(Node * parent, Node * node);
  76. Node * createNode(const char * name, const char * value, bool group = false, Node * parent = 0);
  77. Node * findNode(S32 id);
  78. S32 getSelected(){return(mRoot->getSelected());}
  79. //
  80. void expandNode(Node * node, bool expand);
  81. void selectNode(Node * node, bool select);
  82. //
  83. void sort();
  84. void clear();
  85. S32 mTabSize;
  86. S32 mMaxWidth;
  87. S32 mTxtOffset;
  88. // GuiControl
  89. void onMouseDown(const GuiEvent & event);
  90. void onMouseDragged(const GuiEvent & event);
  91. void onMouseUp(const GuiEvent & event);
  92. bool onWake();
  93. // GuiArrayCtrl
  94. void onRenderCell(Point2I offset, Point2I cell, bool, bool);
  95. DECLARE_CONOBJECT(CreatorTree);
  96. DECLARE_CATEGORY( "Gui Editor" );
  97. };
  98. #endif