scene_tree_dock.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*************************************************************************/
  2. /* scene_tree_dock.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_DOCK_H
  30. #define SCENE_TREE_DOCK_H
  31. #include "scene/gui/control.h"
  32. #include "scene/gui/tree.h"
  33. #include "scene/gui/label.h"
  34. #include "scene/gui/button.h"
  35. #include "scene/gui/tool_button.h"
  36. #include "scene/gui/box_container.h"
  37. #include "scene_tree_editor.h"
  38. #include "create_dialog.h"
  39. #include "editor_data.h"
  40. #include "groups_editor.h"
  41. #include "connections_dialog.h"
  42. #include "script_create_dialog.h"
  43. #include "reparent_dialog.h"
  44. #include "scene/animation/animation_player.h"
  45. #include "editor_sub_scene.h"
  46. class EditorNode;
  47. class SceneTreeDock : public VBoxContainer {
  48. OBJ_TYPE( SceneTreeDock, VBoxContainer );
  49. enum Tool {
  50. TOOL_NEW,
  51. TOOL_INSTANCE,
  52. TOOL_REPLACE,
  53. TOOL_CONNECT,
  54. TOOL_GROUP,
  55. TOOL_SCRIPT,
  56. TOOL_MOVE_UP,
  57. TOOL_MOVE_DOWN,
  58. TOOL_DUPLICATE,
  59. TOOL_REPARENT,
  60. TOOL_ERASE,
  61. TOOL_BUTTON_MAX
  62. };
  63. int current_option;
  64. CreateDialog *create_dialog;
  65. ToolButton *tool_buttons[TOOL_BUTTON_MAX];
  66. SceneTreeEditor *scene_tree;
  67. HBoxContainer *tool_hbc;
  68. void _tool_selected(int p_tool, bool p_confirm_override = false);
  69. EditorData *editor_data;
  70. EditorSelection *editor_selection;
  71. GroupsEditor *groups_editor;
  72. ConnectionsDialog *connect_dialog;
  73. ScriptCreateDialog *script_create_dialog;
  74. AcceptDialog *accept;
  75. ConfirmationDialog *delete_dialog;
  76. ReparentDialog *reparent_dialog;
  77. FileDialog *file;
  78. EditorSubScene *import_subscene_dialog;
  79. void _create();
  80. Node *scene_root;
  81. Node *edited_scene;
  82. EditorNode *editor;
  83. Node *_duplicate(Node *p_node, Map<Node*,Node*> &duplimap);
  84. void _node_reparent(NodePath p_path,bool p_node_only);
  85. void _set_owners(Node *p_owner, const Array& p_nodes);
  86. void _load_request(const String& p_path);
  87. void _script_open_request(const Ref<Script>& p_script);
  88. void _node_selected();
  89. void _script_created(Ref<Script> p_script);
  90. void _delete_confirm();
  91. void _update_tool_buttons();
  92. void _node_prerenamed(Node* p_node, const String& p_new_name);
  93. void _unhandled_key_input(InputEvent p_event);
  94. void _import_subscene();
  95. void _fill_path_renames(Vector<StringName> base_path,Vector<StringName> new_base_path,Node * p_node, List<Pair<NodePath,NodePath> > *p_renames);
  96. protected:
  97. void _notification(int p_what);
  98. static void _bind_methods();
  99. public:
  100. void import_subscene();
  101. void set_edited_scene(Node* p_scene);
  102. Node* instance(const String& p_path);
  103. void set_selected(Node *p_node, bool p_emit_selected=false);
  104. void fill_path_renames(Node* p_node, Node *p_new_parent, List<Pair<NodePath,NodePath> > *p_renames);
  105. void perform_node_renames(Node* p_base,List<Pair<NodePath,NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims=NULL);
  106. SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data);
  107. };
  108. #endif // SCENE_TREE_DOCK_H