fix position where rubberband rect is drawn
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Jun 2014 12:32:35 +0000 (08:32 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Jun 2014 12:33:13 +0000 (08:33 -0400)
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_drag.cc

index c1302aa785ebdb3e1378a58b93f4a1aefc4a612b..9371fbbd46f9734fc53b440e6bcc28136acb4c05 100644 (file)
@@ -118,6 +118,15 @@ Editor::initialize_canvas ()
        _trackview_group = new ArdourCanvas::Group (hv_scroll_group);
        CANVAS_DEBUG_NAME (_trackview_group, "Canvas TrackViews");
        
+       // used to show zoom mode active zooming
+       zoom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
+       zoom_rect->hide();
+       zoom_rect->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
+
+       // used as rubberband rect
+       rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
+       rubberband_rect->hide();
+
        /* a group to hold stuff while it gets dragged around. Must be the
         * uppermost (last) group with hv_scroll_group as a parent
         */
@@ -202,15 +211,6 @@ Editor::initialize_canvas ()
        transport_punchout_line->set_y1 (ArdourCanvas::COORD_MAX);
        transport_punchout_line->hide();
 
-       // used to show zoom mode active zooming
-       zoom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
-       zoom_rect->hide();
-       zoom_rect->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
-
-       // used as rubberband rect
-       rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
-       rubberband_rect->hide();
-
        tempo_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
        meter_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_meter_bar_event), meter_bar));
        marker_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_marker_bar_event), marker_bar));
index d4a6c8e00f2c318d3f002c686c039e38e4537a9e..2711ec85d0b77c6ec6862361d1b78f6c22667384 100644 (file)
@@ -181,6 +181,9 @@ DragManager::motion_handler (GdkEvent* e, bool from_autoscroll)
 
        for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
                bool const t = (*i)->motion_handler (e, from_autoscroll);
+               /* run all handlers; return true if at least one of them
+                  returns true (indicating that the event has been handled).
+               */
                if (t) {
                        r = true;
                }
@@ -3577,28 +3580,28 @@ RubberbandSelectDrag::motion (GdkEvent* event, bool)
                double x2 = _editor->sample_to_pixel (end);
                const double min_dimension = 2.0;
 
-               _editor->rubberband_rect->set_x0 (x1);
                if (_vertical_only) {
                        /* fixed 10 pixel width */
-                       _editor->rubberband_rect->set_x1 (x1 + 10);
+                       x2 = x1 + 10;
                } else {
                        if (x2 < x1) {
                                x2 = min (x1 - min_dimension, x2);
                        } else {
                                x2 = max (x1 + min_dimension, x2);
                        }
-                       _editor->rubberband_rect->set_x1 (x2);
                } 
 
-               _editor->rubberband_rect->set_y0 (y1);
                if (y2 < y1) {
                        y2 = min (y1 - min_dimension, y2);
                } else {
                        y2 = max (y1 + min_dimension, y2);
                }
 
-               _editor->rubberband_rect->set_y1 (y2);
-               
+               /* translate rect into item space and set */
+
+               Rect r (x1, y1, x2, y2);
+
+               _editor->rubberband_rect->set (_editor->rubberband_rect->canvas_to_item (r));
                _editor->rubberband_rect->show();
                _editor->rubberband_rect->raise_to_top();