mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge pull request #107918 from kitbdev/fix-text-editor-theme-reload
Fix custom Text Editor theme changes on reload
This commit is contained in:
@@ -695,7 +695,45 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||
EDITOR_SETTING_BASIC(Variant::STRING, PROPERTY_HINT_ENUM, "text_editor/theme/color_theme", "Default", "Default,Godot 2,Custom")
|
||||
|
||||
// Theme: Highlighting
|
||||
_load_godot2_text_editor_theme();
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/symbol_color", Color(0.73, 0.87, 1.0), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/keyword_color", Color(1.0, 1.0, 0.7), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/control_flow_keyword_color", Color(1.0, 0.85, 0.7), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/base_type_color", Color(0.64, 1.0, 0.83), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/engine_type_color", Color(0.51, 0.83, 1.0), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/user_type_color", Color(0.42, 0.67, 0.93), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/comment_color", Color(0.4, 0.4, 0.4), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/doc_comment_color", Color(0.5, 0.6, 0.7), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/string_color", Color(0.94, 0.43, 0.75), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/background_color", Color(0.13, 0.12, 0.15), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_background_color", Color(0.17, 0.16, 0.2), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_selected_color", Color(0.26, 0.26, 0.27), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_existing_color", Color(0.87, 0.87, 0.87, 0.13), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_scroll_color", Color(1, 1, 1, 0.29), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_scroll_hovered_color", Color(1, 1, 1, 0.4), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/completion_font_color", Color(0.67, 0.67, 0.67), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/text_color", Color(0.67, 0.67, 0.67), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/line_number_color", Color(0.67, 0.67, 0.67, 0.4), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/safe_line_number_color", Color(0.67, 0.78, 0.67, 0.6), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/caret_color", Color(0.67, 0.67, 0.67), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/caret_background_color", Color(0, 0, 0), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/text_selected_color", Color(0, 0, 0, 0), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/selection_color", Color(0.41, 0.61, 0.91, 0.35), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/number_color", Color(0.92, 0.58, 0.2), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/function_color", Color(0.4, 0.64, 0.81), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/member_variable_color", Color(0.9, 0.31, 0.35), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4), "")
|
||||
EDITOR_SETTING_BASIC(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/warning_color", Color(1.0, 0.8, 0.4, 0.1), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/bookmark_color", Color(0.08, 0.49, 0.98), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/breakpoint_color", Color(0.9, 0.29, 0.3), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/executing_line_color", Color(0.98, 0.89, 0.27), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/folded_code_region_color", Color(0.68, 0.46, 0.77, 0.2), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1), "")
|
||||
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "text_editor/theme/highlighting/search_result_border_color", Color(0.41, 0.61, 0.91, 0.38), "")
|
||||
|
||||
// Appearance
|
||||
EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "text_editor/appearance/enable_inline_color_picker", true, "");
|
||||
|
||||
@@ -2633,7 +2633,9 @@ void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme
|
||||
}
|
||||
}
|
||||
|
||||
void EditorThemeManager::_generate_text_editor_defaults(ThemeConfiguration &p_config) {
|
||||
void EditorThemeManager::_populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
|
||||
String text_editor_color_theme = EDITOR_GET("text_editor/theme/color_theme");
|
||||
if (text_editor_color_theme == "Default" || text_editor_color_theme == "Custom") {
|
||||
// Adaptive colors for comments and elements with lower relevance.
|
||||
const Color dim_color = Color(p_config.font_color, 0.5);
|
||||
const float mono_value = p_config.mono_color.r;
|
||||
@@ -2687,55 +2689,53 @@ void EditorThemeManager::_generate_text_editor_defaults(ThemeConfiguration &p_co
|
||||
const Color search_result_border_color = p_config.dark_theme ? Color(0.41, 0.61, 0.91, 0.38) : Color(0, 0.4, 1, 0.38);
|
||||
/* clang-format on */
|
||||
|
||||
EditorSettings *setting = EditorSettings::get_singleton();
|
||||
HashMap<StringName, Color> colors;
|
||||
colors["text_editor/theme/highlighting/symbol_color"] = symbol_color;
|
||||
colors["text_editor/theme/highlighting/keyword_color"] = keyword_color;
|
||||
colors["text_editor/theme/highlighting/control_flow_keyword_color"] = control_flow_keyword_color;
|
||||
colors["text_editor/theme/highlighting/base_type_color"] = base_type_color;
|
||||
colors["text_editor/theme/highlighting/engine_type_color"] = engine_type_color;
|
||||
colors["text_editor/theme/highlighting/user_type_color"] = user_type_color;
|
||||
colors["text_editor/theme/highlighting/comment_color"] = comment_color;
|
||||
colors["text_editor/theme/highlighting/doc_comment_color"] = doc_comment_color;
|
||||
colors["text_editor/theme/highlighting/string_color"] = string_color;
|
||||
colors["text_editor/theme/highlighting/background_color"] = te_background_color;
|
||||
colors["text_editor/theme/highlighting/completion_background_color"] = completion_background_color;
|
||||
colors["text_editor/theme/highlighting/completion_selected_color"] = completion_selected_color;
|
||||
colors["text_editor/theme/highlighting/completion_existing_color"] = completion_existing_color;
|
||||
colors["text_editor/theme/highlighting/completion_scroll_color"] = completion_scroll_color;
|
||||
colors["text_editor/theme/highlighting/completion_scroll_hovered_color"] = completion_scroll_hovered_color;
|
||||
colors["text_editor/theme/highlighting/completion_font_color"] = completion_font_color;
|
||||
colors["text_editor/theme/highlighting/text_color"] = text_color;
|
||||
colors["text_editor/theme/highlighting/line_number_color"] = line_number_color;
|
||||
colors["text_editor/theme/highlighting/safe_line_number_color"] = safe_line_number_color;
|
||||
colors["text_editor/theme/highlighting/caret_color"] = caret_color;
|
||||
colors["text_editor/theme/highlighting/caret_background_color"] = caret_background_color;
|
||||
colors["text_editor/theme/highlighting/text_selected_color"] = text_selected_color;
|
||||
colors["text_editor/theme/highlighting/selection_color"] = selection_color;
|
||||
colors["text_editor/theme/highlighting/brace_mismatch_color"] = brace_mismatch_color;
|
||||
colors["text_editor/theme/highlighting/current_line_color"] = current_line_color;
|
||||
colors["text_editor/theme/highlighting/line_length_guideline_color"] = line_length_guideline_color;
|
||||
colors["text_editor/theme/highlighting/word_highlighted_color"] = word_highlighted_color;
|
||||
colors["text_editor/theme/highlighting/number_color"] = number_color;
|
||||
colors["text_editor/theme/highlighting/function_color"] = function_color;
|
||||
colors["text_editor/theme/highlighting/member_variable_color"] = member_variable_color;
|
||||
colors["text_editor/theme/highlighting/mark_color"] = mark_color;
|
||||
colors["text_editor/theme/highlighting/warning_color"] = warning_color;
|
||||
colors["text_editor/theme/highlighting/bookmark_color"] = bookmark_color;
|
||||
colors["text_editor/theme/highlighting/breakpoint_color"] = breakpoint_color;
|
||||
colors["text_editor/theme/highlighting/executing_line_color"] = executing_line_color;
|
||||
colors["text_editor/theme/highlighting/code_folding_color"] = code_folding_color;
|
||||
colors["text_editor/theme/highlighting/folded_code_region_color"] = folded_code_region_color;
|
||||
colors["text_editor/theme/highlighting/search_result_color"] = search_result_color;
|
||||
colors["text_editor/theme/highlighting/search_result_border_color"] = search_result_border_color;
|
||||
|
||||
/* clang-format off */
|
||||
setting->set_initial_value("text_editor/theme/highlighting/symbol_color", symbol_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/keyword_color", keyword_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/control_flow_keyword_color", control_flow_keyword_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/base_type_color", base_type_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/engine_type_color", engine_type_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/user_type_color", user_type_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/comment_color", comment_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/doc_comment_color", doc_comment_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/string_color", string_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/background_color", te_background_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_background_color", completion_background_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_selected_color", completion_selected_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_existing_color", completion_existing_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_scroll_color", completion_scroll_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_scroll_hovered_color", completion_scroll_hovered_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/completion_font_color", completion_font_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/text_color", text_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/line_number_color", line_number_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/safe_line_number_color", safe_line_number_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/caret_color", caret_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/caret_background_color", caret_background_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/text_selected_color", text_selected_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/selection_color", selection_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/brace_mismatch_color", brace_mismatch_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/current_line_color", current_line_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/line_length_guideline_color", line_length_guideline_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/word_highlighted_color", word_highlighted_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/number_color", number_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/function_color", function_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/member_variable_color", member_variable_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/mark_color", mark_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/warning_color", warning_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/bookmark_color", bookmark_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/breakpoint_color", breakpoint_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/executing_line_color", executing_line_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/code_folding_color", code_folding_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/folded_code_region_color", folded_code_region_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/search_result_color", search_result_color, true);
|
||||
setting->set_initial_value("text_editor/theme/highlighting/search_result_border_color", search_result_border_color, true);
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
void EditorThemeManager::_populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
|
||||
String text_editor_color_theme = EDITOR_GET("text_editor/theme/color_theme");
|
||||
for (const KeyValue<StringName, Color> &setting : colors) {
|
||||
EditorSettings::get_singleton()->set_initial_value(setting.key, setting.value);
|
||||
if (text_editor_color_theme == "Default") {
|
||||
_generate_text_editor_defaults(p_config);
|
||||
EditorSettings::get_singleton()->set_manually(setting.key, setting.value);
|
||||
}
|
||||
}
|
||||
} else if (text_editor_color_theme == "Godot 2") {
|
||||
EditorSettings::get_singleton()->load_text_editor_theme();
|
||||
}
|
||||
|
||||
@@ -157,7 +157,6 @@ class EditorThemeManager {
|
||||
static void _populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);
|
||||
static void _populate_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);
|
||||
|
||||
static void _generate_text_editor_defaults(ThemeConfiguration &p_config);
|
||||
static void _populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);
|
||||
static void _populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user