Browse Source

Initial code for custom canvas icons

tags/1.9.4
falkTX 11 years ago
parent
commit
6fb99f14ba
9 changed files with 152 additions and 15 deletions
  1. +3
    -0
      resources/resources.qrc
  2. +18
    -0
      resources/scalable/pb_configure.svg
  3. +18
    -0
      resources/scalable/pb_file.svg
  4. +18
    -0
      resources/scalable/pb_plugin.svg
  5. +12
    -0
      source/backend/CarlaBackend.hpp
  6. +38
    -8
      source/backend/engine/CarlaEngineJack.cpp
  7. +18
    -5
      source/carla.py
  8. +7
    -0
      source/carla_backend.py
  9. +20
    -2
      source/patchcanvas.py

+ 3
- 0
resources/resources.qrc View File

@@ -85,6 +85,9 @@

<file>scalable/pb_generic.svg</file>
<file>scalable/pb_hardware.svg</file>
<file>scalable/pb_plugin.svg</file>
<file>scalable/pb_file.svg</file>
<file>scalable/pb_configure.svg</file>
<file>scalable/pb_audacious.svg</file>
<file>scalable/pb_clementine.svg</file>
<file>scalable/pb_distrho.svg</file>


+ 18
- 0
resources/scalable/pb_configure.svg View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="4.7412mm" height="4.7625mm" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 0.0991055 0.0995508"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css">
<![CDATA[
.fil0 {fill:gray}
]]>
</style>
</defs>
<g id="Layer_x0020_1">
<metadata id="CorelCorpID_0Corel-Layer"/>
<path class="fil0" d="M0.0977447 0.0757067c-0.0106585,-0.00798914 -0.02486,-0.0189361 -0.0399833,-0.0321008 -0.00695026,-0.00743939 0.00104515,-0.0133361 -0.00182484,-0.0262626 -0.00100126,-0.00450252 -0.00442936,-0.00907819 -0.00780729,-0.0109177 -0.00443145,-0.00242057 -0.0182254,-0.00644441 -0.0245381,-0.00642351 -0.00101798,0.000865386 -0.00278429,0.00283236 -0.00424541,0.0044837 0.000804767,0.00100753 0.0138462,0.00998121 0.0149708,0.0108591 0.00342392,0.00266305 0.00458404,0.00266514 0.00325042,0.00841557 -0.00150293,0.00647785 -0.00513379,0.0116514 -0.0107902,0.0150962 -0.00781356,0.00475335 -0.00604307,0.00373119 -0.0168562,-0.00415762l-0.00683321 -0.00486623c-0.000792226,0.00173077 -0.00188545,0.00346154 -0.00308738,0.00628137 0.00317517,0.005347 0.0142496,0.0206522 0.0191744,0.0224122 0.00926423,0.00331522 0.0178219,-0.00363086 0.0228909,0.00143813 0.0106292,0.0103909 0.0192705,0.0178031 0.0350962,0.0379829 0.00676841,0.00814174 0.0273934,-0.0171363 0.0205832,-0.0222408z"/>
</g>
</svg>

+ 18
- 0
resources/scalable/pb_file.svg View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="3.6601mm" height="4.4602mm" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 0.0724159 0.0882461"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css">
<![CDATA[
.fil0 {fill:gray}
]]>
</style>
</defs>
<g id="Layer_x0020_1">
<metadata id="CorelCorpID_0Corel-Layer"/>
<polygon class="fil0" points="-0,0 0.0496332,0 0.0724159,0.0218013 0.0724159,0.0882461 -0,0.0882461 "/>
</g>
</svg>

