summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/ChangeLog2
-rw-r--r--muse2/muse/widgets/knob.cpp31
-rw-r--r--muse2/muse/widgets/knob.h5
3 files changed, 37 insertions, 1 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 854d87bf..d333b4fc 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,5 @@
+13.08.2011:
+ - Make the shininess of the Knob ring a little smarter (Orcan)
05.08.2011:
- Parts having hidden events now drawn using 'jagged' ends and special white edges. (Tim p4.0.29)
- Improved border drawing guaranteed to show L/R touching part borders. TODO: Top and bottom borders. (Tim)
diff --git a/muse2/muse/widgets/knob.cpp b/muse2/muse/widgets/knob.cpp
index ae88e2f4..dc41e1c4 100644
--- a/muse2/muse/widgets/knob.cpp
+++ b/muse2/muse/widgets/knob.cpp
@@ -64,6 +64,9 @@ Knob::Knob(QWidget* parent, const char* name)
d_markerColor = palette().dark().color().darker(125);
d_dotWidth = 8;
+ l_slope = 0;
+ l_const = 100;
+
setMinimumSize(30,30);
setUpdateTime(50);
}
@@ -94,6 +97,31 @@ void Knob::setTotalAngle (double angle)
}
//------------------------------------------------------------
+// Knob::setRange
+// Set the range and step size of the knob
+//
+// Sets the paramaters that define the shininess of the ring
+// surrounding the knob and then proceeds by passing the
+// parameters to the parent class' setRange() function.
+//------------------------------------------------------------
+
+void Knob::setRange(double vmin, double vmax, double vstep, int pagesize)
+ {
+ // divide by zero protection. probably too cautious
+ if (! (vmin == vmax || qMax(-vmin, vmax) == 0))
+ {
+ if (vmin * vmax < 0)
+ l_slope = 80.0 / qMax(-vmin, vmax);
+ else
+ {
+ l_slope = 80.0 / (vmax - vmin);
+ l_const = 100 - l_slope * vmin;
+ }
+ }
+ SliderBase::setRange(vmin, vmax, vstep, pagesize);
+ }
+
+//------------------------------------------------------------
// QwtKnob::drawKnob
// const QRect &r -- borders of the knob
//------------------------------------------------------------
@@ -132,7 +160,8 @@ void Knob::drawKnob(QPainter* p, const QRect& r)
QPen pn;
pn.setCapStyle(Qt::FlatCap);
- pn.setColor(d_shinyColor.lighter(100+ abs(d_angle*100)/300));
+
+ pn.setColor(d_shinyColor.lighter(l_const + abs(value() * l_slope)));
pn.setWidth(d_shineWidth * 2);
p->setPen(pn);
p->drawArc(aRect, 0, 360 * 16);
diff --git a/muse2/muse/widgets/knob.h b/muse2/muse/widgets/knob.h
index 09e13c93..2a553c4e 100644
--- a/muse2/muse/widgets/knob.h
+++ b/muse2/muse/widgets/knob.h
@@ -36,6 +36,9 @@ class Knob : public SliderBase, public ScaleIf
double d_totalAngle;
double d_nTurns;
+ double l_const;
+ double l_slope;
+
QRect kRect;
bool _faceColSel;
QColor d_faceColor;
@@ -62,6 +65,8 @@ class Knob : public SliderBase, public ScaleIf
Knob(QWidget* parent = 0, const char *name = 0);
~Knob() {}
+ void setRange(double vmin, double vmax, double vstep = 0.0,
+ int pagesize = 1);
void setKnobWidth(int w);
void setTotalAngle (double angle);
void setBorderWidth(int bw);