scene_tree_dock.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*************************************************************************/
  2. /* scene_tree_dock.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SCENE_TREE_DOCK_H
  31. #define SCENE_TREE_DOCK_H
  32. #include "connections_dialog.h"
  33. #include "create_dialog.h"
  34. #include "editor_data.h"
  35. #include "editor_sub_scene.h"
  36. #include "groups_editor.h"
  37. #include "reparent_dialog.h"
  38. #include "scene/animation/animation_player.h"
  39. #include "scene/gui/box_container.h"
  40. #include "scene/gui/button.h"
  41. #include "scene/gui/control.h"
  42. #include "scene/gui/label.h"
  43. #include "scene/gui/popup_menu.h"
  44. #include "scene/gui/tool_button.h"
  45. #include "scene/gui/tree.h"
  46. #include "scene_tree_editor.h"
  47. #include "script_create_dialog.h"
  48. class EditorNode;
  49. class SceneTreeDock : public VBoxContainer {
  50. OBJ_TYPE(SceneTreeDock, VBoxContainer);
  51. enum Tool {
  52. TOOL_NEW,
  53. TOOL_INSTANCE,
  54. TOOL_REPLACE,
  55. TOOL_CONNECT,
  56. TOOL_GROUP,
  57. TOOL_ATTACH_SCRIPT,
  58. TOOL_CLEAR_SCRIPT,
  59. TOOL_MOVE_UP,
  60. TOOL_MOVE_DOWN,
  61. TOOL_DUPLICATE,
  62. TOOL_REPARENT,
  63. TOOL_NEW_SCENE_FROM,
  64. TOOL_MERGE_FROM_SCENE,
  65. TOOL_MULTI_EDIT,
  66. TOOL_ERASE,
  67. TOOL_COPY_NODE_PATH,
  68. TOOL_BUTTON_MAX
  69. };
  70. int current_option;
  71. CreateDialog *create_dialog;
  72. ToolButton *button_add;
  73. ToolButton *button_instance;
  74. ToolButton *button_create_script;
  75. ToolButton *button_clear_script;
  76. SceneTreeEditor *scene_tree;
  77. HBoxContainer *tool_hbc;
  78. void _tool_selected(int p_tool, bool p_confirm_override = false);
  79. EditorData *editor_data;
  80. EditorSelection *editor_selection;
  81. //GroupsEditor *groups_editor;
  82. //ConnectionsDialog *connect_dialog;
  83. ScriptCreateDialog *script_create_dialog;
  84. AcceptDialog *accept;
  85. ConfirmationDialog *delete_dialog;
  86. ReparentDialog *reparent_dialog;
  87. EditorFileDialog *file;
  88. EditorSubScene *import_subscene_dialog;
  89. EditorFileDialog *new_scene_from_dialog;
  90. LineEdit *filter;
  91. TextureFrame *filter_icon;
  92. PopupMenu *menu;
  93. bool first_enter;
  94. void _create();
  95. Node *scene_root;
  96. Node *edited_scene;
  97. EditorNode *editor;
  98. Node *_duplicate(Node *p_node, Map<Node *, Node *> &duplimap);
  99. void _node_reparent(NodePath p_path, bool p_keep_global_xform);
  100. void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform);
  101. void _set_owners(Node *p_owner, const Array &p_nodes);
  102. void _load_request(const String &p_path);
  103. void _script_open_request(const Ref<Script> &p_script);
  104. bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
  105. void _node_selected();
  106. void _node_renamed();
  107. void _script_created(Ref<Script> p_script);
  108. void _delete_confirm();
  109. void _node_prerenamed(Node *p_node, const String &p_new_name);
  110. void _unhandled_key_input(InputEvent p_event);
  111. void _import_subscene();
  112. void _new_scene_from(String p_file);
  113. bool _validate_no_foreign();
  114. void _selection_changed();
  115. void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames);
  116. void _normalize_drop(Node *&to_node, int &to_pos, int p_type);
  117. void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type);
  118. void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type);
  119. void _script_dropped(String p_file, NodePath p_to);
  120. void _tree_rmb(const Vector2 &p_menu_pos);
  121. void _filter_changed(const String &p_filter);
  122. void _perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos);
  123. void _replace_with_branch_scene(const String &p_file, Node *base);
  124. void _file_selected(String p_file);
  125. protected:
  126. void _notification(int p_what);
  127. static void _bind_methods();
  128. public:
  129. String get_filter();
  130. void set_filter(const String &p_filter);
  131. void import_subscene();
  132. void set_edited_scene(Node *p_scene);
  133. void instance(const String &p_path);
  134. void instance_scenes(const Vector<String> &p_files, Node *p_parent = NULL);
  135. void set_selected(Node *p_node, bool p_emit_selected = false);
  136. void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath> > *p_renames);
  137. void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims = NULL);
  138. SceneTreeEditor *get_tree_editor() { return scene_tree; }
  139. EditorData *get_editor_data() { return editor_data; }
  140. void open_script_dialog(Node *p_for_node);
  141. SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data);
  142. };
  143. #endif // SCENE_TREE_DOCK_H