Pass whole GdkEventButton into port matrix button

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
This commit is contained in:
Carl Hetherington 2011-12-07 01:44:47 +00:00
parent 790d9042c6
commit 668c8b1f9e
8 changed files with 28 additions and 23 deletions

View file

@ -334,7 +334,7 @@ PortMatrixBody::on_button_press_event (GdkEventButton* ev)
(*i)->button_press ( (*i)->button_press (
(*i)->parent_to_component_x (ev->x), (*i)->parent_to_component_x (ev->x),
(*i)->parent_to_component_y (ev->y), (*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)->button_release (
(*i)->parent_to_component_x (ev->x), (*i)->parent_to_component_x (ev->x),
(*i)->parent_to_component_y (ev->y), (*i)->parent_to_component_y (ev->y),
ev->button, ev->time, ev->state ev
); );
} else { } else {
(*i)->button_release ( (*i)->button_release (
-1, -1, -1, -1,
ev->button, ev->time, ev->state ev
); );
} }
} }

View file

@ -18,6 +18,7 @@
*/ */
#include <iostream> #include <iostream>
#include "gtkmm2ext/keyboard.h"
#include "ardour/bundle.h" #include "ardour/bundle.h"
#include "ardour/types.h" #include "ardour/types.h"
#include "port_matrix_column_labels.h" #include "port_matrix_column_labels.h"
@ -451,7 +452,7 @@ PortMatrixColumnLabels::position_to_channel (double p, double o, boost::shared_p
} }
void 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()); 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; 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 ( _matrix->popup_menu (
w, w,
ARDOUR::BundleChannel (), ARDOUR::BundleChannel (),
t ev->time
); );
} }
} }

View file

@ -36,7 +36,7 @@ class PortMatrixColumnLabels : public PortMatrixLabels
public: public:
PortMatrixColumnLabels (PortMatrix *, PortMatrixBody *); 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 component_to_parent_x (double x) const;
double parent_to_component_x (double x) const; double parent_to_component_x (double x) const;

View file

@ -50,8 +50,8 @@ public:
virtual double parent_to_component_y (double y) const = 0; virtual double parent_to_component_y (double y) const = 0;
virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0; virtual void mouseover_changed (std::list<PortMatrixNode> const &) = 0;
virtual void draw_extra (cairo_t *) = 0; virtual void draw_extra (cairo_t *) = 0;
virtual void button_press (double, double, int, uint32_t, guint) {} virtual void button_press (double, double, GdkEventButton *) {}
virtual void button_release (double, double, int, uint32_t, guint) {} virtual void button_release (double, double, GdkEventButton *) {}
virtual void motion (double, double) {} virtual void motion (double, double) {}
void set_show_ports (bool); void set_show_ports (bool);

View file

@ -312,12 +312,12 @@ PortMatrixGrid::position_to_node (double x, double y) const
} }
void 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 px = position_to_channel (x, y, _matrix->visible_columns());
ARDOUR::BundleChannel const py = position_to_channel (y, x, _matrix->visible_rows()); ARDOUR::BundleChannel const py = position_to_channel (y, x, _matrix->visible_rows());
if (b == 1) { if (ev->button == 1) {
_dragging = true; _dragging = true;
_drag_valid = (px.bundle && py.bundle); _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_x = x / grid_spacing ();
_drag_start_y = y / 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 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) { if (x != -1) {
@ -387,7 +387,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
} else { } 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 */ /* associate/disassociate things diagonally down and right until we run out */
PortMatrixNode::State s = (PortMatrixNode::State) 0; PortMatrixNode::State s = (PortMatrixNode::State) 0;
while (1) { while (1) {

View file

@ -41,8 +41,8 @@ class PortMatrixGrid : public PortMatrixComponent
public: public:
PortMatrixGrid (PortMatrix *, PortMatrixBody *); PortMatrixGrid (PortMatrix *, PortMatrixBody *);
void button_press (double, double, int, uint32_t, guint); void button_press (double, double, GdkEventButton *);
void button_release (double, double, int, uint32_t, guint); void button_release (double, double, GdkEventButton *);
void motion (double, double); void motion (double, double);
double component_to_parent_x (double x) const; double component_to_parent_x (double x) const;

View file

@ -20,6 +20,7 @@
#include <iostream> #include <iostream>
#include <boost/weak_ptr.hpp> #include <boost/weak_ptr.hpp>
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include "gtkmm2ext/keyboard.h"
#include "ardour/bundle.h" #include "ardour/bundle.h"
#include "port_matrix_row_labels.h" #include "port_matrix_row_labels.h"
#include "port_matrix.h" #include "port_matrix.h"
@ -140,7 +141,7 @@ PortMatrixRowLabels::render (cairo_t* cr)
} }
void 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()); 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; 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 ( _matrix->popup_menu (
ARDOUR::BundleChannel (), ARDOUR::BundleChannel (),
w, w,
t ev->time
); );
} }
} }

View file

@ -43,7 +43,7 @@ class PortMatrixRowLabels : public PortMatrixLabels
public: public:
PortMatrixRowLabels (PortMatrix *, PortMatrixBody *); 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 component_to_parent_x (double x) const;
double parent_to_component_x (double x) const; double parent_to_component_x (double x) const;