Browse Source

Rework calf skin a bit, add custom meters; Misc changes to basefx

tags/1.9.6
falkTX 10 years ago
parent
commit
ae913d80c7
10 changed files with 452 additions and 309 deletions
  1. BIN
      resources/bitmaps/button_calf3.png
  2. BIN
      resources/bitmaps/button_calf3_down.png
  3. BIN
      resources/bitmaps/meter_calf_off.png
  4. BIN
      resources/bitmaps/meter_calf_on.png
  5. +4
    -1
      resources/resources.qrc
  6. +94
    -87
      resources/ui/carla_plugin_basic_fx.ui
  7. +253
    -202
      resources/ui/carla_plugin_calf.ui
  8. +5
    -1
      source/carla_host.py
  9. +34
    -8
      source/carla_skin.py
  10. +62
    -10
      source/widgets/digitalpeakmeter.py

BIN
resources/bitmaps/button_calf3.png View File

Before After
Width: 30  |  Height: 20  |  Size: 848B

BIN
resources/bitmaps/button_calf3_down.png View File

Before After
Width: 30  |  Height: 20  |  Size: 798B

BIN
resources/bitmaps/meter_calf_off.png View File

Before After
Width: 100  |  Height: 12  |  Size: 928B

BIN
resources/bitmaps/meter_calf_on.png View File

Before After
Width: 78  |  Height: 4  |  Size: 785B

+ 4
- 1
resources/resources.qrc View File

@@ -59,8 +59,10 @@
<file>bitmaps/background_zynfx.png</file>
<file>bitmaps/button_calf1.png</file>
<file>bitmaps/button_calf2.png</file>
<file>bitmaps/button_calf3.png</file>
<file>bitmaps/button_calf1_down.png</file>
<file>bitmaps/button_calf2_down.png</file>
<file>bitmaps/button_calf3_down.png</file>
<file>bitmaps/button_calf1_hover.png</file>
<file>bitmaps/button_calf2_hover.png</file>
<file>bitmaps/button_distrho.png</file>
@@ -116,8 +118,9 @@

<file>bitmaps/led_calf_off.png</file>
<file>bitmaps/led_calf_on.png</file>

<file>bitmaps/logo_calf.png</file>
<file>bitmaps/meter_calf_off.png</file>
<file>bitmaps/meter_calf_on.png</file>

<file>bitmaps/rack_interior_left.png</file>
<file>bitmaps/rack_interior_right.png</file>


+ 94
- 87
resources/ui/carla_plugin_basic_fx.ui View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<width>338</width>
<height>71</height>
</rect>
</property>
@@ -33,7 +33,7 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>1</number>
</property>
@@ -195,92 +195,99 @@
</spacer>
</item>
<item>
<widget class="LEDButton" name="led_control">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_midi">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_audio_in">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_audio_out">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
<layout class="QHBoxLayout" name="layout_leds">
<property name="spacing">
<number>1</number>
</property>
</widget>
<item>
<widget class="LEDButton" name="led_control">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_midi">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_audio_in">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_audio_out">
<property name="minimumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_5">


