fix comment
[ardour.git] / gtk2_ardour / editor_canvas_events.cc
index 0c55da8a0a568f953dc3745d33a42b9619dabcda..5bd0060d231d8eda915d4ec02464a1319bc2d0d9 100644 (file)
@@ -63,23 +63,29 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
        framepos_t xdelta;
        int direction = ev->direction;
 
+       /* this event arrives without transformation by the canvas, so we have
+        * to transform the coordinates to be able to look things up.
+        */
+
+       Duple event_coords = _track_canvas->window_to_canvas (Duple (ev->x, ev->y));
+       
   retry:
        switch (direction) {
        case GDK_SCROLL_UP:
-               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+               if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
                        //for mouse-wheel zoom, force zoom-focus to mouse
                        Editing::ZoomFocus temp_focus = zoom_focus;
                        zoom_focus = Editing::ZoomFocusMouse;
                        temporal_zoom_step (false);
                        zoom_focus = temp_focus;
                        return true;
-               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
                        direction = GDK_SCROLL_LEFT;
                        goto retry;
-               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
                        if (!current_stepping_trackview) {
                                step_timeout = Glib::signal_timeout().connect (sigc::mem_fun(*this, &Editor::track_height_step_timeout), 500);
-                               std::pair<TimeAxisView*, int> const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value());
+                               std::pair<TimeAxisView*, int> const p = trackview_by_y_position (event_coords.y);
                                current_stepping_trackview = p.first;
                                if (!current_stepping_trackview) {
                                        return false;
@@ -95,20 +101,20 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
                break;
 
        case GDK_SCROLL_DOWN:
-               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+               if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
                        //for mouse-wheel zoom, force zoom-focus to mouse
                        Editing::ZoomFocus temp_focus = zoom_focus;
                        zoom_focus = Editing::ZoomFocusMouse;
                        temporal_zoom_step (true);
                        zoom_focus = temp_focus;
                        return true;
-               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
                        direction = GDK_SCROLL_RIGHT;
                        goto retry;
-               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
                        if (!current_stepping_trackview) {
                                step_timeout = Glib::signal_timeout().connect (sigc::mem_fun(*this, &Editor::track_height_step_timeout), 500);
-                               std::pair<TimeAxisView*, int> const p = trackview_by_y_position (ev->y + vertical_adjustment.get_value());
+                               std::pair<TimeAxisView*, int> const p = trackview_by_y_position (event_coords.y);
                                current_stepping_trackview = p.first;
                                if (!current_stepping_trackview) {
                                        return false;
@@ -124,7 +130,7 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
                break;
 
        case GDK_SCROLL_LEFT:
-               xdelta = (current_page_frames() / 8);
+               xdelta = (current_page_samples() / 8);
                if (leftmost_frame > xdelta) {
                        reset_x_origin (leftmost_frame - xdelta);
                } else {
@@ -133,11 +139,11 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
                break;
 
        case GDK_SCROLL_RIGHT:
-               xdelta = (current_page_frames() / 8);
+               xdelta = (current_page_samples() / 8);
                if (max_framepos - xdelta > leftmost_frame) {
                        reset_x_origin (leftmost_frame + xdelta);
                } else {
-                       reset_x_origin (max_framepos - current_page_frames());
+                       reset_x_origin (max_framepos - current_page_samples());
                }
                break;