Fix port click detection

git-svn-id: file:///home/vcs/svn/jsweeper/trunk@7 6611ac79-6612-48ef-a1e9-b906f853523e
master
petern 2009-11-26 19:30:14 +00:00
parent 01c06da832
commit a3bc38d0c1
1 changed files with 21 additions and 18 deletions

View File

@ -548,6 +548,9 @@ bool Matrix::on_button_press_event(GdkEventButton *event)
ClientList::iterator clit;
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
Client *c = *clit;
if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
if (c->rect.Hit(event->x, event->y)) {
c->m_expanded = !c->m_expanded;
Refresh();
@ -567,33 +570,34 @@ bool Matrix::on_button_press_event(GdkEventButton *event)
}
}
Port *p1 = NULL;
Port *p2 = NULL;
// Check port hit
PortList::iterator plit;
for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) {
Port *p = *plit;
if (p->rect.HitX(event->x)) p1 = p;
if (p->rect.HitY(event->y)) p2 = p;
if (p1 != NULL && p2 != NULL) {
pm.ToggleConnect(p1, p2);
return true;
}
}
PortGroup *pg1 = NULL;
PortGroup *pg2 = NULL;
Port *p1 = NULL;
Port *p2 = NULL;
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
Client *c = *clit;
if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
PortGroupList::iterator pglit;
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
PortGroup *pg = *pglit;
PortList::iterator plit;
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
Port *p = *plit;
if (p->rect.HitX(event->x)) p1 = p;
if (p->rect.HitY(event->y)) p2 = p;
if (p1 != NULL && p2 != NULL) {
pm.ToggleConnect(p1, p2);
return true;
}
}
if (pg->rect.HitX(event->x)) pg1 = pg;
if (pg->rect.HitY(event->y)) pg2 = pg;
@ -612,6 +616,5 @@ bool Matrix::on_button_press_event(GdkEventButton *event)
}
}
std::cout << event->x << ", " << event->y << std::endl;
return true;
return false;
}