diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-03 23:36:11 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-03 23:36:11 +0200 |
commit | 3a20c417cbf7d5db1d9d26abfbda388e58f96c18 (patch) | |
tree | a7552bff0a5164446eaade0dde570cd6111e474d /src/gui/ScrollablePage.cpp | |
parent | c080342fcd358561af7edc64cea2222880923b93 (diff) |
Align list items, dont process selected item twice if changed in event loop, mouse button events should only occur when pressing left mouse button
Diffstat (limited to 'src/gui/ScrollablePage.cpp')
-rw-r--r-- | src/gui/ScrollablePage.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp index de036b9..73b445e 100644 --- a/src/gui/ScrollablePage.cpp +++ b/src/gui/ScrollablePage.cpp @@ -10,15 +10,16 @@ namespace gsr { bool ScrollablePage::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) { const mgl::vec2f draw_pos = position + offset; offset = draw_pos + mgl::vec2f(0.0f, get_border_size(window)).floor(); + Widget *selected_widget = selected_child_widget; - if(selected_child_widget) { - if(!selected_child_widget->on_event(event, window, offset)) + if(selected_widget) { + if(!selected_widget->on_event(event, window, offset)) return false; } // Process widgets by visibility (backwards) for(auto it = widgets.rbegin(), end = widgets.rend(); it != end; ++it) { - if(it->get() != selected_child_widget) { + if(it->get() != selected_widget) { if(!(*it)->on_event(event, window, offset)) return false; } @@ -30,6 +31,7 @@ namespace gsr { void ScrollablePage::draw(mgl::Window &window, mgl::vec2f offset) { const mgl::vec2f draw_pos = position + offset; offset = draw_pos + mgl::vec2f(0.0f, get_border_size(window)).floor(); + Widget *selected_widget = selected_child_widget; mgl_scissor prev_scissor; mgl_window_get_scissor(window.internal_window(), &prev_scissor); @@ -51,12 +53,12 @@ namespace gsr { window.draw(border); for(auto &widget : widgets) { - if(widget.get() != selected_child_widget) + if(widget.get() != selected_widget) widget->draw(window, offset); } - if(selected_child_widget) - selected_child_widget->draw(window, offset); + if(selected_widget) + selected_widget->draw(window, offset); mgl_window_set_scissor(window.internal_window(), &prev_scissor); } |