summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_rulers.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-04-18 15:14:48 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-04-18 15:14:48 -0400
commitddd21c110c5d8f6e1214e85f75f8f26157d4bfa2 (patch)
tree44ee8c108d2f77dd2d5c9a4c4764583811d4485e /gtk2_ardour/editor_rulers.cc
parent55d7e8da19463bb0317026677d324e91568010b1 (diff)
fix various event coordinate system problems with button events on the rulers
Diffstat (limited to 'gtk2_ardour/editor_rulers.cc')
-rw-r--r--gtk2_ardour/editor_rulers.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index 0566bca2da..27a13a94b7 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -30,6 +30,7 @@
#include <gtk/gtkaction.h>
#include "canvas/group.h"
+#include "canvas/canvas.h"
#include "ardour/session.h"
#include "ardour/tempo.h"
@@ -250,8 +251,17 @@ Editor::ruler_button_press (GdkEventButton* ev)
_session->cancel_audition ();
}
- /* playhead cursor */
- _drags->set (new CursorDrag (this, *playhead_cursor, false), reinterpret_cast<GdkEvent *> (ev));
+ /* playhead cursor drag: CursorDrag expects an event with
+ * 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;
}
@@ -265,21 +275,21 @@ Editor::ruler_button_release (GdkEventButton* ev)
return false;
}
- gint x,y;
- Gdk::ModifierType state;
-
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;
}
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();
- framepos_t where = leftmost_frame + pixel_to_sample (x);
+ framepos_t where = window_event_frame ((GdkEvent*) ev);
+
snap_to (where);
popup_ruler_menu (where);
}