editor_help.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*************************************************************************/
  2. /* editor_help.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 EDITOR_HELP_H
  31. #define EDITOR_HELP_H
  32. #include "editor/code_editor.h"
  33. #include "editor/doc/doc_data.h"
  34. #include "editor/editor_plugin.h"
  35. #include "scene/gui/menu_button.h"
  36. #include "scene/gui/panel_container.h"
  37. #include "scene/gui/rich_text_label.h"
  38. #include "scene/gui/split_container.h"
  39. #include "scene/gui/tab_container.h"
  40. #include "scene/gui/text_edit.h"
  41. #include "scene/main/timer.h"
  42. class FindBar : public HBoxContainer {
  43. GDCLASS(FindBar, HBoxContainer);
  44. LineEdit *search_text;
  45. ToolButton *find_prev;
  46. ToolButton *find_next;
  47. Label *error_label;
  48. TextureButton *hide_button;
  49. String prev_search;
  50. Control *container;
  51. HBoxContainer *hbc;
  52. VBoxContainer *vbc_search_text;
  53. RichTextLabel *rich_text_label;
  54. void _show_search();
  55. void _hide_bar();
  56. void _search_text_changed(const String &p_text);
  57. void _search_text_entered(const String &p_text);
  58. void _update_size();
  59. protected:
  60. void _notification(int p_what);
  61. void _unhandled_input(const Ref<InputEvent> &p_event);
  62. bool _search(bool p_search_previous = false);
  63. static void _bind_methods();
  64. public:
  65. void set_error(const String &p_label);
  66. void set_rich_text_label(RichTextLabel *p_rich_text_label);
  67. void popup_search();
  68. bool search_prev();
  69. bool search_next();
  70. FindBar();
  71. };
  72. class EditorHelp : public VBoxContainer {
  73. GDCLASS(EditorHelp, VBoxContainer);
  74. enum Page {
  75. PAGE_CLASS_LIST,
  76. PAGE_CLASS_DESC,
  77. PAGE_CLASS_PREV,
  78. PAGE_CLASS_NEXT,
  79. PAGE_SEARCH,
  80. CLASS_SEARCH,
  81. };
  82. bool select_locked;
  83. String prev_search;
  84. String edited_class;
  85. Vector<Pair<String, int> > section_line;
  86. Map<String, int> method_line;
  87. Map<String, int> signal_line;
  88. Map<String, int> property_line;
  89. Map<String, int> theme_property_line;
  90. Map<String, int> constant_line;
  91. Map<String, int> enum_line;
  92. Map<String, Map<String, int> > enum_values_line;
  93. int description_line;
  94. RichTextLabel *class_desc;
  95. HSplitContainer *h_split;
  96. static DocData *doc;
  97. ConfirmationDialog *search_dialog;
  98. LineEdit *search;
  99. FindBar *find_bar;
  100. String base_path;
  101. Color title_color;
  102. Color text_color;
  103. Color headline_color;
  104. Color base_type_color;
  105. Color type_color;
  106. Color comment_color;
  107. Color symbol_color;
  108. Color value_color;
  109. Color qualifier_color;
  110. void _init_colors();
  111. void _help_callback(const String &p_topic);
  112. void _add_text(const String &p_bbcode);
  113. bool scroll_locked;
  114. //void _button_pressed(int p_idx);
  115. void _add_type(const String &p_type, const String &p_enum = String());
  116. void _add_method(const DocData::MethodDoc &p_method, bool p_overview = true);
  117. void _class_list_select(const String &p_select);
  118. void _class_desc_select(const String &p_select);
  119. void _class_desc_input(const Ref<InputEvent> &p_input);
  120. Error _goto_desc(const String &p_class, int p_vscr = -1);
  121. //void _update_history_buttons();
  122. void _update_doc();
  123. void _request_help(const String &p_string);
  124. void _search(const String &p_str);
  125. void _unhandled_key_input(const Ref<InputEvent> &p_ev);
  126. String _fix_constant(const String &p_constant) const;
  127. protected:
  128. void _notification(int p_what);
  129. static void _bind_methods();
  130. public:
  131. static void generate_doc();
  132. static DocData *get_doc_data() { return doc; }
  133. void go_to_help(const String &p_help);
  134. void go_to_class(const String &p_class, int p_scroll = 0);
  135. Vector<Pair<String, int> > get_sections();
  136. void scroll_to_section(int p_section_index);
  137. void popup_search();
  138. void search_again();
  139. String get_class();
  140. void set_focused() { class_desc->grab_focus(); }
  141. int get_scroll() const;
  142. void set_scroll(int p_scroll);
  143. EditorHelp();
  144. ~EditorHelp();
  145. };
  146. class EditorHelpBit : public PanelContainer {
  147. GDCLASS(EditorHelpBit, PanelContainer);
  148. RichTextLabel *rich_text;
  149. void _go_to_help(String p_what);
  150. void _meta_clicked(String p_select);
  151. protected:
  152. static void _bind_methods();
  153. void _notification(int p_what);
  154. public:
  155. RichTextLabel *get_rich_text() { return rich_text; }
  156. void set_text(const String &p_text);
  157. EditorHelpBit();
  158. };
  159. #endif // EDITOR_HELP_H