From 6e2c9f398c74b8d73d02814e5e9e6d09ad0ef51c Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Sat, 29 Jan 2022 20:48:30 +0300 Subject: [PATCH] Fix theming of doc background --- editor/editor_help.cpp | 10 +++++----- editor/editor_help.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 6d5e56184a8..6421d88780e 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -163,14 +163,14 @@ void EditorHelp::_class_desc_select(const String &p_select) { void EditorHelp::_class_desc_input(const Ref &p_input) { } -void EditorHelp::_class_desc_resized() { +void EditorHelp::_class_desc_resized(bool p_force_update_theme) { // Add extra horizontal margins for better readability. // The margins increase as the width of the editor help container increases. Ref doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); real_t char_width = doc_code_font->get_char_size('x', 0, font_size).width; const int new_display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; - if (display_margin != new_display_margin) { + if (display_margin != new_display_margin || p_force_update_theme) { display_margin = new_display_margin; Ref class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("RichTextLabel"))->duplicate(); @@ -1772,7 +1772,7 @@ void EditorHelp::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { if (is_inside_tree()) { - _class_desc_resized(); + _class_desc_resized(true); } update_toggle_scripts_button(); } break; @@ -1876,8 +1876,8 @@ EditorHelp::EditorHelp() { class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select)); class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input)); - class_desc->connect("resized", callable_mp(this, &EditorHelp::_class_desc_resized)); - _class_desc_resized(); + class_desc->connect("resized", callable_mp(this, &EditorHelp::_class_desc_resized), varray(false)); + _class_desc_resized(false); // Added second so it opens at the bottom so it won't offset the entire widget. find_bar = memnew(FindBar); diff --git a/editor/editor_help.h b/editor/editor_help.h index 237cf4f3479..10281a764c7 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -155,7 +155,7 @@ class EditorHelp : public VBoxContainer { void _class_list_select(const String &p_select); void _class_desc_select(const String &p_select); void _class_desc_input(const Ref &p_input); - void _class_desc_resized(); + void _class_desc_resized(bool p_force_update_theme); int display_margin = 0; Error _goto_desc(const String &p_class, int p_vscr = -1);