summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkit <kitbdev@gmail.com>2024-07-27 17:14:51 -0400
committerkit <kitbdev@gmail.com>2024-07-27 17:14:51 -0400
commitb6c054e7935e8fd0baf9b36cb71fe061c46df9a0 (patch)
tree62f3fbbcf674193aa46272555277be14e63e8997
parent607b230ffe120b2757c56bd3d52a7a0d4e502cfe (diff)
downloadredot-engine-b6c054e7935e8fd0baf9b36cb71fe061c46df9a0.tar.gz
Fix TextEdit placeholder fit content height
-rw-r--r--scene/gui/text_edit.cpp12
-rw-r--r--scene/gui/text_edit.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 3f1b9fc981..6e5f7f0787 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -764,7 +764,7 @@ void TextEdit::_notification(int p_what) {
}
}
- bool draw_placeholder = text.size() == 1 && text[0].is_empty() && ime_text.is_empty();
+ bool draw_placeholder = _using_placeholder();
// Get the highlighted words.
String highlighted_text = get_selected_text(0);
@@ -2849,6 +2849,10 @@ void TextEdit::_update_placeholder() {
}
}
+bool TextEdit::_using_placeholder() const {
+ return text.size() == 1 && text[0].is_empty() && ime_text.is_empty();
+}
+
void TextEdit::_update_theme_item_cache() {
Control::_update_theme_item_cache();
@@ -7840,10 +7844,10 @@ void TextEdit::_update_scrollbars() {
h_scroll->set_begin(Point2(0, size.height - hmin.height));
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- bool draw_placeholder = text.size() == 1 && text[0].length() == 0;
+ bool draw_placeholder = _using_placeholder();
int visible_rows = get_visible_line_count();
- int total_rows = draw_placeholder ? placeholder_wraped_rows.size() - 1 : get_total_visible_line_count();
+ int total_rows = draw_placeholder ? placeholder_wraped_rows.size() : get_total_visible_line_count();
if (scroll_past_end_of_file_enabled && !fit_content_height) {
total_rows += visible_rows - 1;
}
@@ -7921,7 +7925,7 @@ void TextEdit::_scroll_moved(double p_to_val) {
}
if (v_scroll->is_visible_in_tree()) {
// Set line ofs and wrap ofs.
- bool draw_placeholder = text.size() == 1 && text[0].length() == 0;
+ bool draw_placeholder = _using_placeholder();
int v_scroll_i = floor(get_v_scroll());
int sc = 0;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 4d9d169c1c..c8cd7b0e4d 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -297,6 +297,7 @@ private:
Vector<String> placeholder_wraped_rows;
void _update_placeholder();
+ bool _using_placeholder() const;
/* Initialize to opposite first, so we get past the early-out in set_editable. */
bool editable = false;