Merge lp:~notabilis27/widelands/bug-mousewheel into lp:widelands

Proposed by Notabilis
Status: Merged
Merged at revision: 8030
Proposed branch: lp:~notabilis27/widelands/bug-mousewheel
Merge into: lp:widelands
Diff against target: 60 lines (+22/-9)
2 files modified
src/ui_basic/panel.cc (+21/-8)
src/ui_basic/panel.h (+1/-1)
To merge this branch: bzr merge lp:~notabilis27/widelands/bug-mousewheel
Reviewer Review Type Date Requested Status
SirVer Approve
kaputtnik (community) testing Approve
Review via email: mp+299629@code.launchpad.net
To post a comment you must log in.
Revision history for this message
kaputtnik (franku) wrote :

Great :)

review: Approve (testing)
Revision history for this message
SirVer (sirver) wrote :

Awesome! THanks for taking care of this issue. I didn't test, but found a few nits in the code. Could you consider them pleaes?

review: Needs Fixing
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1181. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/143769774.
Appveyor build 1019. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_notabilis27_widelands_bug_mousewheel-1019.

Revision history for this message
Notabilis (notabilis27) wrote :

Okay, is changed. And it really does look better.
Also did a short test after modifying the code, seems like I haven't introduced new mistakes.

Revision history for this message
SirVer (sirver) wrote :

Cool, I think the code reads quite clear now. Let's get that in!

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/panel.cc'
2--- src/ui_basic/panel.cc 2016-03-10 15:00:32 +0000
3+++ src/ui_basic/panel.cc 2016-07-11 17:00:11 +0000
4@@ -857,14 +857,27 @@
5 }
6
7
8-bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y) {
9- // TODO(GunChleoc): This is just a hack for focussed panels
10- // We need to find the actualy scrollable panel beneaththe mouse cursor,
11- // so we can have multiple scrollable elements on the same screen
12- // e.g. load map with a long desctiprion has 2 of them.
13- if (focus_) {
14- if (focus_->do_mousewheel(which, x, y))
15+bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y, Point rel_mouse_pos) {
16+
17+ // Check if a child-panel is beneath the mouse and processes the event
18+ for (Panel * child = first_child_; child; child = child->next_) {
19+ if (!child->handles_mouse() || !child->is_visible()) {
20+ continue;
21+ }
22+ if (rel_mouse_pos.x >= child->x_ + static_cast<int32_t>(child->w_)
23+ || rel_mouse_pos.x < child->x_
24+ || rel_mouse_pos.y >= child->y_ + static_cast<int32_t>(child->h_)
25+ || rel_mouse_pos.y < child->y_) {
26+ continue;
27+ }
28+ // Found a child at the position
29+ if (child->do_mousewheel(which, x, y, rel_mouse_pos
30+ - Point(child->get_x() + child->get_lborder(), child->get_y() + child->get_tborder()))) {
31 return true;
32+ }
33+ // Break after the first hit panel in the list. The panels are ordered from top to bottom,
34+ // so only the highest window at the current mouse coordinates receives the event
35+ break;
36 }
37
38 return handle_mousewheel(which, x, y);
39@@ -1065,7 +1078,7 @@
40 if (!p) {
41 return false;
42 }
43- return p->do_mousewheel(which, x, y);
44+ return p->do_mousewheel(which, x, y, p->get_mouse_position());
45 }
46
47
48
49=== modified file 'src/ui_basic/panel.h'
50--- src/ui_basic/panel.h 2016-02-18 18:27:52 +0000
51+++ src/ui_basic/panel.h 2016-07-11 17:00:11 +0000
52@@ -288,7 +288,7 @@
53 bool do_mouserelease(const uint8_t btn, int32_t x, int32_t y);
54 bool do_mousemove
55 (const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
56- bool do_mousewheel(uint32_t which, int32_t x, int32_t y);
57+ bool do_mousewheel(uint32_t which, int32_t x, int32_t y, Point rel_mouse_pos);
58 bool do_key(bool down, SDL_Keysym code);
59 bool do_textinput(const std::string& text);
60 bool do_tooltip();

Subscribers

People subscribed via source and target branches

to status/vote changes: