editor_help.h 6.2 KB

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