diff --git a/Makefile b/Makefile index 071cbb20e..ad2847d25 100644 --- a/Makefile +++ b/Makefile @@ -282,6 +282,7 @@ RES = \ bin/resources/ui_carla_parameter.py \ bin/resources/ui_carla_plugin_basic_fx.py \ bin/resources/ui_carla_plugin_calf.py \ + bin/resources/ui_carla_plugin_compact.py \ bin/resources/ui_carla_plugin_default.py \ bin/resources/ui_carla_plugin_sf2.py \ bin/resources/ui_carla_plugin_zynfx.py \ @@ -327,6 +328,7 @@ UIs = \ source/ui_carla_parameter.py \ source/ui_carla_plugin_basic_fx.py \ source/ui_carla_plugin_calf.py \ + source/ui_carla_plugin_compact.py \ source/ui_carla_plugin_default.py \ source/ui_carla_plugin_sf2.py \ source/ui_carla_plugin_zynfx.py \ @@ -573,6 +575,7 @@ endif $(LINK) $(PREFIX)/share/carla/ui_carla_parameter.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_basic_fx.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_calf.py $(DESTDIR)$(PREFIX)/share/carla/resources/ + $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_compact.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_default.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_sf2.py $(DESTDIR)$(PREFIX)/share/carla/resources/ $(LINK) $(PREFIX)/share/carla/ui_carla_plugin_zynfx.py $(DESTDIR)$(PREFIX)/share/carla/resources/ diff --git a/resources/bitmaps/dial_14.png b/resources/bitmaps/dial_14.png new file mode 100644 index 000000000..fdda04a77 Binary files /dev/null and b/resources/bitmaps/dial_14.png differ diff --git a/resources/bitmaps/dial_14d.png b/resources/bitmaps/dial_14d.png new file mode 100644 index 000000000..e3f47ea65 Binary files /dev/null and b/resources/bitmaps/dial_14d.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index c982b98fd..6a6375536 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -106,6 +106,8 @@ bitmaps/dial_12d.png bitmaps/dial_13.png bitmaps/dial_13d.png + bitmaps/dial_14.png + bitmaps/dial_14d.png bitmaps/kbd_h_dark.png bitmaps/kbd_v_dark.png diff --git a/resources/ui/carla_plugin_basic_fx.ui b/resources/ui/carla_plugin_basic_fx.ui index 8a20da087..f3d230114 100644 --- a/resources/ui/carla_plugin_basic_fx.ui +++ b/resources/ui/carla_plugin_basic_fx.ui @@ -6,8 +6,8 @@ 0 0 - 338 - 71 + 552 + 60 @@ -16,157 +16,212 @@ Frame + + 0 + - 1 + 0 - 2 + 4 3 - 2 + 6 - 0 + 3 - + 1 - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 1 - - - - - - + - 24 + 72 24 - 24 - 24 - - - - - - - - :/bitmaps/button_off.png:/bitmaps/button_off.png - - - - 24 + 72 24 - - true - - - true - + + + 0 + + + 0 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_off.png:/bitmaps/button_off.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_gui.png:/bitmaps/button_gui.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_edit.png:/bitmaps/button_edit.png + + + + 24 + 24 + + + + true + + + true + + + + - - - - 24 - 24 - - - - - 24 - 24 - - - - + + + Qt::Horizontal - - - :/bitmaps/button_gui.png:/bitmaps/button_gui.png + + QSizePolicy::Fixed - + - 24 - 24 + 6 + 1 - - true - - - true - - + - + - 24 - 24 + 0 + 20 - 24 - 24 + 16777215 + 20 - - - - - - :/bitmaps/button_edit.png:/bitmaps/button_edit.png - - - - 24 - 24 - + + 0 - - true + + 1 - - true + + Qt::Vertical - + Qt::Horizontal + + QSizePolicy::Fixed + - 40 - 20 + 8 + 1 @@ -177,23 +232,74 @@ PluginName - Qt::AlignCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + Qt::Horizontal - 40 - 20 + 20 + 1 + + + + 4 + + + 4 + + + 2 + + + 4 + + + 2 + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + + @@ -289,22 +395,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 1 - - - - @@ -321,36 +411,26 @@ - + - 10 + 1 + + + 12 - 2 + 4 + + + 10 - - - - 20 - 0 - - - - - 20 - 16777215 - - - - - - + - + Qt::Horizontal @@ -363,102 +443,8 @@ - - - - 34 - 34 - - - - - 34 - 34 - - - - - - - - - 34 - 34 - - - - - 34 - 34 - - - - - - - - 1 - - - 0 - - - 0 - - - 0 - - - 4 - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - - - - - - - - 20 - 0 - - - - - 20 - 16777215 - - + + @@ -482,11 +468,6 @@ QPushButton
pixmapbutton.h
- - PixmapDial - QDial -
pixmapdial.h
-
diff --git a/resources/ui/carla_plugin_compact.ui b/resources/ui/carla_plugin_compact.ui new file mode 100644 index 000000000..ec1834710 --- /dev/null +++ b/resources/ui/carla_plugin_compact.ui @@ -0,0 +1,417 @@ + + + PluginWidget + + + + 0 + 0 + 425 + 30 + + + + Qt::CustomContextMenu + + + Frame + + + 0 + + + + 1 + + + 4 + + + 3 + + + 6 + + + 3 + + + + + + 72 + 24 + + + + + 72 + 24 + + + + + 0 + + + 0 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_off.png:/bitmaps/button_off.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_gui.png:/bitmaps/button_gui.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_edit.png:/bitmaps/button_edit.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 1 + + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + 0 + + + 1 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 8 + 1 + + + + + + + + PluginName + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 19 + 1 + + + + + + + + 4 + + + 4 + + + 2 + + + 4 + + + 2 + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + + + + + + + 1 + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + + + DigitalPeakMeter + QWidget +
digitalpeakmeter.h
+ 1 +
+ + LEDButton + QPushButton +
ledbutton.h
+
+ + PixmapButton + QPushButton +
pixmapbutton.h
+
+
+ + + + +
diff --git a/resources/ui/carla_plugin_default.ui b/resources/ui/carla_plugin_default.ui index 28bead933..4795d0954 100644 --- a/resources/ui/carla_plugin_default.ui +++ b/resources/ui/carla_plugin_default.ui @@ -16,6 +16,9 @@ Frame + + 0 + 2 diff --git a/resources/ui/carla_plugin_zynfx.ui b/resources/ui/carla_plugin_zynfx.ui index 9ad8124f8..5704953fc 100644 --- a/resources/ui/carla_plugin_zynfx.ui +++ b/resources/ui/carla_plugin_zynfx.ui @@ -6,8 +6,8 @@ 0 0 - 559 - 75 + 484 + 65 @@ -24,116 +24,156 @@ - 1 + 0 - 2 + 4 3 - 2 + 6 - 0 + 3 - + 1 - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 1 - - - - - + - 24 + 72 24 - 24 + 72 24 - - - - - - :/bitmaps/button_off.png:/bitmaps/button_off.png - - - - 24 - 24 - - - - true - - - true - + + + 0 + + + 0 + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_off.png:/bitmaps/button_off.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_gui.png:/bitmaps/button_gui.png + + + + 24 + 24 + + + + true + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + + + + + :/bitmaps/button_edit.png:/bitmaps/button_edit.png + + + + 24 + 24 + + + + true + + + true + + + + - - - - 24 - 24 - - - - - 24 - 24 - - - - - - - - :/bitmaps/button_edit.png:/bitmaps/button_edit.png - - - - 24 - 24 - - - - true - - - true - - - - - + Qt::Horizontal @@ -142,57 +182,49 @@ - 10 - 10 + 6 + 1 - - - Preset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - + + - 3 - 10 + 0 + 20 - - - - - + - 125 - 0 + 16777215 + 20 + + 0 + + + 1 + + + Qt::Vertical + - + Qt::Horizontal + + QSizePolicy::Fixed + - 40 - 20 + 8 + 1 @@ -211,143 +243,145 @@ - + Qt::Horizontal - 40 - 20 + 20 + 1 - - - - 160 - 0 - - - - - 160 - 16777215 - - - - - - - Qt::AlignCenter - - - - - - - - 14 - 14 - - - - - 14 - 14 - - - - - - - true - - - - - - - - 14 - 14 - - - - - 14 - 14 - - - - - - - true - - - - - - - - 14 - 14 - - - - - 14 - 14 - - - - - - - true - - - - - - - - 14 - 14 - - - - - 14 - 14 - + + + 4 - - + + 4 - - true + + 4 - + + + + Preset: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 125 + 0 + + + + + - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 1 - + + + 1 - + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + + + + + + 14 + 14 + + + + + 14 + 14 + + + + + + + true + + + +
@@ -365,36 +399,26 @@ - + - 10 + 1 + + + 12 - 2 + 4 + + + 10 - - - - 20 - 0 - - - - - 20 - 16777215 - - - - - - + - + Qt::Horizontal @@ -407,53 +431,26 @@ - - - - 34 - 34 - - - - - 34 - 34 - - - - - - - - - 34 - 34 - - - - - 34 - 34 - - + + - + - 1 + 4 - 0 + 4 - 0 + 2 - 0 + 4 - 4 + 2 @@ -489,22 +486,6 @@ - - - - - 20 - 0 - - - - - 20 - 16777215 - - - - @@ -526,11 +507,6 @@ QPushButton
pixmapbutton.h
- - PixmapDial - QDial -
pixmapdial.h
-
diff --git a/source/carla_host.py b/source/carla_host.py index 2b0d0cdea..b41167419 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -128,12 +128,6 @@ class HostWindow(QMainWindow): self.fClientName = CARLA_CLIENT_NAME or "Carla" self.fSessionManagerName = "" - # ---------------------------------------------------------------------------------------------------- - # Internal stuff (rack) - - self.fCurrentRow = -1 - self.fLastSelectedItem = None - # ---------------------------------------------------------------------------------------------------- # Internal stuff (patchbay) @@ -239,8 +233,6 @@ class HostWindow(QMainWindow): self.ui.rackScrollBar.rangeChanged.connect(sb.setRange) self.ui.rackScrollBar.valueChanged.connect(sb.setValue) - self.ui.listWidget.currentRowChanged.connect(self.slot_currentRowChanged) - self.ui.rack.setStyleSheet(""" QLabel#pad_left { background-image: url(:/bitmaps/rack_padding_left.png); @@ -420,6 +412,17 @@ class HostWindow(QMainWindow): # -------------------------------------------------------------------------------------------------------- # Setup + def compactPlugin(self, pluginId): + if pluginId > self.fPluginCount: + return + + pitem = self.fPluginList[pluginId] + + if pitem is None: + return + + pitem.recreateWidget(True) + def setLoadRDFsNeeded(self): self.fLadspaRdfNeedsUpdate = True @@ -1505,24 +1508,6 @@ class HostWindow(QMainWindow): vsb.setValue(yp * vsb.maximum()) self.updateCanvasInitialPos() - # -------------------------------------------------------------------------------------------------------- - # Rack stuff - - @pyqtSlot(int) - def slot_currentRowChanged(self, row): - self.fCurrentRow = row - - if self.fLastSelectedItem is not None: - self.fLastSelectedItem.setSelected(False) - - if row < 0 or row >= self.fPluginCount or self.fPluginList[row] is None: - self.fLastSelectedItem = None - return - - pitem = self.fPluginList[row] - pitem.getWidget().setSelected(True) - self.fLastSelectedItem = pitem.getWidget() - # -------------------------------------------------------------------------------------------------------- # Timers @@ -1574,10 +1559,7 @@ class HostWindow(QMainWindow): if pitem is None: return - self.ui.listWidget.setCurrentRow(-1) - self.fCurrentRow = -1 - self.fLastSelectedItem = None - + self.ui.listWidget.customClearSelection() pitem.recreateWidget() # -------------------------------------------------------------------------------------------------------- diff --git a/source/carla_skin.py b/source/carla_skin.py old mode 100644 new mode 100755 index 0096ddfef..e70f2741e --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -38,6 +38,7 @@ else: import ui_carla_plugin_default import ui_carla_plugin_basic_fx import ui_carla_plugin_calf +import ui_carla_plugin_compact import ui_carla_plugin_sf2 import ui_carla_plugin_zynfx @@ -45,6 +46,33 @@ from carla_widgets import * from digitalpeakmeter import DigitalPeakMeter from pixmapdial import PixmapDial +# ------------------------------------------------------------------------------------------------------------ +# Plugin Skin Rules + +# Base is a QFrame (NoFrame, Plain, 0-size lines), with "PluginWidget" as object name. +# Spacing of the top-most layout must be 1px. +# Top and bottom margins must be 3px (can be splitted between different qt layouts). +# Left and right margins must be 6px (can be splitted between different qt layouts). +# If the left or right side has built-in margins, say a transparent png border, +# those margins must be taken into consideration. +# +# There's a top and bottom layout, separated by a horizontal line. +# Compacted skins do not have the bottom layout and separating line. + +# T O P A R E A +# +# ----------------------------------------------------------------- +# | <> | <> [ WIDGETS ] [ LEDS ] | +# | BUTTONS <> | <> PLUGIN NAME < spacer > [ WIDGETS ] [ LEDS ] | +# | <> | <> [ WIDGETS ] [ LEDS ] | +# ----------------------------------------------------------------- +# +# Buttons area has size fixed. (TBA) +# Spacers at the left of the plugin name must be 8x1 in size (fixed). +# The line before the plugin name must be height-10px (fixed). +# WIDGETS area can be extended to the left, if using meters they should have 80px. +# WIDGETS margins are 4px for left+right and 2px for top+bottom, with 4px spacing. + # ------------------------------------------------------------------------------------------------------------ # Try to "shortify" a parameter name @@ -107,12 +135,62 @@ def getParameterShortName(paramName): return paramName.strip() +# ------------------------------------------------------------------------------------------------------------ +# Get RGB colors for a plugin category + +def getColorFromCategory(category): + r = 40 + g = 40 + b = 40 + + if category == PLUGIN_CATEGORY_MODULATOR: + r += 10 + elif category == PLUGIN_CATEGORY_EQ: + g += 10 + elif category == PLUGIN_CATEGORY_FILTER: + b += 10 + elif category == PLUGIN_CATEGORY_DELAY: + r += 15 + b -= 15 + elif category == PLUGIN_CATEGORY_DISTORTION: + g += 10 + b += 10 + elif category == PLUGIN_CATEGORY_DYNAMICS: + r += 10 + b += 10 + elif category == PLUGIN_CATEGORY_UTILITY: + r += 10 + g += 10 + + return (r, g, b) + +def getModColorFromCategory(category): + if category == PLUGIN_CATEGORY_NONE: + return (40, 40, 40) + if category == PLUGIN_CATEGORY_SYNTH: + return (30, 150, 49) + if category == PLUGIN_CATEGORY_DELAY: + return (47, 47, 47) + if category in (PLUGIN_CATEGORY_EQ, PLUGIN_CATEGORY_FILTER): + return (255, 220, 25) + if category == PLUGIN_CATEGORY_DISTORTION: + return (255, 127, 25) + if category == PLUGIN_CATEGORY_DYNAMICS: + return (255, 25, 25) + if category == PLUGIN_CATEGORY_MODULATOR: + return (109, 31, 142) + if category == PLUGIN_CATEGORY_UTILITY: + return (95, 95, 95) + if category == PLUGIN_CATEGORY_OTHER: + return (92, 210, 254) + return (40, 40, 40) + # ------------------------------------------------------------------------------------------------------------ # Abstract plugin slot class AbstractPluginSlot(QFrame, PluginEditParentMeta): #class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass): - def __init__(self, parent, host, pluginId): + def __init__(self, parent, host, pluginId, skinStyle): QFrame.__init__(self, parent) self.host = host @@ -126,6 +204,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.fPluginId = pluginId self.fPluginInfo = host.get_plugin_info(self.fPluginId) + self.fSkinStyle = skinStyle #if not gCarla.isLocal: #self.fPluginInfo['hints'] &= ~PLUGIN_HAS_CUSTOM_UI @@ -133,9 +212,8 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): # ------------------------------------------------------------- # Internal stuff - self.fIsActive = bool(host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5) - self.fIsCollapsed = False - self.fIsSelected = False + self.fIsActive = bool(host.get_internal_parameter_value(self.fPluginId, PARAMETER_ACTIVE) >= 0.5) + self.fIsSelected = False self.fLastGreenLedState = False self.fLastBlueLedState = False @@ -172,16 +250,15 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.cb_presets = None - self.label_name = None - self.label_type = None + self.label_name = None + self.label_presets = None + self.label_type = None self.led_control = None self.led_midi = None self.led_audio_in = None self.led_audio_out = None - self.line = None - self.peak_in = None self.peak_out = None @@ -236,7 +313,6 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): if self.fPluginId == pluginId: self.setProgram(index, True) - @pyqtSlot(int, int) def slot_handleMidiProgramChangedCallback(self, pluginId, index): if self.fPluginId == pluginId: @@ -259,18 +335,38 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.b_enable.setChecked(self.fIsActive) self.b_enable.clicked.connect(self.slot_enableClicked) + if "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact): + self.b_enable.setPixmaps(":/bitmaps/button_calf3.png", ":/bitmaps/button_calf3_down.png", ":/bitmaps/button_calf3.png") + else: + self.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") + if self.b_gui is not None: self.b_gui.clicked.connect(self.slot_showCustomUi) self.b_gui.setEnabled(bool(self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI)) - if self.b_edit is None: - # Edit dialog *must* be available + if "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact): + self.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png") + elif self.fPluginInfo['iconName'] == "distrho" or self.fSkinStyle in ("3bandeq","3bandsplitter","pingpongpan"): + self.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png") + elif self.fPluginInfo['iconName'] == "file": + self.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png") + else: + self.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") + + if self.b_edit is not None: + self.b_edit.clicked.connect(self.slot_showEditDialog) + + if "calf" in self.fSkinStyle and not isinstance(self, PluginSlot_Compact): + self.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png") + else: + self.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") + + else: + # Edit button *must* be available self.b_edit = QPushButton(self) self.b_edit.setCheckable(True) self.b_edit.hide() - self.b_edit.clicked.connect(self.slot_showEditDialog) - if self.b_remove is not None: self.b_remove.clicked.connect(self.slot_removePlugin) @@ -278,6 +374,30 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.label_name.setEnabled(self.fIsActive) self.label_name.setText(self.fPluginInfo['name']) + nameFont = self.label_name.font() + + if self.fSkinStyle == "openav": + QFontDatabase.addApplicationFont(":/fonts/uranium.ttf") + nameFont.setFamily("Uranium") + nameFont.setPointSize(13) + nameFont.setCapitalization(QFont.AllUppercase) + + elif "calf" in self.fSkinStyle: + nameFont.setBold(True) + nameFont.setPointSize(10) + + else: + nameFont.setBold(True) + nameFont.setPointSize(9) + + self.label_name.setFont(nameFont) + + if self.label_presets is not None: + presetFont = self.label_presets.font() + presetFont.setBold(True) + presetFont.setPointSize(8) + self.label_presets.setFont(presetFont) + if self.label_type is not None: self.label_type.setText(getPluginTypeAsString(self.fPluginInfo['type'])) @@ -301,19 +421,31 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.peak_in.setChannelCount(self.fPeaksInputCount) self.peak_in.setMeterColor(DigitalPeakMeter.COLOR_GREEN) self.peak_in.setMeterOrientation(DigitalPeakMeter.HORIZONTAL) - if (self.fPeaksInputCount == 0 and not isinstance(self, PluginSlot_Default)) or self.fIsCollapsed: + + if "calf" in self.fSkinStyle: + self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_CALF) + elif self.fSkinStyle == "rncbc": + self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC) + elif self.fSkinStyle in ("mod", "openav", "zynfx"): + self.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) + + if self.fPeaksInputCount == 0 and not isinstance(self, PluginSlot_Default): self.peak_in.hide() if self.peak_out is not None: self.peak_out.setChannelCount(self.fPeaksOutputCount) self.peak_out.setMeterColor(DigitalPeakMeter.COLOR_BLUE) self.peak_out.setMeterOrientation(DigitalPeakMeter.HORIZONTAL) - if (self.fPeaksOutputCount == 0 and not isinstance(self, PluginSlot_Default)) or self.fIsCollapsed: - self.peak_out.hide() - if self.line is not None: - if self.fIsCollapsed: - self.line.hide() + if "calf" in self.fSkinStyle: + self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_CALF) + elif self.fSkinStyle == "rncbc": + self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_RNCBC) + elif self.fSkinStyle in ("mod", "openav", "zynfx"): + self.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) + + if self.fPeaksOutputCount == 0 and not isinstance(self, PluginSlot_Default): + self.peak_out.hide() for paramIndex, paramWidget in self.fParameterList: paramWidget.setContextMenuPolicy(Qt.CustomContextMenu) @@ -321,8 +453,50 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): paramWidget.realValueChanged.connect(self.slot_parameterValueChanged) paramWidget.setValue(self.host.get_internal_parameter_value(self.fPluginId, paramIndex)) - if self.fIsCollapsed: - paramWidget.hide() + # ------------------------------------------------------------- + + if self.fSkinStyle == "mod": + styleSheet = """ + QFrame#PluginWidget { + background-color: rgb(%i, %i, %i); + } + QLabel#label_name { color: #FFFFFF; } + QLabel#label_name:disabled { color: #505050; } + """ % getModColorFromCategory(self.fPluginInfo['category']) + + elif self.fSkinStyle == "openav": + styleSheet = """ + QFrame#PluginWidget { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #303030, stop: %f #111111, stop: 1.0 #111111); + } + QLabel#label_name { color: #FF5100; } + QLabel#label_name:disabled { color: #505050; } + """ % (0.95 if isinstance(self, PluginSlot_Compact) else 0.35) + + else: + if self.fSkinStyle in ("3bandeq", "calf_black", "calf_blue", "nekobi", "zynfx"): + styleSheet2 = "background-image: url(:/bitmaps/background_%s.png);" % self.fSkinStyle + else: + styleSheet2 = "background-color: rgb(%i, %i, %i);" % getColorFromCategory(self.fPluginInfo['category']) + styleSheet2 += "background-image: url(:/bitmaps/background_noise1.png);" + + styleSheet = """ + QFrame#PluginWidget { + %s + background-repeat: repeat-xy; + } + QLabel#label_name, + QLabel#label_audio_in, + QLabel#label_audio_out, + QLabel#label_midi, + QLabel#label_presets { color: #BBB; } + QLabel#label_name:disabled { color: #555; } + """ % styleSheet2 + + self.setStyleSheet(styleSheet) + + # ------------------------------------------------------------- self.setWindowTitle(self.fPluginInfo['name']) @@ -636,32 +810,74 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): painter.setBrush(Qt.black) painter.drawLine(0, self.height()-1, self.width(), self.height()-1) - def showDefaultCustomMenu(self, isEnabled, bEdit = None, bGui = None): + def updateParameterValues(self): + for paramIndex, paramWidget in self.fParameterList: + if paramIndex < 0: + continue + + paramWidget.blockSignals(True) + paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex)) + paramWidget.blockSignals(False) + + #------------------------------------------------------------------ + + @pyqtSlot(bool) + def slot_enableClicked(self, yesNo): + self.setActive(yesNo, False, True) + + @pyqtSlot() + def slot_showDefaultCustomMenu(self): menu = QMenu(self) - actActive = menu.addAction(self.tr("Disable") if isEnabled else self.tr("Enable")) + # ------------------------------------------------------------- + # Expand/Minimize + + actCompact = menu.addAction(self.tr("Expand") if isinstance(self, PluginSlot_Compact) else self.tr("Minimize")) menu.addSeparator() + # ------------------------------------------------------------- + # Bypass and Enable/Disable + + actBypass = menu.addAction(self.tr("Bypass")) + actEnable = menu.addAction(self.tr("Disable") if self.fIsActive else self.tr("Enable")) + menu.addSeparator() + + if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET: + actBypass.setCheckable(True) + actBypass.setChecked(self.host.get_internal_parameter_value(self.fPluginId, PARAMETER_DRYWET) == 0.0) + else: + actBypass.setVisible(False) + + # ------------------------------------------------------------- + # Reset and Randomize parameters + actReset = menu.addAction(self.tr("Reset parameters")) actRandom = menu.addAction(self.tr("Randomize parameters")) menu.addSeparator() - if bEdit is not None: - actEdit = menu.addAction(self.tr("Edit")) + # ------------------------------------------------------------- + # Edit and Show Custom UI + + actEdit = menu.addAction(self.tr("Edit")) + actGui = menu.addAction(self.tr("Show Custom UI")) + menu.addSeparator() + + if self.b_edit is not None: actEdit.setCheckable(True) - actEdit.setChecked(bEdit.isChecked()) + actEdit.setChecked(self.b_edit.isChecked()) else: - actEdit = None + actEdit.setVisible(False) - if bGui is not None: - actGui = menu.addAction(self.tr("Show Custom UI")) + if self.b_gui is not None: actGui.setCheckable(True) - actGui.setChecked(bGui.isChecked()) - actGui.setEnabled(bGui.isEnabled()) + actGui.setChecked(self.b_gui.isChecked()) + actGui.setEnabled(self.b_gui.isEnabled()) else: - actGui = None + actGui.setVisible(False) + + # ------------------------------------------------------------- + # Other stuff - menu.addSeparator() actClone = menu.addAction(self.tr("Clone")) actReplace = menu.addAction(self.tr("Replace...")) actRename = menu.addAction(self.tr("Rename...")) @@ -670,13 +886,34 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): if self.fIdleTimerId != 0: actRemove.setVisible(False) + # ------------------------------------------------------------- + # exec + actSel = menu.exec_(QCursor.pos()) if not actSel: return - if actSel == actActive: - self.setActive(not isEnabled, True, True) + # ------------------------------------------------------------- + # Expand/Minimize + + elif actSel == actCompact: + # FIXME + gCarla.gui.compactPlugin(self.fPluginId) + + # ------------------------------------------------------------- + # Bypass and Enable/Disable + + elif actSel == actBypass: + value = 0.0 if actBypass.isChecked() else 1.0 + self.host.set_drywet(self.fPluginId, value) + self.setParameterValue(PARAMETER_DRYWET, value, True) + + elif actSel == actEnable: + self.setActive(not self.fIsActive, True, True) + + # ------------------------------------------------------------- + # Reset and Randomize parameters elif actSel == actReset: self.host.reset_parameters(self.fPluginId) @@ -684,17 +921,26 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): elif actSel == actRandom: self.host.randomize_parameters(self.fPluginId) - elif actSel == actGui: - bGui.click() + # ------------------------------------------------------------- + # Edit and Show Custom UI elif actSel == actEdit: - bEdit.click() + self.b_edit.click() + + elif actSel == actGui: + self.b_gui.click() + + # ------------------------------------------------------------- + # Clone elif actSel == actClone: if not self.host.clone_plugin(self.fPluginId): CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + # ------------------------------------------------------------- + # Rename + elif actSel == actRename: oldName = self.fPluginInfo['name'] newNameTry = QInputDialog.getText(self, self.tr("Rename Plugin"), self.tr("New plugin name:"), QLineEdit.Normal, oldName) @@ -710,32 +956,22 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + # ------------------------------------------------------------- + # Replace + elif actSel == actReplace: + # FIXME gCarla.gui.slot_pluginAdd(self.fPluginId) + # ------------------------------------------------------------- + # Remove + elif actSel == actRemove: if not self.host.remove_plugin(self.fPluginId): CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) - def updateParameterValues(self): - for paramIndex, paramWidget in self.fParameterList: - if paramIndex < 0: - continue - - paramWidget.blockSignals(True) - paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex)) - paramWidget.blockSignals(False) - - #------------------------------------------------------------------ - - @pyqtSlot(bool) - def slot_enableClicked(self, yesNo): - self.setActive(yesNo, False, True) - - @pyqtSlot() - def slot_showDefaultCustomMenu(self): - self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui) + # ------------------------------------------------------------- @pyqtSlot() def slot_knobCustomMenu(self): @@ -855,7 +1091,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): class PluginSlot_Default(AbstractPluginSlot): def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) + AbstractPluginSlot.__init__(self, parent, host, pluginId, "default") self.ui = ui_carla_plugin_default.Ui_PluginWidget() self.ui.setupUi(self) @@ -866,25 +1102,6 @@ class PluginSlot_Default(AbstractPluginSlot): self.fColorBottom = QColor(47, 47, 47) self.fColorSeprtr = QColor(70, 70, 70) - # ------------------------------------------------------------- - # Set-up GUI - - self.setStyleSheet(""" - QLabel#label_name { - color: #BBB; - } - """) - - self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") - - if self.fPluginInfo['iconName'] == "distrho": - self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png") - elif self.fPluginInfo['iconName'] == "file": - self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png") - else: - self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") - # ------------------------------------------------------------- self.b_enable = self.ui.b_enable @@ -962,89 +1179,49 @@ class PluginSlot_Default(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ -class PluginSlot_BasicFX(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) - self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget() +class PluginSlot_Compact(AbstractPluginSlot): + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) + self.ui = ui_carla_plugin_compact.Ui_PluginWidget() self.ui.setupUi(self) - if self.fPluginInfo['type'] == PLUGIN_INTERNAL and self.fPluginInfo['label'] == "midifile": - self.fIsCollapsed = True + self.b_enable = self.ui.b_enable + self.b_gui = self.ui.b_gui + self.b_edit = self.ui.b_edit - # ------------------------------------------------------------- - # Set-up GUI + self.label_name = self.ui.label_name - labelFont = self.ui.label_name.font() - labelFont.setBold(True) - labelFont.setPointSize(9) - self.ui.label_name.setFont(labelFont) - - r = 40 - g = 40 - b = 40 - - if self.fPluginInfo['category'] == PLUGIN_CATEGORY_MODULATOR: - r += 10 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_EQ: - g += 10 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_FILTER: - b += 10 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DELAY: - r += 15 - b -= 15 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DISTORTION: - g += 10 - b += 10 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_DYNAMICS: - r += 10 - b += 10 - elif self.fPluginInfo['category'] == PLUGIN_CATEGORY_UTILITY: - r += 10 - g += 10 - - bg = "noise1" - - if self.fPluginInfo['maker'] in ("falkTX, Michael Gruhn", "DISTRHO") and "3bandeq" in self.fPluginInfo['label'].lower(): - bg = "3bandeq" - - self.setStyleSheet(""" - PluginSlot_BasicFX#PluginWidget { - background-color: rgb(%i, %i, %i); - background-image: url(:/bitmaps/background_%s.png); - background-repeat: repeat-xy; - } - QLabel#label_name { - color: #BBB; - } - QLabel#label_name:disabled { - color: #555; - } - """ % (r, g, b, bg)) - - self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") - - if self.fPluginInfo['iconName'] == "distrho": - self.ui.b_gui.setPixmaps(":/bitmaps/button_distrho.png", ":/bitmaps/button_distrho_down.png", ":/bitmaps/button_distrho_hover.png") - elif self.fPluginInfo['iconName'] == "file": - self.ui.b_gui.setPixmaps(":/bitmaps/button_file.png", ":/bitmaps/button_file_down.png", ":/bitmaps/button_file_hover.png") - else: - self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") - - if self.fIsCollapsed: - self.layout().setAlignment(Qt.AlignCenter) - self.layout().setContentsMargins(2,2,2,0) - self.ui.layout_leds.setContentsMargins(0,4,0,0) - self.ui.w_knobs.hide() - self.ui.w_screws_left.hide() - self.ui.w_screws_right.hide() - self.ui.label_name.setFixedHeight(self.ui.b_enable.height()) - print("TO BOTTOM") + self.led_control = self.ui.led_control + self.led_midi = self.ui.led_midi + self.led_audio_in = self.ui.led_audio_in + self.led_audio_out = self.ui.led_audio_out + + self.peak_in = self.ui.peak_in + self.peak_out = self.ui.peak_out + + self.ready() + + self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu) + + #------------------------------------------------------------------ + + def getFixedHeight(self): + if self.fSkinStyle == "calf_blue": + return 36 + return 30 + +# ------------------------------------------------------------------------------------------------------------ + +class PluginSlot_BasicFX(AbstractPluginSlot): + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) + self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget() + self.ui.setupUi(self) # ------------------------------------------------------------- # Set-up parameters - parameterCount = self.host.get_parameter_count(self.fPluginId) if not self.fIsCollapsed else 0 + parameterCount = self.host.get_parameter_count(self.fPluginId) index = 0 for i in range(parameterCount): @@ -1081,49 +1258,72 @@ class PluginSlot_BasicFX(AbstractPluginSlot): #else: _r = 255 - float(index)/8*200 _g = 55 + float(index)/8*200 - _b = (r-40)*4 + _b = 0 #(r-40)*4 + index += 1 #if _r < 140: _r = 140 #if _g < 140: _g = 140 #if _b < 140: _b = 140 widget = PixmapDial(self, i) - widget.setPixmap(3) widget.setLabel(paramName) - widget.setCustomPaintColor(QColor(_r, _g, _b)) - widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR) - widget.forceWhiteLabelGradientText() widget.setMinimum(paramRanges['min']) widget.setMaximum(paramRanges['max']) - if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0: - widget.setEnabled(False) - - self.ui.w_knobs.layout().insertWidget(index, widget) - index += 1 + if skinStyle == "mod": + widget.setPixmap(14) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + elif skinStyle == "openav": + widget.setPixmap(11) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + else: + widget.setPixmap(3) + widget.setCustomPaintColor(QColor(_r, _g, _b)) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_COLOR) + widget.forceWhiteLabelGradientText() self.fParameterList.append([i, widget]) + self.ui.w_knobs_left.layout().addWidget(widget) + + if self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET: + widget = PixmapDial(self, PARAMETER_DRYWET) + widget.setLabel("Dry/Wet") + widget.setMinimum(0.0) + widget.setMaximum(1.0) + + if skinStyle == "mod": + widget.setPixmap(14) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + elif skinStyle == "openav": + widget.setPixmap(13) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + else: + widget.setPixmap(3) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET) + widget.forceWhiteLabelGradientText() + + self.fParameterList.append([PARAMETER_DRYWET, widget]) + self.ui.w_knobs_right.layout().addWidget(widget) + + if self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME: + widget = PixmapDial(self, PARAMETER_VOLUME) + widget.setLabel("Volume") + widget.setMinimum(0.0) + widget.setMaximum(1.27) + + if skinStyle == "mod": + widget.setPixmap(14) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + elif skinStyle == "openav": + widget.setPixmap(12) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + else: + widget.setPixmap(3) + widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL) + widget.forceWhiteLabelGradientText() - self.ui.dial_drywet.setIndex(PARAMETER_DRYWET) - self.ui.dial_drywet.setPixmap(3) - self.ui.dial_drywet.setLabel("Dry/Wet") - self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_WET) - self.ui.dial_drywet.setMinimum(0.0) - self.ui.dial_drywet.setMaximum(1.0) - self.ui.dial_drywet.forceWhiteLabelGradientText() - self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) - - self.ui.dial_vol.setIndex(PARAMETER_VOLUME) - self.ui.dial_vol.setPixmap(3) - self.ui.dial_vol.setLabel("Volume") - self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_CARLA_VOL) - self.ui.dial_vol.setMinimum(0.0) - self.ui.dial_vol.setMaximum(1.27) - self.ui.dial_vol.forceWhiteLabelGradientText() - self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) - - self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet]) - self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol]) + self.fParameterList.append([PARAMETER_VOLUME, widget]) + self.ui.w_knobs_right.layout().addWidget(widget) # ------------------------------------------------------------- @@ -1138,8 +1338,6 @@ class PluginSlot_BasicFX(AbstractPluginSlot): self.led_audio_in = self.ui.led_audio_in self.led_audio_out = self.ui.led_audio_out - self.line = self.ui.line - self.peak_in = self.ui.peak_in self.peak_out = self.ui.peak_out @@ -1150,7 +1348,10 @@ class PluginSlot_BasicFX(AbstractPluginSlot): #------------------------------------------------------------------ def getFixedHeight(self): - return 28 if self.fIsCollapsed else 79 + if self.fSkinStyle == "mod": + return 86 + + return 80 #------------------------------------------------------------------ @@ -1169,14 +1370,11 @@ class PluginSlot_BasicFX(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ class PluginSlot_Calf(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) self.ui = ui_carla_plugin_calf.Ui_PluginWidget() self.ui.setupUi(self) - # FIXME - self.fIsCollapsed = False - audioCount = self.host.get_audio_port_count_info(self.fPluginId) midiCount = self.host.get_midi_port_count_info(self.fPluginId) @@ -1187,34 +1385,12 @@ class PluginSlot_Calf(AbstractPluginSlot): self.fButtonFont.setBold(False) self.fButtonFont.setPointSize(8) - # Use black for mono plugins - self.fBackgroundBlack = bool("mono" in self.fPluginInfo["label"].lower()) - self.fButtonColorOn = QColor( 18, 41, 87) self.fButtonColorOff = QColor(150, 150, 150) # ------------------------------------------------------------- # Set-up GUI - self.setStyleSheet(""" - QLabel#label_name, QLabel#label_audio_in, QLabel#label_audio_out, QLabel#label_midi { - color: #BBB; - } - QLabel#label_name:disabled { - color: #667; - } - PluginSlot_Calf#PluginWidget { - background-image: url(:/bitmaps/background_calf_%s.png); - background-repeat: repeat-xy; - border: 2px; - } - """ % ("black" if self.fBackgroundBlack else "blue")) - - self.ui.line.setStyleSheet("* { color: #FF5100; }") - - self.ui.b_enable.setPixmaps(":/bitmaps/button_calf3.png", ":/bitmaps/button_calf3_down.png", ":/bitmaps/button_calf3.png") - self.ui.b_gui.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_calf2.png", ":/bitmaps/button_calf2_down.png", ":/bitmaps/button_calf2_hover.png") self.ui.b_remove.setPixmaps(":/bitmaps/button_calf1.png", ":/bitmaps/button_calf1_down.png", ":/bitmaps/button_calf1_hover.png") self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont) @@ -1225,24 +1401,11 @@ class PluginSlot_Calf(AbstractPluginSlot): else: self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont) - labelFont = self.ui.label_name.font() - labelFont.setBold(True) - labelFont.setPointSize(10) - self.ui.label_name.setFont(labelFont) - - self.ui.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_CALF) - self.ui.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_CALF) - if audioCount['ins'] == 0: self.ui.label_audio_in.hide() - self.ui.peak_in.hide() - - if audioCount['outs'] > 0: - self.ui.peak_out.setMinimumWidth(200) if audioCount['outs'] == 0: self.ui.label_audio_out.hide() - self.ui.peak_out.hide() if midiCount['ins'] == 0: self.ui.label_midi.hide() @@ -1255,7 +1418,7 @@ class PluginSlot_Calf(AbstractPluginSlot): # ------------------------------------------------------------- # Set-up parameters - parameterCount = self.host.get_parameter_count(self.fPluginId) if not self.fIsCollapsed else 0 + parameterCount = self.host.get_parameter_count(self.fPluginId) index = 0 limit = 7 if midiCount['ins'] == 0 else 6 @@ -1303,8 +1466,6 @@ class PluginSlot_Calf(AbstractPluginSlot): self.label_name = self.ui.label_name self.led_midi = self.ui.led_midi - self.line = self.ui.line - self.peak_in = self.ui.peak_in self.peak_out = self.ui.peak_out @@ -1332,149 +1493,15 @@ class PluginSlot_Calf(AbstractPluginSlot): #------------------------------------------------------------------ def paintEvent(self, event): - painter = QPainter(self) - painter.setBrush(Qt.transparent) - - painter.setPen(QPen(QColor(20, 20, 20) if self.fBackgroundBlack else QColor(75, 86, 99), 1)) - painter.drawRect(0, 1, self.width()-1, 88-3) - - painter.setPen(QPen(QColor(45, 45, 45) if self.fBackgroundBlack else QColor(86, 99, 114), 1)) - painter.drawLine(0, 0, self.width(), 0) - - AbstractPluginSlot.paintEvent(self, event) - -# ------------------------------------------------------------------------------------------------------------ - -class PluginSlot_OpenAV(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) - self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget() - self.ui.setupUi(self) - - # ------------------------------------------------------------- - # Set-up GUI - - QFontDatabase.addApplicationFont(":/fonts/uranium.ttf") - - labelFont = QFont() - labelFont.setFamily("Uranium") - labelFont.setPointSize(13) - labelFont.setCapitalization(QFont.AllUppercase) - self.ui.label_name.setFont(labelFont) - - self.setStyleSheet(""" - PluginSlot_OpenAV#PluginWidget { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #303030, stop: 0.35 #111111, stop: 1.0 #111111); - } - """) - - self.ui.label_name.setStyleSheet("* { color: #FF5100; }") - #self.ui.line.setStyleSheet("* { background-color: #FF5100; color: #FF5100; }") - - self.ui.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) - self.ui.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) - - self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") - self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") - - # ------------------------------------------------------------- - # Set-up parameters - - parameterCount = self.host.get_parameter_count(self.fPluginId) if not self.fIsCollapsed else 0 - - index = 0 - for i in range(parameterCount): - if index >= 8: - break - - paramInfo = self.host.get_parameter_info(self.fPluginId, i) - paramData = self.host.get_parameter_data(self.fPluginId, i) - paramRanges = self.host.get_parameter_ranges(self.fPluginId, i) - - if paramData['type'] != PARAMETER_INPUT: - continue - if paramData['hints'] & PARAMETER_IS_BOOLEAN: - continue - if paramData['hints'] & PARAMETER_IS_INTEGER: - continue - if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0: - continue - - paramName = getParameterShortName(paramInfo['name']) - - widget = PixmapDial(self, i) - widget.setPixmap(11) - widget.setLabel(paramName) - widget.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) - widget.setMinimum(paramRanges['min']) - widget.setMaximum(paramRanges['max']) - - if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0: - widget.setEnabled(False) - - self.ui.w_knobs.layout().insertWidget(index, widget) - index += 1 - - self.fParameterList.append([i, widget]) - - self.ui.dial_drywet.setIndex(PARAMETER_DRYWET) - self.ui.dial_drywet.setPixmap(13) - self.ui.dial_drywet.setLabel("Dry/Wet") - self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) - self.ui.dial_drywet.setMinimum(0.0) - self.ui.dial_drywet.setMaximum(1.0) - self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) + isBlack = bool(self.fSkinStyle == "calf_black") - self.ui.dial_vol.setIndex(PARAMETER_VOLUME) - self.ui.dial_vol.setPixmap(12) - self.ui.dial_vol.setLabel("Volume") - self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) - self.ui.dial_vol.setMinimum(0.0) - self.ui.dial_vol.setMaximum(1.27) - self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) - - self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet]) - self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol]) - - # ------------------------------------------------------------- - - self.b_enable = self.ui.b_enable - self.b_gui = self.ui.b_gui - self.b_edit = self.ui.b_edit - - self.label_name = self.ui.label_name - - self.led_control = self.ui.led_control - self.led_midi = self.ui.led_midi - self.led_audio_in = self.ui.led_audio_in - self.led_audio_out = self.ui.led_audio_out - - self.line = self.ui.line - - self.peak_in = self.ui.peak_in - self.peak_out = self.ui.peak_out - - self.ready() - - self.customContextMenuRequested.connect(self.slot_showDefaultCustomMenu) - - #------------------------------------------------------------------ - - def getFixedHeight(self): - return 28 if self.fIsCollapsed else 79 - - #------------------------------------------------------------------ - - def paintEvent(self, event): painter = QPainter(self) painter.setBrush(Qt.transparent) - painter.setPen(QPen(QColor(42, 42, 42), 1)) - painter.drawRect(0, 1, self.width()-1, 79-3) + painter.setPen(QPen(QColor(20, 20, 20) if isBlack else QColor(75, 86, 99), 1)) + painter.drawRect(0, 1, self.width()-1, self.height()-3) - painter.setPen(QPen(QColor(60, 60, 60), 1)) + painter.setPen(QPen(QColor(45, 45, 45) if isBlack else QColor(86, 99, 114), 1)) painter.drawLine(0, 0, self.width(), 0) AbstractPluginSlot.paintEvent(self, event) @@ -1482,8 +1509,8 @@ class PluginSlot_OpenAV(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ class PluginSlot_Nekobi(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) #self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget() #self.ui.setupUi(self) @@ -1498,16 +1525,6 @@ class PluginSlot_Nekobi(AbstractPluginSlot): self.fPixmapRight = QPixmap(":/bitmaps/background_nekobi_right.png") self.fPixmapRightRect = QRectF(0, 0, self.fPixmapRight.width(), self.fPixmapRight.height()) - #self.setStyleSheet(""" - #PluginSlot_Nekobi#PluginWidget { - #background-image: url(:/bitmaps/background_nekobi.png); - #background-repeat: repeat-xy; - #} - #QLabel#label_name { - #color: #BBB; - #} - #""") - #------------------------------------------------------------------ def getFixedHeight(self): @@ -1534,36 +1551,15 @@ class PluginSlot_Nekobi(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ class PluginSlot_SF2(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) self.ui = ui_carla_plugin_sf2.Ui_PluginWidget() self.ui.setupUi(self) - # ------------------------------------------------------------- - # Set-up GUI - - #labelFont = self.ui.label_name.font() - #labelFont.setBold(True) - #labelFont.setPointSize(9) - #self.ui.label_name.setFont(labelFont) - - self.setStyleSheet(""" - PluginSlot_SF2#PluginWidget { - background-image: url(:/bitmaps/background_3bandeq.png); - background-repeat: repeat-xy; - } - QLabel#label_name { - color: #BBB; - } - """) - - self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") - # ------------------------------------------------------------- # Set-up parameters - parameterCount = self.host.get_parameter_count(self.fPluginId) if not self.fIsCollapsed else 0 + parameterCount = self.host.get_parameter_count(self.fPluginId) index = 0 for i in range(parameterCount): @@ -1621,8 +1617,6 @@ class PluginSlot_SF2(AbstractPluginSlot): self.led_midi = self.ui.led_midi self.led_audio_out = self.ui.led_audio_out - self.line = self.ui.line - self.peak_out = self.ui.peak_out self.ready() @@ -1632,7 +1626,7 @@ class PluginSlot_SF2(AbstractPluginSlot): #------------------------------------------------------------------ def getFixedHeight(self): - return 79 + return 80 #------------------------------------------------------------------ @@ -1641,7 +1635,7 @@ class PluginSlot_SF2(AbstractPluginSlot): painter.setBrush(Qt.transparent) painter.setPen(QPen(QColor(42, 42, 42), 1)) - painter.drawRect(0, 1, self.width()-1, 79-3) + painter.drawRect(0, 1, self.width()-1, self.height()-3) painter.setPen(QPen(QColor(60, 60, 60), 1)) painter.drawLine(0, 0, self.width(), 0) @@ -1651,45 +1645,15 @@ class PluginSlot_SF2(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ class PluginSlot_ZynFX(AbstractPluginSlot): - def __init__(self, parent, host, pluginId): - AbstractPluginSlot.__init__(self, parent, host, pluginId) + def __init__(self, parent, host, pluginId, skinStyle): + AbstractPluginSlot.__init__(self, parent, host, pluginId, skinStyle) self.ui = ui_carla_plugin_zynfx.Ui_PluginWidget() self.ui.setupUi(self) - # ------------------------------------------------------------- - # Set-up GUI - - self.setStyleSheet(""" - PluginSlot_ZynFX#PluginWidget { - background-image: url(:/bitmaps/background_zynfx.png); - background-repeat: repeat-xy; - border: 2px; - } - QLabel#label_name, QLabel#label_presets { - color: #BBB; - } - """) - - self.ui.b_enable.setPixmaps(":/bitmaps/button_off.png", ":/bitmaps/button_on.png", ":/bitmaps/button_off.png") - self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") - - labelFont = self.ui.label_name.font() - labelFont.setBold(True) - labelFont.setPointSize(9) - self.ui.label_name.setFont(labelFont) - - presetFont = self.ui.label_presets.font() - presetFont.setBold(True) - presetFont.setPointSize(8) - self.ui.label_presets.setFont(presetFont) - - self.ui.peak_in.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) - self.ui.peak_out.setMeterStyle(DigitalPeakMeter.STYLE_OPENAV) - # ------------------------------------------------------------- # Set-up parameters - parameterCount = self.host.get_parameter_count(self.fPluginId) if not self.fIsCollapsed else 0 + parameterCount = self.host.get_parameter_count(self.fPluginId) index = 0 for i in range(parameterCount): @@ -1701,8 +1665,6 @@ class PluginSlot_ZynFX(AbstractPluginSlot): continue if paramData['hints'] & PARAMETER_IS_BOOLEAN: continue - if paramData['hints'] & PARAMETER_IS_INTEGER: - continue if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0: continue @@ -1783,29 +1745,29 @@ class PluginSlot_ZynFX(AbstractPluginSlot): if (paramData['hints'] & PARAMETER_IS_ENABLED) == 0: widget.setEnabled(False) - self.ui.w_knobs.layout().insertWidget(index, widget) + self.ui.w_knobs_left.layout().insertWidget(index, widget) index += 1 self.fParameterList.append([i, widget]) - self.ui.dial_drywet.setIndex(PARAMETER_DRYWET) - self.ui.dial_drywet.setPixmap(5) - self.ui.dial_drywet.setLabel("Wet") - self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) - self.ui.dial_drywet.setMinimum(0.0) - self.ui.dial_drywet.setMaximum(1.0) - self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) - - self.ui.dial_vol.setIndex(PARAMETER_VOLUME) - self.ui.dial_vol.setPixmap(5) - self.ui.dial_vol.setLabel("Vol") - self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) - self.ui.dial_vol.setMinimum(0.0) - self.ui.dial_vol.setMaximum(1.27) - self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) - - self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet]) - self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol]) + #self.ui.dial_drywet.setIndex(PARAMETER_DRYWET) + #self.ui.dial_drywet.setPixmap(5) + #self.ui.dial_drywet.setLabel("Wet") + #self.ui.dial_drywet.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + #self.ui.dial_drywet.setMinimum(0.0) + #self.ui.dial_drywet.setMaximum(1.0) + #self.ui.dial_drywet.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_DRYWET) + + #self.ui.dial_vol.setIndex(PARAMETER_VOLUME) + #self.ui.dial_vol.setPixmap(5) + #self.ui.dial_vol.setLabel("Vol") + #self.ui.dial_vol.setCustomPaintMode(PixmapDial.CUSTOM_PAINT_MODE_NO_GRADIENT) + #self.ui.dial_vol.setMinimum(0.0) + #self.ui.dial_vol.setMaximum(1.27) + #self.ui.dial_vol.setVisible(self.fPluginInfo['hints'] & PLUGIN_CAN_VOLUME) + + #self.fParameterList.append([PARAMETER_DRYWET, self.ui.dial_drywet]) + #self.fParameterList.append([PARAMETER_VOLUME, self.ui.dial_vol]) # ------------------------------------------------------------- # Set-up MIDI programs @@ -1835,19 +1797,19 @@ class PluginSlot_ZynFX(AbstractPluginSlot): # ------------------------------------------------------------- self.b_enable = self.ui.b_enable + self.b_gui = self.ui.b_gui self.b_edit = self.ui.b_edit self.cb_presets = self.ui.cb_presets - self.label_name = self.ui.label_name + self.label_name = self.ui.label_name + self.label_presets = self.ui.label_presets self.led_control = self.ui.led_control self.led_midi = self.ui.led_midi self.led_audio_in = self.ui.led_audio_in self.led_audio_out = self.ui.led_audio_out - self.line = self.ui.line - self.peak_in = self.ui.peak_in self.peak_out = self.ui.peak_out @@ -1859,7 +1821,7 @@ class PluginSlot_ZynFX(AbstractPluginSlot): #------------------------------------------------------------------ def getFixedHeight(self): - return 30 if self.fIsCollapsed else 79 + return 80 #------------------------------------------------------------------ @@ -1877,39 +1839,60 @@ class PluginSlot_ZynFX(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ -def createPluginSlot(parent, host, pluginId, useSkins): - if not useSkins: - return PluginSlot_Default(parent, host, pluginId) - +def getSkinStyle(host, pluginId): pluginInfo = host.get_plugin_info(pluginId) pluginName = host.get_real_plugin_name(pluginId) - pluginLabel = pluginInfo['label'] + pluginLabel = pluginInfo['label'].lower() pluginMaker = pluginInfo['maker'] uniqueId = pluginInfo['uniqueId'] - #pluginIcon = pluginInfo['iconName'] - + # Samplers + if pluginInfo['type'] == PLUGIN_GIG: + return "gig" if pluginInfo['type'] == PLUGIN_SF2: - return PluginSlot_SF2(parent, host, pluginId) - - if pluginMaker == "OpenAV Productions": - return PluginSlot_OpenAV(parent, host, pluginId) + return "sf2" + if pluginInfo['type'] == PLUGIN_SFZ: + return "sfz" + # ZynFX if pluginInfo['type'] == PLUGIN_INTERNAL: if pluginLabel.startswith("zyn") and pluginInfo['category'] != PLUGIN_CATEGORY_SYNTH: - return PluginSlot_ZynFX(parent, host, pluginId) + return "zynfx" - elif pluginInfo['type'] == PLUGIN_LADSPA: - if pluginLabel.startswith("Zyn") and pluginMaker.startswith("Josep Andreu"): - return PluginSlot_ZynFX(parent, host, pluginId) + if pluginInfo['type'] == PLUGIN_LADSPA: + if pluginLabel.startswith("zyn") and pluginMaker.startswith("Josep Andreu"): + return "zynfx" + # Groups if pluginName.split(" ", 1)[0].lower() == "calf": - return PluginSlot_Calf(parent, host, pluginId) + return "calf_black" if "mono" in pluginLabel else "calf_blue" + if pluginLabel.startswith("http://portalmod.com/") or pluginLabel.startswith("http://plugin.org.uk/swh-plugins/"): + return "mod" + if pluginMaker == "OpenAV Productions": + return "openav" + + # DISTRHO Plugins + if pluginMaker.startswith("falkTX, ") or pluginMaker == "DISTRHO": + return pluginLabel + + return "default" + +def createPluginSlot(parent, host, pluginId, options): + if not options['useSkins']: + return PluginSlot_Default(parent, host, pluginId) + + skinStyle = getSkinStyle(host, pluginId) + + if options['compact'] or "compact" in skinStyle: + return PluginSlot_Compact(parent, host, pluginId, skinStyle) + + if "calf" in skinStyle: + return PluginSlot_Calf(parent, host, pluginId, skinStyle) - #if pluginName.lower() == "nekobi": - #return PluginSlot_Nekobi(parent, pluginId) + if skinStyle == "zynfx": + return PluginSlot_ZynFX(parent, host, pluginId, skinStyle) - return PluginSlot_BasicFX(parent, host, pluginId) + return PluginSlot_BasicFX(parent, host, pluginId, skinStyle) # ------------------------------------------------------------------------------------------------------------ # Main Testing @@ -1930,7 +1913,8 @@ if __name__ == '__main__': #host.add_plugin(BINARY_NATIVE, PLUGIN_LV2, "", "", "http://calf.sourceforge.net/plugins/Compressor", 0, None, 0x0) host.set_active(0, True) - gui = createPluginSlot(None, host, 0, True) + #gui = createPluginSlot(None, host, 0, True) + gui = PluginSlot_Compact(None, host, 0, "default") gui.testTimer() gui.show() diff --git a/source/widgets/digitalpeakmeter.py b/source/widgets/digitalpeakmeter.py index cbd2c120b..2c8598843 100644 --- a/source/widgets/digitalpeakmeter.py +++ b/source/widgets/digitalpeakmeter.py @@ -24,6 +24,8 @@ from carla_config import * # ------------------------------------------------------------------------------------------------------------ # Imports (Global) +from math import sqrt + if config_UseQt5: from PyQt5.QtCore import qCritical, Qt, QTimer, QSize from PyQt5.QtGui import QColor, QLinearGradient, QPainter, QPen, QPixmap @@ -323,13 +325,9 @@ class DigitalPeakMeter(QWidget): # draw levels for level in self.fChannelData: - if level == 0.0: - meterPos += meterSize - continue - - blevel = int(level*26.0)*3 - - painter.drawPixmap(5, meterPos, blevel, 4, self.fMeterPixmaps[1], 0, 0, blevel, 4) + if level != 0.0: + blevel = int(sqrt(level)*26.0)*3 + painter.drawPixmap(5, meterPos, blevel, 4, self.fMeterPixmaps[1], 0, 0, blevel, 4) meterPos += meterSize def paintEvent(self, event): @@ -371,16 +369,13 @@ class DigitalPeakMeter(QWidget): # draw levels for level in self.fChannelData: if level == 0.0: - meterPos += meterSize+meterPad - continue - - if self.fMeterOrientation == self.HORIZONTAL: - painter.drawRect(0, meterPos, int(level * float(width)), meterSize) - meterPos += meterSize+meterPad - + pass + elif self.fMeterOrientation == self.HORIZONTAL: + painter.drawRect(0, meterPos, int(sqrt(level) * float(width)), meterSize) elif self.fMeterOrientation == self.VERTICAL: - painter.drawRect(meterPos, height - int(level * float(height)), meterSize, height) - meterPos += meterSize+meterPad + painter.drawRect(meterPos, height - int(sqrt(level) * float(height)), meterSize, height) + + meterPos += meterSize+meterPad if not self.fMeterLinesEnabled: return diff --git a/source/widgets/racklistwidget.py b/source/widgets/racklistwidget.py index 5e4b28673..57df287e8 100644 --- a/source/widgets/racklistwidget.py +++ b/source/widgets/racklistwidget.py @@ -42,6 +42,7 @@ from carla_skin import * class RackListItem(QListWidgetItem): kRackItemType = QListWidgetItem.UserType + 1 + kMinimumWidth = 620 def __init__(self, parent, pluginId, useSkins): QListWidgetItem.__init__(self, parent, self.kRackItemType) @@ -59,11 +60,15 @@ class RackListItem(QListWidgetItem): self.fParent = parent self.fPluginId = pluginId - self.fUseSkins = useSkins self.fWidget = None + self.fOptions = { + 'compact': False, + 'useSkins': useSkins + } + self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) - #self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled|Qt.ItemIsDropEnabled) + #self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled) # ---------------------------------------------------------------------------------------------------- # Set-up GUI @@ -76,17 +81,21 @@ class RackListItem(QListWidgetItem): if self.fWidget is None: return - self.fWidget.fEditDialog.close() - self.fWidget.fEditDialog.setParent(None) - self.fWidget.fEditDialog.deleteLater() - del self.fWidget.fEditDialog + widget = self.fWidget + self.fWidget = None - self.fWidget.close() - self.fWidget.setParent(None) - self.fWidget.deleteLater() - del self.fWidget + self.fParent.customClearSelection() + self.fParent.setItemWidget(self, None) - self.fWidget = None + widget.fEditDialog.close() + widget.fEditDialog.setParent(None) + widget.fEditDialog.deleteLater() + del widget.fEditDialog + + widget.close() + widget.setParent(None) + widget.deleteLater() + del widget def getEditDialog(self): if self.fWidget is None: @@ -108,15 +117,24 @@ class RackListItem(QListWidgetItem): if self.fWidget is not None: self.fWidget.setPluginId(pluginId) + def setSelected(self, select): + if self.fWidget is not None: + self.fWidget.setSelected(select) + + QListWidgetItem.setSelected(self, select) + # -------------------------------------------------------------------------------------------------------- - def recreateWidget(self): + def recreateWidget(self, invertCompactOption = False): + if invertCompactOption: + self.fOptions['compact'] = not self.fOptions['compact'] + self.close() - self.fWidget = createPluginSlot(self.fParent, self.host, self.fPluginId, self.fUseSkins) + self.fWidget = createPluginSlot(self.fParent, self.host, self.fPluginId, self.fOptions) self.fWidget.setFixedHeight(self.fWidget.getFixedHeight()) - self.setSizeHint(QSize(620, self.fWidget.getFixedHeight())) + self.setSizeHint(QSize(self.kMinimumWidth, self.fWidget.getFixedHeight())) self.fParent.setItemWidget(self, self.fWidget) @@ -143,10 +161,15 @@ class RackListWidget(QListWidget): if not WINDOWS: exts.append(".so") - self.fSupportedExtensions = tuple(i.replace("*","") for i in exts) + self.fSupportedExtensions = tuple(i.replace("*","").lower() for i in exts) + self.fLastSelectedItem = None self.fWasLastDragValid = False - self.setMinimumWidth(640) + self.fPixmapL = QPixmap(":/bitmaps/rack_interior_left.png") + self.fPixmapR = QPixmap(":/bitmaps/rack_interior_right.png") + self.fPixmapWidth = self.fPixmapL.width() + + self.setMinimumWidth(RackListItem.kMinimumWidth) self.setSelectionMode(QAbstractItemView.SingleSelection) self.setSortingEnabled(False) @@ -158,11 +181,6 @@ class RackListWidget(QListWidget): 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 createItem(self, pluginId, useSkins): @@ -173,13 +191,18 @@ class RackListWidget(QListWidget): # -------------------------------------------------------------------------------------------------------- + def customClearSelection(self): + self.setCurrentRow(-1) + self.clearSelection() + self.clearFocus() + 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")): + if MACOS and filename.lower().endswith((".vst", ".vst3")): return True elif os.path.isfile(filename): @@ -264,9 +287,9 @@ class RackListWidget(QListWidget): # -------------------------------------------------------------------------------------------------------- def mousePressEvent(self, event): - if self.itemAt(event.pos()) is None: + if self.itemAt(event.pos()) is None and self.currentRow() != -1: event.accept() - self.setCurrentRow(-1) + self.customClearSelection() return QListWidget.mousePressEvent(self, event) @@ -277,4 +300,19 @@ class RackListWidget(QListWidget): painter.drawTiledPixmap(self.width()-self.fPixmapWidth-2, 0, self.fPixmapWidth, self.height(), self.fPixmapR) QListWidget.paintEvent(self, event) + # -------------------------------------------------------------------------------------------------------- + + def selectionChanged(self, selected, deselected): + for index in deselected.indexes(): + item = self.itemFromIndex(index) + if item is not None: + item.setSelected(False) + + for index in selected.indexes(): + item = self.itemFromIndex(index) + if item is not None: + item.setSelected(True) + + QListWidget.selectionChanged(self, selected, deselected) + # ------------------------------------------------------------------------------------------------------------