From c4e0adad1b930e71fe9b12c3dff420ddf8e575cf Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 5 Jan 2014 19:07:48 +0000 Subject: [PATCH] More calf skin work, looking good --- resources/bitmaps/led_calf_off.png | Bin 0 -> 554 bytes resources/bitmaps/led_calf_on.png | Bin 0 -> 698 bytes resources/resources.qrc | 7 +++++ resources/ui/carla_plugin_calf.ui | 43 ++++++++++++++++++++++++++--- source/carla_skin.py | 33 ++++++++++++++++++---- source/widgets/ledbutton.py | 26 +++++++++++++---- source/widgets/pixmapbutton.py | 23 +++++++++++++-- 7 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 resources/bitmaps/led_calf_off.png create mode 100644 resources/bitmaps/led_calf_on.png diff --git a/resources/bitmaps/led_calf_off.png b/resources/bitmaps/led_calf_off.png new file mode 100644 index 0000000000000000000000000000000000000000..f89e4ea59bff455e0972a2d04e5be8ff8c1ca836 GIT binary patch literal 554 zcmV+_0@eMAP)P000>X1^@s6#OZ}&00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3labT3lag+-G2N4000McNliru-T?&?2{Cct!Vmxe0k=s+ zK~zY`-IhC!+dvG4zj*|ky@_jICU?joQsoXgLoVameTo$6{hA?}f}E9hEiWtt-Xa4K zkOb-f=AR)sN`Ud;Q31Bw?ZW`O-OeGcwZ}V|L-zaqKZ|ZQoA)6AU%q~Wlp!S#@(no! zvj_!Ke*XA=rMCzawhXm?>9F8T^5m*y^Vg;Lx=&eM`v4q-qfU<%gPI5|VAP!kjhkU=i7 zS{>9JAOgKPV9lN!P7R8IWT+L2LP;I~l0ej>caR3s9eyw5*Y7`2pP+t*`V60*p*AQ_ z0XaiIK|4Y}`gK3Q54jp6EnkJaWRG9#a@?x;1q!G{bdZbJibZxw^Jm(p_pqD2b{V4L zqS`<+^c1zwrj3^ldWm-iY?TxBkA{O{U^R*}mQ(x8kr4U30wUtIp`++z)&ZC*TqAWY zCS_|N7Ik15Qp`G+HxRi_3|#}!9&MyRRR literal 0 HcmV?d00001 diff --git a/resources/bitmaps/led_calf_on.png b/resources/bitmaps/led_calf_on.png new file mode 100644 index 0000000000000000000000000000000000000000..26b8b4cbf51605066555be85862aad89a840999c GIT binary patch literal 698 zcmV;r0!96aP)P000>X1^@s6#OZ}&00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3labT3lag+-G2N4000McNliru-T?&?3N>AzRmuPW0!K+i zK~zY`-ImL7-Bt{SKLCf6oHU}f+DHrOARVOu7vUnbRt0GwmUvzOvN*hoC$=;9PDWk? zGuV*e`S{~OP=Mr}tpGeeKE4~^>FH@f#u)Ff4T5I{qog$--I*~R25Z4tRO`ZGmsOKxc~?mNvIMcM6UZ+ zLKIcQY$?%Fkj;=&Nk)=G2__kddlKS=+yq%l%naQ&^zMWdU62{1Dba-R#B~Au9EPiv zm@2jvbT8P44cRwjJ0T;;KJbL_z{kWzac)pj0TZQ|Vt0n!@92jO-E7r;IH7`j;9Z%b zINYYBrcgw1Q>+xqT|s}^vHJ}GuY-tWwu0MWiZD~~$m=10e6DO}l>0*Qoh_466#IE! zkm<}!hC8zl=Fu6SEA!9#eaJs8!%3gZ=fwv(%31jF_w`F$ID~(H;=i&n$uY<_$kvHN znFVsLL;UE(QOVX<%oyvLIj)C9Z$veGH)Io##N5f3`c`;8{sKa=Q_to=+~!;ebT zdPBO7x^|g6IR{cZx*1~UFnSQf$uWpJ@U}ovZ&Z@uFb6p|q!hvm=;bYV>%3?KZ-ZzZ zzX|gCy4rITv=_7#Fa^;|kAnv>C($q7@z!sF9B+{51uf@3`SMdAK};tvyQD8Q-!l0T gKN89hu>TL_FJdF{OEaolJpcdz07*qoM6N<$f~2oJ=l}o! literal 0 HcmV?d00001 diff --git a/resources/resources.qrc b/resources/resources.qrc index c8f728b84..532648901 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -82,6 +82,7 @@ bitmaps/button_gui_hover2.png bitmaps/button_off.png bitmaps/button_on.png + bitmaps/dial_01.png bitmaps/dial_01d.png bitmaps/dial_02.png @@ -92,15 +93,21 @@ bitmaps/dial_04d.png bitmaps/dial_05.png bitmaps/dial_05d.png + bitmaps/kbd_h_classic.png bitmaps/kbd_h_orange.png bitmaps/kbd_v_classic.png bitmaps/kbd_v_orange.png + bitmaps/led_off.png bitmaps/led_blue.png bitmaps/led_green.png bitmaps/led_red.png bitmaps/led_yellow.png + + bitmaps/led_calf_off.png + bitmaps/led_calf_on.png + bitmaps/logo_calf.png bitmaps/canvas/frame_node_header.png diff --git a/resources/ui/carla_plugin_calf.ui b/resources/ui/carla_plugin_calf.ui index 623155830..ffbdd3a1d 100644 --- a/resources/ui/carla_plugin_calf.ui +++ b/resources/ui/carla_plugin_calf.ui @@ -6,7 +6,7 @@ 0 0 - 665 + 644 80 @@ -103,8 +103,29 @@ + + + 25 + 25 + + + + + 25 + 25 + + - M + + + + + 25 + 25 + + + + true @@ -139,7 +160,14 @@ - + + + + 150 + 0 + + + @@ -159,7 +187,14 @@ - + + + + 150 + 0 + + + diff --git a/source/carla_skin.py b/source/carla_skin.py index 399c7c614..e24dca3a3 100644 --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -19,7 +19,7 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt4.QtGui import QFrame +from PyQt4.QtGui import QFont, QFrame # ------------------------------------------------------------------------------------------------------------ # Imports (Custom) @@ -559,6 +559,13 @@ class PluginSlot_Calf(PluginSlot): self.fIsActive = False + self.fButtonFont = QFont() + self.fButtonFont.setBold(False) + self.fButtonFont.setPointSize(9) + + self.fButtonColorOn = QColor( 18, 41, 87) + self.fButtonColorOff = QColor(150, 150, 150) + # ------------------------------------------------------------- # Set-up GUI @@ -575,10 +582,18 @@ class PluginSlot_Calf(PluginSlot): 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_gui.setEnabled((self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI) != 0) + self.ui.b_edit.setTopText(self.tr("Edit"), self.fButtonColorOn, self.fButtonFont) + self.ui.b_remove.setTopText(self.tr("Remove"), self.fButtonColorOn, self.fButtonFont) - self.ui.led_midi.setColor(self.ui.led_midi.RED) - self.ui.led_midi.setEnabled(False) + if self.fPluginInfo['hints'] & PLUGIN_HAS_CUSTOM_UI: + self.ui.b_gui.setEnabled(True) + self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont) + else: + self.ui.b_gui.setEnabled(False) + self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont) + + self.ui.led_midi.setColor(self.ui.led_midi.CALF) + #self.ui.led_midi.setEnabled(False) self.ui.peak_in.setColor(self.ui.peak_in.GREEN) self.ui.peak_in.setChannels(self.fPeaksInputCount) @@ -606,12 +621,18 @@ class PluginSlot_Calf(PluginSlot): #------------------------------------------------------------------ def getFixedHeight(self): - return 80 + return 75 #------------------------------------------------------------------ def recheckPluginHints(self, hints): - self.ui.b_gui.setEnabled(hints & PLUGIN_HAS_CUSTOM_UI) + if hints & PLUGIN_HAS_CUSTOM_UI: + self.ui.b_gui.setEnabled(True) + self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOn, self.fButtonFont) + else: + self.ui.b_gui.setEnabled(False) + self.ui.b_gui.setTopText(self.tr("GUI"), self.fButtonColorOff, self.fButtonFont) + PluginSlot.recheckPluginHints(self, hints) def setName(self, name): diff --git a/source/widgets/ledbutton.py b/source/widgets/ledbutton.py index 04fb95dfa..ba4b37ff8 100644 --- a/source/widgets/ledbutton.py +++ b/source/widgets/ledbutton.py @@ -26,11 +26,14 @@ from PyQt4.QtGui import QPainter, QPixmap, QPushButton # Widget Class class LEDButton(QPushButton): + # normal OFF = 0 BLUE = 1 GREEN = 2 RED = 3 YELLOW = 4 + # extra + CALF = 5 def __init__(self, parent): QPushButton.__init__(self, parent) @@ -41,15 +44,20 @@ class LEDButton(QPushButton): self.setCheckable(True) self.setText("") - self.setColor(self.BLUE) - self.fLastColor = self.OFF self.fPixmap.load(":/bitmaps/led_off.png") + self.setColor(self.BLUE) + def setColor(self, color): self.fColor = color - size = 14 + self._loadPixmapNow() + + # Fix calf off + if color == self.CALF: + self.fPixmap.load(":/bitmaps/led_calf_off.png") + size = self.fPixmap.width() self.fPixmapRect = QRectF(0, 0, size, size) self.setMinimumSize(size, size) @@ -59,6 +67,12 @@ class LEDButton(QPushButton): painter = QPainter(self) event.accept() + self._loadPixmapNow() + + painter.drawPixmap(self.fPixmapRect, self.fPixmap, self.fPixmapRect) + + def _loadPixmapNow(self): + if self.isChecked(): if self.fLastColor != self.fColor: if self.fColor == self.OFF: @@ -71,13 +85,13 @@ class LEDButton(QPushButton): self.fPixmap.load(":/bitmaps/led_red.png") elif self.fColor == self.YELLOW: self.fPixmap.load(":/bitmaps/led_yellow.png") + elif self.fColor == self.CALF: + self.fPixmap.load(":/bitmaps/calf_on.png") else: return self.fLastColor = self.fColor elif self.fLastColor != self.OFF: - self.fPixmap.load(":/bitmaps/led_off.png") + self.fPixmap.load(":/bitmaps/led_calf_off.png" if self.fColor == self.CALF else ":/bitmaps/led_off.png") self.fLastColor = self.OFF - - painter.drawPixmap(self.fPixmapRect, self.fPixmap, self.fPixmapRect) diff --git a/source/widgets/pixmapbutton.py b/source/widgets/pixmapbutton.py index 2840409d6..382d75edf 100644 --- a/source/widgets/pixmapbutton.py +++ b/source/widgets/pixmapbutton.py @@ -19,8 +19,8 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt4.QtCore import QRectF -from PyQt4.QtGui import QPainter, QPixmap, QPushButton +from PyQt4.QtCore import QPointF, QRectF +from PyQt4.QtGui import QColor, QFont, QPainter, QPixmap, QPushButton # ------------------------------------------------------------------------------------------------------------ # Widget Class @@ -36,6 +36,10 @@ class PixmapButton(QPushButton): self.fIsHovered = False + self.fTopText = "" + self.fTopTextColor = QColor() + self.fTopTextFont = QFont() + self.setText("") def setPixmaps(self, normal, down, hover): @@ -51,6 +55,11 @@ class PixmapButton(QPushButton): self.setMinimumSize(width, height) self.setMaximumSize(width, height) + def setTopText(self, text, color, font): + self.fTopText = text + self.fTopTextColor = color + self.fTopTextFont = font + def enterEvent(self, event): self.fIsHovered = True QPushButton.enterEvent(self, event) @@ -77,3 +86,13 @@ class PixmapButton(QPushButton): else: painter.drawPixmap(self.fPixmapRect, self.fPixmapNormal, self.fPixmapRect) + + if not self.fTopText: + return + + painter.save() + painter.setPen(self.fTopTextColor) + painter.setBrush(self.fTopTextColor) + painter.setFont(self.fTopTextFont) + painter.drawText(QPointF(10, 16), self.fTopText) + painter.restore()