summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog2
-rw-r--r--muse2/muse/widgets/meter.cpp168
-rw-r--r--muse2/muse/widgets/meter.h37
-rw-r--r--muse2/muse/widgets/verticalmeter.cpp81
-rw-r--r--muse2/muse/widgets/verticalmeter.h2
5 files changed, 248 insertions, 42 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index d333b4fc..e9be48f4 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,5 @@
+15.08.2011:
+ - Remodel the Meter and the VerticalMeter (Orcan)
13.08.2011:
- Make the shininess of the Knob ring a little smarter (Orcan)
05.08.2011:
diff --git a/muse2/muse/widgets/meter.cpp b/muse2/muse/widgets/meter.cpp
index 6619d1dc..9f13059e 100644
--- a/muse2/muse/widgets/meter.cpp
+++ b/muse2/muse/widgets/meter.cpp
@@ -2,11 +2,11 @@
// MusE
// Linux Music Editor
// $Id: meter.cpp,v 1.4.2.2 2009/05/03 04:14:00 terminator356 Exp $
+// redesigned by oget on 2011/08/15
//
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================
-#include <stdio.h>
#include <cmath>
#include <QMouseEvent>
@@ -30,7 +30,8 @@ Meter::Meter(QWidget* parent, MeterType type)
// This is absolutely required for speed! Otherwise painfully slow because we get
// full rect paint events even on small scrolls! See help on QPainter::scroll().
setAttribute(Qt::WA_OpaquePaintEvent);
-
+ //setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
+
mtype = type;
overflow = false;
val = 0.0;
@@ -41,6 +42,57 @@ Meter::Meter(QWidget* parent, MeterType type)
redScale = 0;
setLineWidth(0);
setMidLineWidth(0);
+
+ dark_red_end = QColor(0x8e0000);
+ dark_red_begin = QColor(0x8e3800);
+
+ dark_yellow_end = QColor(0x8e6800);
+ dark_yellow_center = QColor(0x8e8e00);
+ dark_yellow_begin = QColor(0x6a8400);
+
+ dark_green_end = QColor(0x467800);
+ dark_green_begin = QColor(0x007000);
+
+ light_red_end = QColor(0xff0000);
+ light_red_begin = QColor(0xdd8800);
+
+ light_yellow_end = QColor(0xddcc00);
+ light_yellow_center = QColor(0xffff00);
+ light_yellow_begin = QColor(0xddff00);
+
+ light_green_end = QColor(0x88ff00);
+ light_green_begin = QColor(0x00ff00);
+
+ mask_center = QColor(225, 225, 225, 64);
+ mask_edge = QColor(30, 30, 30, 64);
+
+ separator_color = QColor(0x666666);
+ peak_color = QColor(0xeeeeee);
+
+ darkGradGreen.setColorAt(1, dark_green_begin);
+ darkGradGreen.setColorAt(0, dark_green_end);
+
+ darkGradYellow.setColorAt(1, dark_yellow_begin);
+ darkGradYellow.setColorAt(0.5, dark_yellow_center);
+ darkGradYellow.setColorAt(0, dark_yellow_end);
+
+ darkGradRed.setColorAt(1, dark_red_begin);
+ darkGradRed.setColorAt(0, dark_red_end);
+
+ lightGradGreen.setColorAt(1, light_green_begin);
+ lightGradGreen.setColorAt(0, light_green_end);
+
+ lightGradYellow.setColorAt(1, light_yellow_begin);
+ lightGradYellow.setColorAt(0.5, light_yellow_center);
+ lightGradYellow.setColorAt(0, light_yellow_end);
+
+ lightGradRed.setColorAt(1, light_red_begin);
+ lightGradRed.setColorAt(0, light_red_end);
+
+ maskGrad.setColorAt(0, mask_edge);
+ maskGrad.setColorAt(0.5, mask_center);
+ maskGrad.setColorAt(1, mask_edge);
+
}
//---------------------------------------------------------
@@ -106,17 +158,23 @@ void Meter::setRange(double min, double max)
// paintEvent
//---------------------------------------------------------
-void Meter::paintEvent(QPaintEvent* /*ev*/)
+void Meter::paintEvent(QPaintEvent* ev)
{
// TODO: Could make better use of event rectangle, for speed.
QPainter p(this);
+ //p.setRenderHint(QPainter::Antialiasing);
double range = maxScale - minScale;
-
+ /*
int fw = frameWidth();
int w = width() - 2*fw;
int h = height() - 2*fw;
+ */
+
+ QRect rect = ev->rect();
+ int w = rect.width();
+ int h = rect.height();
int yv;
if(mtype == DBMeter)
@@ -135,10 +193,17 @@ void Meter::paintEvent(QPaintEvent* /*ev*/)
ymax = maxVal == 0 ? 0 : int(((maxScale - (fast_log10(maxVal) * 20.0)) * h)/range);
else
ymax = maxVal == 0 ? 0 : int(((maxScale - maxVal) * h)/range);
- p.setPen(Qt::white);
+ p.setPen(peak_color);
p.drawLine(0, ymax, w, ymax);
+
+ // Draw the transparent layer on top of everything to give a 3d look
+ maskGrad.setStart(QPointF(0, 0));
+ maskGrad.setFinalStop(QPointF(w, 0));
+ p.fillRect(0, 0, w, h, QBrush(maskGrad));
+
}
+
//---------------------------------------------------------
// drawVU
//---------------------------------------------------------
@@ -150,60 +215,119 @@ void Meter::drawVU(QPainter& p, int w, int h, int yv)
double range = maxScale - minScale;
int y1 = int((maxScale - redScale) * h / range);
int y2 = int((maxScale - yellowScale) * h / range);
-
+
+ darkGradGreen.setStart(QPointF(0, y2));
+ darkGradGreen.setFinalStop(QPointF(0, h));
+ darkGradYellow.setStart(QPointF(0, y1));
+ darkGradYellow.setFinalStop(QPointF(0, y2));
+ darkGradRed.setStart(QPointF(0, 0));
+ darkGradRed.setFinalStop(QPointF(0, y1));
+
+ lightGradGreen.setStart(QPointF(0, y2));
+ lightGradGreen.setFinalStop(QPointF(0, h));
+ lightGradYellow.setStart(QPointF(0, y1));
+ lightGradYellow.setFinalStop(QPointF(0, y2));
+ lightGradRed.setStart(QPointF(0, 0));
+ lightGradRed.setFinalStop(QPointF(0, y1));
+
if(yv < y1)
{
// Red section:
- p.fillRect(0, 0, w, yv, QBrush(0x8e0000)); // dark red
- p.fillRect(0, yv, w, y1-yv, QBrush(0xff0000)); // light red
+ p.fillRect(0, 0, w, yv, QBrush(darkGradRed)); // dark red
+ p.fillRect(0, yv, w, y1-yv, QBrush(lightGradRed)); // light red
// Yellow section:
- p.fillRect(0, y1, w, y2-y1, QBrush(0xffff00)); // light yellow
+ p.fillRect(0, y1, w, y2-y1, QBrush(lightGradYellow)); // light yellow
// Green section:
- p.fillRect(0, y2, w, h-y2, QBrush(0x00ff00)); // light green
+ p.fillRect(0, y2, w, h-y2, QBrush(lightGradGreen)); // light green
}
else
if(yv < y2)
{
// Red section:
- p.fillRect(0, 0, w, y1, QBrush(0x8e0000)); // dark red
+ p.fillRect(0, 0, w, y1, QBrush(darkGradRed)); // dark red
// Yellow section:
- p.fillRect(0, y1, w, yv-y1, QBrush(0x8e8e00)); // dark yellow
- p.fillRect(0, yv, w, y2-yv, QBrush(0xffff00)); // light yellow
+ p.fillRect(0, y1, w, yv-y1, QBrush(darkGradYellow)); // dark yellow
+ p.fillRect(0, yv, w, y2-yv, QBrush(lightGradYellow)); // light yellow
// Green section:
- p.fillRect(0, y2, w, h-y2, QBrush(0x00ff00)); // light green
+ p.fillRect(0, y2, w, h-y2, QBrush(lightGradGreen)); // light green
}
else
//if(yv <= y3)
{
// Red section:
- p.fillRect(0, 0, w, y1, QBrush(0x8e0000)); // dark red
+ p.fillRect(0, 0, w, y1, QBrush(darkGradRed)); // dark red
// Yellow section:
- p.fillRect(0, y1, w, y2-y1, QBrush(0x8e8e00)); // dark yellow
+ p.fillRect(0, y1, w, y2-y1, QBrush(darkGradYellow)); // dark yellow
// Green section:
- p.fillRect(0, y2, w, yv-y2, QBrush(0x007000)); // dark green
- p.fillRect(0, yv, w, h-yv, QBrush(0x00ff00)); // light green
+ p.fillRect(0, y2, w, yv-y2, QBrush(darkGradGreen)); // dark green
+ p.fillRect(0, yv, w, h-yv, QBrush(lightGradGreen)); // light green
}
+
+ p.fillRect(0,y1, w, 1, separator_color);
+ p.fillRect(0,y2, w, 1, separator_color);
+
}
else
{
- p.fillRect(0, 0, w, yv, QBrush(0x007000)); // dark green
- p.fillRect(0, yv, w, h-yv, QBrush(0x00ff00)); // light green
+ darkGradGreen.setStart(QPointF(0, 0));
+ darkGradGreen.setFinalStop(QPointF(0, h));
+
+ lightGradGreen.setStart(QPointF(0, 0));
+ lightGradGreen.setFinalStop(QPointF(0, h));
+
+ p.fillRect(0, 0, w, yv, QBrush(darkGradGreen)); // dark green
+ p.fillRect(0, yv, w, h-yv, QBrush(lightGradGreen)); // light green
}
+
}
//---------------------------------------------------------
// resizeEvent
//---------------------------------------------------------
-void Meter::resizeEvent(QResizeEvent* /*ev*/)
+void Meter::resizeEvent(QResizeEvent* ev)
{
-
+ // Round corners of the widget.
+
+ QSize size = ev->size();
+ int w = size.width();
+ int h = size.height();
+ QPainterPath rounded_rect;
+ rounded_rect.addRoundedRect(0,0,w,h, w/2.5, w/3);
+ QRegion maskregion(rounded_rect.toFillPolygon().toPolygon());
+ setMask(maskregion);
+
+ /*
+ // Another method to do the above. I don't know yet which one is more efficient - Orcan
+ QRect rect(0,0,w,h);
+ int r = 6;
+
+ QRegion region;
+ // middle and borders
+ region += rect.adjusted(r, 0, -r, 0);
+ region += rect.adjusted(0, r, 0, -r);
+ // top left
+ QRect corner(rect.topLeft(), QSize(r*2, r*2));
+ region += QRegion(corner, QRegion::Ellipse);
+ // top right
+ corner.moveTopRight(rect.topRight());
+ region += QRegion(corner, QRegion::Ellipse);
+ // bottom left
+ corner.moveBottomLeft(rect.bottomLeft());
+ region += QRegion(corner, QRegion::Ellipse);
+ // bottom right
+ corner.moveBottomRight(rect.bottomRight());
+ region += QRegion(corner, QRegion::Ellipse);
+ // return region;
+ setMask(region);
+ */
+
}
//---------------------------------------------------------
diff --git a/muse2/muse/widgets/meter.h b/muse2/muse/widgets/meter.h
index cced6e7a..848ae855 100644
--- a/muse2/muse/widgets/meter.h
+++ b/muse2/muse/widgets/meter.h
@@ -2,6 +2,7 @@
// MusE
// Linux Music Editor
// $Id: meter.h,v 1.1.1.1.2.2 2009/05/03 04:14:00 terminator356 Exp $
+// redesigned by oget on 2011/08/15
//
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================
@@ -20,6 +21,41 @@ class Meter : public QFrame {
Q_OBJECT
public:
enum MeterType {DBMeter, LinMeter};
+
+ protected:
+ QLinearGradient darkGradRed;
+ QColor dark_red_end;
+ QColor dark_red_begin;
+
+ QLinearGradient darkGradYellow;
+ QColor dark_yellow_end;
+ QColor dark_yellow_center;
+ QColor dark_yellow_begin;
+
+ QLinearGradient darkGradGreen;
+ QColor dark_green_end;
+ QColor dark_green_begin;
+
+ QLinearGradient lightGradRed;
+ QColor light_red_end;
+ QColor light_red_begin;
+
+ QLinearGradient lightGradYellow;
+ QColor light_yellow_end;
+ QColor light_yellow_center;
+ QColor light_yellow_begin;
+
+ QLinearGradient lightGradGreen;
+ QColor light_green_end;
+ QColor light_green_begin;
+
+ QLinearGradient maskGrad;
+ QColor mask_center;
+ QColor mask_edge;
+
+ QColor separator_color;;
+ QColor peak_color;
+
private:
MeterType mtype;
bool overflow;
@@ -30,7 +66,6 @@ class Meter : public QFrame {
void drawVU(QPainter& p, int, int, int);
-
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent*);
void mousePressEvent(QMouseEvent*);
diff --git a/muse2/muse/widgets/verticalmeter.cpp b/muse2/muse/widgets/verticalmeter.cpp
index dbe50723..76f8dcd1 100644
--- a/muse2/muse/widgets/verticalmeter.cpp
+++ b/muse2/muse/widgets/verticalmeter.cpp
@@ -2,11 +2,11 @@
// MusE
// Linux Music Editor
// $Id: meter.cpp,v 1.4.2.2 2009/05/03 04:14:00 terminator356 Exp $
+// redesigned by oget on 2011/08/15
//
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================
-#include <stdio.h>
#include <cmath>
#include <QMouseEvent>
@@ -107,7 +107,7 @@ void VerticalMeter::setRange(double min, double max)
// paintEvent
//---------------------------------------------------------
-void VerticalMeter::paintEvent(QPaintEvent* /*ev*/)
+void VerticalMeter::paintEvent(QPaintEvent* ev)
{
// TODO: Could make better use of event rectangle, for speed.
@@ -115,9 +115,15 @@ void VerticalMeter::paintEvent(QPaintEvent* /*ev*/)
double range = maxScale - minScale;
+ /*
int fw = frameWidth();
int w = width() - 2*fw;
int h = height() - 2*fw;
+ */
+
+ QRect rect = ev->rect();
+ int w = rect.width();
+ int h = rect.height();
int xv;
@@ -139,8 +145,13 @@ void VerticalMeter::paintEvent(QPaintEvent* /*ev*/)
xcenter = maxVal == 0 ? 0 : int(((maxScale - (fast_log10(0) * 20.0)) * w)/range);
else
xcenter = maxVal == 0 ? 0 : int(((0) * w)/range);
- p.setPen(Qt::white);
+ p.setPen(peak_color);
p.drawLine(xcenter, 0, xcenter, h);
+
+ // Draw the transparent layer on top of everything to give a 3d look
+ maskGrad.setStart(QPointF(0, 0));
+ maskGrad.setFinalStop(QPointF(0, h));
+ p.fillRect(0, 0, w, h, QBrush(maskGrad));
}
//---------------------------------------------------------
@@ -154,58 +165,92 @@ void VerticalMeter::drawVU(QPainter& p, int w, int h, int xv)
double range = maxScale - minScale;
int x1 = int((maxScale - redScale) * w / range);
int x2 = int((maxScale - yellowScale) * w / range);
+
+ darkGradGreen.setStart(QPointF(x2, 0));
+ darkGradGreen.setFinalStop(QPointF(w, 0));
+ darkGradYellow.setStart(QPointF(x1, 0));
+ darkGradYellow.setFinalStop(QPointF(x2, 0));
+ darkGradRed.setStart(QPointF(0, 0));
+ darkGradRed.setFinalStop(QPointF(x1, 0));
+
+ lightGradGreen.setStart(QPointF(x2, 0));
+ lightGradGreen.setFinalStop(QPointF(w, 0));
+ lightGradYellow.setStart(QPointF(x1, 0));
+ lightGradYellow.setFinalStop(QPointF(x2, 0));
+ lightGradRed.setStart(QPointF(0, 0));
+ lightGradRed.setFinalStop(QPointF(x1, 0));
+
if(xv < x1)
{
// Red section:
- p.fillRect(0, 0, xv, h, QBrush(0x8e0000)); // dark red
- p.fillRect(xv, 0, x1-xv, h, QBrush(0xff0000)); // light red
+ p.fillRect(0, 0, xv, h, QBrush(darkGradRed)); // dark red
+ p.fillRect(xv, 0, x1-xv, h, QBrush(lightGradRed)); // light red
// Yellow section:
- p.fillRect(x1, 0, x2-x1, h, QBrush(0xffff00)); // light yellow
+ p.fillRect(x1, 0, x2-x1, h, QBrush(lightGradYellow)); // light yellow
// Green section:
- p.fillRect(x2, 0, w-x2, h, QBrush(0x00ff00)); // light green
+ p.fillRect(x2, 0, w-x2, h, QBrush(lightGradGreen)); // light green
}
else
if(xv < x2)
{
// Red section:
- p.fillRect(0, 0, x1, h, QBrush(0x8e0000)); // dark red
+ p.fillRect(0, 0, x1, h, QBrush(darkGradRed)); // dark red
// Yellow section:
- p.fillRect(x1, 0, xv-x1, h, QBrush(0x8e8e00)); // dark yellow
- p.fillRect(xv, 0, x2-xv, h, QBrush(0xffff00)); // light yellow
+ p.fillRect(x1, 0, xv-x1, h, QBrush(darkGradYellow)); // dark yellow
+ p.fillRect(xv, 0, x2-xv, h, QBrush(lightGradYellow)); // light yellow
// Green section:
- p.fillRect(x2, 0, w-x2, h, QBrush(0x00ff00)); // light green
+ p.fillRect(x2, 0, w-x2, h, QBrush(lightGradGreen)); // light green
}
else
//if(yv <= y3)
{
// Red section:
- p.fillRect(0, 0, x1, h, QBrush(0x8e0000)); // dark red
+ p.fillRect(0, 0, x1, h, QBrush(darkGradRed)); // dark red
// Yellow section:
- p.fillRect(x1, 0, x2-x1, h, QBrush(0x8e8e00)); // dark yellow
+ p.fillRect(x1, 0, x2-x1, h, QBrush(darkGradYellow)); // dark yellow
// Green section:
- p.fillRect(x2, 0, xv-x2, h, QBrush(0x007000)); // dark green
- p.fillRect(xv, 0, w-xv, h, QBrush(0x00ff00)); // light green
+ p.fillRect(x2, 0, xv-x2, h, QBrush(darkGradGreen)); // dark green
+ p.fillRect(xv, 0, w-xv, h, QBrush(lightGradGreen)); // light green
}
+
+ p.fillRect(x1,0, 1, h, separator_color);
+ p.fillRect(x2,0, 1, h, separator_color);
+
}
else
{
- p.fillRect(0, 0, xv, h, QBrush(0x00ff00)); // dark green
- p.fillRect(xv, 0, w-xv, h, QBrush(0x007000)); // light green
+ darkGradGreen.setStart(QPointF(0, 0));
+ darkGradGreen.setFinalStop(QPointF(w, 0));
+
+ lightGradGreen.setStart(QPointF(0, 0));
+ lightGradGreen.setFinalStop(QPointF(w, 0));
+
+ p.fillRect(0, 0, xv, h, QBrush(lightGradGreen)); // light green
+ p.fillRect(xv, 0, w-xv, h, QBrush(darkGradGreen)); // dark green
}
+
}
//---------------------------------------------------------
// resizeEvent
//---------------------------------------------------------
-void VerticalMeter::resizeEvent(QResizeEvent* /*ev*/)
+void VerticalMeter::resizeEvent(QResizeEvent* ev)
{
+ // Round corners of the widget.
+ QSize size = ev->size();
+ int w = size.width();
+ int h = size.height();
+ QPainterPath rounded_rect;
+ rounded_rect.addRoundedRect(0,0,w,h, h/3, h/2.5);
+ QRegion maskregion(rounded_rect.toFillPolygon().toPolygon());
+ setMask(maskregion);
}
diff --git a/muse2/muse/widgets/verticalmeter.h b/muse2/muse/widgets/verticalmeter.h
index facc8b8c..9613ec43 100644
--- a/muse2/muse/widgets/verticalmeter.h
+++ b/muse2/muse/widgets/verticalmeter.h
@@ -9,9 +9,9 @@
#ifndef __VERTICALMETER_H__
#define __VERTICALMETER_H__
-#include <QFrame>
#include "meter.h"
+class QPaintEvent;
class QResizeEvent;
class QMouseEvent;
class QPainter;