+ 253
- 202
resources/ui/carla_plugin_calf.ui View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>68</height>
<width>563</width>
<height>89</height>
</rect>
</property>
<property name="contextMenuPolicy">
@@ -22,48 +22,63 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>8</number>
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>8</number>
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
<number>2</number>
</property>
<item row="0" column="5">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
<number>3</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label_audio_in">
<widget class="PixmapButton" name="b_enable">
<property name="text">
<string>AUDIO IN</string>
<string>Enable</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_active">
<property name="text">
<string>On/Off</string>
</property>
</widget>
</item>
<item>
<widget class="DigitalPeakMeter" name="peak_in" native="true">
<property name="minimumSize">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>150</width>
<height>0</height>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_name">
<property name="font">
@@ -81,228 +96,264 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
<number>3</number>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<item>
<widget class="PixmapButton" name="b_gui">
<widget class="QLabel" name="label_midi">
<property name="text">
<string>GUI</string>
<string>MIDI</string>
</property>
<property name="checkable">
<bool>true</bool>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<widget class="PixmapButton" name="b_edit">
<widget class="LEDButton" name="led_midi">
<property name="minimumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Edit</string>
<string/>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="PixmapButton" name="b_remove">
<widget class="QLabel" name="label_audio_in">
<property name="text">
<string>Remove</string>
<string>AUDIO IN</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<widget class="DigitalPeakMeter" name="peak_in" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="3" rowspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_midi">
<property name="text">
<string>MIDI</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="LEDButton" name="led_midi">
<property name="minimumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>40</height>
</size>
</property>
</spacer>
<item>
<widget class="QLabel" name="label_audio_out">
<property name="text">
<string>AUDIO OUT</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<widget class="DigitalPeakMeter" name="peak_out" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="0" column="6">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<item>
<widget class="Line" name="line">
<property name="lineWidth">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_audio_out">
<property name="text">
<string>AUDIO OUT</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<widget class="DigitalPeakMeter" name="peak_out" native="true">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1" rowspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
<property name="midLineWidth">
<number>1</number>
</property>
</spacer>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="1" column="4" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="w_knobs" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
<property name="bottomMargin">
<number>0</number>
</property>
</spacer>
<item>
<widget class="PixmapButton" name="b_gui">
<property name="text">
<string>GUI</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="PixmapButton" name="b_edit">
<property name="text">
<string>Edit</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="PixmapButton" name="b_remove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_logo">
<property name="minimumSize">
<size>
<width>71</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>71</width>
<height>30</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/bitmaps/logo_calf.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="w_knobs" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_logo">
<property name="minimumSize">
<size>
<width>71</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>71</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/bitmaps/logo_calf.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>


+ 5
- 1
source/carla_host.py View File

@@ -1244,7 +1244,11 @@ class HostWindow(QMainWindow):

showTimePanel = settings.value("ShowTimePanel", True, type=bool)
self.ui.act_settings_show_time_panel.setChecked(showTimePanel)
self.ui.panelTime.setVisible(showTimePanel)

if showTimePanel:
QTimer.singleShot(0, self.ui.panelTime.show)
else:
self.ui.panelTime.hide()

showToolbar = settings.value("ShowToolbar", True, type=bool)
self.ui.act_settings_show_toolbar.setChecked(showToolbar)


+ 34
- 8
source/carla_skin.py View File

@@ -275,6 +275,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta):
self.b_remove.clicked.connect(self.slot_removePlugin)

if self.label_name is not None:
self.label_name.setEnabled(self.fIsActive)
self.label_name.setText(self.fPluginInfo['name'])

if self.label_type is not None:
@@ -371,6 +372,9 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta):
self.fEditDialog.clearNotes()
self.midiActivityChanged(False)

if self.label_name is not None:
self.label_name.setEnabled(self.fIsActive)

# called from rack, checks if param is possible first
def setInternalParameter(self, parameterId, value):
if parameterId <= PARAMETER_MAX or parameterId >= PARAMETER_NULL:
@@ -964,6 +968,9 @@ class PluginSlot_BasicFX(AbstractPluginSlot):
self.ui = ui_carla_plugin_basic_fx.Ui_PluginWidget()
self.ui.setupUi(self)

if self.fPluginInfo['type'] == PLUGIN_INTERNAL and self.fPluginInfo['label'] == "midifile":
self.fIsCollapsed = True

# -------------------------------------------------------------
# Set-up GUI

@@ -1009,6 +1016,9 @@ class PluginSlot_BasicFX(AbstractPluginSlot):
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")
@@ -1021,11 +1031,15 @@ class PluginSlot_BasicFX(AbstractPluginSlot):
else:
self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png")

#if self.fIsCollapsed:
#self.ui.w_knobs.hide()
#self.ui.horizontalLayout_2.setContentsMargins(0,0,0,0)
#self.ui.horizontalLayout_2.setSpacing(0)
#self.ui.horizontalLayout_2.SetMaximumSize(0,0)
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")

