Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,9 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_draw_line_numbers(EDITOR_GET("text_editor/appearance/gutters/show_line_numbers"));
text_editor->set_line_numbers_zero_padded(EDITOR_GET("text_editor/appearance/gutters/line_numbers_zero_padded"));

// Appearance: Scrollbar
text_editor->set_scrollbar_touch_area_enabled(EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area"));

// Appearance: Minimap
text_editor->set_draw_minimap(EDITOR_GET("text_editor/appearance/minimap/show_minimap"));
text_editor->set_minimap_width((int)EDITOR_GET("text_editor/appearance/minimap/minimap_width") * EDSCALE);
Expand Down
25 changes: 23 additions & 2 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,12 @@ void TextEdit::_notification(int p_what) {
if (draw_minimap) {
xmargin_end -= minimap_width;
}

// Use the local variable to adjust for increased scrollbar touch area.
if (increase_scrollbar_touch_area) {
xmargin_end -= 50; // Hardcoded value matching the increased touch area size.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding the value, this should use the v scroll bar's width instead.

}

// Let's do it easy for now.
theme_cache.style_normal->draw(ci, Rect2(Point2(), size));
if (!editable) {
Expand Down Expand Up @@ -5913,6 +5919,18 @@ double TextEdit::get_scroll_pos_for_line(int p_line, int p_wrap_index) const {
return new_line_scroll_pos;
}

void TextEdit::set_scrollbar_touch_area_enabled(bool p_enabled) {
if (increase_scrollbar_touch_area == p_enabled) {
return; // No need to update if the value is unchanged.
}

increase_scrollbar_touch_area = p_enabled;

// Update layout to reflect the new scrollbar configuration.
_update_scrollbars();
queue_redraw(); // Requests a redraw of the viewport to reflect changes.
}

// Visible lines.
void TextEdit::set_line_as_first_visible(int p_line, int p_wrap_index) {
ERR_FAIL_INDEX(p_line, text.size());
Expand Down Expand Up @@ -8204,7 +8222,8 @@ void TextEdit::_scroll_lines_down() {

void TextEdit::_update_minimap_hover() {
const Point2 mp = get_local_mouse_pos();
const int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
int scrollbar_offset = increase_scrollbar_touch_area ? 50 : 0;
const int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT) - scrollbar_offset;

bool hovering_sidebar = mp.x > xmargin_end - minimap_width && mp.x < xmargin_end;
if (!hovering_sidebar) {
Expand All @@ -8231,7 +8250,9 @@ void TextEdit::_update_minimap_hover() {
void TextEdit::_update_minimap_click() {
Point2 mp = get_local_mouse_pos();

int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
int scrollbar_offset = increase_scrollbar_touch_area ? 50 : 0;
int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT) - scrollbar_offset;

if (!dragging_minimap && (mp.x < xmargin_end - minimap_width || mp.x > xmargin_end)) {
minimap_clicked = false;
return;
Expand Down
4 changes: 4 additions & 0 deletions scene/gui/text_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ class TextEdit : public Control {
bool scrolling = false;
bool updating_scrolls = false;

bool increase_scrollbar_touch_area = false;

void _update_scrollbars();
int _get_control_height() const;

Expand Down Expand Up @@ -995,6 +997,8 @@ class TextEdit : public Control {

double get_scroll_pos_for_line(int p_line, int p_wrap_index = 0) const;

void set_scrollbar_touch_area_enabled(bool p_enabled);

// Visible lines.
void set_line_as_first_visible(int p_line, int p_wrap_index = 0);
int get_first_visible_line() const;
Expand Down
Loading