浏览代码

Merge pull request #73106 from YuriSizov/editor-help-theming-2000

Improve EditorHelp theming and make font size settings work
Rémi Verschelde 2 年之前
父节点
当前提交
b601f7959b
共有 4 个文件被更改,包括 261 次插入237 次删除
  1. 223 217
      editor/editor_help.cpp
  2. 33 16
      editor/editor_help.h
  3. 2 1
      editor/editor_node.cpp
  4. 3 3
      editor/editor_settings.cpp

文件差异内容过多而无法显示
+ 223 - 217
editor/editor_help.cpp


+ 33 - 16
editor/editor_help.h

@@ -125,25 +125,33 @@ class EditorHelp : public VBoxContainer {
 
 	String base_path;
 
-	Color text_color;
-	Color title_color;
-	Color headline_color;
-	Color comment_color;
-	Color symbol_color;
-	Color value_color;
-	Color qualifier_color;
-	Color type_color;
-
-	Ref<Font> doc_font;
-	Ref<Font> doc_bold_font;
-	Ref<Font> doc_title_font;
-	Ref<Font> doc_code_font;
-
-	int doc_title_font_size;
+	struct ThemeCache {
+		Ref<StyleBox> background_style;
+
+		Color text_color;
+		Color title_color;
+		Color headline_color;
+		Color comment_color;
+		Color symbol_color;
+		Color value_color;
+		Color qualifier_color;
+		Color type_color;
+
+		Ref<Font> doc_font;
+		Ref<Font> doc_bold_font;
+		Ref<Font> doc_italic_font;
+		Ref<Font> doc_title_font;
+		Ref<Font> doc_code_font;
+		Ref<Font> doc_kbd_font;
+
+		int doc_font_size = 0;
+		int doc_title_font_size = 0;
+		int doc_code_font_size = 0;
+		int doc_kbd_font_size = 0;
+	} theme_cache;
 
 	int scroll_to = -1;
 
-	void _update_theme();
 	void _help_callback(const String &p_topic);
 
 	void _add_text(const String &p_bbcode);
@@ -156,6 +164,13 @@ class EditorHelp : public VBoxContainer {
 
 	void _add_bulletpoint();
 
+	void _push_normal_font();
+	void _pop_normal_font();
+	void _push_title_font();
+	void _pop_title_font();
+	void _push_code_font();
+	void _pop_code_font();
+
 	void _class_desc_finished();
 	void _class_list_select(const String &p_select);
 	void _class_desc_select(const String &p_select);
@@ -181,6 +196,8 @@ class EditorHelp : public VBoxContainer {
 	static void _gen_doc_thread(void *p_udata);
 
 protected:
+	virtual void _update_theme_item_cache() override;
+
 	void _notification(int p_what);
 	static void _bind_methods();
 

+ 2 - 1
editor/editor_node.cpp

@@ -691,10 +691,11 @@ void EditorNode::_notification(int p_what) {
 
 			bool theme_changed =
 					EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||
-					EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||
 					EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/font") ||
 					EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/main_font") ||
 					EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/code_font") ||
+					EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||
+					EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/help/help") ||
 					EditorSettings::get_singleton()->check_changed_settings_in_group("filesystem/file_dialog/thumbnail_size");
 
 			if (theme_changed) {

+ 3 - 3
editor/editor_settings.cpp

@@ -586,9 +586,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
 
 	// Help
 	_initial_set("text_editor/help/show_help_index", true);
-	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_font_size", 15, "8,48,1")
-	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_source_font_size", 14, "8,48,1")
-	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_title_font_size", 23, "8,48,1")
+	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_font_size", 16, "8,48,1")
+	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_source_font_size", 15, "8,48,1")
+	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/help/help_title_font_size", 23, "8,64,1")
 	EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/help/class_reference_examples", 0, "GDScript,C#,GDScript and C#")
 
 	/* Editors */

部分文件因为文件数量过多而无法显示