# -------------------------------------------------------------
# Set-up parameters
@@ -1145,7 +1159,7 @@ class PluginSlot_BasicFX(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.getFixedHeight()-3)

painter.setPen(QPen(QColor(60, 60, 60), 1))
painter.drawLine(0, 0, self.width(), 0)
@@ -1174,7 +1188,7 @@ class PluginSlot_Calf(AbstractPluginSlot):
self.fButtonFont.setPointSize(8)

# Use black for mono plugins
self.fBackgroundBlack = audioCount['ins'] == 1
self.fBackgroundBlack = bool("mono" in self.fPluginInfo["label"].lower())

self.fButtonColorOn = QColor( 18, 41, 87)
self.fButtonColorOff = QColor(150, 150, 150)
@@ -1186,6 +1200,9 @@ class PluginSlot_Calf(AbstractPluginSlot):
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;
@@ -1193,6 +1210,9 @@ class PluginSlot_Calf(AbstractPluginSlot):
}
""" % ("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")
@@ -1210,6 +1230,9 @@ class PluginSlot_Calf(AbstractPluginSlot):
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()
@@ -1272,6 +1295,7 @@ class PluginSlot_Calf(AbstractPluginSlot):

# -------------------------------------------------------------

self.b_enable = self.ui.b_enable
self.b_gui = self.ui.b_gui
self.b_edit = self.ui.b_edit
self.b_remove = self.ui.b_remove
@@ -1279,6 +1303,8 @@ 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

@@ -1291,7 +1317,7 @@ class PluginSlot_Calf(AbstractPluginSlot):
#------------------------------------------------------------------

def getFixedHeight(self):
return 88
return 94 if max(self.peak_in.channelCount(), self.peak_out.channelCount()) < 2 else 106

#------------------------------------------------------------------



+ 62
- 10
source/widgets/digitalpeakmeter.py View File

@@ -26,11 +26,11 @@ from carla_config import *

if config_UseQt5:
from PyQt5.QtCore import qCritical, Qt, QTimer, QSize
from PyQt5.QtGui import QColor, QLinearGradient, QPainter, QPen
from PyQt5.QtGui import QColor, QLinearGradient, QPainter, QPen, QPixmap
from PyQt5.QtWidgets import QWidget
else:
from PyQt4.QtCore import qCritical, Qt, QTimer, QSize
from PyQt4.QtGui import QColor, QLinearGradient, QPainter, QPen, QWidget
from PyQt4.QtGui import QColor, QLinearGradient, QPainter, QPen, QPixmap, QWidget

# ------------------------------------------------------------------------------------------------------------
# Widget Class
@@ -48,6 +48,7 @@ class DigitalPeakMeter(QWidget):
STYLE_DEFAULT = 1
STYLE_OPENAV = 2
STYLE_RNCBC = 3
STYLE_CALF = 4

# --------------------------------------------------------------------------------------------------------

@@ -71,6 +72,7 @@ class DigitalPeakMeter(QWidget):

self.fMeterBackground = QColor("#070707")
self.fMeterGradient = QLinearGradient(0, 0, 0, 0)
self.fMeterPixmaps = ()

self.fSmoothMultiplier = 2

@@ -96,6 +98,13 @@ class DigitalPeakMeter(QWidget):
self.fChannelData.append(0.0)
self.fLastChannelData.append(0.0)

if self.fMeterStyle == self.STYLE_CALF:
if self.fChannelCount > 0:
self.setFixedSize(100, 12*self.fChannelCount)
else:
self.setMinimumSize(0, 0)
self.setMaximumSize(9999, 9999)

# --------------------------------------------------------------------------------------------------------

def meterColor(self):
@@ -155,7 +164,7 @@ class DigitalPeakMeter(QWidget):
if self.fMeterStyle == style:
return

if style not in (self.STYLE_DEFAULT, self.STYLE_OPENAV, self.STYLE_RNCBC):
if style not in (self.STYLE_DEFAULT, self.STYLE_OPENAV, self.STYLE_RNCBC, self.STYLE_CALF):
return qCritical("DigitalPeakMeter::setMeterStyle(%i) - invalid style" % style)

if style == self.STYLE_DEFAULT:
@@ -164,6 +173,17 @@ class DigitalPeakMeter(QWidget):
self.fMeterBackground = QColor("#1A1A1A")
elif style == self.STYLE_RNCBC:
self.fMeterBackground = QColor("#070707")
elif style == self.STYLE_CALF:
self.fMeterBackground = QColor("#000")

if style == self.STYLE_CALF:
self.fMeterPixmaps = (QPixmap(":/bitmaps/meter_calf_off.png"), QPixmap(":/bitmaps/meter_calf_on.png"))
if self.fChannelCount > 0:
self.setFixedSize(100, 12*self.fChannelCount)
else:
self.fMeterPixmaps = ()
self.setMinimumSize(0, 0)
self.setMaximumSize(9999, 9999)

self.fMeterStyle = style

@@ -235,10 +255,6 @@ class DigitalPeakMeter(QWidget):
self.fMeterGradient.setColorAt(0.8, self.fMeterColorBase)
self.fMeterGradient.setColorAt(1.0, self.fMeterColorBase)

elif self.fMeterStyle == self.STYLE_OPENAV:
self.fMeterGradient.setColorAt(0.0, self.fMeterColorBase)
self.fMeterGradient.setColorAt(1.0, self.fMeterColorBase)

elif self.fMeterStyle == self.STYLE_RNCBC:
if self.fMeterColor == self.COLOR_BLUE:
c1 = QColor(40,160,160)
@@ -265,6 +281,10 @@ class DigitalPeakMeter(QWidget):
self.fMeterGradient.setColorAt(0.8, c1)
self.fMeterGradient.setColorAt(1.0, c1)

elif self.fMeterStyle in (self.STYLE_OPENAV, self.STYLE_CALF):
self.fMeterGradient.setColorAt(0.0, self.fMeterColorBase)
self.fMeterGradient.setColorAt(1.0, self.fMeterColorBase)

self.updateGrandientFinalStop()

def updateGrandientFinalStop(self):
@@ -284,7 +304,38 @@ class DigitalPeakMeter(QWidget):

# --------------------------------------------------------------------------------------------------------

def drawCalf(self, event):
painter = QPainter(self)
event.accept()

# no channels, draw black
if self.fChannelCount == 0:
painter.setPen(QPen(Qt.black, 2))
painter.setBrush(Qt.black)
painter.drawRect(0, 0, self.width(), self.height())
return

for i in range(self.fChannelCount):
painter.drawPixmap(0, 12*i, self.fMeterPixmaps[0])

meterPos = 4
meterSize = 12

# 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)
meterPos += meterSize

def paintEvent(self, event):
if self.fMeterStyle == self.STYLE_CALF:
return self.drawCalf(event)

painter = QPainter(self)
event.accept()

@@ -304,9 +355,6 @@ class DigitalPeakMeter(QWidget):
meterSize = (height if self.fMeterOrientation == self.HORIZONTAL else width)/self.fChannelCount

# set pen/brush for levels
painter.setPen(QPen(self.fMeterBackground, 0))
painter.setBrush(self.fMeterGradient)

if self.fMeterStyle == self.STYLE_OPENAV:
colorTrans = QColor(self.fMeterColorBase)
colorTrans.setAlphaF(0.5)
@@ -316,6 +364,10 @@ class DigitalPeakMeter(QWidget):
meterPad += 2
meterSize -= 2

else:
painter.setPen(QPen(self.fMeterBackground, 0))
painter.setBrush(self.fMeterGradient)

# draw levels
for level in self.fChannelData:
if level == 0.0:


Loading…
Cancel
Save