Browse Source

Make the patchbay connections always have a group and port id

tags/1.9.4
falkTX 11 years ago
parent
commit
43fd066ff5
9 changed files with 232 additions and 143 deletions
  1. +1
    -4
      source/backend/CarlaBackend.h
  2. +1
    -2
      source/backend/engine/CarlaEngine.cpp
  3. +97
    -24
      source/backend/engine/CarlaEngineJack.cpp
  4. +0
    -1
      source/backend/standalone/CarlaStandalone.cpp
  5. +1
    -4
      source/carla_backend.py
  6. +3
    -2
      source/carla_host.py
  7. +5
    -5
      source/carla_patchbay.py
  8. +3
    -3
      source/includes/lv2/atom-util.h
  9. +121
    -98
      source/patchcanvas.py

+ 1
- 4
source/backend/CarlaBackend.h View File

@@ -861,16 +861,13 @@ typedef enum {
/*!
* A patchbay connection has been added.
* @param pluginId Connection Id
* @param value1 Output port Id
* @param value2 Input port Id
* @param valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax.
*/
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26,

/*!
* A patchbay connection has been removed.
* @param pluginId Connection Id
* @param value1 Output port Id
* @param value2 Input port Id
*/
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27,



+ 1
- 2
source/backend/engine/CarlaEngine.cpp View File

@@ -1142,7 +1142,6 @@ CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const
CARLA_SAFE_ASSERT_RETURN_ERRN(pData->curPluginCount != 0, "Invalid engine internal data (err #39)");
CARLA_SAFE_ASSERT_RETURN_ERRN(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #40)");
CARLA_SAFE_ASSERT_RETURN_ERRN(id < pData->curPluginCount, "Invalid plugin Id (err #7)");
carla_debug("CarlaEngine::getPlugin(%i) [count:%i]", id, pData->curPluginCount);

return pData->plugins[id].plugin;
}
@@ -1841,7 +1840,7 @@ bool CarlaEngine::patchbayDisconnect(const uint connectionId)
CARLA_SAFE_ASSERT_RETURN(false, false);
}

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connection.id, connection.portOut, connection.portIn, 0.0f, nullptr);
callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, connection.id, 0, 0, 0.0f, nullptr);

rack->usedConnections.remove(it);
return true;


+ 97
- 24
source/backend/engine/CarlaEngineJack.cpp View File

@@ -958,6 +958,25 @@ public:
return false;
}

if (portA < 0 || portB < 0)
{
// both must be < 0
CARLA_SAFE_ASSERT_RETURN(portA < 0 && portB < 0, false);

#if 0
ConnectionToId connectionToId;
connectionToId.setData(fLastConnectionId++, portIdA.groupId, portIdA.portId, portIdB.groupId, portIdB.portId);
fUsedConnections.append(connectionToId);

char strBuf[STR_MAX+1];
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", portIdA.groupId, portIdA.portId, portIdB.groupId, portIdB.portId);

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf);
#endif

return true;
}

char portNameA[STR_MAX+1];
char portNameB[STR_MAX+1];
getFullPortName(portA, portNameA);
@@ -1481,19 +1500,22 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fullPortNameA != nullptr,);
CARLA_SAFE_ASSERT_RETURN(fullPortNameB != nullptr,);

const int portIdA(getPortId(fullPortNameA));
const int portIdB(getPortId(fullPortNameB));
const PortNameToId& portIdA(getPortNameToId(fullPortNameA));
const PortNameToId& portIdB(getPortNameToId(fullPortNameB));

if (portIdA == -1 || portIdB == -1)
if (portIdA.portId == -1 || portIdB.portId == -1)
return;

if (connect)
{
ConnectionToId connectionToId;
connectionToId.setData(fLastConnectionId++, portIdA, portIdB);
connectionToId.setData(fLastConnectionId++, portIdA.groupId, portIdA.portId, portIdB.groupId, portIdB.portId);
fUsedConnections.append(connectionToId);

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr);
char strBuf[STR_MAX+1];
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", portIdA.groupId, portIdA.portId, portIdB.groupId, portIdB.portId);

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf);
}
else
{
@@ -1501,9 +1523,10 @@ protected:
{
const ConnectionToId& connectionToId(it.getValue());

if (connectionToId.portOut == portIdA && connectionToId.portIn == portIdB)
if (connectionToId.groupOut == portIdA.groupId && connectionToId.portOut == portIdA.portId &&
connectionToId.groupIn == portIdB.groupId && connectionToId.portIn == portIdB.portId)
{
callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, static_cast<uint>(connectionToId.id), connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr);
callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED, static_cast<uint>(connectionToId.id), 0, 0, 0.0f, nullptr);
fUsedConnections.remove(it);
break;
}
@@ -1671,9 +1694,7 @@ private:

