diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-11 15:38:06 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-11 15:38:06 +0200 |
commit | d08401236c8e13165550724f646f0f458b0f0895 (patch) | |
tree | bde7b7755118b3522cb53d8f418f404fe3dd3c38 /scene/gui/text_edit.cpp | |
parent | 5f5ca23586d1e9928b1fb7a7a8f604fe02f3a824 (diff) | |
parent | 2924bfd4d3c6dbdf01df3263000070634826f0a9 (diff) | |
download | redot-engine-d08401236c8e13165550724f646f0f458b0f0895.tar.gz |
Merge pull request #81312 from YuriSizov/theme-static-binds
Register theme properties with ThemeDB
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r-- | scene/gui/text_edit.cpp | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 1184e071ac..292809b40d 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -39,9 +39,9 @@ #include "core/os/os.h" #include "core/string/string_builder.h" #include "core/string/translation.h" -#include "label.h" - +#include "scene/gui/label.h" #include "scene/main/window.h" +#include "scene/theme/theme_db.h" /////////////////////////////////////////////////////////////////////////////// /// TEXT /// @@ -3000,51 +3000,11 @@ void TextEdit::_update_theme_item_cache() { Control::_update_theme_item_cache(); theme_cache.base_scale = get_theme_default_base_scale(); - - /* Internal API for CodeEdit */ - theme_cache.brace_mismatch_color = get_theme_color(SNAME("brace_mismatch_color"), SNAME("CodeEdit")); - theme_cache.code_folding_color = get_theme_color(SNAME("code_folding_color"), SNAME("CodeEdit")); - theme_cache.folded_eol_icon = get_theme_icon(SNAME("folded_eol_icon"), SNAME("CodeEdit")); - - /* Search */ - theme_cache.search_result_color = get_theme_color(SNAME("search_result_color")); - theme_cache.search_result_border_color = get_theme_color(SNAME("search_result_border_color")); - - /* Caret */ - theme_cache.caret_width = get_theme_constant(SNAME("caret_width")); - theme_cache.caret_color = get_theme_color(SNAME("caret_color")); - theme_cache.caret_background_color = get_theme_color(SNAME("caret_background_color")); - - /* Selection */ - theme_cache.font_selected_color = get_theme_color(SNAME("font_selected_color")); - theme_cache.selection_color = get_theme_color(SNAME("selection_color")); use_selected_font_color = theme_cache.font_selected_color != Color(0, 0, 0, 0); - /* Other visuals */ - theme_cache.style_normal = get_theme_stylebox(SNAME("normal")); - theme_cache.style_focus = get_theme_stylebox(SNAME("focus")); - theme_cache.style_readonly = get_theme_stylebox(SNAME("read_only")); - - theme_cache.tab_icon = get_theme_icon(SNAME("tab")); - theme_cache.space_icon = get_theme_icon(SNAME("space")); - - theme_cache.font = get_theme_font(SNAME("font")); - theme_cache.font_size = get_theme_font_size(SNAME("font_size")); - theme_cache.font_color = get_theme_color(SNAME("font_color")); - theme_cache.font_readonly_color = get_theme_color(SNAME("font_readonly_color")); - theme_cache.font_placeholder_color = get_theme_color(SNAME("font_placeholder_color")); - - theme_cache.outline_size = get_theme_constant(SNAME("outline_size")); - theme_cache.outline_color = get_theme_color(SNAME("font_outline_color")); - - theme_cache.line_spacing = get_theme_constant(SNAME("line_spacing")); if (text.get_line_height() + theme_cache.line_spacing < 1) { WARN_PRINT("Line height is too small, please increase font_size and/or line_spacing"); } - - theme_cache.background_color = get_theme_color(SNAME("background_color")); - theme_cache.current_line_color = get_theme_color(SNAME("current_line_color")); - theme_cache.word_highlighted_color = get_theme_color(SNAME("word_highlighted_color")); } void TextEdit::_update_caches() { @@ -6053,7 +6013,7 @@ bool TextEdit::is_drawing_spaces() const { } void TextEdit::_bind_methods() { - /*Internal. */ + /* Internal. */ ClassDB::bind_method(D_METHOD("_text_changed_emit"), &TextEdit::_text_changed_emit); @@ -6512,6 +6472,48 @@ void TextEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("gutter_added")); ADD_SIGNAL(MethodInfo("gutter_removed")); + /* Theme items */ + /* Internal API for CodeEdit */ + BIND_THEME_ITEM_EXT(Theme::DATA_TYPE_COLOR, TextEdit, brace_mismatch_color, "brace_mismatch_color", "CodeEdit"); + BIND_THEME_ITEM_EXT(Theme::DATA_TYPE_COLOR, TextEdit, code_folding_color, "code_folding_color", "CodeEdit"); + BIND_THEME_ITEM_EXT(Theme::DATA_TYPE_ICON, TextEdit, folded_eol_icon, "folded_eol_icon", "CodeEdit"); + + /* Search */ + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, search_result_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, search_result_border_color); + + /* Caret */ + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TextEdit, caret_width); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, caret_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, caret_background_color); + + /* Selection */ + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, font_selected_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, selection_color); + + /* Other visuals */ + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TextEdit, style_normal, "normal"); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TextEdit, style_focus, "focus"); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TextEdit, style_readonly, "read_only"); + + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TextEdit, tab_icon, "tab"); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TextEdit, space_icon, "space"); + + BIND_THEME_ITEM(Theme::DATA_TYPE_FONT, TextEdit, font); + BIND_THEME_ITEM(Theme::DATA_TYPE_FONT_SIZE, TextEdit, font_size); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, font_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, font_readonly_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, font_placeholder_color); + + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TextEdit, outline_size); + BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_COLOR, TextEdit, outline_color, "font_outline_color"); + + BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, TextEdit, line_spacing); + + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, background_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, current_line_color); + BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, TextEdit, word_highlighted_color); + /* Settings. */ GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "gui/timers/text_edit_idle_detect_sec", PROPERTY_HINT_RANGE, "0,10,0.01,or_greater"), 3); GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/common/text_edit_undo_stack_max_size", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 1024); |