+ 18
- 0
resources/scalable/pb_plugin.svg View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Creator: CorelDRAW -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="4.585mm" height="4.4467mm" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 0.26727 0.259208"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css">
<![CDATA[
.fil0 {fill:gray}
]]>
</style>
</defs>
<g id="Layer_x0020_1">
<metadata id="CorelCorpID_0Corel-Layer"/>
<path class="fil0" d="M0.26727 0.111367l-0.0358964 -0.0096532 -0.0102011 -0.0227223c0.00591083,-0.00853398 0.0156923,-0.023212 0.0193589,-0.0299039l-0.0265521 -0.0250365c-0.0103294,0.00638883 -0.0220869,0.0143457 -0.0334772,0.0218713 -0.00839408,-0.00483826 -0.0130691,-0.00723407 -0.019866,-0.0116759 -0.00298456,-0.0130108 -0.00383563,-0.0171263 -0.00787528,-0.0342059 -0.0127485,-5.2463e-005 -0.0255029,-5.2463e-005 -0.0382514,0 -0.00404548,0.0170796 -0.00489655,0.0211951 -0.00788111,0.0342059 -0.00679105,0.00444187 -0.0114719,0.00683768 -0.0198602,0.0116759 -0.0113961,-0.00752553 -0.0231537,-0.0154824 -0.0334772,-0.0218713l-0.0265521 0.0250365c0.00366658,0.00669195 0.0134422,0.0213699 0.0193589,0.0299039l-0.010207 0.0227223 -0.0358905 0.0096532 0 0.0364735 0.0358905 0.0096532 0.010207 0.0227223c-0.00591666,0.00853398 -0.0156923,0.023212 -0.0193589,0.0299039l0.0265521 0.0250365c0.0103236,-0.00638883 0.0220811,-0.0143399 0.0334772,-0.0218713 0.00838825,0.00483826 0.0130691,0.00723407 0.0198602,0.0116759 0.00298456,0.0130108 0.00383563,0.0171263 0.00788111,0.0342059 0.0127485,5.2463e-005 0.0255029,5.2463e-005 0.0382514,0 0.00403965,-0.0170796 0.00489072,-0.0211951 0.00787528,-0.0342059 0.00679688,-0.00444187 0.0114719,-0.00683768 0.019866,-0.0116759 0.0113903,0.00753136 0.0231479,0.0154824 0.0334772,0.0218713l0.0265521 -0.0250365c-0.00366658,-0.00669195 -0.013448,-0.0213699 -0.0193589,-0.0299039l0.0102011 -0.0227223 0.0358964 -0.0096532 0 -0.0364735zm-0.133635 -0.0312505c0.0273332,0 0.0494843,0.0221511 0.0494843,0.0494843 0,0.0273332 -0.0221511,0.0494843 -0.0494843,0.0494843 -0.0273332,0 -0.0494843,-0.0221511 -0.0494843,-0.0494843 0,-0.0273332 0.0221511,-0.0494843 0.0494843,-0.0494843z"/>
</g>
</svg>

+ 12
- 0
source/backend/CarlaBackend.hpp View File

@@ -203,6 +203,17 @@ enum InternalParametersIndex {
PARAMETER_MAX = -9 //!< Max value, defined for convenience
};

/*!
* The icon of a patchbay client/group.
*/
enum PatchbayIconType {
PATCHBAY_ICON_APPLICATION = 0, //!< Generic application icon.
PATCHBAY_ICON_HARDWARE = 1, //!< Hardware icon.
PATCHBAY_ICON_PLUGIN = 2, //!< Plugin icon.
PATCHBAY_ICON_DISTRHO = 3, //!< DISTRHO icon.
PATCHBAY_ICON_FILE = 4 //!< File icon.
};

/*!
* Options used in the CarlaEngine::setOption() and set_option() calls.\n
* All options except paths must be set before initiliazing or after closing the engine.
@@ -530,6 +541,7 @@ enum CallbackType {
* Canvas client added
*
* \param value1 Client Id
* \param value2 Client Icon
* \param valueStr Client name
*/
CALLBACK_PATCHBAY_CLIENT_ADDED = 18,


+ 38
- 8
source/backend/engine/CarlaEngineJack.cpp View File

@@ -526,7 +526,7 @@ public:
fOptions.processMode = PROCESS_MODE_MULTIPLE_CLIENTS;
#else
# ifndef CARLA_PROPER_CPP11_SUPPORT
carla_zeroStruct<jack_port_t*>(fRackPorts, rackPortCount);
carla_fill<jack_port_t*>(fRackPorts, rackPortCount, nullptr);
# endif
#endif

@@ -545,6 +545,7 @@ public:
fUsedGroupNames.clear();
fUsedPortNames.clear();
fUsedConnections.clear();
fPluginClientNames.clear();
#endif
}

@@ -587,6 +588,7 @@ public:
fUsedGroupNames.clear();
fUsedPortNames.clear();
fUsedConnections.clear();
fPluginClientNames.clear();

fClient = jackbridge_client_open(clientName, JackNullOption, nullptr);

@@ -693,6 +695,7 @@ public:
fUsedGroupNames.clear();
fUsedPortNames.clear();
fUsedConnections.clear();
fPluginClientNames.clear();
#endif
return false;
}
@@ -746,6 +749,12 @@ public:
# if 0
jackbridge_set_latency_callback(client, carla_jack_latency_callback_plugin, plugin);
# endif
CARLA_ASSERT(client != nullptr);

if (client == nullptr)
return nullptr;

fPluginClientNames.append(QString(jackbridge_get_client_name(client)));
}
#endif

@@ -851,8 +860,8 @@ public:
return false;
}