bool operator==(const PortNameToId& portNameId) noexcept
{
if (portNameId.groupId != groupId)
return false;
if (portNameId.portId != portId)
if (portNameId.groupId != groupId || portNameId.portId != portId)
return false;
if (std::strcmp(portNameId.name, name) != 0)
return false;
@@ -1690,30 +1711,36 @@ private:

struct ConnectionToId {
uint id;
int groupOut;
int portOut;
int groupIn;
int portIn;

void clear() noexcept
{
id = 0;
portOut = -1;
portIn = -1;
id = 0;
groupOut = -1;
portOut = -1;
groupIn = -1;
portIn = -1;
}

void setData(const uint i, const int out, const int in) noexcept
void setData(const uint i, const int gout, const int pout, const int gin, const int pin) noexcept
{
id = i;
portOut = out;
portIn = in;
id = i;
groupOut = gout;
portOut = pout;
groupIn = gin;
portIn = pin;
}

bool operator==(const ConnectionToId& connectionId) const noexcept
{
if (connectionId.id != id)
return false;
if (connectionId.portOut != portOut)
if (connectionId.groupOut != groupOut || connectionId.portOut != portOut)
return false;
if (connectionId.portIn != portIn)
if (connectionId.groupIn != groupIn || connectionId.portIn != portIn)
return false;
return true;
}
@@ -1780,6 +1807,23 @@ private:
return -1;
}

const PortNameToId& getPortNameToId(const char* const fullName)
{
static const PortNameToId fallback = { -1, -1, { '\0' }, { '\0' } };

CARLA_SAFE_ASSERT_RETURN(fullName != nullptr, fallback);

for (LinkedList<PortNameToId>::Itenerator it = fUsedPortNames.begin(); it.valid(); it.next())
{
const PortNameToId& portNameId(it.getValue());

if (std::strcmp(portNameId.fullName, fullName) == 0)
return portNameId;
}

return fallback;
}

void getFullPortName(const int portId, char nameBuf[STR_MAX+1])
{
for (LinkedList<PortNameToId>::Itenerator it = fUsedPortNames.begin(); it.valid(); it.next())
@@ -1904,6 +1948,32 @@ private:
findPluginIdAndIcon(groupName, pluginId, icon);

callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, static_cast<uint>(groupId), icon, pluginId, 0.0f, groupName);

if (pluginId >= 0)
{
CarlaPlugin* const plugin(getPlugin(static_cast<uint32_t>(pluginId)));

if (plugin != nullptr && plugin->isEnabled())
{
unsigned int canvasPortFlags;
char strBuf[STR_MAX+1];

for (uint32_t j=0, count=plugin->getParameterCount(); j < count; ++j)
{
if ((plugin->getParameterData(j).hints & PARAMETER_IS_AUTOMABLE) == 0)
continue;

canvasPortFlags = PATCHBAY_PORT_TYPE_PARAMETER;

if (! plugin->isParameterOutput(j))
canvasPortFlags |= PATCHBAY_PORT_IS_INPUT;

plugin->getParameterName(j, strBuf);

callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, static_cast<uint>(groupId), static_cast<int>(j)-1, static_cast<int>(canvasPortFlags), 0.0f, strBuf);
}
}
}
}

bool portIsInput = (jackPortFlags & JackPortIsInput);
@@ -1947,22 +2017,25 @@ private:
jack_port_t* const jackPort(jackbridge_port_by_name(fClient, ports[i]));
const char* const fullPortName(ports[i]);

const int thisPortId(getPortId(fullPortName));
const PortNameToId& thisPort(getPortNameToId(fullPortName));

CARLA_SAFE_ASSERT_CONTINUE(jackPort != nullptr);
CARLA_SAFE_ASSERT_CONTINUE(thisPortId != -1);
CARLA_SAFE_ASSERT_CONTINUE(thisPort.portId != -1);

