Optimize theme usage in editor log
(cherry picked from commit c65360eed1
)
This commit is contained in:
parent
59061dc619
commit
7c349574d7
@ -58,18 +58,23 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorLog::_notification(int p_what) {
|
void EditorLog::_notification(int p_what) {
|
||||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
switch (p_what) {
|
||||||
//button->set_icon(get_icon("Console","EditorIcons"));
|
case NOTIFICATION_ENTER_TREE:
|
||||||
log->add_font_override("normal_font", get_font("output_source", "EditorFonts"));
|
case NOTIFICATION_THEME_CHANGED: {
|
||||||
log->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
|
|
||||||
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
|
|
||||||
Ref<DynamicFont> df_output_code = get_font("output_source", "EditorFonts");
|
|
||||||
if (df_output_code.is_valid()) {
|
|
||||||
if (log != nullptr) {
|
if (log != nullptr) {
|
||||||
log->add_font_override("normal_font", get_font("output_source", "EditorFonts"));
|
Ref<DynamicFont> df_output_code = get_font("output_source", "EditorFonts");
|
||||||
log->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
|
if (df_output_code.is_valid()) {
|
||||||
|
log->add_font_override("normal_font", get_font("output_source", "EditorFonts"));
|
||||||
|
log->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
theme_cache.error_color = get_color("error_color", "Editor");
|
||||||
|
theme_cache.error_icon = get_icon("Error", "EditorIcons");
|
||||||
|
theme_cache.warning_color = get_color("warning_color", "Editor");
|
||||||
|
theme_cache.warning_icon = get_icon("Warning", "EditorIcons");
|
||||||
|
theme_cache.message_color = get_color("font_color", "Editor") * Color(1, 1, 1, 0.6);
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,22 +109,22 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) {
|
|||||||
case MSG_TYPE_STD: {
|
case MSG_TYPE_STD: {
|
||||||
} break;
|
} break;
|
||||||
case MSG_TYPE_ERROR: {
|
case MSG_TYPE_ERROR: {
|
||||||
log->push_color(get_color("error_color", "Editor"));
|
log->push_color(theme_cache.error_color);
|
||||||
Ref<Texture> icon = get_icon("Error", "EditorIcons");
|
Ref<Texture> icon = theme_cache.error_icon;
|
||||||
log->add_image(icon);
|
log->add_image(icon);
|
||||||
log->add_text(" ");
|
log->add_text(" ");
|
||||||
tool_button->set_icon(icon);
|
tool_button->set_icon(icon);
|
||||||
} break;
|
} break;
|
||||||
case MSG_TYPE_WARNING: {
|
case MSG_TYPE_WARNING: {
|
||||||
log->push_color(get_color("warning_color", "Editor"));
|
log->push_color(theme_cache.warning_color);
|
||||||
Ref<Texture> icon = get_icon("Warning", "EditorIcons");
|
Ref<Texture> icon = theme_cache.warning_icon;
|
||||||
log->add_image(icon);
|
log->add_image(icon);
|
||||||
log->add_text(" ");
|
log->add_text(" ");
|
||||||
tool_button->set_icon(icon);
|
tool_button->set_icon(icon);
|
||||||
} break;
|
} break;
|
||||||
case MSG_TYPE_EDITOR: {
|
case MSG_TYPE_EDITOR: {
|
||||||
// Distinguish editor messages from messages printed by the project
|
// Distinguish editor messages from messages printed by the project
|
||||||
log->push_color(get_color("font_color", "Editor") * Color(1, 1, 1, 0.6));
|
log->push_color(theme_cache.message_color);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,16 @@
|
|||||||
class EditorLog : public VBoxContainer {
|
class EditorLog : public VBoxContainer {
|
||||||
GDCLASS(EditorLog, VBoxContainer);
|
GDCLASS(EditorLog, VBoxContainer);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Color error_color;
|
||||||
|
Ref<Texture> error_icon;
|
||||||
|
|
||||||
|
Color warning_color;
|
||||||
|
Ref<Texture> warning_icon;
|
||||||
|
|
||||||
|
Color message_color;
|
||||||
|
} theme_cache;
|
||||||
|
|
||||||
Button *clearbutton;
|
Button *clearbutton;
|
||||||
Button *copybutton;
|
Button *copybutton;
|
||||||
Label *title;
|
Label *title;
|
||||||
|
Loading…
Reference in New Issue
Block a user