Stop line drags in collapsed groups.

git-svn-id: svn://localhost/ardour2/branches/3.0@5390 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2009-07-19 21:57:51 +00:00
parent 9f5b9f3c3e
commit e11d65d98d
2 changed files with 18 additions and 11 deletions

View File

@ -30,6 +30,7 @@ using namespace std;
PortMatrixGrid::PortMatrixGrid (PortMatrix* m, PortMatrixBody* b)
: PortMatrixComponent (m, b),
_dragging (false),
_drag_valid (false),
_moved (false)
{
@ -291,18 +292,21 @@ PortMatrixGrid::position_to_node (uint32_t x, uint32_t y) const
void
PortMatrixGrid::button_press (double x, double y, int b, uint32_t t)
{
pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel> px = position_to_group_and_channel (x / grid_spacing(), _matrix->columns());
pair<boost::shared_ptr<PortGroup>, ARDOUR::BundleChannel> py = position_to_group_and_channel (y / grid_spacing(), _matrix->rows());
if (b == 1) {
_dragging = true;
_drag_valid = (px.second.bundle && py.second.bundle);
_moved = false;
_drag_start_x = x / grid_spacing ();
_drag_start_y = y / grid_spacing ();
} else if (b == 3) {
_matrix->popup_menu (
position_to_group_and_channel (x / grid_spacing(), _matrix->columns()),
position_to_group_and_channel (y / grid_spacing(), _matrix->rows()), t);
_matrix->popup_menu (px, py, t);
}
}
@ -408,12 +412,14 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t t)
if (_dragging && _moved) {
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 (_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));
}
}
}
@ -462,7 +468,7 @@ PortMatrixGrid::draw_extra (cairo_t* cr)
cairo_stroke (cr);
}
if (_dragging && _moved) {
if (_dragging && _drag_valid && _moved) {
list<PortMatrixNode> const p = nodes_on_line (_drag_start_x, _drag_start_y, _drag_x, _drag_y);
@ -525,7 +531,7 @@ PortMatrixGrid::motion (double x, double y)
_moved = true;
}
if (_dragging && _moved) {
if (_dragging && _drag_valid && _moved) {
_drag_x = px;
_drag_y = py;
_body->queue_draw ();

View File

@ -69,6 +69,7 @@ private:
bool toggle_state (PortMatrixNode::State) const;
bool _dragging;
bool _drag_valid;
bool _moved;
int _drag_start_x;
int _drag_start_y;