if (const char** connections = jackbridge_port_get_all_connections(fClient, jackPort))
{
for (int j=0; connections[j] != nullptr; ++j)
{
const int targetPortId(getPortId(connections[j]));
const PortNameToId& targetPort(getPortNameToId(connections[j]));

ConnectionToId connectionToId;
connectionToId.setData(fLastConnectionId++, thisPortId, targetPortId);
connectionToId.setData(fLastConnectionId++, thisPort.groupId, thisPort.portId, targetPort.groupId, targetPort.portId);
fUsedConnections.append(connectionToId);

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr);
char strBuf[STR_MAX+1];
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", thisPort.groupId, thisPort.portId, targetPort.groupId, targetPort.portId);

callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf);
}

jackbridge_free(connections);


+ 0
- 1
source/backend/standalone/CarlaStandalone.cpp View File

@@ -1754,7 +1754,6 @@ float carla_get_default_parameter_value(uint pluginId, uint32_t parameterId)
float carla_get_current_parameter_value(uint pluginId, uint32_t parameterId)
{
CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr, 0.0f);
carla_debug("carla_get_current_parameter_value(%i, %i)", pluginId, parameterId);

if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId))
{


+ 1
- 4
source/carla_backend.py View File

@@ -650,14 +650,11 @@ ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED = 25

# A patchbay connection has been added.
# @param pluginId Connection Id
# @param value1 Output port Id
# @param value2 Input port Id
# @param valueStr Out group, port plus in group and port, in "og:op:ig:ip" syntax.
ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED = 26

# A patchbay connection has been removed.
# @param pluginId Connection Id
# @param value1 Output port Id
# @param value2 Input port Id
ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED = 27

# Engine started.


+ 3
- 2
source/carla_host.py View File

@@ -149,7 +149,7 @@ class HostWindow(QMainWindow):
PatchbayPortAddedCallback = pyqtSignal(int, int, int, str)
PatchbayPortRemovedCallback = pyqtSignal(int, int)
PatchbayPortRenamedCallback = pyqtSignal(int, int, str)
PatchbayConnectionAddedCallback = pyqtSignal(int, int, int)
PatchbayConnectionAddedCallback = pyqtSignal(int, int, int, int, int)
PatchbayConnectionRemovedCallback = pyqtSignal(int, int, int)
EngineStartedCallback = pyqtSignal(int, int, str)
EngineStoppedCallback = pyqtSignal()
@@ -1278,7 +1278,8 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
elif action == ENGINE_CALLBACK_PATCHBAY_PORT_RENAMED:
gCarla.gui.PatchbayPortRenamedCallback.emit(pluginId, value1, valueStr)
elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED:
gCarla.gui.PatchbayConnectionAddedCallback.emit(pluginId, value1, value2)
gOut, pOut, gIn, pIn = [int(i) for i in valueStr.split(":")]
gCarla.gui.PatchbayConnectionAddedCallback.emit(pluginId, gOut, pOut, gIn, pIn)
elif action == ENGINE_CALLBACK_PATCHBAY_CONNECTION_REMOVED:
gCarla.gui.PatchbayConnectionRemovedCallback.emit(pluginId, value1, value2)
elif action == ENGINE_CALLBACK_ENGINE_STARTED:


+ 5
- 5
source/carla_patchbay.py View File

@@ -879,17 +879,17 @@ class CarlaPatchbayW(QFrame):
@pyqtSlot(int, int)
def slot_handlePatchbayPortRemovedCallback(self, groupId, portId):
#if not self.fEngineStarted: return
patchcanvas.removePort(portId)
patchcanvas.removePort(groupId, portId)
QTimer.singleShot(0, self.fMiniCanvasPreview.update)

@pyqtSlot(int, int, str)
def slot_handlePatchbayPortRenamedCallback(self, groupId, portId, newPortName):
patchcanvas.renamePort(portId, newPortName)
patchcanvas.renamePort(groupId, portId, newPortName)
QTimer.singleShot(0, self.fMiniCanvasPreview.update)

@pyqtSlot(int, int, int)
def slot_handlePatchbayConnectionAddedCallback(self, connectionId, portOutId, portInId):
patchcanvas.connectPorts(connectionId, portOutId, portInId)
@pyqtSlot(int, int, int, int, int)
def slot_handlePatchbayConnectionAddedCallback(self, connectionId, groupOutId, portOutId, groupInId, portInId):
patchcanvas.connectPorts(connectionId, groupOutId, portOutId, groupInId, portInId)
QTimer.singleShot(0, self.fMiniCanvasPreview.update)

@pyqtSlot(int, int, int)


+ 3
- 3
source/includes/lv2/atom-util.h View File

@@ -80,10 +80,10 @@ lv2_atom_sequence_begin(const LV2_Atom_Sequence_Body* body)
}

