From 03025f60b6db551335f3101c1d024dd86b492beb Mon Sep 17 00:00:00 2001 From: Martin Chuckeles Date: Thu, 3 Mar 2016 20:26:50 +0100 Subject: [PATCH 1/3] Move the call hint under the current line --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index bf012b7a03..257b36ca96 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -967,7 +967,7 @@ void TextEdit::_notification(int p_what) { } - Point2 hint_ofs = Vector2(completion_hint_offset,cursor_pos.y-minsize.y); + Point2 hint_ofs = Vector2(completion_hint_offset,cursor_pos.y+minsize.y); draw_style_box(sb,Rect2(hint_ofs,minsize)); spacing=0; From 26cc14e83974b9d865edfb4f03396bdad5a29b87 Mon Sep 17 00:00:00 2001 From: Martin Chuckeles Date: Thu, 3 Mar 2016 20:31:25 +0100 Subject: [PATCH 2/3] Hide hint if completion is active --- scene/gui/text_edit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 257b36ca96..db0c7b3ac9 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -931,7 +931,7 @@ void TextEdit::_notification(int p_what) { } - if (completion_hint!="") { + if (completion_hint!="" && !completion_active) { Ref sb = get_stylebox("panel","TooltipPanel"); Ref font = cache.font; From 47206b409d6802ac9ccbaedaa0daedc30b739e2f Mon Sep 17 00:00:00 2001 From: Martin Chuckeles Date: Fri, 4 Mar 2016 11:05:42 +0100 Subject: [PATCH 3/3] Add editor settings for call hint placement Added settings: text_editor/put_callhint_tooltip_below_current_line and text_editor/callhint_tooltip_offset --- scene/gui/text_edit.cpp | 33 ++++++++++++++++--- scene/gui/text_edit.h | 7 ++++ tools/editor/code_editor.cpp | 6 ++++ tools/editor/plugins/script_editor_plugin.cpp | 3 ++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index db0c7b3ac9..5d7436517f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -847,7 +847,7 @@ void TextEdit::_notification(int p_what) { } } - + bool completion_below = false; if (completion_active) { // code completion box Ref csb = get_stylebox("completion"); @@ -878,11 +878,12 @@ void TextEdit::_notification(int p_what) { } int th = h + csb->get_minimum_size().y; + if (cursor_pos.y+get_row_height()+th > get_size().height) { completion_rect.pos.y=cursor_pos.y-th; } else { completion_rect.pos.y=cursor_pos.y+get_row_height()+csb->get_offset().y; - + completion_below = true; } if (cursor_pos.x-nofs+w+scrollw > get_size().width) { @@ -930,8 +931,24 @@ void TextEdit::_notification(int p_what) { completion_line_ofs=line_from; } + + // check to see if the hint should be drawn + bool show_hint = false; + if (completion_hint!="") { + if (completion_active) { + if (completion_below && !callhint_below) { + show_hint = true; + } + else if (!completion_below && callhint_below) { + show_hint = true; + } + } + else { + show_hint = true; + } + } - if (completion_hint!="" && !completion_active) { + if (show_hint) { Ref sb = get_stylebox("panel","TooltipPanel"); Ref font = cache.font; @@ -967,7 +984,15 @@ void TextEdit::_notification(int p_what) { } - Point2 hint_ofs = Vector2(completion_hint_offset,cursor_pos.y+minsize.y); + Point2 hint_ofs = Vector2(completion_hint_offset,cursor_pos.y) + callhint_offset; + + if (callhint_below) { + hint_ofs.y += get_row_height() + sb->get_offset().y; + } + else { + hint_ofs.y -= minsize.y + sb->get_offset().y; + } + draw_style_box(sb,Rect2(hint_ofs,minsize)); spacing=0; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 2ca5ab054a..44e780aaf3 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -231,6 +231,9 @@ class TextEdit : public Control { bool next_operation_is_complex; + bool callhint_below; + Vector2 callhint_offset; + int get_visible_rows() const; int get_char_count(); @@ -326,6 +329,10 @@ public: brace_matching_enabled=p_enabled; update(); } + inline void set_callhint_settings(bool below, Vector2 offset) { + callhint_below = below; + callhint_offset = offset; + } void set_auto_indent(bool p_auto_indent); void cursor_set_column(int p_col, bool p_adjust_viewport=true); diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index fe863bfebc..f7d335fba3 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -568,6 +568,12 @@ void CodeTextEditor::_on_settings_change() { ); enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true); + + // call hint settings + text_editor->set_callhint_settings( + EDITOR_DEF("text_editor/put_callhint_tooltip_below_current_line", true), + EDITOR_DEF("text_editor/callhint_tooltip_offset", Vector2()) + ); } void CodeTextEditor::_text_changed_idle_timeout() { diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 8d0527cff7..474bafee69 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1928,6 +1928,9 @@ void ScriptEditor::edit(const Ref