@@ -17,6 +17,7 @@ | |||||
*.pyc | *.pyc | ||||
ui_*.py | ui_*.py | ||||
*.moc | |||||
moc_*.cpp | moc_*.cpp | ||||
ui_*.h | ui_*.h | ||||
@@ -33,6 +34,7 @@ carla-discovery-unix64 | |||||
c++/carla-backend/doxygen/ | c++/carla-backend/doxygen/ | ||||
c++/carla-includes/vst/ | c++/carla-includes/vst/ | ||||
c++/jackmeter/cadence_jackmeter | c++/jackmeter/cadence_jackmeter | ||||
c++/xycontroller/cadence_xycontroller | |||||
c++/*/*-build-*-Debug/ | c++/*/*-build-*-Debug/ | ||||
c++/*/*-build-*-Release/ | c++/*/*-build-*-Release/ | ||||
@@ -95,21 +95,21 @@ void DigitalPeakMeter::setOrientation(Orientation orientation) | |||||
if (m_orientation == HORIZONTAL) | if (m_orientation == HORIZONTAL) | ||||
{ | { | ||||
m_gradientMeter.setColorAt(0.0, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.2, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.4, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.6, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.8, Qt::yellow); | |||||
m_gradientMeter.setColorAt(1.0, Qt::red); | |||||
m_gradientMeter.setColorAt(0.0f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.2f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.4f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.6f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.8f, Qt::yellow); | |||||
m_gradientMeter.setColorAt(1.0f, Qt::red); | |||||
} | } | ||||
else if (m_orientation == VERTICAL) | else if (m_orientation == VERTICAL) | ||||
{ | { | ||||
m_gradientMeter.setColorAt(0.0, Qt::red); | |||||
m_gradientMeter.setColorAt(0.2, Qt::yellow); | |||||
m_gradientMeter.setColorAt(0.4, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.6, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.8, m_colorBase); | |||||
m_gradientMeter.setColorAt(1.0, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.0f, Qt::red); | |||||
m_gradientMeter.setColorAt(0.2f, Qt::yellow); | |||||
m_gradientMeter.setColorAt(0.4f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.6f, m_colorBase); | |||||
m_gradientMeter.setColorAt(0.8f, m_colorBase); | |||||
m_gradientMeter.setColorAt(1.0f, m_colorBase); | |||||
} | } | ||||
else | else | ||||
return qCritical("DigitalPeakMeter::setOrientation(%i) - invalid orientation", orientation); | return qCritical("DigitalPeakMeter::setOrientation(%i) - invalid orientation", orientation); | ||||
@@ -220,21 +220,21 @@ void DigitalPeakMeter::paintEvent(QPaintEvent*) | |||||
// Base | // Base | ||||
painter.setPen(m_colorBaseT); | painter.setPen(m_colorBaseT); | ||||
painter.drawLine(lsmall * 0.25, 2, lsmall * 0.25, lfull-2); | |||||
painter.drawLine(lsmall * 0.50, 2, lsmall * 0.50, lfull-2); | |||||
painter.drawLine(lsmall * 0.25f, 2, lsmall * 0.25f, lfull-2); | |||||
painter.drawLine(lsmall * 0.50f, 2, lsmall * 0.50f, lfull-2); | |||||
// Yellow | // Yellow | ||||
painter.setPen(QColor(110, 110, 15, 100)); | painter.setPen(QColor(110, 110, 15, 100)); | ||||
painter.drawLine(lsmall * 0.70, 2, lsmall * 0.70, lfull-2); | |||||
painter.drawLine(lsmall * 0.83, 2, lsmall * 0.83, lfull-2); | |||||
painter.drawLine(lsmall * 0.70f, 2, lsmall * 0.70f, lfull-2); | |||||
painter.drawLine(lsmall * 0.83f, 2, lsmall * 0.83f, lfull-2); | |||||
// Orange | // Orange | ||||
painter.setPen(QColor(180, 110, 15, 100)); | painter.setPen(QColor(180, 110, 15, 100)); | ||||
painter.drawLine(lsmall * 0.90, 2, lsmall * 0.90, lfull-2); | |||||
painter.drawLine(lsmall * 0.90f, 2, lsmall * 0.90f, lfull-2); | |||||
// Red | // Red | ||||
painter.setPen(QColor(110, 15, 15, 100)); | painter.setPen(QColor(110, 15, 15, 100)); | ||||
painter.drawLine(lsmall * 0.96, 2, lsmall * 0.96, lfull-2); | |||||
painter.drawLine(lsmall * 0.96f, 2, lsmall * 0.96f, lfull-2); | |||||
} | } | ||||
else if (m_orientation == VERTICAL) | else if (m_orientation == VERTICAL) | ||||
@@ -245,21 +245,21 @@ void DigitalPeakMeter::paintEvent(QPaintEvent*) | |||||
// Base | // Base | ||||
painter.setPen(m_colorBaseT); | painter.setPen(m_colorBaseT); | ||||
painter.drawLine(2, lsmall - (lsmall * 0.25), lfull-2, lsmall - (lsmall * 0.25)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.50), lfull-2, lsmall - (lsmall * 0.50)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.25f), lfull-2, lsmall - (lsmall * 0.25f)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.50f), lfull-2, lsmall - (lsmall * 0.50f)); | |||||
// Yellow | // Yellow | ||||
painter.setPen(QColor(110, 110, 15, 100)); | painter.setPen(QColor(110, 110, 15, 100)); | ||||
painter.drawLine(2, lsmall - (lsmall * 0.70), lfull-2, lsmall - (lsmall * 0.70)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.83), lfull-2, lsmall - (lsmall * 0.83)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.70f), lfull-2, lsmall - (lsmall * 0.70f)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.83f), lfull-2, lsmall - (lsmall * 0.83f)); | |||||
// Orange | // Orange | ||||
painter.setPen(QColor(180, 110, 15, 100)); | painter.setPen(QColor(180, 110, 15, 100)); | ||||
painter.drawLine(2, lsmall - (lsmall * 0.90), lfull-2, lsmall - (lsmall * 0.90)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.90f), lfull-2, lsmall - (lsmall * 0.90f)); | |||||
// Red | // Red | ||||
painter.setPen(QColor(110, 15, 15, 100)); | painter.setPen(QColor(110, 15, 15, 100)); | ||||
painter.drawLine(2, lsmall - (lsmall * 0.96), lfull-2, lsmall - (lsmall * 0.96)); | |||||
painter.drawLine(2, lsmall - (lsmall * 0.96f), lfull-2, lsmall - (lsmall * 0.96f)); | |||||
} | } | ||||
} | } | ||||
@@ -20,8 +20,8 @@ | |||||
#include <QtCore/QTimer> | #include <QtCore/QTimer> | ||||
#include <QtGui/QPainter> | #include <QtGui/QPainter> | ||||
PixmapDial::PixmapDial(QWidget* parent): | |||||
QDial(parent) | |||||
PixmapDial::PixmapDial(QWidget* parent) | |||||
: QDial(parent) | |||||
{ | { | ||||
m_pixmap.load(":/bitmaps/dial_01d.png"); | m_pixmap.load(":/bitmaps/dial_01d.png"); | ||||
m_pixmap_n_str = "01"; | m_pixmap_n_str = "01"; | ||||
@@ -36,7 +36,7 @@ PixmapDial::PixmapDial(QWidget* parent): | |||||
m_orientation = VERTICAL; | m_orientation = VERTICAL; | ||||
m_label = ""; | m_label = ""; | ||||
m_label_pos = QPointF(0.0, 0.0); | |||||
m_label_pos = QPointF(0.0f, 0.0f); | |||||
m_label_width = 0; | m_label_width = 0; | ||||
m_label_height = 0; | m_label_height = 0; | ||||
m_label_gradient = QLinearGradient(0, 0, 0, 1); | m_label_gradient = QLinearGradient(0, 0, 0, 1); | ||||
@@ -91,27 +91,23 @@ void PixmapDial::setLabel(QString label) | |||||
m_label_width = QFontMetrics(font()).width(label); | m_label_width = QFontMetrics(font()).width(label); | ||||
m_label_height = QFontMetrics(font()).height(); | m_label_height = QFontMetrics(font()).height(); | ||||
m_label_pos.setX((p_size/2)-(m_label_width/2)); | |||||
m_label_pos.setY(p_size+m_label_height); | |||||
m_label_pos.setX(float(p_size)/2 - float(m_label_width)/2); | |||||
m_label_pos.setY(p_size + m_label_height); | |||||
m_label_gradient.setColorAt(0.0, m_color1); | |||||
m_label_gradient.setColorAt(0.6, m_color1); | |||||
m_label_gradient.setColorAt(1.0, m_color2); | |||||
m_label_gradient.setColorAt(0.0f, m_color1); | |||||
m_label_gradient.setColorAt(0.6f, m_color1); | |||||
m_label_gradient.setColorAt(1.0f, m_color2); | |||||
m_label_gradient.setStart(0, p_size/2); | |||||
m_label_gradient.setStart(0, float(p_size)/2); | |||||
m_label_gradient.setFinalStop(0, p_size+m_label_height+5); | m_label_gradient.setFinalStop(0, p_size+m_label_height+5); | ||||
m_label_gradient_rect = QRectF(p_size*1/8, p_size/2, p_size*6/8, p_size+m_label_height+5); | |||||
m_label_gradient_rect = QRectF(float(p_size)/8, float(p_size)/2, float(p_size*6)/8, p_size+m_label_height+5); | |||||
update(); | update(); | ||||
} | } | ||||
void PixmapDial::setPixmap(int pixmap_id) | |||||
void PixmapDial::setPixmap(int pixmapId) | |||||
{ | { | ||||
if (pixmap_id > 10) | |||||
m_pixmap_n_str = QString::number(pixmap_id); | |||||
else | |||||
m_pixmap_n_str = QString("0%1").arg(pixmap_id); | |||||
m_pixmap_n_str.sprintf("%02i", pixmapId); | |||||
m_pixmap.load(QString(":/bitmaps/dial_%1%2.png").arg(m_pixmap_n_str).arg(isEnabled() ? "" : "d")); | m_pixmap.load(QString(":/bitmaps/dial_%1%2.png").arg(m_pixmap_n_str).arg(isEnabled() ? "" : "d")); | ||||
if (m_pixmap.width() > m_pixmap.height()) | if (m_pixmap.width() > m_pixmap.height()) | ||||
@@ -163,7 +159,7 @@ void PixmapDial::enterEvent(QEvent* event) | |||||
{ | { | ||||
m_hovered = true; | m_hovered = true; | ||||
if (m_hover_step == HOVER_MIN) | if (m_hover_step == HOVER_MIN) | ||||
m_hover_step = HOVER_MIN + 1; | |||||
m_hover_step += 1; | |||||
QDial::enterEvent(event); | QDial::enterEvent(event); | ||||
} | } | ||||
@@ -171,7 +167,7 @@ void PixmapDial::leaveEvent(QEvent* event) | |||||
{ | { | ||||
m_hovered = false; | m_hovered = false; | ||||
if (m_hover_step == HOVER_MAX) | if (m_hover_step == HOVER_MAX) | ||||
m_hover_step = HOVER_MAX - 1; | |||||
m_hover_step -= 1; | |||||
QDial::leaveEvent(event); | QDial::leaveEvent(event); | ||||
} | } | ||||
@@ -185,12 +181,10 @@ void PixmapDial::paintEvent(QPaintEvent*) | |||||
painter.setBrush(m_label_gradient); | painter.setBrush(m_label_gradient); | ||||
painter.drawRect(m_label_gradient_rect); | painter.drawRect(m_label_gradient_rect); | ||||
painter.setPen(isEnabled() ? m_colorT[0] : m_colorT[1]); | |||||
painter.setPen(m_colorT[isEnabled() ? 0 : 1]); | |||||
painter.drawText(m_label_pos, m_label); | painter.drawText(m_label_pos, m_label); | ||||
} | } | ||||
QRectF target, source; | |||||
if (isEnabled()) | if (isEnabled()) | ||||
{ | { | ||||
float current = value()-minimum(); | float current = value()-minimum(); | ||||
@@ -199,19 +193,19 @@ void PixmapDial::paintEvent(QPaintEvent*) | |||||
if (divider == 0.0f) | if (divider == 0.0f) | ||||
return; | return; | ||||
target = QRectF(0.0, 0.0, p_size, p_size); | |||||
float value = current/divider; | float value = current/divider; | ||||
QRectF source, target(0.0f, 0.0f, p_size, p_size); | |||||
int xpos, ypos, per = int((p_count-1) * value); | |||||
int xpos, ypos, per = (p_count-1)*value; | |||||
if (m_orientation == HORIZONTAL) | if (m_orientation == HORIZONTAL) | ||||
{ | { | ||||
xpos = p_size*per; | xpos = p_size*per; | ||||
ypos = 0.0; | |||||
ypos = 0.0f; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
xpos = 0.0; | |||||
xpos = 0.0f; | |||||
ypos = p_size*per; | ypos = p_size*per; | ||||
} | } | ||||
@@ -219,12 +213,99 @@ void PixmapDial::paintEvent(QPaintEvent*) | |||||
painter.drawPixmap(target, m_pixmap, source); | painter.drawPixmap(target, m_pixmap, source); | ||||
// Custom knobs (Dry/Wet and Volume) | // Custom knobs (Dry/Wet and Volume) | ||||
// TODO | |||||
if (m_custom_paint == CUSTOM_PAINT_CARLA_WET || m_custom_paint == CUSTOM_PAINT_CARLA_VOL) | |||||
{ | |||||
// knob color | |||||
QColor colorGreen(0x5D, 0xE7, 0x3D, 191 + m_hover_step*7); | |||||
QColor colorBlue(0x3E, 0xB8, 0xBE, 191 + m_hover_step*7); | |||||
// draw small circle | |||||
QRectF ballRect(8.0, 8.0, 15.0, 15.0); | |||||
QPainterPath ballPath; | |||||
ballPath.addEllipse(ballRect); | |||||
//painter.drawRect(ballRect); | |||||
float tmpValue = (0.375f + 0.75f*value); | |||||
float ballValue = tmpValue - floorf(tmpValue); | |||||
QPointF ballPoint(ballPath.pointAtPercent(ballValue)); | |||||
// draw arc | |||||
int startAngle = 216*16; | |||||
int spanAngle = -252*16*value; | |||||
if (m_custom_paint == CUSTOM_PAINT_CARLA_WET) | |||||
{ | |||||
painter.setBrush(colorBlue); | |||||
painter.setPen(QPen(colorBlue, 0)); | |||||
painter.drawEllipse(QRectF(ballPoint.x(), ballPoint.y(), 2.2, 2.2)); | |||||
QConicalGradient gradient(15.5, 15.5, -45); | |||||
gradient.setColorAt(0.0, colorBlue); | |||||
gradient.setColorAt(0.125, colorBlue); | |||||
gradient.setColorAt(0.625, colorGreen); | |||||
gradient.setColorAt(0.75, colorGreen); | |||||
gradient.setColorAt(0.76, colorGreen); | |||||
gradient.setColorAt(1.0, colorGreen); | |||||
painter.setBrush(gradient); | |||||
painter.setPen(QPen(gradient, 3)); | |||||
} | |||||
else | |||||
{ | |||||
painter.setBrush(colorBlue); | |||||
painter.setPen(QPen(colorBlue, 0)); | |||||
painter.drawEllipse(QRectF(ballPoint.x(), ballPoint.y(), 2.2, 2.2)); | |||||
painter.setBrush(colorBlue); | |||||
painter.setPen(QPen(colorBlue, 3)); | |||||
} | |||||
painter.drawArc(4.0, 4.0, 26.0, 26.0, startAngle, spanAngle); | |||||
} | |||||
// Custom knobs (L and R) | // Custom knobs (L and R) | ||||
// TODO | |||||
else if (m_custom_paint == CUSTOM_PAINT_CARLA_L || m_custom_paint == CUSTOM_PAINT_CARLA_R) | |||||
{ | |||||
// knob color | |||||
QColor color(0xAD + m_hover_step*5, 0xD5 + m_hover_step*4, 0x4B + m_hover_step*5); | |||||
// draw small circle | |||||
QRectF ballRect(7.0, 8.0, 11.0, 12.0); | |||||
QPainterPath ballPath; | |||||
ballPath.addEllipse(ballRect); | |||||
//painter.drawRect(ballRect); | |||||
float tmpValue = (0.375f + 0.75f*value); | |||||
float ballValue = tmpValue - floorf(tmpValue); | |||||
QPointF ballPoint(ballPath.pointAtPercent(ballValue)); | |||||
painter.setBrush(color); | |||||
painter.setPen(QPen(color, 0)); | |||||
painter.drawEllipse(QRectF(ballPoint.x(), ballPoint.y(), 2.0f, 2.0f)); | |||||
int startAngle, spanAngle; | |||||
// draw arc | |||||
if (m_custom_paint == CUSTOM_PAINT_CARLA_L) | |||||
{ | |||||
startAngle = 216*16; | |||||
spanAngle = -252.0*16*value; | |||||
} | |||||
else if (m_custom_paint == CUSTOM_PAINT_CARLA_R) | |||||
{ | |||||
startAngle = 324.0*16; | |||||
spanAngle = 252.0*16*(1.0-value); | |||||
} | |||||
else | |||||
return; | |||||
painter.setPen(QPen(color, 2)); | |||||
painter.drawArc(3.5, 4.5, 22.0, 22.0, startAngle, spanAngle); | |||||
if (HOVER_MIN < m_hover_step && m_hover_step < HOVER_MAX) | |||||
{ | |||||
m_hover_step += m_hovered ? 1 : -1; | |||||
QTimer::singleShot(20, this, SLOT(update())); | |||||
} | |||||
} | |||||
if (HOVER_MIN > m_hover_step && m_hover_step < HOVER_MAX) | |||||
if (HOVER_MIN < m_hover_step && m_hover_step < HOVER_MAX) | |||||
{ | { | ||||
m_hover_step += m_hovered ? 1 : -1; | m_hover_step += m_hovered ? 1 : -1; | ||||
QTimer::singleShot(20, this, SLOT(update())); | QTimer::singleShot(20, this, SLOT(update())); | ||||
@@ -232,9 +313,8 @@ void PixmapDial::paintEvent(QPaintEvent*) | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
target = QRectF(0.0, 0.0, p_size, p_size); | |||||
source = target; | |||||
painter.drawPixmap(target, m_pixmap, source); | |||||
QRectF target(0.0, 0.0, p_size, p_size); | |||||
painter.drawPixmap(target, m_pixmap, target); | |||||
} | } | ||||
} | } | ||||
@@ -39,11 +39,11 @@ public: | |||||
PixmapDial(QWidget* parent); | PixmapDial(QWidget* parent); | ||||
int getSize() const; | |||||
int getSize() const; | |||||
void setCustomPaint(CustomPaint paint); | void setCustomPaint(CustomPaint paint); | ||||
void setEnabled(bool enabled); | void setEnabled(bool enabled); | ||||
void setLabel(QString label); | void setLabel(QString label); | ||||
void setPixmap(int pixmap_id); | |||||
void setPixmap(int pixmapId); | |||||
QSize minimumSizeHint() const; | QSize minimumSizeHint() const; | ||||
QSize sizeHint() const; | QSize sizeHint() const; | ||||
@@ -64,7 +64,7 @@ private: | |||||
Orientation m_orientation; | Orientation m_orientation; | ||||
bool m_hovered; | bool m_hovered; | ||||
int m_hover_step; | |||||
unsigned short m_hover_step; | |||||
QString m_label; | QString m_label; | ||||
QPointF m_label_pos; | QPointF m_label_pos; | ||||
@@ -80,8 +80,8 @@ private: | |||||
int p_width, p_height, p_size, p_count; | int p_width, p_height, p_size, p_count; | ||||
static const int HOVER_MIN = 0; | |||||
static const int HOVER_MAX = 9; | |||||
static const unsigned short HOVER_MIN = 0; | |||||
static const unsigned short HOVER_MAX = 9; | |||||
}; | }; | ||||
#endif // PIXMAPDIAL_H | #endif // PIXMAPDIAL_H |
@@ -60,11 +60,9 @@ private: | |||||
//QMutex mutex; | //QMutex mutex; | ||||
}; | }; | ||||
qreal abs_q(const qreal value) | |||||
float abs_f(const float value) | |||||
{ | { | ||||
if (value < 1.0) | |||||
return -value; | |||||
return value; | |||||
return (value < 1.0f) ? -value : value; | |||||
} | } | ||||
#if 0 | #if 0 | ||||
@@ -890,6 +888,10 @@ int main(int argc, char* argv[]) | |||||
{ | { | ||||
MIDI_CC_LIST__init(); | MIDI_CC_LIST__init(); | ||||
#ifdef Q_OS_WIN | |||||
QApplication::setGraphicsSystem("raster"); | |||||
#endif | |||||
QApplication app(argc, argv); | QApplication app(argc, argv); | ||||
app.setApplicationName("XY-Controller"); | app.setApplicationName("XY-Controller"); | ||||
app.setApplicationVersion(VERSION); | app.setApplicationVersion(VERSION); | ||||
@@ -54,7 +54,7 @@ class DigitalPeakMeter(QWidget): | |||||
if level < 0.0: | if level < 0.0: | ||||
level = -level | level = -level | ||||
else if level > 1.0: | |||||
elif level > 1.0: | |||||
level = 1.0 | level = 1.0 | ||||
self.m_channelsData[meter-1] = level | self.m_channelsData[meter-1] = level | ||||
@@ -17,14 +17,17 @@ | |||||
# For a full copy of the GNU General Public License see the COPYING file | # For a full copy of the GNU General Public License see the COPYING file | ||||
# Imports (Global) | # Imports (Global) | ||||
from math import floor | |||||
from PyQt4.QtCore import Qt, QPointF, QRectF, QTimer, QSize, SLOT | from PyQt4.QtCore import Qt, QPointF, QRectF, QTimer, QSize, SLOT | ||||
from PyQt4.QtGui import QColor, QConicalGradient, QDial, QFontMetrics, QLinearGradient, QPainter, QPainterPath, QPen, QPixmap | from PyQt4.QtGui import QColor, QConicalGradient, QDial, QFontMetrics, QLinearGradient, QPainter, QPainterPath, QPen, QPixmap | ||||
# Widget Class | # Widget Class | ||||
class PixmapDial(QDial): | class PixmapDial(QDial): | ||||
# enum Orientation | |||||
HORIZONTAL = 0 | HORIZONTAL = 0 | ||||
VERTICAL = 1 | VERTICAL = 1 | ||||
# enum CustomPaint | |||||
CUSTOM_PAINT_NULL = 0 | CUSTOM_PAINT_NULL = 0 | ||||
CUSTOM_PAINT_CARLA_WET = 1 | CUSTOM_PAINT_CARLA_WET = 1 | ||||
CUSTOM_PAINT_CARLA_VOL = 2 | CUSTOM_PAINT_CARLA_VOL = 2 | ||||
@@ -89,25 +92,21 @@ class PixmapDial(QDial): | |||||
self.m_label_width = QFontMetrics(self.font()).width(label) | self.m_label_width = QFontMetrics(self.font()).width(label) | ||||
self.m_label_height = QFontMetrics(self.font()).height() | self.m_label_height = QFontMetrics(self.font()).height() | ||||
self.m_label_pos.setX((self.p_size / 2) - (self.m_label_width / 2)) | |||||
self.m_label_pos.setX(float(self.p_size)/2 - float(self.m_label_width)/2) | |||||
self.m_label_pos.setY(self.p_size + self.m_label_height) | self.m_label_pos.setY(self.p_size + self.m_label_height) | ||||
self.m_label_gradient.setColorAt(0.0, self.m_color1) | self.m_label_gradient.setColorAt(0.0, self.m_color1) | ||||
self.m_label_gradient.setColorAt(0.6, self.m_color1) | self.m_label_gradient.setColorAt(0.6, self.m_color1) | ||||
self.m_label_gradient.setColorAt(1.0, self.m_color2) | self.m_label_gradient.setColorAt(1.0, self.m_color2) | ||||
self.m_label_gradient.setStart(0, self.p_size / 2) | |||||
self.m_label_gradient.setStart(0, float(self.p_size)/2) | |||||
self.m_label_gradient.setFinalStop(0, self.p_size + self.m_label_height + 5) | self.m_label_gradient.setFinalStop(0, self.p_size + self.m_label_height + 5) | ||||
self.m_label_gradient_rect = QRectF(self.p_size * 1 / 8, self.p_size / 2, self.p_size * 6 / 8, self.p_size + self.m_label_height + 5) | |||||
self.m_label_gradient_rect = QRectF(float(self.p_size)/8, float(self.p_size)/2, float(self.p_size)*6/8, self.p_size+self.m_label_height+5) | |||||
self.update() | self.update() | ||||
def setPixmap(self, pixmap_id): | |||||
if pixmap_id > 10: | |||||
self.m_pixmap_n_str = str(pixmap_id) | |||||
else: | |||||
self.m_pixmap_n_str = "0%i" % pixmap_id | |||||
def setPixmap(self, pixmapId): | |||||
self.m_pixmap_n_str = "%02i" % pixmapId | |||||
self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmap_n_str, "" if self.isEnabled() else "d")) | self.m_pixmap.load(":/bitmaps/dial_%s%s.png" % (self.m_pixmap_n_str, "" if self.isEnabled() else "d")) | ||||
if self.m_pixmap.width() > self.m_pixmap.height(): | if self.m_pixmap.width() > self.m_pixmap.height(): | ||||
@@ -135,10 +134,10 @@ class PixmapDial(QDial): | |||||
self.p_height = 1 | self.p_height = 1 | ||||
if self.m_orientation == self.HORIZONTAL: | if self.m_orientation == self.HORIZONTAL: | ||||
self.p_size = self.p_height | |||||
self.p_size = self.p_height | |||||
self.p_count = self.p_width / self.p_height | self.p_count = self.p_width / self.p_height | ||||
else: | else: | ||||
self.p_size = self.p_width | |||||
self.p_size = self.p_width | |||||
self.p_count = self.p_height / self.p_width | self.p_count = self.p_height / self.p_width | ||||
self.setMinimumSize(self.p_size, self.p_size + self.m_label_height + 5) | self.setMinimumSize(self.p_size, self.p_size + self.m_label_height + 5) | ||||
@@ -146,14 +145,14 @@ class PixmapDial(QDial): | |||||
def enterEvent(self, event): | def enterEvent(self, event): | ||||
self.m_hovered = True | self.m_hovered = True | ||||
if self.m_hover_step == self.HOVER_MIN: | |||||
self.m_hover_step = self.HOVER_MIN + 1 | |||||
if self.m_hover_step == self.HOVER_MIN: | |||||
self.m_hover_step += 1 | |||||
QDial.enterEvent(self, event) | QDial.enterEvent(self, event) | ||||
def leaveEvent(self, event): | def leaveEvent(self, event): | ||||
self.m_hovered = False | self.m_hovered = False | ||||
if self.m_hover_step == self.HOVER_MAX: | |||||
self.m_hover_step = self.HOVER_MAX - 1 | |||||
if self.m_hover_step == self.HOVER_MAX: | |||||
self.m_hover_step -= 1 | |||||
QDial.leaveEvent(self, event) | QDial.leaveEvent(self, event) | ||||
def paintEvent(self, event): | def paintEvent(self, event): | ||||
@@ -165,7 +164,7 @@ class PixmapDial(QDial): | |||||
painter.setBrush(self.m_label_gradient) | painter.setBrush(self.m_label_gradient) | ||||
painter.drawRect(self.m_label_gradient_rect) | painter.drawRect(self.m_label_gradient_rect) | ||||
painter.setPen(self.m_colorT[0] if self.isEnabled() else self.m_colorT[1]) | |||||
painter.setPen(self.m_colorT[0 if self.isEnabled() else 1]) | |||||
painter.drawText(self.m_label_pos, self.m_label) | painter.drawText(self.m_label_pos, self.m_label) | ||||
if self.isEnabled(): | if self.isEnabled(): | ||||
@@ -175,8 +174,8 @@ class PixmapDial(QDial): | |||||
if divider == 0.0: | if divider == 0.0: | ||||
return | return | ||||
target = QRectF(0.0, 0.0, self.p_size, self.p_size) | |||||
value = current / divider | value = current / divider | ||||
target = QRectF(0.0, 0.0, self.p_size, self.p_size) | |||||
per = int((self.p_count - 1) * value) | per = int((self.p_count - 1) * value) | ||||
@@ -196,20 +195,18 @@ class PixmapDial(QDial): | |||||
colorGreen = QColor(0x5D, 0xE7, 0x3D, 191 + self.m_hover_step*7) | colorGreen = QColor(0x5D, 0xE7, 0x3D, 191 + self.m_hover_step*7) | ||||
colorBlue = QColor(0x3E, 0xB8, 0xBE, 191 + self.m_hover_step*7) | colorBlue = QColor(0x3E, 0xB8, 0xBE, 191 + self.m_hover_step*7) | ||||
#colorGreen = QColor(0x5D + self.m_hover_step*6, 0xE7 + self.m_hover_step*1, 0x3D + self.m_hover_step*5) | |||||
#colorBlue = QColor(0x52 + self.m_hover_step*8, 0xEE + self.m_hover_step*1, 0xF8 + self.m_hover_step/2) | |||||
# draw small circle | # draw small circle | ||||
ballPath = QPainterPath() | |||||
ballRect = QRectF(8.0, 8.0, 15.0, 15.0) | ballRect = QRectF(8.0, 8.0, 15.0, 15.0) | ||||
ballPath = QPainterPath() | |||||
ballPath.addEllipse(ballRect) | ballPath.addEllipse(ballRect) | ||||
#painter.drawRect(ballRect) | #painter.drawRect(ballRect) | ||||
ballValue = (0.375 + 0.75*value) % 1.0 | |||||
tmpValue = (0.375 + 0.75*value) | |||||
ballValue = tmpValue - floor(tmpValue) | |||||
ballPoint = ballPath.pointAtPercent(ballValue) | ballPoint = ballPath.pointAtPercent(ballValue) | ||||
# draw arc | # draw arc | ||||
startAngle = 216*16 | startAngle = 216*16 | ||||
spanAngle = -252.0*16*value | |||||
spanAngle = -252*16*value | |||||
if self.m_custom_paint == self.CUSTOM_PAINT_CARLA_WET: | if self.m_custom_paint == self.CUSTOM_PAINT_CARLA_WET: | ||||
painter.setBrush(colorBlue) | painter.setBrush(colorBlue) | ||||
@@ -242,11 +239,12 @@ class PixmapDial(QDial): | |||||
color = QColor(0xAD + self.m_hover_step*5, 0xD5 + self.m_hover_step*4, 0x4B + self.m_hover_step*5) | color = QColor(0xAD + self.m_hover_step*5, 0xD5 + self.m_hover_step*4, 0x4B + self.m_hover_step*5) | ||||
# draw small circle | # draw small circle | ||||
ballPath = QPainterPath() | |||||
ballRect = QRectF(7.0, 8.0, 11.0, 12.0) | ballRect = QRectF(7.0, 8.0, 11.0, 12.0) | ||||
ballPath = QPainterPath() | |||||
ballPath.addEllipse(ballRect) | ballPath.addEllipse(ballRect) | ||||
#painter.drawRect(ballRect) | #painter.drawRect(ballRect) | ||||
ballValue = (0.375 + 0.75*value) % 1.0 | |||||
tmpValue = (0.375 + 0.75*value) | |||||
ballValue = tmpValue - floor(tmpValue) | |||||
ballPoint = ballPath.pointAtPercent(ballValue) | ballPoint = ballPath.pointAtPercent(ballValue) | ||||
painter.setBrush(color) | painter.setBrush(color) | ||||
@@ -272,8 +270,7 @@ class PixmapDial(QDial): | |||||
else: | else: | ||||
target = QRectF(0.0, 0.0, self.p_size, self.p_size) | target = QRectF(0.0, 0.0, self.p_size, self.p_size) | ||||
source = target | |||||
painter.drawPixmap(target, self.m_pixmap, source) | |||||
painter.drawPixmap(target, self.m_pixmap, target) | |||||
def resizeEvent(self, event): | def resizeEvent(self, event): | ||||
self.updateSizes() | self.updateSizes() | ||||