/** Get an iterator pointing to the end of a Sequence body. */
static inline const LV2_Atom_Event*
lv2_atom_sequence_end(const LV2_Atom_Sequence_Body* body, uint32_t size)
static inline LV2_Atom_Event*
lv2_atom_sequence_end(LV2_Atom_Sequence_Body* body, uint32_t size)
{
return (const LV2_Atom_Event*)((const uint8_t*)body + lv2_atom_pad_size(size));
return (LV2_Atom_Event*)((uint8_t*)body + lv2_atom_pad_size(size));
}

/** Return true iff @p i has reached the end of @p body. */


+ 121
- 98
source/patchcanvas.py View File

@@ -157,7 +157,9 @@ class port_dict_t(object):
class connection_dict_t(object):
__slots__ = [
'connection_id',
'group_in_id',
'port_in_id',
'group_out_id',
'port_out_id',
'widget'
]
@@ -377,7 +379,7 @@ def clear():
group_list_ids.append(group.group_id)

for port in canvas.port_list:
port_list_ids.append(port.port_id)
port_list_ids.append((port.group_id, port.port_id))

for connection in canvas.connection_list:
connection_list_ids.append(connection.connection_id)
@@ -385,8 +387,8 @@ def clear():
for idx in connection_list_ids:
disconnectPorts(idx)

for idx in port_list_ids:
removePort(idx)
for group_id, port_id in port_list_ids:
removePort(group_id, port_id)

for idx in group_list_ids:
removeGroup(idx)
@@ -596,7 +598,9 @@ def splitGroup(group_id):
if connection.port_out_id in port_list_ids or connection.port_in_id in port_list_ids:
connection_dict = connection_dict_t()
connection_dict.connection_id = connection.connection_id
connection_dict.group_in_id = connection.group_in_id
connection_dict.port_in_id = connection.port_in_id
connection_dict.group_out_id = connection.group_out_id
connection_dict.port_out_id = connection.port_out_id
connection_dict.widget = None
conns_data.append(connection_dict)
@@ -606,7 +610,7 @@ def splitGroup(group_id):
disconnectPorts(conn.connection_id)

for port_id in port_list_ids:
removePort(port_id)
removePort(group_id, port_id)

removeGroup(group_id)

@@ -617,7 +621,7 @@ def splitGroup(group_id):
addPort(group_id, port.port_id, port.port_name, port.port_mode, port.port_type, port.is_alternate)

for conn in conns_data:
connectPorts(conn.connection_id, conn.port_out_id, conn.port_in_id)
connectPorts(conn.connection_id, conn.group_out_id, conn.port_out_id, conn.group_in_id, conn.port_in_id)

QTimer.singleShot(0, canvas.scene.update)

@@ -673,7 +677,9 @@ def joinGroup(group_id):
if connection.port_out_id in port_list_ids or connection.port_in_id in port_list_ids:
connection_dict = connection_dict_t()
connection_dict.connection_id = connection.connection_id
connection_dict.group_in_id = connection.group_in_id
connection_dict.port_in_id = connection.port_in_id
connection_dict.group_out_id = connection.group_out_id
connection_dict.port_out_id = connection.port_out_id
connection_dict.widget = None
conns_data.append(connection_dict)
@@ -683,7 +689,7 @@ def joinGroup(group_id):
disconnectPorts(conn.connection_id)

for port_id in port_list_ids:
removePort(port_id)
removePort(group_id, port_id)

removeGroup(group_id)

@@ -694,7 +700,7 @@ def joinGroup(group_id):
addPort(group_id, port.port_id, port.port_name, port.port_mode, port.port_type, port.is_alternate)

for conn in conns_data:
connectPorts(conn.connection_id, conn.port_out_id, conn.port_in_id)
connectPorts(conn.connection_id, conn.group_out_id, conn.port_out_id, conn.group_in_id, conn.port_in_id)

QTimer.singleShot(0, canvas.scene.update)

