summaryrefslogtreecommitdiff
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 4a1e93eaad..d2306abfd7 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -172,7 +172,9 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) {
void EditorHelp::_class_desc_resized() {
// Add extra horizontal margins for better readability.
// The margins increase as the width of the editor help container increases.
- const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - 900 * EDSCALE) * 0.5;
+ Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts");
+ real_t char_width = doc_code_font->get_char_size('x').width;
+ const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5;
Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate();
class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin);
@@ -1467,6 +1469,11 @@ void EditorHelp::_notification(int p_what) {
_update_doc();
} break;
+ case NOTIFICATION_THEME_CHANGED: {
+ if (is_visible_in_tree()) {
+ _class_desc_resized();
+ }
+ } break;
default: break;
}
}