@@ -35,138 +35,13 @@ else: | |||
# Imports (Custom Stuff) | |||
from carla_host import * | |||
from carla_patchbay import CarlaPatchbayW | |||
from carla_rack import CarlaRackW | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Tab widget (rack + patchbay) | |||
class CarlaMultiW(QTabWidget): | |||
def __init__(self, parent, host): | |||
QTabWidget.__init__(self, parent) | |||
if False: | |||
# kdevelop likes this :) | |||
host = CarlaHostMeta() | |||
self.host = host | |||
# ------------------------------------------------------------- | |||
self.fRack = CarlaRackW(parent, host, False) | |||
self.fPatchbay = CarlaPatchbayW(parent, host, False, False) | |||
self.fParent = parent | |||
self.fUseCustomPaint = parent.getSavedSettings()[CARLA_KEY_CUSTOM_PAINTING] | |||
self.addTab(self.fRack, "Plugins") | |||
self.addTab(self.fPatchbay, "Patchbay") | |||
#self.fPatchbay.hide() | |||
#self.removeTab(1) | |||
#self.fPatchbay.setParent(None) | |||
#self.fPatchbay.setWindowTitle(parent.windowTitle()) | |||
#self.fPatchbay.show() | |||
#self.scene = self.fPatchbay.scene | |||
parent.ui.act_plugins_enable.triggered.connect(self.fRack.slot_pluginsEnable) | |||
parent.ui.act_plugins_disable.triggered.connect(self.fRack.slot_pluginsDisable) | |||
parent.ui.act_plugins_volume100.triggered.connect(self.fRack.slot_pluginsVolume100) | |||
parent.ui.act_plugins_mute.triggered.connect(self.fRack.slot_pluginsMute) | |||
parent.ui.act_plugins_wet100.triggered.connect(self.fRack.slot_pluginsWet100) | |||
parent.ui.act_plugins_bypass.triggered.connect(self.fRack.slot_pluginsBypass) | |||
parent.ui.act_plugins_center.triggered.connect(self.fRack.slot_pluginsCenter) | |||
parent.ui.act_plugins_panic.triggered.connect(self.fRack.slot_pluginsDisable) | |||
parent.ui.act_canvas_show_internal.triggered.connect(self.fPatchbay.slot_canvasShowInternal) | |||
parent.ui.act_canvas_show_external.triggered.connect(self.fPatchbay.slot_canvasShowExternal) | |||
parent.ui.act_canvas_arrange.triggered.connect(self.fPatchbay.slot_canvasArrange) | |||
parent.ui.act_canvas_refresh.triggered.connect(self.fPatchbay.slot_canvasRefresh) | |||
parent.ui.act_canvas_zoom_fit.triggered.connect(self.fPatchbay.slot_canvasZoomFit) | |||
parent.ui.act_canvas_zoom_in.triggered.connect(self.fPatchbay.slot_canvasZoomIn) | |||
parent.ui.act_canvas_zoom_out.triggered.connect(self.fPatchbay.slot_canvasZoomOut) | |||
parent.ui.act_canvas_zoom_100.triggered.connect(self.fPatchbay.slot_canvasZoomReset) | |||
parent.ui.act_canvas_print.triggered.connect(self.fPatchbay.slot_canvasPrint) | |||
parent.ui.act_canvas_save_image.triggered.connect(self.fPatchbay.slot_canvasSaveImage) | |||
# TODO, later | |||
parent.ui.act_canvas_arrange.setEnabled(False) | |||
parent.ui.act_settings_configure.triggered.connect(self.fPatchbay.slot_configureCarla) | |||
# ----------------------------------------------------------------- | |||
# HostWidgetMeta methods | |||
def removeAllPlugins(self): | |||
self.fRack.removeAllPlugins() | |||
self.fPatchbay.removeAllPlugins() | |||
def engineStarted(self): | |||
self.fRack.engineStarted() | |||
self.fPatchbay.engineStarted() | |||
self.fParent.engineStarted() | |||
def engineStopped(self): | |||
self.fRack.engineStopped() | |||
self.fPatchbay.engineStopped() | |||
self.fParent.engineStopped() | |||
def idleFast(self): | |||
self.fRack.idleFast() | |||
self.fPatchbay.idleFast() | |||
def idleSlow(self): | |||
self.fRack.idleSlow() | |||
self.fPatchbay.idleSlow() | |||
def projectLoadingStarted(self): | |||
self.fRack.projectLoadingStarted() | |||
self.fPatchbay.projectLoadingStarted() | |||
def projectLoadingFinished(self): | |||
self.fRack.projectLoadingFinished() | |||
self.fPatchbay.projectLoadingFinished() | |||
def saveSettings(self, settings): | |||
self.fRack.saveSettings(settings) | |||
self.fPatchbay.saveSettings(settings) | |||
def showEditDialog(self, pluginId): | |||
self.fRack.showEditDialog(pluginId) | |||
# ----------------------------------------------------------------- | |||
# ----------------------------------------------------------------- | |||
def paintEvent(self, event): | |||
QTabWidget.paintEvent(self, event) | |||
if MACOS or not self.fUseCustomPaint: | |||
return | |||
painter = QPainter(self) | |||
painter.setBrush(QColor(36, 36, 36)) | |||
painter.setPen(QColor(62, 62, 62)) | |||
painter.drawRect(1, self.height()/2, self.width()-3, self.height()-self.height()/2-1) | |||
def resizeEvent(self, event): | |||
QTabWidget.resizeEvent(self, event) | |||
if self.currentIndex() == 0: | |||
self.fixCanvasPreviewSize() | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Main Window | |||
class CarlaHostW(HostWindow): | |||
def __init__(self, host): | |||
HostWindow.__init__(self, host) | |||
# ------------------------------------------------------------- | |||
# Set-up container | |||
#self.fContainer = CarlaMultiW(self, host) | |||
#self.setupContainer(False) | |||
#class CarlaHostW(HostWindow): | |||
#def __init__(self, host): | |||
#HostWindow.__init__(self, host) | |||
# ------------------------------------------------------------- | |||
# Set-up GUI stuff | |||
@@ -317,7 +192,7 @@ if __name__ == '__main__': | |||
# ------------------------------------------------------------- | |||
# Create GUI | |||
gui = CarlaHostW(host) | |||
gui = HostWindow(host, True) | |||
# ------------------------------------------------------------- | |||
# Load project file if set | |||
@@ -20,17 +20,6 @@ | |||
# Imports (Custom Stuff) | |||
from carla_host import * | |||
from carla_patchbay import CarlaPatchbayW | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Main Window | |||
class CarlaHostW(HostWindow): | |||
def __init__(self, host): | |||
HostWindow.__init__(self, host) | |||
self.fContainer = CarlaPatchbayW(self, host) | |||
self.setupContainer(True, self.fContainer.themeData) | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Main | |||
@@ -70,7 +59,7 @@ if __name__ == '__main__': | |||
# ------------------------------------------------------------- | |||
# Create GUI | |||
gui = CarlaHostW(host) | |||
gui = HostWindow(host, True) | |||
# ------------------------------------------------------------- | |||
# Load project file if set | |||
@@ -20,17 +20,6 @@ | |||
# Imports (Custom Stuff) | |||
from carla_host import * | |||
from carla_rack import CarlaRackW | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Main Window | |||
class CarlaHostW(HostWindow): | |||
def __init__(self, host): | |||
HostWindow.__init__(self, host) | |||
self.fContainer = CarlaRackW(self, host) | |||
self.setupContainer(False) | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Main | |||
@@ -70,7 +59,7 @@ if __name__ == '__main__': | |||
# ------------------------------------------------------------- | |||
# Create GUI | |||
gui = CarlaHostW(host) | |||
gui = HostWindow(host, False) | |||
# ------------------------------------------------------------- | |||
# Load project file if set | |||
@@ -75,7 +75,7 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
# -------------------------------------------------------------------------------------------------------- | |||
def __init__(self, host, withCanvas=True, parent=None): | |||
def __init__(self, host, withCanvas, parent=None): | |||
QMainWindow.__init__(self, parent) | |||
self.host = host | |||
self.ui = ui_carla_host.Ui_CarlaHostW() | |||
@@ -143,6 +143,8 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
self.fCanvasWidth = 0 | |||
self.fCanvasHeight = 0 | |||
self.fWithCanvas = withCanvas | |||
# ---------------------------------------------------------------------------------------------------- | |||
# Internal stuff (transport, TODO remove) | |||
@@ -181,8 +183,8 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
self.setTransportMenuEnabled(False) | |||
if not withCanvas: | |||
self.ui.act_canvas_show_internal.setEnabled(False) | |||
self.ui.act_canvas_show_external.setEnabled(False) | |||
self.ui.act_canvas_show_internal.setVisible(False) | |||
self.ui.act_canvas_show_external.setVisible(False) | |||
self.ui.act_canvas_arrange.setVisible(False) | |||
self.ui.act_canvas_print.setVisible(False) | |||
self.ui.act_canvas_refresh.setVisible(False) | |||
@@ -193,11 +195,15 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
self.ui.act_canvas_zoom_out.setVisible(False) | |||
self.ui.act_settings_show_meters.setVisible(False) | |||
self.ui.act_settings_show_keyboard.setVisible(False) | |||
self.ui.menu_Canvas.setEnabled(False) | |||
self.ui.menu_Canvas.setVisible(False) | |||
self.ui.menu_Canvas_Zoom.setEnabled(False) | |||
self.ui.menu_Canvas_Zoom.setVisible(False) | |||
self.ui.menu_Canvas_Zoom.menuAction().setVisible(False) | |||
self.ui.menu_Canvas.setEnabled(False) | |||
self.ui.menu_Canvas.setVisible(False) | |||
self.ui.menu_Canvas.menuAction().setVisible(False) | |||
self.ui.miniCanvasPreview.hide() | |||
self.ui.tabWidget.removeTab(1) | |||
self.ui.tabWidget.tabBar().hide() | |||
# ---------------------------------------------------------------------------------------------------- | |||
# Set up GUI (disk) | |||
@@ -653,7 +659,7 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
if pitem is None: | |||
continue | |||
pitem.closeEditDialog() | |||
pitem.close() | |||
del pitem | |||
self.fPluginCount = 0 | |||
@@ -929,10 +935,11 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
if self.host.is_engine_running(): | |||
self.host.patchbay_refresh(self.fExternalPatchbay) | |||
for pedit in self.fPluginList: | |||
if pedit is None: | |||
break | |||
pedit.reloadAll() | |||
for pitem in self.fPluginList: | |||
if pitem is None: | |||
break | |||
pitem.getEditDialog().reloadAll() | |||
QTimer.singleShot(1000 if self.fSavedSettings[CARLA_KEY_CANVAS_EYE_CANDY] else 0, self.ui.miniCanvasPreview.update) | |||
@@ -1791,6 +1798,20 @@ class HostWindow(QMainWindow, PluginEditParentMeta): | |||
QMainWindow.timerEvent(self, event) | |||
# -------------------------------------------------------------------------------------------------------- | |||
# paint event | |||
#def paintEvent(self, event): | |||
#QMainWindow.paintEvent(self, event) | |||
#if MACOS or not self.fSavedSettings[CARLA_KEY_CUSTOM_PAINTING]: | |||
#return | |||
#painter = QPainter(self) | |||
#painter.setBrush(QColor(36, 36, 36)) | |||
#painter.setPen(QColor(62, 62, 62)) | |||
#painter.drawRect(1, self.height()/2, self.width()-3, self.height()-self.height()/2-1) | |||
# -------------------------------------------------------------------------------------------------------- | |||
# close event | |||
@@ -46,125 +46,6 @@ class CarlaRackList(QListWidget): | |||
QListWidget.__init__(self, parent) | |||
self.host = host | |||
if False: | |||
# kdevelop likes this :) | |||
host = CarlaHostMeta() | |||
self.host = host | |||
# ------------------------------------------------------------- | |||
exts = host.get_supported_file_extensions().split(";") | |||
# plugin files | |||
exts.append("dll") | |||
if MACOS: | |||
exts.append("dylib") | |||
if not WINDOWS: | |||
exts.append("so") | |||
self.fSupportedExtensions = tuple(i.replace("*.","") for i in exts) | |||
self.fWasLastDragValid = False | |||
self.setMinimumWidth(640+20) # required by zita, 591 was old value | |||
self.setSelectionMode(QAbstractItemView.SingleSelection) | |||
self.setSortingEnabled(False) | |||
#self.setSortingEnabled(True) | |||
self.setDragEnabled(True) | |||
self.setDragDropMode(QAbstractItemView.DropOnly) | |||
self.setDropIndicatorShown(True) | |||
self.viewport().setAcceptDrops(True) | |||
self.setFrameShape(QFrame.NoFrame) | |||
self.setFrameShadow(QFrame.Plain) | |||
self.fPixmapL = QPixmap(":/bitmaps/rack_interior_left.png") | |||
self.fPixmapR = QPixmap(":/bitmaps/rack_interior_right.png") | |||
self.fPixmapWidth = self.fPixmapL.width() | |||
def isDragEventValid(self, urls): | |||
for url in urls: | |||
filename = url.toLocalFile() | |||
if os.path.isdir(filename): | |||
if os.path.exists(os.path.join(filename, "manifest.ttl")): | |||
return True | |||
elif os.path.isfile(filename): | |||
if filename.lower().endswith(self.fSupportedExtensions): | |||
return True | |||
return False | |||
def dragEnterEvent(self, event): | |||
if self.isDragEventValid(event.mimeData().urls()): | |||
self.fWasLastDragValid = True | |||
event.acceptProposedAction() | |||
return | |||
self.fWasLastDragValid = False | |||
QListWidget.dragEnterEvent(self, event) | |||
def dragMoveEvent(self, event): | |||
if self.fWasLastDragValid: | |||
event.acceptProposedAction() | |||
tryItem = self.itemAt(event.pos()) | |||
if tryItem is not None: | |||
self.setCurrentRow(tryItem.widget.getPluginId()) | |||
else: | |||
self.setCurrentRow(-1) | |||
return | |||
QListWidget.dragMoveEvent(self, event) | |||
#def dragLeaveEvent(self, event): | |||
#self.fWasLastDragValid = False | |||
#QListWidget.dragLeaveEvent(self, event) | |||
def dropEvent(self, event): | |||
event.acceptProposedAction() | |||
urls = event.mimeData().urls() | |||
if len(urls) == 0: | |||
return | |||
tryItem = self.itemAt(event.pos()) | |||
if tryItem is not None: | |||
pluginId = tryItem.widget.getPluginId() | |||
self.host.replace_plugin(pluginId) | |||
for url in urls: | |||
filename = url.toLocalFile() | |||
if not self.host.load_file(filename): | |||
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), | |||
self.tr("Failed to load file"), | |||
self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) | |||
if tryItem is not None: | |||
self.host.replace_plugin(self.parent().fPluginCount) | |||
#tryItem.widget.setActive(True, True, True) | |||
def mousePressEvent(self, event): | |||
if self.itemAt(event.pos()) is None: | |||
event.accept() | |||
self.setCurrentRow(-1) | |||
return | |||
QListWidget.mousePressEvent(self, event) | |||
def paintEvent(self, event): | |||
painter = QPainter(self.viewport()) | |||
painter.drawTiledPixmap(0, 0, self.fPixmapWidth, self.height(), self.fPixmapL) | |||
painter.drawTiledPixmap(self.width()-self.fPixmapWidth-2, 0, self.fPixmapWidth, self.height(), self.fPixmapR) | |||
QListWidget.paintEvent(self, event) | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Rack widget | |||
@@ -80,7 +80,7 @@ class PluginHost(CarlaHostPlugin): | |||
class CarlaMiniW(ExternalUI, HostWindow): | |||
def __init__(self, host, parent=None): | |||
ExternalUI.__init__(self) | |||
HostWindow.__init__(self, host, parent) | |||
HostWindow.__init__(self, host, sys.argv[0].lower().endswith("/carla-plugin-patchbay"), parent) | |||
self.host = host | |||
if False: | |||
@@ -90,15 +90,6 @@ class CarlaMiniW(ExternalUI, HostWindow): | |||
host.setExternalUI(self) | |||
if sys.argv[0].lower().endswith("/carla-plugin-patchbay"): | |||
from carla_patchbay import CarlaPatchbayW | |||
self.fContainer = CarlaPatchbayW(self, host) | |||
self.setupContainer(True, self.fContainer.themeData) | |||
else: | |||
from carla_rack import CarlaRackW | |||
self.fContainer = CarlaRackW(self, host) | |||
self.setupContainer(False) | |||
self.fFirstInit = True | |||
self.setWindowTitle(self.fUiName) | |||
@@ -35,7 +35,7 @@ else: | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Imports (Custom Stuff) | |||
from carla_skin import createPluginSlot | |||
from carla_skin import * | |||
# ------------------------------------------------------------------------------------------------------------ | |||
# Rack Widget item | |||
@@ -79,6 +79,9 @@ class RackListItem(QListWidgetItem): | |||
def getEditDialog(self): | |||
return self.fWidget.fEditDialog | |||
def getPluginId(self): | |||
return self.fPluginId | |||
def getWidget(self): | |||
return self.fWidget | |||
@@ -94,6 +97,7 @@ class RackListItem(QListWidgetItem): | |||
if self.fWidget is not None: | |||
self.fWidget.fEditDialog.close() | |||
self.fWidget.close() | |||
del self.fWidget.fEditDialog | |||
del self.fWidget | |||
self.fWidget = createPluginSlot(self.fParent, self.host, self.fPluginId, self.fUseSkins) | |||
@@ -120,7 +124,7 @@ class RackListWidget(QListWidget): | |||
self.fSupportedExtensions = [] | |||
self.fWasLastDragValid = False | |||
self.setMinimumWidth(700) | |||
self.setMinimumWidth(740) | |||
self.setSelectionMode(QAbstractItemView.SingleSelection) | |||
self.setSortingEnabled(False) | |||
@@ -145,8 +149,117 @@ class RackListWidget(QListWidget): | |||
def setHost(self, host): | |||
self.host = host | |||
exts = host.get_supported_file_extensions().split(";") | |||
exts.append(".dll") | |||
if MACOS: | |||
exts.append(".dylib") | |||
if not WINDOWS: | |||
exts.append(".so") | |||
self.fSupportedExtensions = tuple(i.replace("*","") for i in exts) | |||
# -------------------------------------------------------------------------------------------------------- | |||
def isDragUrlValid(self, url): | |||
filename = url.toLocalFile() | |||
if os.path.isdir(filename): | |||
if os.path.exists(os.path.join(filename, "manifest.ttl")): | |||
return True | |||
if filename.lower().endswith((".vst", ".vst3")): | |||
return True | |||
elif os.path.isfile(filename): | |||
if filename.lower().endswith(self.fSupportedExtensions): | |||
return True | |||
return False | |||
# -------------------------------------------------------------------------------------------------------- | |||
def dragEnterEvent(self, event): | |||
urls = event.mimeData().urls() | |||
for url in urls: | |||
if self.isDragUrlValid(url): | |||
self.fWasLastDragValid = True | |||
event.acceptProposedAction() | |||
return | |||
self.fWasLastDragValid = False | |||
QListWidget.dragEnterEvent(self, event) | |||
def dragMoveEvent(self, event): | |||
if not self.fWasLastDragValid: | |||
QListWidget.dragMoveEvent(self, event) | |||
return | |||
event.acceptProposedAction() | |||
tryItem = self.itemAt(event.pos()) | |||
if tryItem is not None: | |||
self.setCurrentRow(tryItem.getPluginId()) | |||
else: | |||
self.setCurrentRow(-1) | |||
def dragLeaveEvent(self, event): | |||
self.fWasLastDragValid = False | |||
QListWidget.dragLeaveEvent(self, event) | |||
# -------------------------------------------------------------------------------------------------------- | |||
# FIXME: this needs some attention | |||
# if dropping project file over 1 plugin, load it in rack or patchbay | |||
# if dropping regular files over 1 plugin, keep replacing plugins | |||
def dropEvent(self, event): | |||
event.acceptProposedAction() | |||
urls = event.mimeData().urls() | |||
if len(urls) == 0: | |||
return | |||
tryItem = self.itemAt(event.pos()) | |||
if tryItem is not None: | |||
pluginId = tryItem.getPluginId() | |||
else: | |||
pluginId = -1 | |||
for url in urls: | |||
if pluginId >= 0: | |||
self.host.replace_plugin(pluginId) | |||
pluginId += 1 | |||
if pluginId > self.host.get_current_plugin_count(): | |||
pluginId = -1 | |||
filename = url.toLocalFile() | |||
if not self.host.load_file(filename): | |||
CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), | |||
self.tr("Failed to load file"), | |||
self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) | |||
if tryItem is not None: | |||
self.host.replace_plugin(self.host.get_max_plugin_number()) | |||
#tryItem.widget.setActive(True, True, True) | |||
# -------------------------------------------------------------------------------------------------------- | |||
def mousePressEvent(self, event): | |||
if self.itemAt(event.pos()) is None: | |||
event.accept() | |||
self.setCurrentRow(-1) | |||
return | |||
QListWidget.mousePressEvent(self, event) | |||
def paintEvent(self, event): | |||
painter = QPainter(self.viewport()) | |||
painter.drawTiledPixmap(0, 0, self.fPixmapWidth, self.height(), self.fPixmapL) | |||