diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2014-06-24 10:32:41 -0500 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2014-06-24 10:33:28 -0500 |
commit | 2cc25a9d791cef50ef997147584e28e9afcf1b4c (patch) | |
tree | 1782b457a32bb52dfd8900dfa6bb0bc3bad2aabe /libs/canvas/canvas.cc | |
parent | 4bba1059e8aeeeb66cbd34701b91b7a7151ad60c (diff) |
add scroll wheel handler to canvas
Diffstat (limited to 'libs/canvas/canvas.cc')
-rw-r--r-- | libs/canvas/canvas.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 4371e60658..8fc816341b 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -689,6 +689,32 @@ GtkCanvas::context () return w->create_cairo_context (); } +/** Handler for GDK scroll events. + * @param ev Event. + * @return true if the event was handled. + */ +bool +GtkCanvas::on_scroll_event (GdkEventScroll* ev) +{ + /* translate event coordinates from window to canvas */ + + GdkEvent copy = *((GdkEvent*)ev); + Duple winpos = Duple (ev->x, ev->y); + Duple where = window_to_canvas (winpos); + + pick_current_item (winpos, ev->state); + + copy.button.x = where.x; + copy.button.y = where.y; + + /* Coordinates in the event will be canvas coordinates, correctly adjusted + for scroll if this GtkCanvas is in a GtkCanvasViewport. + */ + + DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas scroll @ %1, %2 => %3\n", ev->x, ev->y, where)); + return deliver_event (reinterpret_cast<GdkEvent*>(©)); +} + /** Handler for GDK button press events. * @param ev Event. * @return true if the event was handled. |