scenes_dock.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*************************************************************************/
  2. /* scenes_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 SCENES_DOCK_H
  30. #define SCENES_DOCK_H
  31. #include "scene/main/timer.h"
  32. #include "scene/gui/control.h"
  33. #include "scene/gui/tree.h"
  34. #include "scene/gui/label.h"
  35. #include "scene/gui/tool_button.h"
  36. #include "scene/gui/option_button.h"
  37. #include "scene/gui/box_container.h"
  38. #include "os/dir_access.h"
  39. #include "os/thread.h"
  40. #include "editor_file_system.h"
  41. class EditorNode;
  42. class ScenesDockFilter;
  43. class ScenesDock : public VBoxContainer {
  44. OBJ_TYPE( ScenesDock, VBoxContainer );
  45. EditorNode *editor;
  46. Set<String> favorites;
  47. Button *button_reload;
  48. Button *button_instance;
  49. Button *button_favorite;
  50. Button *button_open;
  51. Timer *timer;
  52. ScenesDockFilter *tree_filter;
  53. bool updating_tree;
  54. Tree * tree;
  55. bool _create_tree(TreeItem *p_parent,EditorFileSystemDirectory *p_dir);
  56. void _update_tree();
  57. void _rescan();
  58. void _favorites_toggled(bool);
  59. void _favorite_toggled();
  60. void _instance_pressed();
  61. void _open_pressed();
  62. void _save_favorites();
  63. protected:
  64. void _notification(int p_what);
  65. static void _bind_methods();
  66. public:
  67. String get_selected_path() const;
  68. ScenesDock(EditorNode *p_editor);
  69. ~ScenesDock();
  70. };
  71. class ScenesDockFilter : public HBoxContainer {
  72. OBJ_TYPE( ScenesDockFilter, HBoxContainer );
  73. private:
  74. friend class ScenesDock;
  75. enum Command {
  76. CMD_CLEAR_FILTER,
  77. };
  78. Tree *tree;
  79. OptionButton *filter_option;
  80. LineEdit *search_box;
  81. ToolButton *clear_search_button;
  82. enum FilterOption {
  83. FILTER_PATH, // NAME or Folder
  84. FILTER_NAME,
  85. FILTER_FOLDER,
  86. };
  87. FilterOption _current_filter;
  88. //Vector<String> filters;
  89. void _command(int p_command);
  90. void _search_text_changed(const String& p_newtext);
  91. void _setup_filters();
  92. void _file_filter_selected(int p_idx);
  93. protected:
  94. void _notification(int p_what);
  95. static void _bind_methods();
  96. public:
  97. String get_search_term();
  98. FilterOption get_file_filter();
  99. ScenesDockFilter();
  100. };
  101. #endif // SCENES_DOCK_H