widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07861
[Merge] lp:~notabilis27/widelands/bug-mousewheel into lp:widelands
Notabilis has proposed merging lp:~notabilis27/widelands/bug-mousewheel into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1386740 in widelands: "Fix mousewheel function"
https://bugs.launchpad.net/widelands/+bug/1386740
For more details, see:
https://code.launchpad.net/~notabilis27/widelands/bug-mousewheel/+merge/299629
--
Your team Widelands Developers is requested to review the proposed merge of lp:~notabilis27/widelands/bug-mousewheel into lp:widelands.
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2016-03-10 15:00:32 +0000
+++ src/ui_basic/panel.cc 2016-07-10 19:54:22 +0000
@@ -857,14 +857,20 @@
}
-bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y) {
- // TODO(GunChleoc): This is just a hack for focussed panels
- // We need to find the actualy scrollable panel beneaththe mouse cursor,
- // so we can have multiple scrollable elements on the same screen
- // e.g. load map with a long desctiprion has 2 of them.
- if (focus_) {
- if (focus_->do_mousewheel(which, x, y))
- return true;
+bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y, Point rel_mouse_pos) {
+
+ // Check if a child-panel is beneath the mouse and processes the event
+ for (Panel * child = first_child_; child; child = child->next_) {
+ if (!child->handles_mouse() || !child->is_visible())
+ continue;
+ if (rel_mouse_pos.x < child->x_ + static_cast<int32_t>(child->w_) && rel_mouse_pos.x >= child->x_
+ &&
+ rel_mouse_pos.y < child->y_ + static_cast<int32_t>(child->h_) && rel_mouse_pos.y >= child->y_) {
+ // Found a child at the position
+ if (child->do_mousewheel(which, x, y, rel_mouse_pos
+ - Point(child->get_x() + child->get_lborder(), child->get_y() + child->get_tborder())))
+ return true;
+ }
}
return handle_mousewheel(which, x, y);
@@ -1065,7 +1071,8 @@
if (!p) {
return false;
}
- return p->do_mousewheel(which, x, y);
+ return p->do_mousewheel(which, x, y,
+ p->get_mouse_position() - Point(p->get_x() + p->get_lborder(), p->get_y() + p->get_tborder()));
}
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2016-02-18 18:27:52 +0000
+++ src/ui_basic/panel.h 2016-07-10 19:54:22 +0000
@@ -288,7 +288,7 @@
bool do_mouserelease(const uint8_t btn, int32_t x, int32_t y);
bool do_mousemove
(const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
- bool do_mousewheel(uint32_t which, int32_t x, int32_t y);
+ bool do_mousewheel(uint32_t which, int32_t x, int32_t y, Point rel_mouse_pos);
bool do_key(bool down, SDL_Keysym code);
bool do_textinput(const std::string& text);
bool do_tooltip();