summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-10-23 19:18:20 +0300
committerGitHub <noreply@github.com>2020-10-23 19:18:20 +0300
commitb09e60ef1a46baaab997cbdccf2ad7912cb7faee (patch)
tree5626fb16b64bbc2aad83687a91379e4abd1a1cea /scene
parentd5073c6b4ce864f169e4e1ad18d411fe5928c766 (diff)
parent4c65dc975c5735d6fe312e9d630da32543750b44 (diff)
Merge pull request #43026 from Chaosus/color_autocompletion
Shows ColorRect in Color constants autocompletion
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/text_edit.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index dc21980473..c87f639193 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1367,6 +1367,10 @@ void TextEdit::_notification(int p_what) {
int scrollw = get_theme_constant("completion_scroll_width");
Color scrollc = get_theme_color("completion_scroll_color");
+#ifdef TOOLS_ENABLED
+ scrollw *= EDSCALE;
+#endif
+
const int completion_options_size = completion_options.size();
int lines = MIN(completion_options_size, maxlines);
int w = 0;
@@ -1389,6 +1393,17 @@ void TextEdit::_notification(int p_what) {
Size2 icon_area_size(get_row_height(), get_row_height());
w += icon_area_size.width + icon_hsep;
+ int line_from = CLAMP(completion_index - lines / 2, 0, completion_options_size - lines);
+
+ for (int i = 0; i < lines; i++) {
+ int l = line_from + i;
+ ERR_CONTINUE(l < 0 || l >= completion_options_size);
+ if (completion_options[l].default_value.get_type() == Variant::COLOR) {
+ w += icon_area_size.width;
+ break;
+ }
+ }
+
int th = h + csb->get_minimum_size().y;
if (cursor_pos.y + get_row_height() + th > get_size().height) {
@@ -1415,7 +1430,6 @@ void TextEdit::_notification(int p_what) {
if (cache.completion_background_color.a > 0.01) {
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color);
}
- int line_from = CLAMP(completion_index - lines / 2, 0, completion_options_size - lines);
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(nofs, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color);
@@ -1437,6 +1451,11 @@ void TextEdit::_notification(int p_what) {
}
title_pos.x = icon_area.position.x + icon_area.size.width + icon_hsep;
+
+ if (completion_options[l].default_value.get_type() == Variant::COLOR) {
+ draw_rect(Rect2(Point2(completion_rect.position.x + completion_rect.size.width - icon_area_size.x, icon_area.position.y), icon_area_size), (Color)completion_options[l].default_value);
+ }
+
draw_string(cache.font, title_pos, completion_options[l].display, completion_options[l].font_color, completion_rect.size.width - (icon_area_size.x + icon_hsep));
}