aboutsummaryrefslogtreecommitdiff
path: root/src/gui/ScrollablePage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/ScrollablePage.cpp')
-rw-r--r--src/gui/ScrollablePage.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp
index 94da907..923a0c8 100644
--- a/src/gui/ScrollablePage.cpp
+++ b/src/gui/ScrollablePage.cpp
@@ -28,12 +28,12 @@ namespace gsr {
offset.y += scroll_y;
Widget *selected_widget = selected_child_widget;
- if(event.type == mgl::Event::MouseButtonPressed || event.type == mgl::Event::MouseButtonReleased) {
- if(!mgl::IntRect(scissor_pos, scissor_size).contains({event.mouse_button.x, event.mouse_button.y}))
- return true;
- } else if(event.type == mgl::Event::MouseMoved) {
- if(!mgl::IntRect(scissor_pos, scissor_size).contains({event.mouse_move.x, event.mouse_move.y}))
- return true;
+ if(event.type == mgl::Event::MouseButtonPressed && scrollbar_rect.contains(mgl::vec2f(event.mouse_button.x, event.mouse_button.y))) {
+ set_widget_as_selected_in_parent();
+ moving_scrollbar_with_cursor = true;
+ scrollbar_move_cursor_start_pos = mgl::vec2f(event.mouse_button.x, event.mouse_button.y);
+ scrollbar_move_cursor_scroll_y_start = scroll_y;
+ return false;
}
if(event.type == mgl::Event::MouseButtonReleased && moving_scrollbar_with_cursor) {
@@ -42,6 +42,14 @@ namespace gsr {
return false;
}
+ if(event.type == mgl::Event::MouseButtonPressed || event.type == mgl::Event::MouseButtonReleased) {
+ if(!mgl::IntRect(scissor_pos, scissor_size).contains({event.mouse_button.x, event.mouse_button.y}))
+ return true;
+ } else if(event.type == mgl::Event::MouseMoved) {
+ if(!mgl::IntRect(scissor_pos, scissor_size).contains({event.mouse_move.x, event.mouse_move.y}))
+ return true;
+ }
+
if(selected_widget) {
if(!selected_widget->on_event(event, window, offset))
return false;
@@ -65,14 +73,6 @@ namespace gsr {
return false;
}
- if(event.type == mgl::Event::MouseButtonPressed && scrollbar_rect.contains(mgl::vec2f(event.mouse_button.x, event.mouse_button.y))) {
- set_widget_as_selected_in_parent();
- moving_scrollbar_with_cursor = true;
- scrollbar_move_cursor_start_pos = mgl::vec2f(event.mouse_button.x, event.mouse_button.y);
- scrollbar_move_cursor_scroll_y_start = scroll_y;
- return false;
- }
-
return true;
}