diff options
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); } |