scene_tree_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*************************************************************************/
  2. /* scene_tree_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef SCENE_TREE_EDITOR_H
  30. #define SCENE_TREE_EDITOR_H
  31. #include "scene/gui/tree.h"
  32. #include "scene/gui/button.h"
  33. #include "scene/gui/dialogs.h"
  34. #include "undo_redo.h"
  35. #include "editor_data.h"
  36. /**
  37. @author Juan Linietsky <[email protected]>
  38. */
  39. class SceneTreeEditor : public Control {
  40. OBJ_TYPE( SceneTreeEditor, Control );
  41. EditorSelection *editor_selection;
  42. enum {
  43. BUTTON_SUBSCENE=0,
  44. BUTTON_VISIBILITY=1,
  45. BUTTON_SCRIPT=2,
  46. BUTTON_LOCK=3,
  47. BUTTON_GROUP=4,
  48. };
  49. Tree *tree;
  50. Node *selected;
  51. AcceptDialog *error;
  52. int blocked;
  53. void _compute_hash(Node *p_node,uint64_t &hash);
  54. void _add_nodes(Node *p_node,TreeItem *p_parent);
  55. void _test_update_tree();
  56. void _update_tree();
  57. void _tree_changed();
  58. void _node_removed(Node *p_node);
  59. TreeItem* _find(TreeItem *p_node,const NodePath& p_path);
  60. void _notification(int p_what);
  61. void _selected_changed();
  62. void _rename_node(ObjectID p_node,const String& p_name);
  63. void _cell_collapsed(Object *p_obj);
  64. uint64_t last_hash;
  65. bool can_rename;
  66. bool can_open_instance;
  67. bool updating_tree;
  68. void _renamed();
  69. UndoRedo *undo_redo;
  70. Set<Node*> marked;
  71. bool marked_selectable;
  72. bool marked_children_selectable;
  73. bool display_foreign;
  74. bool tree_dirty;
  75. bool pending_test_update;
  76. static void _bind_methods();
  77. void _cell_button_pressed(Object *p_item,int p_column,int p_id);
  78. void _cell_multi_selected(Object *p_object,int p_cel,bool p_selected);
  79. void _update_selection(TreeItem *item);
  80. void _node_script_changed(Node *p_node);
  81. void _node_visibility_changed(Node *p_node);
  82. void _selection_changed();
  83. Node *get_scene_node();
  84. public:
  85. void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; };
  86. void set_display_foreign_nodes(bool p_display);
  87. bool get_display_foreign_nodes() const;
  88. void set_marked(const Set<Node*>& p_marked,bool p_selectable=false,bool p_children_selectable=true);
  89. void set_marked(Node *p_marked,bool p_selectable=false,bool p_children_selectable=true);
  90. void set_selected(Node *p_node,bool p_emit_selected=true);
  91. Node *get_selected();
  92. void set_can_rename(bool p_can_rename) { can_rename=p_can_rename; }
  93. void set_editor_selection(EditorSelection *p_selection);
  94. void update_tree() { _update_tree(); }
  95. SceneTreeEditor(bool p_label=true,bool p_can_rename=false, bool p_can_open_instance=false);
  96. ~SceneTreeEditor();
  97. };
  98. class SceneTreeDialog : public ConfirmationDialog {
  99. OBJ_TYPE( SceneTreeDialog, ConfirmationDialog );
  100. SceneTreeEditor *tree;
  101. // Button *select;
  102. // Button *cancel;
  103. void update_tree();
  104. void _select();
  105. void _cancel();
  106. protected:
  107. void _notification(int p_what);
  108. static void _bind_methods();
  109. public:
  110. SceneTreeEditor *get_tree() { return tree; }
  111. SceneTreeDialog();
  112. ~SceneTreeDialog();
  113. };
  114. #endif