Pass whole GdkEventButton into port matrix button
authorCarl Hetherington <carl@carlh.net>
Wed, 7 Dec 2011 01:44:47 +0000 (01:44 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 7 Dec 2011 01:44:47 +0000 (01:44 +0000)
press/release handlers, rather than just selected
highlights.  Remove port in the port matrix on Keyboard
is_delete_event (part of #4536).

git-svn-id: svn://localhost/ardour2/branches/3.0@10920 d708f5d6-7413-0410-9779-e7cbd77b26cf

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

index 5d7bb0c4b6a32c59b9afdfc93a4a6d71d41f3e90..83864a607c690bb74dc3c699bb8b6b38071ded82 100644 (file)
@@ -334,7 +334,7 @@ PortMatrixBody::on_button_press_event (GdkEventButton* ev)
                        (*i)->button_press (
                                (*i)->parent_to_component_x (ev->x),
                                (*i)->parent_to_component_y (ev->y),
-                               ev->button, ev->time, ev->state
+                               ev
                                );
                }
        }
@@ -350,12 +350,12 @@ PortMatrixBody::on_button_release_event (GdkEventButton* ev)
                        (*i)->button_release (
                                (*i)->parent_to_component_x (ev->x),
                                (*i)->parent_to_component_y (ev->y),
-                               ev->button, ev->time, ev->state
+                               ev
                                );
                } else {
                        (*i)->button_release (
                                -1, -1,
-                               ev->button, ev->time, ev->state
+                               ev
                                );
                }
        }
index 04b57c404fc1994b8923106a851f38f2f1562f52..5496c40a491d4c4b0517101494edcb366bddfce1 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <iostream>
+#include "gtkmm2ext/keyboard.h"
 #include "ardour/bundle.h"
 #include "ardour/types.h"
 #include "port_matrix_column_labels.h"
@@ -451,7 +452,7 @@ PortMatrixColumnLabels::position_to_channel (double p, double o, boost::shared_p
 }
 
 void
-PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t, guint)
+PortMatrixColumnLabels::button_press (double x, double y, GdkEventButton* ev)
 {
        ARDOUR::BundleChannel w = position_to_channel (x, y, _matrix->visible_columns());
 
@@ -463,11 +464,13 @@ PortMatrixColumnLabels::button_press (double x, double y, int b, uint32_t t, gui
                w.channel = -1;
        }
 
-       if (b == 3) {
+       if (Gtkmm2ext::Keyboard::is_delete_event (ev) && w.channel != -1) {
+               _matrix->remove_channel (w);
+       } else if (ev->button == 3) {
                _matrix->popup_menu (
                        w,
                        ARDOUR::BundleChannel (),
-                       t
+                       ev->time
                        );
        }
 }
index 9ff59ec33bbfb5f8e2448bb8b29e2da0d859f1ea..b3f2ed8c807f0feb294d993ca6674ae419468458 100644 (file)
@@ -36,7 +36,7 @@ class PortMatrixColumnLabels : public PortMatrixLabels
 public:
        PortMatrixColumnLabels (PortMatrix *, PortMatrixBody *);
 
-       void button_press (double, double, int, uint32_t, guint);
+       void button_press (double, double, GdkEventButton *);
 
        double component_to_parent_x (double x) const;
        double parent_to_component_x (double x) const;
index a574d20341a2456c045a32e920a4232041b7cb02..c61d7ec67dcd1db3188c9bf201ed69f9a580dd24 100644 (file)
@@ -50,8 +50,8 @@ public:
        virtual double parent_to_component_y (double y) const = 0;
        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, guint) {}
-       virtual void button_release (double, double, int, uint32_t, guint) {}
+       virtual void button_press (double, double, GdkEventButton *) {}
+       virtual void button_release (double, double, GdkEventButton *) {}
        virtual void motion (double, double) {}
 
        void set_show_ports (bool);
index a4ca3df1b810d021123df3b98f5ef3e5619d39fc..daa25139dc7f896532d091072fe6ca17254e63d2 100644 (file)
@@ -312,12 +312,12 @@ PortMatrixGrid::position_to_node (double x, double y) const
 }
 
 void
