fix meter marker drags by not using a fake marker till first move, and swapping the...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 13 Dec 2011 19:43:41 +0000 (19:43 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 13 Dec 2011 19:43:41 +0000 (19:43 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10999 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_drag.cc

index 20ebe7f98d51998978b4f7b1c0037f5c5ef6bff9..3847d144d3b436dd8de0b6e49d671d610cd100dc 100644 (file)
@@ -1845,7 +1845,6 @@ MeterMarkerDrag::MeterMarkerDrag (Editor* e, ArdourCanvas::Item* i, bool c)
          _copy (c)
 {
        DEBUG_TRACE (DEBUG::Drags, "New MeterMarkerDrag\n");
-
        _marker = reinterpret_cast<MeterMarker*> (_item->get_data ("marker"));
        assert (_marker);
 }
@@ -1853,36 +1852,6 @@ MeterMarkerDrag::MeterMarkerDrag (Editor* e, ArdourCanvas::Item* i, bool c)
 void
 MeterMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
 {
-       // create a dummy marker for visual representation of moving the
-       // section, because whether its a copy or not, we're going to 
-       // leave or lose the original marker (leave if its a copy; lose if its
-       // not, because we'll remove it from the map).
-       
-       MeterSection section (_marker->meter());
-       
-       if (!section.movable()) {
-               return;
-       }
-       
-       char name[64];
-       snprintf (name, sizeof(name), "%g/%g", _marker->meter().divisions_per_bar(), _marker->meter().note_divisor ());
-       
-       _marker = new MeterMarker (
-               *_editor,
-               *_editor->meter_group,
-               ARDOUR_UI::config()->canvasvar_MeterMarker.get(),
-               name,
-               *new MeterSection (_marker->meter())
-               );
-       
-       _item = &_marker->the_item ();
-       
-       if (!_copy) {
-               TempoMap& map (_editor->session()->tempo_map());
-               /* remove the section while we drag it */
-               map.remove_meter (section);
-       }
-
        Drag::start_grab (event, cursor);
        show_verbose_cursor_time (adjusted_current_frame(event));
 }
@@ -1894,12 +1863,44 @@ MeterMarkerDrag::setup_pointer_frame_offset ()
 }
 
 void
-MeterMarkerDrag::motion (GdkEvent* event, bool)
+MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
 {
-       framepos_t const pf = adjusted_current_frame (event);
+       if (first_move) {
 
-       _marker->set_position (pf);
+               // create a dummy marker for visual representation of moving the
+               // section, because whether its a copy or not, we're going to 
+               // leave or lose the original marker (leave if its a copy; lose if its
+               // not, because we'll remove it from the map).
+               
+               MeterSection section (_marker->meter());
+               
+               if (!section.movable()) {
+                       return;
+               }
+               
+               char name[64];
+               snprintf (name, sizeof(name), "%g/%g", _marker->meter().divisions_per_bar(), _marker->meter().note_divisor ());
+               
+               _marker = new MeterMarker (
+                       *_editor,
+                       *_editor->meter_group,
+                       ARDOUR_UI::config()->canvasvar_MeterMarker.get(),
+                       name,
+                       *new MeterSection (_marker->meter())
+               );
+               
+               /* use the new marker for the grab */
+               swap_grab (&_marker->the_item(), 0, GDK_CURRENT_TIME);
 
+               if (!_copy) {
+                       TempoMap& map (_editor->session()->tempo_map());
+                       /* remove the section while we drag it */
+                       map.remove_meter (section);
+               }
+       }
+
+       framepos_t const pf = adjusted_current_frame (event);
+       _marker->set_position (pf);
        show_verbose_cursor_time (pf);
 }