From f07e5ac1533ed5563b3ffc75a243e3444c2645b8 Mon Sep 17 00:00:00 2001 From: Gwyneth Lowe Date: Fri, 21 Jun 2019 18:16:38 -0500 Subject: [PATCH] Give LineEdit a custom font color when un-editable By default the LineEdit's text when editable is unchecked had some transparency hardcoded. This change adds a custom color to LineEdit for adjusting the font when editable is off. Addresses issue 29814 --- scene/gui/line_edit.cpp | 7 ++----- scene/resources/default_theme/default_theme.cpp | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da6bff8ab82..3e8eda38e1c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -675,10 +675,8 @@ void LineEdit::_notification(int p_what) { RID ci = get_canvas_item(); Ref style = get_stylebox("normal"); - float disabled_alpha = 1.0; // used to set the disabled input text color if (!is_editable()) { style = get_stylebox("read_only"); - disabled_alpha = .5; draw_caret = false; } @@ -724,7 +722,7 @@ void LineEdit::_notification(int p_what) { int font_ascent = font->get_ascent(); Color selection_color = get_color("selection_color"); - Color font_color = get_color("font_color"); + Color font_color = is_editable() ? get_color("font_color") : get_color("font_color_uneditable"); Color font_color_selected = get_color("font_color_selected"); Color cursor_color = get_color("cursor_color"); @@ -732,12 +730,11 @@ void LineEdit::_notification(int p_what) { // draw placeholder color if (using_placeholder) font_color.a *= placeholder_alpha; - font_color.a *= disabled_alpha; bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { Ref r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; - Color color_icon(1, 1, 1, disabled_alpha * .9); + Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9); if (display_clear_icon) { if (clear_button_status.press_attempt && clear_button_status.pressing_inside) { color_icon = get_color("clear_button_color_pressed"); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 2c5dfc375ce..42b445b59c5 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -398,6 +398,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_color("font_color", "LineEdit", control_font_color); theme->set_color("font_color_selected", "LineEdit", Color(0, 0, 0)); + theme->set_color("font_color_uneditable", "LineEdit", Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f)); theme->set_color("cursor_color", "LineEdit", control_font_color_hover); theme->set_color("selection_color", "LineEdit", font_color_selection); theme->set_color("clear_button_color", "LineEdit", control_font_color);