mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Implemented scrolling factor for smooth trackpad scrolling
Working platforms platform: OSX, Windows.
Support for almost all ui elements, including project list.
Ported from 304a1f5b5a (#7864).
Fixes #492 and #3913.
This commit is contained in:
parent
e7328fe5a0
commit
ee670f3724
15 changed files with 111 additions and 67 deletions
|
|
@ -333,7 +333,10 @@ void TextEdit::_update_scrollbars() {
|
|||
v_scroll->show();
|
||||
v_scroll->set_max(total_rows);
|
||||
v_scroll->set_page(visible_rows);
|
||||
v_scroll->set_val(cursor.line_ofs);
|
||||
|
||||
if (fabs(v_scroll->get_val() - (double)cursor.line_ofs) >= 1) {
|
||||
v_scroll->set_val(cursor.line_ofs);
|
||||
}
|
||||
|
||||
} else {
|
||||
cursor.line_ofs = 0;
|
||||
|
|
@ -345,7 +348,9 @@ void TextEdit::_update_scrollbars() {
|
|||
h_scroll->show();
|
||||
h_scroll->set_max(total_width);
|
||||
h_scroll->set_page(visible_width);
|
||||
h_scroll->set_val(cursor.x_ofs);
|
||||
if (fabs(h_scroll->get_val() - (double)cursor.x_ofs) >= 1) {
|
||||
h_scroll->set_val(cursor.x_ofs);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -1431,17 +1436,18 @@ void TextEdit::_input_event(const InputEvent &p_input_event) {
|
|||
}
|
||||
|
||||
if (mb.pressed) {
|
||||
|
||||
if (mb.button_index == BUTTON_WHEEL_UP && !mb.mod.command) {
|
||||
v_scroll->set_val(v_scroll->get_val() - 3);
|
||||
v_scroll->set_val(v_scroll->get_val() - (3 * mb.factor));
|
||||
}
|
||||
if (mb.button_index == BUTTON_WHEEL_DOWN && !mb.mod.command) {
|
||||
v_scroll->set_val(v_scroll->get_val() + 3);
|
||||
v_scroll->set_val(v_scroll->get_val() + (3 * mb.factor));
|
||||
}
|
||||
if (mb.button_index == BUTTON_WHEEL_LEFT) {
|
||||
h_scroll->set_val(h_scroll->get_val() - 3);
|
||||
h_scroll->set_val(h_scroll->get_val() - (100 * mb.factor));
|
||||
}
|
||||
if (mb.button_index == BUTTON_WHEEL_RIGHT) {
|
||||
h_scroll->set_val(h_scroll->get_val() + 3);
|
||||
h_scroll->set_val(h_scroll->get_val() + (100 * mb.factor));
|
||||
}
|
||||
if (mb.button_index == BUTTON_LEFT) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue