Fix dragging grid lines when you move the mouse outside of the grid during the drag.
authorCarl Hetherington <carl@carlh.net>
Wed, 18 Nov 2009 14:53:55 +0000 (14:53 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 18 Nov 2009 14:53:55 +0000 (14:53 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6120 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/port_matrix_body.cc
gtk2_ardour/port_matrix_component.h
gtk2_ardour/port_matrix_grid.cc

index 3d961baa5ce8b9f95e624c1be05ec0cbd2fa80c7..79efd22b7cf3c8cc35eaf71e25a8a03dc0a87ef6 100644 (file)
@@ -328,14 +328,19 @@ PortMatrixBody::on_button_press_event (GdkEventButton* ev)
 bool
 PortMatrixBody::on_button_release_event (GdkEventButton* ev)
 {
-       if (Gdk::Region (_grid->parent_rectangle()).point_in (ev->x, ev->y)) {
-
-               _grid->button_release (
-                       _grid->parent_to_component_x (ev->x),
-                       _grid->parent_to_component_y (ev->y),
-                       ev->button, ev->time
-                       );
-
+       for (list<PortMatrixComponent*>::iterator i = _components.begin(); i != _components.end(); ++i) {
+               if (Gdk::Region ((*i)->parent_rectangle()).point_in (ev->x, ev->y)) {
+                       (*i)->button_release (
+                               (*i)->parent_to_component_x (ev->x),
+                               (*i)->parent_to_component_y (ev->y),
+                               ev->button, ev->time
+                               );
+               } else {
+                       (*i)->button_release (
+                               -1, -1,
+                               ev->button, ev->time
+                               );
+               }
        }
 
        return true;
index cbef95344bb6968b250795d6e1667d03abe5e0fa..86cd0565ae48cffa1309754f8df6470bd4ea672b 100644 (file)
@@ -50,6 +50,7 @@ public:
        virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0;
        virtual void draw_extra (cairo_t *) = 0;
        virtual void button_press (double, double, int, uint32_t) {}
+       virtual void button_release (double, double, int, uint32_t) {}
        virtual void motion (double, double) {}
 
        void set_show_ports (bool);
index 53b4b50b50e0176b55f2650bedb15f3ec7ab38ad..c2af484e6c2f11501e081ef2779c01faca85020d 100644 (file)
@@ -359,29 +359,33 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/)
 {
        if (b == 1) {
 
-               if (_dragging && _moved) {
-
-                       if (_drag_valid) {
-                               list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
-
-                               if (!p.empty()) {
-                                       PortMatrixNode::State const s = get_association (p.front());
-                                       for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
-                                               set_association (*i, toggle_state (s));
+               if (x != -1) {
+                       
+                       if (_dragging && _moved) {
+                               
+                               if (_drag_valid) {
+                                       list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
+                                       
+                                       if (!p.empty()) {
+                                               PortMatrixNode::State const s = get_association (p.front());
+                                               for (list<PortMatrixNode>::const_iterator i = p.begin(); i != p.end(); ++i) {
+                                                       set_association (*i, toggle_state (s));
+                                               }
                                        }
                                }
+                               
+                       } else {
+                               
+                               PortMatrixNode const n = position_to_node (x, y);
+                               if (n.row.bundle && n.column.bundle) {
+                                       PortMatrixNode::State const s = get_association (n);
+                                       set_association (n, toggle_state (s));
+                               }
                        }
 
-               } else {
-
-                       PortMatrixNode const n = position_to_node (x, y);
-                       if (n.row.bundle && n.column.bundle) {
-                               PortMatrixNode::State const s = get_association (n);
-                               set_association (n, toggle_state (s));
-                       }
+                       require_render ();
                }
-
-               require_render ();
+               
                _body->queue_draw ();
        }