Browse Source

Show CV ports as dark audio in canvas

tags/1.9.4
falkTX 10 years ago
parent
commit
4e7d34423f
3 changed files with 51 additions and 30 deletions
  1. +25
    -20
      source/backend/engine/CarlaEngineJack.cpp
  2. +9
    -2
      source/carla_patchbay.py
  3. +17
    -8
      source/patchcanvas.py

+ 25
- 20
source/backend/engine/CarlaEngineJack.cpp View File

@@ -27,6 +27,7 @@


#include <QtCore/QStringList> #include <QtCore/QStringList>


#define URI_CANVAS_CV "http://kxstudio.sf.net/ns/canvas/cv"
#define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon"


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE
@@ -58,11 +59,10 @@ public:


if (fEngine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fEngine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS) if (fEngine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fEngine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
CARLA_SAFE_ASSERT(client != nullptr && port != nullptr);
#if 0
if (jack_uuid_t uuid = jackbridge_port_uuid(port))
jackbridge_set_property(client, uuid, "urn:jack:IsControlVoltage", "NO", "text/plain");
#endif
CARLA_SAFE_ASSERT_RETURN(client != nullptr && port != nullptr,);

if (const jack_uuid_t uuid = jackbridge_port_uuid(port))
jackbridge_set_property(client, uuid, URI_CANVAS_CV, "NO", "text/plain");
} }
else else
{ {
@@ -76,6 +76,9 @@ public:


if (fClient != nullptr && fPort != nullptr) if (fClient != nullptr && fPort != nullptr)
{ {
if (const jack_uuid_t uuid = jackbridge_port_uuid(fPort))
jackbridge_remove_property(fClient, uuid, URI_CANVAS_CV);

try { try {
jackbridge_port_unregister(fClient, fPort); jackbridge_port_unregister(fClient, fPort);
} catch(...) {} } catch(...) {}
@@ -129,11 +132,10 @@ public:


if (fEngine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fEngine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS) if (fEngine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || fEngine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{ {
CARLA_SAFE_ASSERT(client != nullptr && port != nullptr);
#if 0
if (jack_uuid_t uuid = jackbridge_port_uuid(port))
jackbridge_set_property(client, uuid, "urn:jack:IsControlVoltage", "YES", "text/plain");
#endif
CARLA_SAFE_ASSERT_RETURN(client != nullptr && port != nullptr,);

if (const jack_uuid_t uuid = jackbridge_port_uuid(port))
jackbridge_set_property(client, uuid, URI_CANVAS_CV, "YES", "text/plain");
} }
else else
{ {
@@ -147,6 +149,9 @@ public:


if (fClient != nullptr && fPort != nullptr) if (fClient != nullptr && fPort != nullptr)
{ {
if (const jack_uuid_t uuid = jackbridge_port_uuid(fPort))
jackbridge_remove_property(fClient, uuid, URI_CANVAS_CV);

try { try {
jackbridge_port_unregister(fClient, fPort); jackbridge_port_unregister(fClient, fPort);
} catch(...) {} } catch(...) {}
@@ -1424,13 +1429,13 @@ protected:
bool portIsAudio = (std::strcmp(jackbridge_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0); bool portIsAudio = (std::strcmp(jackbridge_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0);
bool portIsCV = false; bool portIsCV = false;


//if (jack_uuid_t uuid = jackbridge_port_uuid(jackPort))
if (const jack_uuid_t uuid = jackbridge_port_uuid(jackPort))
{ {
//char* value = nullptr;
//char* type = nullptr;
char* value = nullptr;
char* type = nullptr;


//if (jackbridge_get_property(uuid, "urn:jack:IsControlVoltage", &value, &type) && value != nullptr && type != nullptr && std::strcmp(type, "text/plain") == 0)
// portIsCV = (std::strcmp(value, "YES") == 0);
if (jackbridge_get_property(uuid, URI_CANVAS_CV, &value, &type) && value != nullptr && type != nullptr && std::strcmp(type, "text/plain") == 0)
portIsCV = (std::strcmp(value, "YES") == 0);
} }


unsigned int canvasPortFlags = 0x0; unsigned int canvasPortFlags = 0x0;
@@ -1902,13 +1907,13 @@ private:
bool portIsAudio = (std::strcmp(jackbridge_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0); bool portIsAudio = (std::strcmp(jackbridge_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0);
bool portIsCV = false; bool portIsCV = false;


//if (jack_uuid_t uuid = jackbridge_port_uuid(jackPort))
if (const jack_uuid_t uuid = jackbridge_port_uuid(jackPort))
{ {
//char* value = nullptr;
//char* type = nullptr;
char* value = nullptr;
char* type = nullptr;


//if (jackbridge_get_property(uuid, "urn:jack:IsControlVoltage", &value, &type) && value != nullptr && type != nullptr && std::strcmp(type, "text/plain") == 0)
// portIsCV = (std::strcmp(value, "YES") == 0);
if (jackbridge_get_property(uuid, URI_CANVAS_CV, &value, &type) && value != nullptr && type != nullptr && std::strcmp(type, "text/plain") == 0)
portIsCV = (std::strcmp(value, "YES") == 0);
} }


unsigned int canvasPortFlags = 0x0; unsigned int canvasPortFlags = 0x0;


+ 9
- 2
source/carla_patchbay.py View File

@@ -854,6 +854,8 @@ class CarlaPatchbayW(QFrame):


@pyqtSlot(int, int, int, str) @pyqtSlot(int, int, int, str)
def slot_handlePatchbayPortAddedCallback(self, clientId, portId, portFlags, portName): def slot_handlePatchbayPortAddedCallback(self, clientId, portId, portFlags, portName):
isAlternate = False

if (portFlags & PATCHBAY_PORT_IS_INPUT): if (portFlags & PATCHBAY_PORT_IS_INPUT):
portMode = patchcanvas.PORT_MODE_INPUT portMode = patchcanvas.PORT_MODE_INPUT
else: else:
@@ -862,13 +864,18 @@ class CarlaPatchbayW(QFrame):
if (portFlags & PATCHBAY_PORT_TYPE_AUDIO): if (portFlags & PATCHBAY_PORT_TYPE_AUDIO):
portType = patchcanvas.PORT_TYPE_AUDIO_JACK portType = patchcanvas.PORT_TYPE_AUDIO_JACK
elif (portFlags & PATCHBAY_PORT_TYPE_CV): elif (portFlags & PATCHBAY_PORT_TYPE_CV):
portType = patchcanvas.PORT_TYPE_AUDIO_JACK # TODO
portType = patchcanvas.PORT_TYPE_AUDIO_JACK
elif (portFlags & PATCHBAY_PORT_TYPE_MIDI): elif (portFlags & PATCHBAY_PORT_TYPE_MIDI):
portType = patchcanvas.PORT_TYPE_MIDI_JACK portType = patchcanvas.PORT_TYPE_MIDI_JACK
#elif (portFlags & PATCHBAY_PORT_TYPE_PARAMETER):
#portType = patchcanvas.PORT_TYPE_PARAMETER
else: else:
portType = patchcanvas.PORT_TYPE_NULL portType = patchcanvas.PORT_TYPE_NULL


patchcanvas.addPort(clientId, portId, portName, portMode, portType)
if (portFlags & PATCHBAY_PORT_TYPE_CV):
isAlternate = True

patchcanvas.addPort(clientId, portId, portName, portMode, portType, isAlternate)
QTimer.singleShot(0, self.fMiniCanvasPreview.update) QTimer.singleShot(0, self.fMiniCanvasPreview.update)


@pyqtSlot(int, int) @pyqtSlot(int, int)


+ 17
- 8
source/patchcanvas.py View File

@@ -1483,7 +1483,7 @@ class CanvasLine(QGraphicsLineItem):
elif port_type1 == PORT_TYPE_MIDI_ALSA: elif port_type1 == PORT_TYPE_MIDI_ALSA:
port_gradient.setColorAt(pos1, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa) port_gradient.setColorAt(pos1, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa)
elif port_type1 == PORT_TYPE_PARAMETER: elif port_type1 == PORT_TYPE_PARAMETER:
pass # TODO
port_gradient.setColorAt(pos1, canvas.theme.line_parameter_sel if self.m_lineSelected else canvas.theme.line_parameter)


if port_type2 == PORT_TYPE_AUDIO_JACK: if port_type2 == PORT_TYPE_AUDIO_JACK:
port_gradient.setColorAt(pos2, canvas.theme.line_audio_jack_sel if self.m_lineSelected else canvas.theme.line_audio_jack) port_gradient.setColorAt(pos2, canvas.theme.line_audio_jack_sel if self.m_lineSelected else canvas.theme.line_audio_jack)
@@ -1492,7 +1492,7 @@ class CanvasLine(QGraphicsLineItem):
elif port_type2 == PORT_TYPE_MIDI_ALSA: elif port_type2 == PORT_TYPE_MIDI_ALSA:
port_gradient.setColorAt(pos2, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa) port_gradient.setColorAt(pos2, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa)
elif port_type2 == PORT_TYPE_PARAMETER: elif port_type2 == PORT_TYPE_PARAMETER:
pass # TODO
port_gradient.setColorAt(pos2, canvas.theme.line_parameter_sel if self.m_lineSelected else canvas.theme.line_parameter)


self.setPen(QPen(port_gradient, 2)) self.setPen(QPen(port_gradient, 2))


@@ -1590,7 +1590,7 @@ class CanvasBezierLine(QGraphicsPathItem):
elif port_type1 == PORT_TYPE_MIDI_ALSA: elif port_type1 == PORT_TYPE_MIDI_ALSA:
port_gradient.setColorAt(pos1, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa) port_gradient.setColorAt(pos1, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa)
elif port_type1 == PORT_TYPE_PARAMETER: elif port_type1 == PORT_TYPE_PARAMETER:
pass # TODO
port_gradient.setColorAt(pos1, canvas.theme.line_parameter_sel if self.m_lineSelected else canvas.theme.line_parameter)


if port_type2 == PORT_TYPE_AUDIO_JACK: if port_type2 == PORT_TYPE_AUDIO_JACK:
port_gradient.setColorAt(pos2, canvas.theme.line_audio_jack_sel if self.m_lineSelected else canvas.theme.line_audio_jack) port_gradient.setColorAt(pos2, canvas.theme.line_audio_jack_sel if self.m_lineSelected else canvas.theme.line_audio_jack)
@@ -1599,7 +1599,7 @@ class CanvasBezierLine(QGraphicsPathItem):
elif port_type2 == PORT_TYPE_MIDI_ALSA: elif port_type2 == PORT_TYPE_MIDI_ALSA:
port_gradient.setColorAt(pos2, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa) port_gradient.setColorAt(pos2, canvas.theme.line_midi_alsa_sel if self.m_lineSelected else canvas.theme.line_midi_alsa)
elif port_type2 == PORT_TYPE_PARAMETER: elif port_type2 == PORT_TYPE_PARAMETER:
pass # TODO
port_gradient.setColorAt(pos2, canvas.theme.line_parameter_sel if self.m_lineSelected else canvas.theme.line_parameter)


self.setPen(QPen(port_gradient, 2)) self.setPen(QPen(port_gradient, 2))


@@ -1631,7 +1631,7 @@ class CanvasLineMov(QGraphicsLineItem):
elif port_type == PORT_TYPE_MIDI_ALSA: elif port_type == PORT_TYPE_MIDI_ALSA:
pen = QPen(canvas.theme.line_midi_alsa, 2) pen = QPen(canvas.theme.line_midi_alsa, 2)
elif port_type == PORT_TYPE_PARAMETER: elif port_type == PORT_TYPE_PARAMETER:
pass # TODO
pen = QPen(canvas.theme.line_parameter, 2)
else: else:
qWarning("PatchCanvas::CanvasLineMov(%s, %s, %s) - invalid port type" % (port_mode2str(port_mode), port_type2str(port_type), parent)) qWarning("PatchCanvas::CanvasLineMov(%s, %s, %s) - invalid port type" % (port_mode2str(port_mode), port_type2str(port_type), parent))
pen = QPen(Qt.black) pen = QPen(Qt.black)
@@ -1688,7 +1688,7 @@ class CanvasBezierLineMov(QGraphicsPathItem):
elif port_type == PORT_TYPE_MIDI_ALSA: elif port_type == PORT_TYPE_MIDI_ALSA:
pen = QPen(canvas.theme.line_midi_alsa, 2) pen = QPen(canvas.theme.line_midi_alsa, 2)
elif port_type == PORT_TYPE_PARAMETER: elif port_type == PORT_TYPE_PARAMETER:
pass # TODO
pen = QPen(canvas.theme.line_parameter, 2)
else: else:
qWarning("PatchCanvas::CanvasBezierLineMov(%s, %s, %s) - invalid port type" % (port_mode2str(port_mode), port_type2str(port_type), parent)) qWarning("PatchCanvas::CanvasBezierLineMov(%s, %s, %s) - invalid port type" % (port_mode2str(port_mode), port_type2str(port_type), parent))
pen = QPen(Qt.black) pen = QPen(Qt.black)
@@ -2013,11 +2013,20 @@ class CanvasPort(QGraphicsItem):
text_pen = canvas.theme.port_midi_alsa_text_sel if self.isSelected() else canvas.theme.port_midi_alsa_text text_pen = canvas.theme.port_midi_alsa_text_sel if self.isSelected() else canvas.theme.port_midi_alsa_text
conn_pen = canvas.theme.port_midi_alsa_pen_sel conn_pen = canvas.theme.port_midi_alsa_pen_sel
elif self.m_port_type == PORT_TYPE_PARAMETER: elif self.m_port_type == PORT_TYPE_PARAMETER:
pass # TODO
poly_color = canvas.theme.port_parameter_bg_sel if self.isSelected() else canvas.theme.port_parameter_bg
poly_pen = canvas.theme.port_parameter_pen_sel if self.isSelected() else canvas.theme.port_parameter_pen
text_pen = canvas.theme.port_parameter_text_sel if self.isSelected() else canvas.theme.port_parameter_text
conn_pen = canvas.theme.port_parameter_pen_sel
else: else:
qCritical("PatchCanvas::CanvasPort.paint() - invalid port type '%s'" % port_type2str(self.m_port_type)) qCritical("PatchCanvas::CanvasPort.paint() - invalid port type '%s'" % port_type2str(self.m_port_type))
return return


if self.m_is_alternate:
poly_color = poly_color.darker(180)
#poly_pen.setColor(poly_pen.color().darker(110))
#text_pen.setColor(text_pen.color()) #.darker(150))
#conn_pen.setColor(conn_pen.color()) #.darker(150))

polygon = QPolygonF() polygon = QPolygonF()
polygon += QPointF(poly_locx[0], 0) polygon += QPointF(poly_locx[0], 0)
polygon += QPointF(poly_locx[1], 0) polygon += QPointF(poly_locx[1], 0)
@@ -2773,7 +2782,7 @@ class CanvasPortGlow(QGraphicsDropShadowEffect):
elif port_type == PORT_TYPE_MIDI_ALSA: elif port_type == PORT_TYPE_MIDI_ALSA:
self.setColor(canvas.theme.line_midi_alsa_glow) self.setColor(canvas.theme.line_midi_alsa_glow)
elif port_type == PORT_TYPE_PARAMETER: elif port_type == PORT_TYPE_PARAMETER:
pass # TODO
self.setColor(canvas.theme.line_parameter_glow)


# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# canvasboxshadow.cpp # canvasboxshadow.cpp


Loading…
Cancel
Save