Merge pull request #64283 from KoBeWi/g3t_no_color
[3.x] Optimize theme usage in editor log
This commit is contained in:
commit
d9dddf3a68
2 changed files with 30 additions and 15 deletions
|
@ -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) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
//button->set_icon(get_icon("Console","EditorIcons"));
|
||||
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));
|
||||
} else if (p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
if (log != nullptr) {
|
||||
Ref<DynamicFont> df_output_code = get_font("output_source", "EditorFonts");
|
||||
if (df_output_code.is_valid()) {
|
||||
if (log != nullptr) {
|
||||
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: {
|
||||
} break;
|
||||
case MSG_TYPE_ERROR: {
|
||||
log->push_color(get_color("error_color", "Editor"));
|
||||
Ref<Texture> icon = get_icon("Error", "EditorIcons");
|
||||
log->push_color(theme_cache.error_color);
|
||||
Ref<Texture> icon = theme_cache.error_icon;
|
||||
log->add_image(icon);
|
||||
log->add_text(" ");
|
||||
tool_button->set_icon(icon);
|
||||
} break;
|
||||
case MSG_TYPE_WARNING: {
|
||||
log->push_color(get_color("warning_color", "Editor"));
|
||||
Ref<Texture> icon = get_icon("Warning", "EditorIcons");
|
||||
log->push_color(theme_cache.warning_color);
|
||||
Ref<Texture> icon = theme_cache.warning_icon;
|
||||
log->add_image(icon);
|
||||
log->add_text(" ");
|
||||
tool_button->set_icon(icon);
|
||||
} break;
|
||||
case MSG_TYPE_EDITOR: {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,16 @@
|
|||
class EditorLog : public 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 *copybutton;
|
||||
Label *title;
|
||||
|
|
Loading…
Reference in a new issue