summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/line_edit.cpp27
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/text_edit.cpp34
-rw-r--r--scene/gui/text_edit.h10
4 files changed, 55 insertions, 18 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 0d3ab36852..fb8396e4ff 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -358,11 +358,20 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
[[fallthrough]];
}
case KEY_LEFT: {
-
#ifndef APPLE_STYLE_KEYS
- if (!k->get_alt())
+ if (!k->get_alt()) {
#endif
+ if (selection.enabled && !k->get_shift()) {
+ set_cursor_position(selection.begin);
+ deselect();
+ handled = true;
+ break;
+ }
+
shift_selection_check_pre(k->get_shift());
+#ifndef APPLE_STYLE_KEYS
+ }
+#endif
#ifdef APPLE_STYLE_KEYS
if (k->get_command()) {
@@ -405,8 +414,20 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
[[fallthrough]];
}
case KEY_RIGHT: {
+#ifndef APPLE_STYLE_KEYS
+ if (!k->get_alt()) {
+#endif
+ if (selection.enabled && !k->get_shift()) {
+ set_cursor_position(selection.end);
+ deselect();
+ handled = true;
+ break;
+ }
- shift_selection_check_pre(k->get_shift());
+ shift_selection_check_pre(k->get_shift());
+#ifndef APPLE_STYLE_KEYS
+ }
+#endif
#ifdef APPLE_STYLE_KEYS
if (k->get_command()) {
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 66ecbea378..b3c4e3fa3c 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -538,7 +538,7 @@ void TabContainer::add_child_notify(Node *p_child) {
update();
p_child->connect_compat("renamed", this, "_child_renamed_callback");
- if (first)
+ if (first && is_inside_tree())
emit_signal("tab_changed", current);
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2fd1ba5535..379e70b951 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -753,10 +753,18 @@ void TextEdit::_notification(int p_what) {
}
}
- if (line_length_guideline) {
- int x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs;
- if (x > xmargin_beg && x < xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color);
+ if (line_length_guidelines) {
+ const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs;
+ if (hard_x > xmargin_beg && hard_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color);
+ }
+
+ // Draw a "Soft" line length guideline, less visible than the hard line length guideline.
+ // It's usually set to a lower column compared to the hard line length guideline.
+ // Only drawn if its column differs from the hard line length guideline.
+ const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs;
+ if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5));
}
}
@@ -6834,13 +6842,18 @@ bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
-void TextEdit::set_show_line_length_guideline(bool p_show) {
- line_length_guideline = p_show;
+void TextEdit::set_show_line_length_guidelines(bool p_show) {
+ line_length_guidelines = p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_soft_column(int p_column) {
+ line_length_guideline_soft_col = p_column;
update();
}
-void TextEdit::set_line_length_guideline_column(int p_column) {
- line_length_guideline_col = p_column;
+void TextEdit::set_line_length_guideline_hard_column(int p_column) {
+ line_length_guideline_hard_col = p_column;
update();
}
@@ -7309,8 +7322,9 @@ TextEdit::TextEdit() {
tooltip_obj = NULL;
line_numbers = false;
line_numbers_zero_padded = false;
- line_length_guideline = false;
- line_length_guideline_col = 80;
+ line_length_guidelines = false;
+ line_length_guideline_soft_col = 80;
+ line_length_guideline_hard_col = 100;
draw_bookmark_gutter = false;
draw_breakpoint_gutter = false;
draw_fold_gutter = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 9986b80fd5..6e267f5a47 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -369,8 +369,9 @@ private:
bool undo_enabled;
bool line_numbers;
bool line_numbers_zero_padded;
- bool line_length_guideline;
- int line_length_guideline_col;
+ bool line_length_guidelines;
+ int line_length_guideline_soft_col;
+ int line_length_guideline_hard_col;
bool draw_bookmark_gutter;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -765,8 +766,9 @@ public:
void set_line_numbers_zero_padded(bool p_zero_padded);
- void set_show_line_length_guideline(bool p_show);
- void set_line_length_guideline_column(int p_column);
+ void set_show_line_length_guidelines(bool p_show);
+ void set_line_length_guideline_soft_column(int p_column);
+ void set_line_length_guideline_hard_column(int p_column);
void set_bookmark_gutter_enabled(bool p_draw);
bool is_bookmark_gutter_enabled() const;