summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2011-04-15 02:45:33 +0000
committerTim E. Real <termtech@rogers.com>2011-04-15 02:45:33 +0000
commit7303c41c6de1c6823de4cfb2d314e42a2ad9ff5f (patch)
treeb40224140a1a58817aaef3633863d4075c3c0a34 /muse2/muse
parent8acbc05a692368347cffa794d047dc4839ad6b78 (diff)
Improved dark part colour gradients. Added gGradientFromQColor() in widgets/utils.cpp
called from PartCanvas draw.
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/arranger/pcanvas.cpp27
-rw-r--r--muse2/muse/widgets/utils.cpp20
-rw-r--r--muse2/muse/widgets/utils.h5
3 files changed, 43 insertions, 9 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 4fc0c3dd..ca2a16b0 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -20,7 +20,7 @@
#include <QPainter>
#include <QUrl>
#include <QPoint>
-#include <QLinearGradient>
+//#include <QLinearGradient>
#include "fastlog.h"
#include "widgets/tools.h"
@@ -40,6 +40,7 @@
#include "mpevent.h"
#include "midievent.h"
#include "midi.h"
+#include "utils.h"
// Moved into global config by Tim.
/*
@@ -1552,10 +1553,18 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
// Hm, put some kind of lower limit? If so do that globally to the adjustment.
QColor c(Qt::black);
c.setAlpha(config.globalAlphaBlend);
+
QLinearGradient gradient(r.topLeft(), r.bottomLeft());
- gradient.setColorAt(0, c);
- gradient.setColorAt(1, c.darker());
+ //gradient.setColorAt(0, c);
+ //gradient.setColorAt(1, c.darker());
+ // Use a colour only about 20% lighter than black, rather than the 50% we use in gGradientFromQColor
+ // and is used in darker()/lighter(), so that it is distinguished a bit better from grey non-part tracks.
+ //c.setRgba(64, 64, 64, c.alpha());
+ gradient.setColorAt(0, QColor(51, 51, 51, config.globalAlphaBlend));
+ gradient.setColorAt(1, c);
QBrush cc(gradient);
+ //QBrush cc(gGradientFromQColor(c, r.topLeft(), r.bottomLeft()));
+
p.setBrush(cc);
p.drawRect(r);
}
@@ -1570,10 +1579,11 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
p.setPen(pen);
QColor c(config.partColors[i]);
c.setAlpha(config.globalAlphaBlend);
- QLinearGradient gradient(r.topLeft(), r.bottomLeft());
- gradient.setColorAt(0, c);
- gradient.setColorAt(1, c.darker());
- QBrush cc(gradient);
+ //QLinearGradient gradient(r.topLeft(), r.bottomLeft());
+ //gradient.setColorAt(0, c);
+ //gradient.setColorAt(1, c.darker());
+ //QBrush cc(gradient);
+ QBrush cc(gGradientFromQColor(c, r.topLeft(), r.bottomLeft()));
p.setBrush(cc);
p.drawRect(r);
@@ -1616,8 +1626,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
p.setPen(Qt::black);
else
p.setPen(Qt::white);
- p.drawText(rr, Qt::AlignTop|Qt::AlignLeft, part->name());
- rr.translate(1,1);
+ p.drawText(rr.translated(1, 1), Qt::AlignTop|Qt::AlignLeft, part->name());
if (rev)
p.setPen(Qt::white);
else
diff --git a/muse2/muse/widgets/utils.cpp b/muse2/muse/widgets/utils.cpp
index 1bf4ca64..693f3c36 100644
--- a/muse2/muse/widgets/utils.cpp
+++ b/muse2/muse/widgets/utils.cpp
@@ -11,6 +11,10 @@
#include <sys/time.h>
#include <QFrame>
+#include <QColor>
+#include <QGradient>
+#include <QLinearGradient>
+#include <QPointF>
#include "utils.h"
@@ -354,3 +358,19 @@ bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth, bool igno
return true;
}
+
+QGradient gGradientFromQColor(const QColor& c, const QPointF& start, const QPointF& finalStop)
+{
+ int h = c.hsvHue(), s = c.hsvSaturation(), a = c.alpha();
+ int cv = c.value();
+ int v0 = cv + (255 - cv)/2;
+ int v1 = cv - cv/2;
+ QColor c0 = QColor::fromHsv(h, s, v0, a);
+ QColor c1 = QColor::fromHsv(h, s, v1, a);
+
+ QLinearGradient gradient(start, finalStop);
+ gradient.setColorAt(0, c0);
+ gradient.setColorAt(1, c1);
+
+ return gradient;
+} \ No newline at end of file
diff --git a/muse2/muse/widgets/utils.h b/muse2/muse/widgets/utils.h
index 654a7834..b6997023 100644
--- a/muse2/muse/widgets/utils.h
+++ b/muse2/muse/widgets/utils.h
@@ -11,6 +11,10 @@
class QFrame;
class QString;
class QWidget;
+class QGradient;
+class QCanvas;
+class QPointF;
+class QColor;
extern QString bitmap2String(int bm);
@@ -18,6 +22,7 @@ extern int string2bitmap(const QString& str);
extern QString u32bitmap2String(unsigned int bm);
extern unsigned int string2u32bitmap(const QString& str);
extern bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth = false, bool ignoreHeight = false, int max = 10, int min = 4);
+extern QGradient gGradientFromQColor(const QColor& c, const QPointF& start, const QPointF& finalStop);
extern int num2cols(int min, int max);
extern QFrame* hLine(QWidget* parent);