-PortMatrixGrid::button_press (double x, double y, int b, uint32_t t, guint)
+PortMatrixGrid::button_press (double x, double y, GdkEventButton* ev)
 {
        ARDOUR::BundleChannel const px = position_to_channel (x, y, _matrix->visible_columns());
        ARDOUR::BundleChannel const py = position_to_channel (y, x, _matrix->visible_rows());
 
-       if (b == 1) {
+       if (ev->button == 1) {
 
                _dragging = true;
                _drag_valid = (px.bundle && py.bundle);
@@ -326,9 +326,9 @@ PortMatrixGrid::button_press (double x, double y, int b, uint32_t t, guint)
                _drag_start_x = x / grid_spacing ();
                _drag_start_y = y / grid_spacing ();
 
-       } else if (b == 3) {
+       } else if (ev->button == 3) {
 
-               _matrix->popup_menu (px, py, t);
+               _matrix->popup_menu (px, py, ev->time);
 
        }
 }
@@ -366,9 +366,9 @@ PortMatrixGrid::set_association (PortMatrixNode node, bool s)
 }
 
 void
-PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint s)
+PortMatrixGrid::button_release (double x, double y, GdkEventButton* ev)
 {
-       if (b == 1) {
+       if (ev->button == 1) {
 
                if (x != -1) {
 
@@ -387,7 +387,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
 
                        } else {
 
-                               if (Keyboard::modifier_state_equals (s, Keyboard::PrimaryModifier)) {
+                               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
                                        /* associate/disassociate things diagonally down and right until we run out */
                                        PortMatrixNode::State s = (PortMatrixNode::State) 0;
                                        while (1) {
index ec7eb32b4bee90d4b571fd8559ee0d10468a4a00..383db2d42bdccb9478c37374f8ee551fdbb9da97 100644 (file)
@@ -41,8 +41,8 @@ class PortMatrixGrid : public PortMatrixComponent
 public:
        PortMatrixGrid (PortMatrix *, PortMatrixBody *);
 
-       void button_press (double, double, int, uint32_t, guint);
-       void button_release (double, double, int, uint32_t, guint);
+       void button_press (double, double, GdkEventButton *);
+       void button_release (double, double, GdkEventButton *);
        void motion (double, double);
 
        double component_to_parent_x (double x) const;
index 38b2dde6a7342e704f13ffe5094a03abc2a388c3..e7f1153e90cc9e9cb9545487925058f6bce9e086 100644 (file)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <boost/weak_ptr.hpp>
 #include <cairo/cairo.h>
+#include "gtkmm2ext/keyboard.h"
 #include "ardour/bundle.h"
 #include "port_matrix_row_labels.h"
 #include "port_matrix.h"
@@ -140,7 +141,7 @@ PortMatrixRowLabels::render (cairo_t* cr)
 }
 
 void
-PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t, guint)
+PortMatrixRowLabels::button_press (double x, double y, GdkEventButton* ev)
 {
        ARDOUR::BundleChannel w = position_to_channel (y, x, _matrix->visible_rows());
 
@@ -152,12 +153,13 @@ PortMatrixRowLabels::button_press (double x, double y, int b, uint32_t t, guint)
                        w.channel = -1;
        }
 
-       if (b == 3) {
-
+       if (Gtkmm2ext::Keyboard::is_delete_event (ev) && w.channel != -1) {
+               _matrix->remove_channel (w);
+       } else if (ev->button == 3) {
                _matrix->popup_menu (
                        ARDOUR::BundleChannel (),
                        w,
-                       t
+                       ev->time
                        );
        }
 }
index 34086b1074dcec8696614ab94a1b80669638fd04..21839df41e77914a57dafc704aef44b78977fa59 100644 (file)
@@ -43,7 +43,7 @@ class PortMatrixRowLabels : public PortMatrixLabels
 public:
        PortMatrixRowLabels (PortMatrix *, PortMatrixBody *);
 
-       void button_press (double, double, int, uint32_t, guint);
+       void button_press (double, double, GdkEventButton *);
 
        double component_to_parent_x (double x) const;
        double parent_to_component_x (double x) const;