summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/widgets/knob.cpp102
-rw-r--r--muse2/muse/widgets/knob.h4
3 files changed, 67 insertions, 42 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 7dc46580..9a3ff964 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+31.07.2011:
+ - Remodel the Knob (Orcan)
+
28.07.2011:
- speeded up structural operations (flo93)
- fixed several heavy bugs in structural operations: (flo93)
diff --git a/muse2/muse/widgets/knob.cpp b/muse2/muse/widgets/knob.cpp
index 8257ff88..ae88e2f4 100644
--- a/muse2/muse/widgets/knob.cpp
+++ b/muse2/muse/widgets/knob.cpp
@@ -48,8 +48,8 @@ Knob::Knob(QWidget* parent, const char* name)
{
hasScale = false;
- d_borderWidth = 2;
- d_borderDist = 4;
+ d_borderWidth = 4;
+ d_shineWidth = 3;
d_totalAngle = 270.0;
d_scaleDist = 1;
d_symbol = Line;
@@ -57,9 +57,11 @@ Knob::Knob(QWidget* parent, const char* name)
d_knobWidth = 30;
_faceColSel = FALSE;
d_faceColor = palette().color(QPalette::Window);
+ d_rimColor = palette().mid().color();
+ d_shinyColor = palette().mid().color();
d_curFaceColor = d_faceColor;
d_altFaceColor = d_faceColor;
- d_markerColor = palette().color(QPalette::WindowText);
+ d_markerColor = palette().dark().color().darker(125);
d_dotWidth = 8;
setMinimumSize(30,30);
@@ -98,39 +100,55 @@ void Knob::setTotalAngle (double angle)
void Knob::drawKnob(QPainter* p, const QRect& r)
{
- QRect aRect;
-
const QPalette& pal = palette();
- QPen pn;
- int bw2 = d_borderWidth / 2;
-
- aRect.setRect(r.x() + bw2,
- r.y() + bw2,
- r.width() - 2*bw2,
- r.height() - 2*bw2);
-
- //
- // draw button face
- //
- p->setPen(Qt::NoPen);
- p->setBrush(d_curFaceColor);
- p->drawEllipse(aRect);
-
- //
- // draw button shades
- //
- pn.setWidth(d_borderWidth);
+
+ QRect aRect;
+ aRect.setRect(r.x() + d_borderWidth,
+ r.y() + d_borderWidth,
+ r.width() - 2*d_borderWidth,
+ r.height() - 2*d_borderWidth);
+
+ int width = r.width();
+ int height = r.height();
+ int size = qMin(width, height);
+ p->setRenderHint(QPainter::Antialiasing, true);
- pn.setColor(pal.color(QPalette::Light));
- p->setPen(pn);
- p->drawArc(aRect, 45*16,180*16);
+ //
+ // draw the rim
+ //
+
+ QLinearGradient linearg(QPoint(r.x(),r.y()), QPoint(size, size));
+ linearg.setColorAt(1 - M_PI_4, d_faceColor.lighter(125));
+ linearg.setColorAt(M_PI_4, d_faceColor.darker(175));
+ p->setBrush(linearg);
+ p->setPen(Qt::NoPen);
+ p->drawEllipse(r.x(),r.y(),size,size);
- pn.setColor(pal.color(QPalette::Dark));
- p->setPen(pn);
- p->drawArc(aRect, 225*16,180*16);
//
+ // draw shiny surrounding
+ //
+
+ QPen pn;
+ pn.setCapStyle(Qt::FlatCap);
+ pn.setColor(d_shinyColor.lighter(100+ abs(d_angle*100)/300));
+ pn.setWidth(d_shineWidth * 2);
+ p->setPen(pn);
+ p->drawArc(aRect, 0, 360 * 16);
+
+ //
+ // draw button face
+ //
+
+ QRadialGradient gradient(size/2, size/2, size-d_borderWidth, size/2-d_borderWidth, size/2-d_borderWidth);
+ gradient.setColorAt(0, d_curFaceColor.lighter(150));
+ gradient.setColorAt(1, d_curFaceColor.darker(150));
+ p->setBrush(gradient);
+ p->setPen(Qt::NoPen);
+ p->drawEllipse(aRect);
+
+ //
// draw marker
//
//drawMarker(p, d_angle, isEnabled() ? d_markerColor : Qt::gray);
@@ -358,10 +376,11 @@ void Knob::drawMarker(QPainter *p, double arc, const QColor &c)
rarc = arc * M_PI / 180.0;
double ca = cos(rarc);
double sa = - sin(rarc);
- radius = kRect.width() / 2 - d_borderWidth;
+
+ radius = kRect.width() / 2 - d_borderWidth + d_shineWidth;
if (radius < 3) radius = 3;
- int ym = kRect.y() + radius + d_borderWidth;
- int xm = kRect.x() + radius + d_borderWidth;
+ int ym = kRect.y() + radius + d_borderWidth - d_shineWidth;
+ int xm = kRect.x() + radius + d_borderWidth - d_shineWidth;
switch (d_symbol)
{
@@ -382,14 +401,15 @@ void Knob::drawMarker(QPainter *p, double arc, const QColor &c)
pn.setWidth(2);
p->setPen(pn);
- rb = qwtMax(double((radius - 4) / 3.0), 0.0);
- re = qwtMax(double(radius - 4), 0.0);
-
- p->drawLine( xm - int(rint(sa * rb)),
- ym - int(rint(ca * rb)),
- xm - int(rint(sa * re)),
- ym - int(rint(ca * re)));
-
+ rb = qwtMax(double((radius - 1) / 3.0), 0.0);
+ re = qwtMax(double(radius - 1), 0.0);
+
+ p->setRenderHint(QPainter::Antialiasing, true);
+ p->drawLine( xm,
+ ym,
+ xm - int(rint(sa * re)),
+ ym - int(rint(ca * re)));
+
break;
}
diff --git a/muse2/muse/widgets/knob.h b/muse2/muse/widgets/knob.h
index 4da733ee..09e13c93 100644
--- a/muse2/muse/widgets/knob.h
+++ b/muse2/muse/widgets/knob.h
@@ -23,7 +23,7 @@ class Knob : public SliderBase, public ScaleIf
bool hasScale;
int d_borderWidth;
- int d_borderDist;
+ int d_shineWidth;
int d_scaleDist;
int d_maxScaleTicks;
int d_newVal;
@@ -39,6 +39,8 @@ class Knob : public SliderBase, public ScaleIf
QRect kRect;
bool _faceColSel;
QColor d_faceColor;
+ QColor d_shinyColor;
+ QColor d_rimColor;
QColor d_curFaceColor;
QColor d_altFaceColor;
QColor d_markerColor;