@@ -810,12 +816,12 @@ def addPort(group_id, port_id, port_name, port_mode, port_type, is_alternate=Fal

QTimer.singleShot(0, canvas.scene.update)

def removePort(port_id):
def removePort(group_id, port_id):
if canvas.debug:
qDebug("PatchCanvas::removePort(%i)" % port_id)
qDebug("PatchCanvas::removePort(%i, %i)" % (group_id, port_id))

for port in canvas.port_list:
if port.port_id == port_id:
if port.group_id == group_id and port.port_id == port_id:
item = port.widget
item.parentItem().removePortFromGroup(port_id)
canvas.scene.removeItem(item)
@@ -826,14 +832,14 @@ def removePort(port_id):
QTimer.singleShot(0, canvas.scene.update)
return

qCritical("PatchCanvas::removePort(%i) - Unable to find port to remove" % port_id)
qCritical("PatchCanvas::removePort(%i, %i) - Unable to find port to remove" % (group_id, port_id))

def renamePort(port_id, new_port_name):
def renamePort(group_id, port_id, new_port_name):
if canvas.debug:
qDebug("PatchCanvas::renamePort(%i, %s)" % (port_id, new_port_name.encode()))
qDebug("PatchCanvas::renamePort(%i, %i, %s)" % (group_id, port_id, new_port_name.encode()))

for port in canvas.port_list:
if port.port_id == port_id:
if port.group_id == group_id and port.port_id == port_id:
port.port_name = new_port_name
port.widget.setPortName(new_port_name)
port.widget.parentItem().updatePositions()
@@ -841,11 +847,11 @@ def renamePort(port_id, new_port_name):
QTimer.singleShot(0, canvas.scene.update)
return

qCritical("PatchCanvas::renamePort(%i, %s) - Unable to find port to rename" % (port_id, new_port_name.encode()))
qCritical("PatchCanvas::renamePort(%i, %i, %s) - Unable to find port to rename" % (group_id, port_id, new_port_name.encode()))

def connectPorts(connection_id, port_out_id, port_in_id):
def connectPorts(connection_id, group_out_id, port_out_id, group_in_id, port_in_id):
if canvas.debug:
qDebug("PatchCanvas::connectPorts(%i, %i, %i)" % (connection_id, port_out_id, port_in_id))
qDebug("PatchCanvas::connectPorts(%i, %i, %i, %i, %i)" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id))

port_out = None
port_in = None
@@ -853,22 +859,24 @@ def connectPorts(connection_id, port_out_id, port_in_id):
port_in_parent = None

for port in canvas.port_list:
if port.port_id == port_out_id:
if port.group_id == group_out_id and port.port_id == port_out_id:
port_out = port.widget
port_out_parent = port_out.parentItem()
elif port.port_id == port_in_id:
elif port.group_id == group_in_id and port.port_id == port_in_id:
port_in = port.widget
port_in_parent = port_in.parentItem()

# FIXME
if not (port_out and port_in):
qCritical("PatchCanvas::connectPorts(%i, %i, %i) - unable to find ports to connect" % (connection_id, port_out_id, port_in_id))
qCritical("PatchCanvas::connectPorts(%i, %i, %i, %i, %i) - unable to find ports to connect" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id))
return

connection_dict = connection_dict_t()
connection_dict.connection_id = connection_id
connection_dict.port_out_id = port_out_id
connection_dict.group_in_id = group_in_id
connection_dict.port_in_id = port_in_id
connection_dict.group_out_id = group_out_id
connection_dict.port_out_id = port_out_id

if options.use_bezier_lines:
connection_dict.widget = CanvasBezierLine(port_out, port_in, None)
@@ -1021,24 +1029,24 @@ def CanvasGetNewGroupPos(horizontal=False):

return new_pos

def CanvasGetFullPortName(port_id):
def CanvasGetFullPortName(group_id, port_id):
if canvas.debug:
qDebug("PatchCanvas::CanvasGetFullPortName(%i)" % port_id)
qDebug("PatchCanvas::CanvasGetFullPortName(%i, %i)" % (group_id, port_id))

for port in canvas.port_list:
if port.port_id == port_id:
if port.group_id == group_id and port.port_id == port_id:
group_id = port.group_id
for group in canvas.group_list:
if group.group_id == group_id:
return group.group_name + ":" + port.port_name
break

qCritical("PatchCanvas::CanvasGetFullPortName(%i) - unable to find port" % port_id)
qCritical("PatchCanvas::CanvasGetFullPortName(%i, %i) - unable to find port" % (group_id, port_id))
return ""

