13
0

fix various event coordinate system problems with button events on the rulers

This commit is contained in:
Paul Davis 2013-04-18 15:14:48 -04:00
parent 55d7e8da19
commit ddd21c110c
2 changed files with 21 additions and 10 deletions

View File

@ -2389,6 +2389,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c)
_grab_zoom = _editor->samples_per_pixel; _grab_zoom = _editor->samples_per_pixel;
framepos_t where = _editor->canvas_event_frame (event, 0, 0); framepos_t where = _editor->canvas_event_frame (event, 0, 0);
_editor->snap_to_with_modifier (where, event); _editor->snap_to_with_modifier (where, event);
_editor->_dragging_playhead = true; _editor->_dragging_playhead = true;

View File

@ -30,6 +30,7 @@
#include <gtk/gtkaction.h> #include <gtk/gtkaction.h>
#include "canvas/group.h" #include "canvas/group.h"
#include "canvas/canvas.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/tempo.h" #include "ardour/tempo.h"
@ -250,8 +251,17 @@ Editor::ruler_button_press (GdkEventButton* ev)
_session->cancel_audition (); _session->cancel_audition ();
} }
/* playhead cursor */ /* playhead cursor drag: CursorDrag expects an event with
_drags->set (new CursorDrag (this, *playhead_cursor, false), reinterpret_cast<GdkEvent *> (ev)); * canvas coordinates, so convert from window coordinates,
* since for now, rulers are still Gtk::Widgets.
*/
GdkEventButton canvas_ev = *ev;
ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (ev->x, ev->y));
canvas_ev.x = rint (d.x);
canvas_ev.y = rint (d.y);
_drags->set (new CursorDrag (this, *playhead_cursor, false), reinterpret_cast<GdkEvent *> (&canvas_ev));
_dragging_playhead = true; _dragging_playhead = true;
} }
@ -265,21 +275,21 @@ Editor::ruler_button_release (GdkEventButton* ev)
return false; return false;
} }
gint x,y;
Gdk::ModifierType state;
if (_drags->active ()) { if (_drags->active ()) {
_drags->end_grab (reinterpret_cast<GdkEvent*> (ev)); GdkEventButton canvas_ev = *ev;
ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (ev->x, ev->y));
canvas_ev.x = rint (d.x);
canvas_ev.x = rint (d.y);
_drags->end_grab (reinterpret_cast<GdkEvent*> (&canvas_ev));
_dragging_playhead = false; _dragging_playhead = false;
} }
if (ev->button == 3) { if (ev->button == 3) {
/* need to use the correct x,y, the event lies */
time_canvas_event_box.get_window()->get_pointer (x, y, state);
stop_canvas_autoscroll(); stop_canvas_autoscroll();
framepos_t where = leftmost_frame + pixel_to_sample (x); framepos_t where = window_event_frame ((GdkEvent*) ev);
snap_to (where); snap_to (where);
popup_ruler_menu (where); popup_ruler_menu (where);
} }