resources_dock.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*************************************************************************/
  2. /* resources_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 RESOURCES_DOCK_H
  31. #define RESOURCES_DOCK_H
  32. #include "create_dialog.h"
  33. #include "editor_file_dialog.h"
  34. #include "scene/gui/box_container.h"
  35. #include "scene/gui/button.h"
  36. #include "scene/gui/control.h"
  37. #include "scene/gui/file_dialog.h"
  38. #include "scene/gui/label.h"
  39. #include "scene/gui/menu_button.h"
  40. #include "scene/gui/tool_button.h"
  41. #include "scene/gui/tree.h"
  42. class EditorNode;
  43. class ResourcesDock : public VBoxContainer {
  44. OBJ_TYPE(ResourcesDock, VBoxContainer);
  45. enum {
  46. TOOL_NEW,
  47. TOOL_OPEN,
  48. TOOL_SAVE,
  49. TOOL_SAVE_AS,
  50. TOOL_MAKE_LOCAL,
  51. TOOL_COPY,
  52. TOOL_PASTE,
  53. TOOL_MAX
  54. };
  55. EditorNode *editor;
  56. Button *button_new;
  57. Button *button_open;
  58. Button *button_save;
  59. Button *button_tools;
  60. CreateDialog *create_dialog;
  61. AcceptDialog *accept;
  62. EditorFileDialog *file;
  63. Tree *resources;
  64. bool block_add;
  65. int current_action;
  66. void _file_action(const String &p_action);
  67. void _delete(Object *p_item, int p_column, int p_id);
  68. void _resource_selected();
  69. void _update_name(TreeItem *item);
  70. void _tool_selected(int p_tool);
  71. void _create();
  72. protected:
  73. void _notification(int p_what);
  74. static void _bind_methods();
  75. public:
  76. void add_resource(const Ref<Resource> &p_resource);
  77. void remove_resource(const Ref<Resource> &p_resource);
  78. void save_resource(const String &p_path, const Ref<Resource> &p_resource);
  79. void save_resource_as(const Ref<Resource> &p_resource);
  80. void cleanup();
  81. ResourcesDock(EditorNode *p_editor);
  82. };
  83. #endif // RESOURCES_DOCK_H