def CanvasGetPortConnectionList(port_id):
def CanvasGetPortConnectionList(group_id, port_id):
if canvas.debug:
qDebug("PatchCanvas::CanvasGetPortConnectionList(%i)" % port_id)
qDebug("PatchCanvas::CanvasGetPortConnectionList(%i, %i)" % (group_id, port_id))

port_con_list = []

@@ -1734,11 +1742,12 @@ class CanvasBezierLineMov(QGraphicsPathItem):
# canvasport.cpp

class CanvasPort(QGraphicsItem):
def __init__(self, port_id, port_name, port_mode, port_type, is_alternate, parent):
def __init__(self, group_id, port_id, port_name, port_mode, port_type, is_alternate, parent):
QGraphicsItem.__init__(self, parent)

# Save Variables, useful for later
self.m_port_id = port_id
self.m_group_id = group_id
self.m_port_id = port_id
self.m_port_mode = port_mode
self.m_port_type = port_type
self.m_port_name = port_name
@@ -1903,12 +1912,12 @@ class CanvasPort(QGraphicsItem):
menu = QMenu()
discMenu = QMenu("Disconnect", menu)

port_con_list = CanvasGetPortConnectionList(self.m_port_id)
port_con_list = CanvasGetPortConnectionList(self.m_group_id, self.m_port_id)

if len(port_con_list) > 0:
for port_id in port_con_list:
port_con_id = CanvasGetConnectedPort(port_id, self.m_port_id)
act_x_disc = discMenu.addAction(CanvasGetFullPortName(port_con_id))
act_x_disc = discMenu.addAction(CanvasGetFullPortName(self.m_group_id, port_con_id))
act_x_disc.setData(port_id)
act_x_disc.triggered.connect(canvas.qobject.PortContextMenuDisconnect)
else:
@@ -2187,11 +2196,11 @@ class CanvasBox(QGraphicsItem):
CanvasItemFX(self, True)
self.setVisible(True)

new_widget = CanvasPort(port_id, port_name, port_mode, port_type, is_alternate, self)
new_widget = CanvasPort(self.m_group_id, port_id, port_name, port_mode, port_type, is_alternate, self)

port_dict = port_dict_t()
port_dict.group_id = self.m_group_id
port_dict.port_id = port_id
port_dict.port_id = port_id
port_dict.port_name = port_name
port_dict.port_mode = port_mode
port_dict.port_type = port_type
@@ -2254,8 +2263,8 @@ class CanvasBox(QGraphicsItem):
def updatePositions(self):
self.prepareGeometryChange()

max_in_width = 0
max_in_height = canvas.theme.box_header_height + canvas.theme.box_header_spacing
max_in_width = 0
max_in_height = canvas.theme.box_header_height + canvas.theme.box_header_spacing
max_out_width = 0
max_out_height = canvas.theme.box_header_height + canvas.theme.box_header_spacing
port_spacing = canvas.theme.port_height + canvas.theme.port_spacing
@@ -2275,7 +2284,7 @@ class CanvasBox(QGraphicsItem):
# Get Port List
port_list = []
for port in canvas.port_list:
if port.port_id in self.m_port_list_ids:
if port.group_id == self.m_group_id and port.port_id in self.m_port_list_ids:
port_list.append(port)

# Get Max Box Width/Height
@@ -2313,12 +2322,12 @@ class CanvasBox(QGraphicsItem):
elif port.port_type == PORT_TYPE_MIDI_JACK and not have_midi_jack_out:
have_midi_jack_out = True
max_out_height += canvas.theme.port_spacingT
elif port.port_type == PORT_TYPE_PARAMETER and not have_parameter_out:
have_parameter_out = True
max_out_height += canvas.theme.port_spacingT
elif port.port_type == PORT_TYPE_MIDI_ALSA and not have_midi_alsa_out:
have_midi_alsa_out = True
max_out_height += canvas.theme.port_spacingT
elif port.port_type == PORT_TYPE_PARAMETER and not have_parameter_out:
have_parameter_out = True
max_out_height += canvas.theme.port_spacingT

if canvas.theme.port_spacingT == 0:
max_in_height += 2
@@ -2350,89 +2359,103 @@ class CanvasBox(QGraphicsItem):