const char* const portNameA = getFullPortName(portA).toUtf8().constData();
const char* const portNameB = getFullPortName(portB).toUtf8().constData();
const char* const portNameA(getFullPortName(portA).toUtf8().constData());
const char* const portNameB(getFullPortName(portB).toUtf8().constData());

if (! jackbridge_connect(fClient, portNameA, portNameB))
{
@@ -877,8 +886,8 @@ public:
{
if (fUsedConnections[i].id == connectionId)
{
const char* const portNameA = getFullPortName(fUsedConnections[i].portOut).toUtf8().constData();
const char* const portNameB = getFullPortName(fUsedConnections[i].portIn).toUtf8().constData();
const char* const portNameA(getFullPortName(fUsedConnections[i].portOut).toUtf8().constData());
const char* const portNameB(getFullPortName(fUsedConnections[i].portIn).toUtf8().constData());

if (! jackbridge_disconnect(fClient, portNameA, portNameB))
{
@@ -1274,7 +1283,15 @@ protected:
groupNameToId.id = fLastGroupId;
groupNameToId.name = name;

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, fLastGroupId, 0, 0.0f, name);
PatchbayIconType groupIcon = PATCHBAY_ICON_APPLICATION;

if (fPluginClientNames.contains(QString(name)))
{
// TODO - identify distrho or file icon
groupIcon = PATCHBAY_ICON_PLUGIN;
}

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, groupIcon, fLastGroupId, 0, 0.0f, name);
fUsedGroupNames.append(groupNameToId);
fLastGroupId++;
}
@@ -1455,6 +1472,8 @@ private:
QList<PortNameToId> fUsedPortNames;
QList<ConnectionToId> fUsedConnections;

QStringList fPluginClientNames;

int getGroupId(QString groupName)
{
for (int i=0, count=fUsedGroupNames.count(); i < count; ++i)
@@ -1528,6 +1547,7 @@ private:
QString fullName(ports[i]);
QString groupName(fullName.split(":").at(0));
int groupId = -1;
int jackPortFlags = jackbridge_port_flags(jackPort);

//if (groupName == ourName)
// continue;
@@ -1547,10 +1567,20 @@ private:
fUsedGroupNames.append(groupNameToId);
parsedGroups.append(groupName);

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, groupId, 0, 0.0f, groupName.toUtf8().constData());
PatchbayIconType groupIcon = PATCHBAY_ICON_APPLICATION;

if (fPluginClientNames.contains(groupName))
{
// TODO - identify distrho or file icon
groupIcon = PATCHBAY_ICON_PLUGIN;
}
else if (jackPortFlags & JackPortIsPhysical)
groupIcon = PATCHBAY_ICON_HARDWARE;

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, groupId, groupIcon, 0.0f, groupName.toUtf8().constData());
}

