summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/graph_edit.cpp12
-rw-r--r--scene/gui/item_list.cpp4
-rw-r--r--scene/gui/popup_menu.cpp4
-rw-r--r--scene/gui/rich_text_label.cpp6
-rw-r--r--scene/gui/scroll_container.cpp30
-rw-r--r--scene/gui/spin_box.cpp6
-rw-r--r--scene/gui/text_edit.cpp18
-rw-r--r--scene/gui/tree.cpp4
8 files changed, 61 insertions, 23 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0bc48677dd..d5df3bac67 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -962,6 +962,18 @@ void GraphEdit::_gui_input(const InputEvent &p_ev) {
//too difficult to get right
//set_zoom(zoom/ZOOM_SCALE);
}
+ if (b.button_index == BUTTON_WHEEL_UP) {
+ h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * b.factor / 8);
+ }
+ if (b.button_index == BUTTON_WHEEL_DOWN) {
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * b.factor / 8);
+ }
+ if (b.button_index == BUTTON_WHEEL_RIGHT) {
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b.factor / 8);
+ }
+ if (b.button_index == BUTTON_WHEEL_LEFT) {
+ v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b.factor / 8);
+ }
}
if (p_ev.type == InputEvent::KEY && p_ev.key.scancode == KEY_D && p_ev.key.pressed && p_ev.key.mod.command) {
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 1dc4230d2a..b79104ba39 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -533,10 +533,14 @@ void ItemList::_gui_input(const InputEvent &p_event) {
}
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
+ scroll_bar->set_value(scroll_bar->get_value() - scroll_bar->get_page() * p_event.mouse_button.factor / 8);
+
scroll_bar->set_value(scroll_bar->get_value() - scroll_bar->get_page() / 8);
}
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
+ scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * p_event.mouse_button.factor / 8);
+
scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() / 8);
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 6ac6eac655..9b9dd820b2 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -273,7 +273,7 @@ void PopupMenu::_gui_input(const InputEvent &p_event) {
Point2 pos = get_position();
int s = (vseparation + font->get_height()) * 3;
- pos.y -= s;
+ pos.y -= (s * b.factor);
set_position(pos);
//update hover
@@ -293,7 +293,7 @@ void PopupMenu::_gui_input(const InputEvent &p_event) {
Point2 pos = get_position();
int s = (vseparation + font->get_height()) * 3;
- pos.y += s;
+ pos.y += (s * b.factor);
set_position(pos);
//update hover
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index e5a17298e4..6e5f218a66 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -780,12 +780,14 @@ void RichTextLabel::_gui_input(InputEvent p_event) {
if (b.button_index == BUTTON_WHEEL_UP) {
if (scroll_active)
- vscroll->set_value(vscroll->get_value() - vscroll->get_page() / 8);
+
+ vscroll->set_value(vscroll->get_value() - vscroll->get_page() * b.factor * 0.5 / 8);
}
if (b.button_index == BUTTON_WHEEL_DOWN) {
if (scroll_active)
- vscroll->set_value(vscroll->get_value() + vscroll->get_page() / 8);
+
+ vscroll->set_value(vscroll->get_value() + vscroll->get_page() * b.factor * 0.5 / 8);
}
} break;
case InputEvent::KEY: {
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 9146fa9393..a89c2b27c9 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -85,20 +85,32 @@ void ScrollContainer::_gui_input(const InputEvent &p_gui_input) {
const InputEventMouseButton &mb = p_gui_input.mouse_button;
if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) {
- if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()) {
- // only horizontal is enabled, scroll horizontally
- h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() / 8);
+ // only horizontal is enabled, scroll horizontally
+ if (h_scroll->is_visible() && !v_scroll->is_visible()) {
+ h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() / 8 * mb.factor);
} else if (v_scroll->is_visible_in_tree()) {
- v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8);
+ v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8 * mb.factor);
}
}
if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
- if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()) {
- // only horizontal is enabled, scroll horizontally
- h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() / 8);
- } else if (v_scroll->is_visible_in_tree()) {
- v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8);
+ // only horizontal is enabled, scroll horizontally
+ if (h_scroll->is_visible() && !v_scroll->is_visible()) {
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() / 8 * mb.factor);
+ } else if (v_scroll->is_visible()) {
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8 * mb.factor);
+ }
+ }
+
+ if (mb.button_index == BUTTON_WHEEL_LEFT && mb.pressed) {
+ if (h_scroll->is_visible_in_tree()) {
+ h_scroll->set_value(h_scroll->get_value() - h_scroll->get_page() * mb.factor / 8);
+ }
+ }
+
+ if (mb.button_index == BUTTON_WHEEL_RIGHT && mb.pressed) {
+ if (h_scroll->is_visible_in_tree()) {
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * mb.factor / 8);
}
}
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index ba8ca63721..83d535a2e7 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -115,13 +115,15 @@ void SpinBox::_gui_input(const InputEvent &p_event) {
} break;
case BUTTON_WHEEL_UP: {
if (line_edit->has_focus()) {
- set_value(get_value() + get_step());
+
+ set_value(get_value() + get_step() * mb.factor);
accept_event();
}
} break;
case BUTTON_WHEEL_DOWN: {
if (line_edit->has_focus()) {
- set_value(get_value() - get_step());
+
+ set_value(get_value() - get_step() * mb.factor);
accept_event();
}
} break;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 3c8545bd75..fb986cfb97 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -334,7 +334,10 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
- v_scroll->set_value(cursor.line_ofs);
+
+ if (fabs(v_scroll->get_value() - (double)cursor.line_ofs) >= 1) {
+ v_scroll->set_value(cursor.line_ofs);
+ }
} else {
cursor.line_ofs = 0;
@@ -346,7 +349,9 @@ void TextEdit::_update_scrollbars() {
h_scroll->show();
h_scroll->set_max(total_width);
h_scroll->set_page(visible_width);
- h_scroll->set_value(cursor.x_ofs);
+ if (fabs(h_scroll->get_value() - (double)cursor.x_ofs) >= 1) {
+ h_scroll->set_value(cursor.x_ofs);
+ }
} else {
@@ -1480,17 +1485,18 @@ void TextEdit::_gui_input(const InputEvent &p_gui_input) {
}
if (mb.pressed) {
+
if (mb.button_index == BUTTON_WHEEL_UP && !mb.mod.command) {
- v_scroll->set_value(v_scroll->get_value() - 3);
+ v_scroll->set_value(v_scroll->get_value() - (3 * mb.factor));
}
if (mb.button_index == BUTTON_WHEEL_DOWN && !mb.mod.command) {
- v_scroll->set_value(v_scroll->get_value() + 3);
+ v_scroll->set_value(v_scroll->get_value() + (3 * mb.factor));
}
if (mb.button_index == BUTTON_WHEEL_LEFT) {
- h_scroll->set_value(h_scroll->get_value() - 3);
+ h_scroll->set_value(h_scroll->get_value() - (100 * mb.factor));
}
if (mb.button_index == BUTTON_WHEEL_RIGHT) {
- h_scroll->set_value(h_scroll->get_value() + 3);
+ h_scroll->set_value(h_scroll->get_value() + (100 * mb.factor));
}
if (mb.button_index == BUTTON_LEFT) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 258e6c9a9f..67c97c2e52 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2341,11 +2341,11 @@ void Tree::_gui_input(InputEvent p_event) {
} break;
case BUTTON_WHEEL_UP: {
- v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() / 8);
+ v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b.factor / 8);
} break;
case BUTTON_WHEEL_DOWN: {
- v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() / 8);
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b.factor / 8);
} break;
}