# Re-position ports, AUDIO_JACK
for port in port_list:
if port.port_type == PORT_TYPE_AUDIO_JACK:
if port.port_mode == PORT_MODE_INPUT:
port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)
if port.port_type != PORT_TYPE_AUDIO_JACK:
continue

if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT

last_in_pos += port_spacing
last_in_type = port.port_type
port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)

elif port.port_mode == PORT_MODE_OUTPUT:
port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)
last_in_pos += port_spacing
last_in_type = port.port_type

elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT

last_out_pos += port_spacing
last_out_type = port.port_type
port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)

last_out_pos += port_spacing
last_out_type = port.port_type

# Re-position ports, MIDI_JACK
for port in port_list:
if port.port_type == PORT_TYPE_MIDI_JACK:
if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT
if port.port_type != PORT_TYPE_MIDI_JACK:
continue

port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)
if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT

last_in_pos += port_spacing
last_in_type = port.port_type
port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)

elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT
last_in_pos += port_spacing
last_in_type = port.port_type

port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)
elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT

port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)

last_out_pos += port_spacing
last_out_type = port.port_type
last_out_pos += port_spacing
last_out_type = port.port_type

# Re-position ports, MIDI_ALSA
for port in port_list:
if port.port_type == PORT_TYPE_MIDI_ALSA:
if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT
if port.port_type != PORT_TYPE_MIDI_ALSA:
continue

if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT

port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)
port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)

last_in_pos += port_spacing
last_in_type = port.port_type
last_in_pos += port_spacing
last_in_type = port.port_type

elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT
elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT

port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)
port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)

last_out_pos += port_spacing
last_out_type = port.port_type
last_out_pos += port_spacing
last_out_type = port.port_type

# Re-position ports, PARAMETER
for port in port_list:
if port.port_type == PORT_TYPE_PARAMETER:
if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT
if port.port_type != PORT_TYPE_PARAMETER:
continue

port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)
if port.port_mode == PORT_MODE_INPUT:
if last_in_type != PORT_TYPE_NULL and port.port_type != last_in_type:
last_in_pos += canvas.theme.port_spacingT

last_in_pos += port_spacing
last_in_type = port.port_type
port.widget.setPos(QPointF(1 + canvas.theme.port_offset, last_in_pos))
port.widget.setPortWidth(max_in_width)

elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT
last_in_pos += port_spacing
last_in_type = port.port_type

elif port.port_mode == PORT_MODE_OUTPUT:
if last_out_type != PORT_TYPE_NULL and port.port_type != last_out_type:
last_out_pos += canvas.theme.port_spacingT

port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)
port.widget.setPos(QPointF(self.p_width - max_out_width - canvas.theme.port_offset - 13, last_out_pos))
port.widget.setPortWidth(max_out_width)

last_out_pos += port_spacing
last_out_type = port.port_type
last_out_pos += port_spacing
last_out_type = port.port_type

self.repaintLines(True)
self.update()
@@ -2464,7 +2487,7 @@ class CanvasBox(QGraphicsItem):
port_con_list_ids = []

for port_id in self.m_port_list_ids:
tmp_port_con_list = CanvasGetPortConnectionList(port_id)
tmp_port_con_list = CanvasGetPortConnectionList(self.m_group_id, port_id)
for port_con_id in tmp_port_con_list:
if port_con_id not in port_con_list:
port_con_list.append(port_con_id)
@@ -2473,7 +2496,7 @@ class CanvasBox(QGraphicsItem):
if len(port_con_list) > 0:
for i in range(len(port_con_list)):
port_con_id = CanvasGetConnectedPort(port_con_list[i], port_con_list_ids[i])
act_x_disc = discMenu.addAction(CanvasGetFullPortName(port_con_id))
act_x_disc = discMenu.addAction(CanvasGetFullPortName(self.m_group_id, port_con_id))
act_x_disc.setData(port_con_list[i])
act_x_disc.triggered.connect(canvas.qobject.PortContextMenuDisconnect)
else:
@@ -2515,7 +2538,7 @@ class CanvasBox(QGraphicsItem):

haveIns = haveOuts = False
for port in canvas.port_list:
if port.port_id in self.m_port_list_ids:
if port.group_id == self.m_group_id and port.port_id in self.m_port_list_ids:
if port.port_mode == PORT_MODE_INPUT:
haveIns = True
elif port.port_mode == PORT_MODE_OUTPUT:


Loading…
Cancel
Save