bool portIsInput = (jackbridge_port_flags(jackPort) & JackPortIsInput);
bool portIsInput = (jackPortFlags & JackPortIsInput);
bool portIsAudio = (std::strcmp(jackbridge_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0);

unsigned int portFlags = 0x0;


+ 18
- 5
source/carla.py View File

@@ -875,7 +875,7 @@ class CarlaMainW(QMainWindow):
self.connect(self, SIGNAL("ReloadParametersCallback(int)"), SLOT("slot_handleReloadParametersCallback(int)"))
self.connect(self, SIGNAL("ReloadProgramsCallback(int)"), SLOT("slot_handleReloadProgramsCallback(int)"))
self.connect(self, SIGNAL("ReloadAllCallback(int)"), SLOT("slot_handleReloadAllCallback(int)"))
self.connect(self, SIGNAL("PatchbayClientAddedCallback(int, QString)"), SLOT("slot_handlePatchbayClientAddedCallback(int, QString)"))
self.connect(self, SIGNAL("PatchbayClientAddedCallback(int, int, QString)"), SLOT("slot_handlePatchbayClientAddedCallback(int, int, QString)"))
self.connect(self, SIGNAL("PatchbayClientRemovedCallback(int)"), SLOT("slot_handlePatchbayClientRemovedCallback(int)"))
self.connect(self, SIGNAL("PatchbayClientRenamedCallback(int, QString)"), SLOT("slot_handlePatchbayClientRenamedCallback(int, QString)"))
self.connect(self, SIGNAL("PatchbayPortAddedCallback(int, int, int, QString)"), SLOT("slot_handlePatchbayPortAddedCallback(int, int, int, QString)"))
@@ -1901,9 +1901,22 @@ class CarlaMainW(QMainWindow):

pwidget.ui.edit_dialog.reloadAll()

@pyqtSlot(int, str)
def slot_handlePatchbayClientAddedCallback(self, clientId, clientName):
patchcanvas.addGroup(clientId, clientName)
@pyqtSlot(int, int, str)
def slot_handlePatchbayClientAddedCallback(self, clientId, clientIcon, clientName):
pcSplit = patchcanvas.SPLIT_UNDEF
pcIcon = patchcanvas.ICON_APPLICATION

if clientIcon == PATCHBAY_ICON_HARDWARE:
pcSplit = patchcanvas.SPLIT_YES
pcIcon = patchcanvas.ICON_HARDWARE
elif clientIcon == PATCHBAY_ICON_PLUGIN:
pcIcon = patchcanvas.ICON_PLUGIN
elif clientIcon == PATCHBAY_ICON_DISTRHO:
pcIcon = patchcanvas.ICON_DISTRHO
elif clientIcon == PATCHBAY_ICON_FILE:
pcIcon = patchcanvas.ICON_FILE

patchcanvas.addGroup(clientId, clientName, pcSplit, pcIcon)
QTimer.singleShot(0, self.ui.miniCanvasPreview, SLOT("update()"))

@pyqtSlot(int)
@@ -2258,7 +2271,7 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
elif action == CALLBACK_RELOAD_ALL:
Carla.gui.emit(SIGNAL("ReloadAllCallback(int)"), pluginId)
elif action == CALLBACK_PATCHBAY_CLIENT_ADDED:
Carla.gui.emit(SIGNAL("PatchbayClientAddedCallback(int, QString)"), value1, cString(valueStr))
Carla.gui.emit(SIGNAL("PatchbayClientAddedCallback(int, int, QString)"), value1, value2, cString(valueStr))
elif action == CALLBACK_PATCHBAY_CLIENT_REMOVED:
Carla.gui.emit(SIGNAL("PatchbayClientRemovedCallback(int)"), value1)
elif action == CALLBACK_PATCHBAY_CLIENT_RENAMED:


+ 7
- 0
source/carla_backend.py View File

@@ -187,6 +187,13 @@ PARAMETER_PANNING = -7
PARAMETER_CTRL_CHANNEL = -8
PARAMETER_MAX = -9

# Patchbay Icon Type
PATCHBAY_ICON_APPLICATION = 0
PATCHBAY_ICON_HARDWARE = 1
PATCHBAY_ICON_PLUGIN = 2
PATCHBAY_ICON_DISTRHO = 3
PATCHBAY_ICON_FILE = 4

# Options Type
OPTION_PROCESS_NAME = 0
OPTION_PROCESS_MODE = 1


+ 20
- 2
source/patchcanvas.py View File

@@ -58,7 +58,10 @@ ACTION_PORTS_DISCONNECT = 7 # conn_id, N, N
# Icon
ICON_HARDWARE = 0
ICON_APPLICATION = 1
ICON_LADISH_ROOM = 2
ICON_PLUGIN = 2
ICON_DISTRHO = 3
ICON_FILE = 4
ICON_LADISH_ROOM = 5

# Split Option
SPLIT_UNDEF = 0
@@ -2518,6 +2521,9 @@ class CanvasIcon(QGraphicsSvgItem):
elif "clementine" in name:
icon_path = ":/scalable/pb_clementine.svg"
self.p_size = QRectF(5, 4, 16, 16)
elif "distrho" in name:
icon_path = ":/scalable/pb_distrho.svg"
self.p_size = QRectF(5, 4, 14, 14)
elif "jamin" in name:
icon_path = ":/scalable/pb_jamin.svg"
self.p_size = QRectF(5, 3, 16, 16)
@@ -2530,12 +2536,24 @@ class CanvasIcon(QGraphicsSvgItem):

else:
icon_path = ":/scalable/pb_generic.svg"
self.p_size = QRectF(5, 3, 16, 16)
self.p_size = QRectF(4, 3, 16, 16)

elif icon == ICON_HARDWARE:
icon_path = ":/scalable/pb_hardware.svg"
self.p_size = QRectF(5, 2, 16, 16)

elif icon == ICON_PLUGIN:
icon_path = ":/scalable/pb_plugin.svg"
self.p_size = QRectF(5, 4, 14, 14)

elif icon == ICON_DISTRHO:
icon_path = ":/scalable/pb_distrho.svg"
self.p_size = QRectF(5, 4, 14, 14)

elif icon == ICON_FILE:
icon_path = ":/scalable/pb_file.svg"
self.p_size = QRectF(5, 4, 12, 14)

elif icon == ICON_LADISH_ROOM:
# TODO - make a unique ladish-room icon
icon_path = ":/scalable/pb_hardware.svg"


Loading…
Cancel
Save