Squashed commit of the following: committags/v2.1-alpha1-winvst0449cd63f7
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:19:23 2018 +0500 carla skin: fancy item selection commit84a7b527a7
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 02:10:49 2018 +0500 carla skin: drawOutline: fixed positioning and optimization commit30681d1523
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Oct 5 01:20:53 2018 +0500 carla skin: drawOutline: set brush only once commit63d2ab2e21
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Thu Oct 4 00:10:39 2018 +0500 carla skin: more neat QColor to tuple conversion commit2137b78109
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 3 16:35:48 2018 +0500 rack item: Skin-independent colorization support Color menu item tints background color, preserving all visible relief. No need to lock it for some skins. commit13fa4f2c34
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 15:00:58 2018 +0500 rack list: Colorized padding commit9964af1994
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 17:48:17 2018 +0500 rack list: Colorized rails commitd212577057
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Wed Oct 10 14:12:36 2018 +0500 rack list: Set frame in ui form commit9a7e060988
Author: Nikita Zlobin <nick87720z@gmail.com> Date: Fri Sep 28 18:44:49 2018 +0500 rack list: Set common frame
@@ -56,61 +56,94 @@ | |||
<number>1</number> | |||
</property> | |||
<item> | |||
<widget class="QLabel" name="pad_left"> | |||
<property name="minimumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>0</height> | |||
</size> | |||
<widget class="QFrame" name="frame"> | |||
<property name="frameShape"> | |||
<enum>QFrame::StyledPanel</enum> | |||
</property> | |||
<property name="maximumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>16777215</height> | |||
</size> | |||
</property> | |||
<property name="text"> | |||
<string/> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="RackListWidget" name="listWidget"> | |||
<property name="contextMenuPolicy"> | |||
<enum>Qt::CustomContextMenu</enum> | |||
</property> | |||
<property name="verticalScrollBarPolicy"> | |||
<enum>Qt::ScrollBarAlwaysOff</enum> | |||
</property> | |||
<property name="horizontalScrollBarPolicy"> | |||
<enum>Qt::ScrollBarAlwaysOff</enum> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="QLabel" name="pad_right"> | |||
<property name="minimumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>0</height> | |||
</size> | |||
</property> | |||
<property name="maximumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>16777215</height> | |||
</size> | |||
</property> | |||
<property name="text"> | |||
<string/> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="QScrollBar" name="rackScrollBar"> | |||
<property name="orientation"> | |||
<enum>Qt::Vertical</enum> | |||
<property name="frameShadow"> | |||
<enum>QFrame::Sunken</enum> | |||
</property> | |||
<layout class="QHBoxLayout" name="horizontalLayout_10"> | |||
<property name="spacing"> | |||
<number>0</number> | |||
</property> | |||
<property name="leftMargin"> | |||
<number>0</number> | |||
</property> | |||
<property name="topMargin"> | |||
<number>0</number> | |||
</property> | |||
<property name="rightMargin"> | |||
<number>0</number> | |||
</property> | |||
<property name="bottomMargin"> | |||
<number>0</number> | |||
</property> | |||
<item> | |||
<widget class="QLabel" name="pad_left"> | |||
<property name="minimumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>0</height> | |||
</size> | |||
</property> | |||
<property name="maximumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>16777215</height> | |||
</size> | |||
</property> | |||
<property name="text"> | |||
<string/> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="RackListWidget" name="listWidget"> | |||
<property name="contextMenuPolicy"> | |||
<enum>Qt::CustomContextMenu</enum> | |||
</property> | |||
<property name="frameShape"> | |||
<enum>QFrame::NoFrame</enum> | |||
</property> | |||
<property name="frameShadow"> | |||
<enum>QFrame::Plain</enum> | |||
</property> | |||
<property name="verticalScrollBarPolicy"> | |||
<enum>Qt::ScrollBarAlwaysOff</enum> | |||
</property> | |||
<property name="horizontalScrollBarPolicy"> | |||
<enum>Qt::ScrollBarAlwaysOff</enum> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="QLabel" name="pad_right"> | |||
<property name="minimumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>0</height> | |||
</size> | |||
</property> | |||
<property name="maximumSize"> | |||
<size> | |||
<width>25</width> | |||
<height>16777215</height> | |||
</size> | |||
</property> | |||
<property name="text"> | |||
<string/> | |||
</property> | |||
</widget> | |||
</item> | |||
<item> | |||
<widget class="QScrollBar" name="rackScrollBar"> | |||
<property name="orientation"> | |||
<enum>Qt::Vertical</enum> | |||
</property> | |||
</widget> | |||
</item> | |||
</layout> | |||
</widget> | |||
</item> | |||
</layout> | |||
@@ -27,12 +27,12 @@ from carla_config import * | |||
import json | |||
if config_UseQt5: | |||
from PyQt5.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer | |||
from PyQt5.QtGui import QImage, QPalette | |||
from PyQt5.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer, QEvent | |||
from PyQt5.QtGui import QImage, QPalette, QBrush | |||
from PyQt5.QtWidgets import QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QMainWindow | |||
else: | |||
from PyQt4.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer | |||
from PyQt4.QtGui import QImage, QPalette | |||
from PyQt4.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer, QEvent | |||
from PyQt4.QtGui import QImage, QPalette, QBrush | |||
from PyQt4.QtGui import QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QMainWindow | |||
# ------------------------------------------------------------------------------------------------------------ | |||
@@ -358,15 +358,9 @@ class HostWindow(QMainWindow): | |||
self.ui.rackScrollBar.rangeChanged.connect(sb.setRange) | |||
self.ui.rackScrollBar.valueChanged.connect(sb.setValue) | |||
self.updateStyle() | |||
self.ui.rack.setStyleSheet(""" | |||
QLabel#pad_left { | |||
background-image: url(:/bitmaps/rack_padding_left.png); | |||
background-repeat: repeat-y; | |||
} | |||
QLabel#pad_right { | |||
background-image: url(:/bitmaps/rack_padding_right.png); | |||
background-repeat: repeat-y; | |||
} | |||
CarlaRackList#CarlaRackList { | |||
background-color: black; | |||
} | |||
@@ -2320,6 +2314,54 @@ class HostWindow(QMainWindow): | |||
QMainWindow.timerEvent(self, event) | |||
# -------------------------------------------------------------------------------------------------------- | |||
# color/style change event | |||
def changeEvent(self, event): | |||
if event.type() in (QEvent.PaletteChange, QEvent.StyleChange): | |||
self.updateStyle() | |||
QWidget.changeEvent(self, event) | |||
def updateStyle(self): | |||
# Rack padding images setup | |||
rack_imgL = QImage(":/bitmaps/rack_padding_left.png") | |||
rack_imgR = QImage(":/bitmaps/rack_padding_right.png") | |||
min_value = 0.07 | |||
value_fix = 1.0/(1.0-rack_imgL.scaled(1, 1, Qt.IgnoreAspectRatio, Qt.SmoothTransformation).pixelColor(0,0).blackF()) | |||
bg_color = self.ui.rack.palette().window().color() | |||
bg_value = 1.0 - bg_color.blackF() | |||
if bg_value == 0: | |||
bg_color = QColor.fromHsvF(0.0, 0.0, min_value*value_fix) | |||
elif bg_value < min_value: | |||
pad_color = bg_color.lighter(100*min_value/bg_value*value_fix) | |||
painter = QPainter() | |||
fillRect = rack_imgL.rect().adjusted(-1,-1,1,1) | |||
painter.begin(rack_imgL) | |||
painter.setCompositionMode(QPainter.CompositionMode_Multiply) | |||
painter.setBrush(pad_color) | |||
painter.drawRect(fillRect) | |||
painter.end() | |||
rack_pixmapL = QPixmap(rack_imgL) | |||
self.imgL_palette = QPalette() | |||
self.imgL_palette.setBrush(QPalette.Window, QBrush(rack_pixmapL)) | |||
self.ui.pad_left.setPalette(self.imgL_palette) | |||
self.ui.pad_left.setAutoFillBackground(True) | |||
painter.begin(rack_imgR) | |||
painter.setCompositionMode(QPainter.CompositionMode_Multiply) | |||
painter.setBrush(pad_color) | |||
painter.drawRect(fillRect) | |||
painter.end() | |||
rack_pixmapR = QPixmap(rack_imgR) | |||
self.imgR_palette = QPalette() | |||
self.imgR_palette.setBrush(QPalette.Window, QBrush(rack_pixmapR)) | |||
self.ui.pad_right.setPalette(self.imgR_palette) | |||
self.ui.pad_right.setAutoFillBackground(True) | |||
# -------------------------------------------------------------------------------------------------------- | |||
# paint event | |||
@@ -25,11 +25,11 @@ from carla_config import * | |||
# Imports (Global) | |||
if config_UseQt5: | |||
from PyQt5.QtCore import Qt, QRectF | |||
from PyQt5.QtCore import Qt, QRectF, QLineF | |||
from PyQt5.QtGui import QFont, QFontDatabase, QPen, QPixmap | |||
from PyQt5.QtWidgets import QColorDialog, QFrame, QPushButton | |||
else: | |||
from PyQt4.QtCore import Qt, QRectF | |||
from PyQt4.QtCore import Qt, QRectF, QLineF | |||
from PyQt4.QtGui import QFont, QFontDatabase, QPen, QPixmap | |||
from PyQt4.QtGui import QColorDialog, QFrame, QPushButton | |||
@@ -300,6 +300,12 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) | |||
host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback) | |||
# Prepare resources | |||
self.sel_pen = QPen(Qt.cyan, 1, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin) | |||
self.sel_pen.setDashPattern([2.0, 4.0]) | |||
self.sel_side_pen = QPen(Qt.cyan, 2, Qt.SolidLine, Qt.FlatCap) | |||
self.shadow_pen = QPen(Qt.black, 1) | |||
# ----------------------------------------------------------------- | |||
@pyqtSlot(int, str) | |||
@@ -527,7 +533,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
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);" % self.fSkinColor | |||
styleSheet2 = "background-color: rgb(200, 200, 200);" | |||
styleSheet2 += "background-image: url(:/bitmaps/background_noise1.png);" | |||
if not self.fDarkStyle: | |||
@@ -987,17 +993,27 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
#------------------------------------------------------------------ | |||
def drawOutline(self): | |||
painter = QPainter(self) | |||
def drawOutline(self, painter): | |||
painter.save() | |||
painter.setBrush(Qt.transparent) | |||
w = float(self.width()) | |||
h = float(self.height()) | |||
painter.setPen(self.shadow_pen) | |||
painter.drawLine(QLineF(0.5, h-1, w-1, h-1)) | |||
if self.fIsSelected: | |||
painter.setPen(QPen(Qt.cyan, 4)) | |||
painter.setBrush(Qt.transparent) | |||
painter.drawRect(0, 0, self.width(), self.height()) | |||
else: | |||
painter.setPen(QPen(Qt.black, 1)) | |||
painter.setBrush(Qt.black) | |||
painter.drawLine(0, self.height()-1, self.width(), self.height()-1) | |||
painter.setCompositionMode(QPainter.CompositionMode_Plus) | |||
painter.setPen(self.sel_pen) | |||
painter.drawRect(QRectF(0.5, 0.5, w-1, h-1)) | |||
sidelines = [QLineF(1, 1, 1, h-1), QLineF(w-1, 1, w-1, h-1)] | |||
painter.setPen(self.sel_side_pen) | |||
painter.drawLines(sidelines) | |||
painter.setCompositionMode(QPainter.CompositionMode_SourceOver) | |||
painter.restore() | |||
def updateParameterValues(self): | |||
for paramIndex, paramWidget in self.fParameterList: | |||
@@ -1026,12 +1042,6 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
actSkin = menu.addAction(self.tr("Change Skin...")) | |||
menu.addSeparator() | |||
if isinstance(self, PluginSlot_Classic): | |||
actCompact.setEnabled(False) | |||
actColor.setEnabled(False) | |||
elif self.fSkinStyle in ("openav", "openav-old", "3bandeq", "calf_black", "calf_blue", "nekobi", "zynfx"): | |||
actColor.setEnabled(False) | |||
# ------------------------------------------------------------- | |||
# Move up and down | |||
@@ -1126,7 +1136,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
if not color.isValid(): | |||
return | |||
color = (color.red(), color.green(), color.blue()) | |||
color = color.getRgb()[0:3] | |||
colorStr = "%i;%i;%i" % color | |||
gCarla.gui.changePluginColor(self.fPluginId, color, colorStr) | |||
@@ -1406,7 +1416,18 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): | |||
QFrame.timerEvent(self, event) | |||
def paintEvent(self, event): | |||
self.drawOutline() | |||
painter = QPainter(self) | |||
# Colorization | |||
if self.fSkinColor != (0,0,0): | |||
painter.setCompositionMode(QPainter.CompositionMode_Multiply) | |||
r,g,b = self.fSkinColor | |||
painter.setBrush(QColor(r,g,b)) | |||
painter.setPen(Qt.NoPen) | |||
painter.drawRect(QRectF(0,0,self.width(),self.height())) | |||
painter.setCompositionMode(QPainter.CompositionMode_SourceOver) | |||
self.drawOutline(painter) | |||
QFrame.paintEvent(self, event) | |||
# ------------------------------------------------------------------------------------------------------------ | |||
@@ -25,11 +25,11 @@ from carla_config import * | |||
# Imports (Global) | |||
if config_UseQt5: | |||
from PyQt5.QtCore import Qt, QSize | |||
from PyQt5.QtCore import Qt, QSize, QRect, QEvent | |||
from PyQt5.QtGui import QPainter, QPixmap | |||
from PyQt5.QtWidgets import QAbstractItemView, QFrame, QListWidget, QListWidgetItem | |||
else: | |||
from PyQt4.QtCore import Qt, QSize | |||
from PyQt4.QtCore import Qt, QSize, QRect, QEvent | |||
from PyQt4.QtGui import QAbstractItemView, QFrame, QListWidget, QListWidgetItem, QPainter, QPixmap | |||
# ------------------------------------------------------------------------------------------------------------ | |||
@@ -242,8 +242,7 @@ class RackListWidget(QListWidget): | |||
self.setDropIndicatorShown(True) | |||
self.viewport().setAcceptDrops(True) | |||
self.setFrameShape(QFrame.NoFrame) | |||
self.setFrameShadow(QFrame.Plain) | |||
self.updateStyle() | |||
# -------------------------------------------------------------------------------------------------------- | |||
@@ -360,14 +359,50 @@ class RackListWidget(QListWidget): | |||
QListWidget.mousePressEvent(self, event) | |||
def changeEvent(self, event): | |||
if event.type() in (QEvent.StyleChange, QEvent.PaletteChange): | |||
self.updateStyle() | |||
QWidget.changeEvent(self, event) | |||
def paintEvent(self, event): | |||
painter = QPainter(self.viewport()) | |||
painter.drawTiledPixmap(0, 0, self.fPixmapWidth, self.height(), self.fPixmapL) | |||
painter.drawTiledPixmap(self.width()-self.fPixmapWidth, 0, self.fPixmapWidth, self.height(), self.fPixmapR) | |||
width = self.width() | |||
height = self.height() | |||
imgL_rect = QRect(0, 0, self.fPixmapWidth, height) | |||
imgR_rect = QRect(width-self.fPixmapWidth, 0, self.fPixmapWidth, height) | |||
painter.setBrush(self.rail_color) | |||
painter.setPen(Qt.NoPen) | |||
painter.drawRects(imgL_rect, imgR_rect) | |||
painter.setCompositionMode(QPainter.CompositionMode_Multiply) | |||
painter.drawTiledPixmap(imgL_rect, self.fPixmapL) | |||
painter.drawTiledPixmap(imgR_rect, self.fPixmapR) | |||
painter.setCompositionMode(QPainter.CompositionMode_Plus) | |||
painter.drawTiledPixmap(imgL_rect, self.fPixmapL) | |||
painter.drawTiledPixmap(imgR_rect, self.fPixmapR) | |||
painter.setCompositionMode(QPainter.CompositionMode_SourceOver) | |||
painter.setPen(self.edge_color) | |||
painter.setBrush(Qt.NoBrush) | |||
painter.drawRect(self.fPixmapWidth, 0, width-self.fPixmapWidth*2, height) | |||
QListWidget.paintEvent(self, event) | |||
# -------------------------------------------------------------------------------------------------------- | |||
def updateStyle(self): | |||
palette = self.palette() | |||
bg_color = palette.window().color() | |||
base_color = palette.base().color() | |||
text_color = palette.text().color() | |||
r0,g0,b0,a = bg_color.getRgb() | |||
r1,g1,b1,a = text_color.getRgb() | |||
self.rail_color = QColor((r0*3+r1)/4, (g0*3+g1)/4, (b0*3+b1)/4) | |||
self.edge_color = self.rail_color.darker(115) if self.rail_color.blackF() > base_color.blackF() else base_color.darker(115) | |||
def selectionChanged(self, selected, deselected): | |||
for index in deselected.indexes(): | |||
item = self.itemFromIndex(index) | |||