summaryrefslogtreecommitdiff
path: root/muse/awl
diff options
context:
space:
mode:
Diffstat (limited to 'muse/awl')
-rw-r--r--muse/awl/CMakeLists.txt11
-rw-r--r--muse/awl/aslider.cpp20
-rw-r--r--muse/awl/aslider.h6
-rw-r--r--muse/awl/drawbar.cpp15
4 files changed, 38 insertions, 14 deletions
diff --git a/muse/awl/CMakeLists.txt b/muse/awl/CMakeLists.txt
index 055b54c4..0544c82d 100644
--- a/muse/awl/CMakeLists.txt
+++ b/muse/awl/CMakeLists.txt
@@ -18,6 +18,8 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================
+include(${PROJECT_SOURCE_DIR}/pch.txt)
+
MACRO(WRAP_CPP outfiles )
FOREACH(it ${ARGN})
SET(${outfiles} ${${outfiles}} ${it}.cpp)
@@ -47,7 +49,13 @@ set(awl_src
awl.cpp utils.cpp ${mocCPP} ${moc_headers}
)
-add_library ( awl STATIC ${awl_src} )
+add_library (
+ awl
+ STATIC
+ ${awl_src}
+ ${PROJECT_BINARY_DIR}/all.h.pch
+ )
+
set_target_properties( awl
PROPERTIES COMPILE_FLAGS "-fPIC -include ${PROJECT_BINARY_DIR}/all.h"
)
@@ -82,6 +90,7 @@ ELSE (APPLE)
floatentry.cpp
drawbar.cpp
${moc_awlplugin_headers}
+ ${PROJECT_BINARY_DIR}/all-pic.h.pch
)
set_target_properties( awlplugin
diff --git a/muse/awl/aslider.cpp b/muse/awl/aslider.cpp
index fe2880d6..79a36b88 100644
--- a/muse/awl/aslider.cpp
+++ b/muse/awl/aslider.cpp
@@ -40,6 +40,7 @@ AbstractSlider::AbstractSlider(QWidget* parent)
_invert = false;
_scaleWidth = 4;
_log = false;
+ _integer = false;
}
//---------------------------------------------------------
@@ -108,10 +109,11 @@ void AbstractSlider::setScaleValueColor(const QColor& c)
void AbstractSlider::wheelEvent(QWheelEvent* ev)
{
- double div = 50.0;
+ double div = 120.0;
if (ev->modifiers() & Qt::ShiftModifier)
- div = 15;
- _value += (ev->delta() * lineStep()) / div;
+ _value += (ev->delta() * pageStep()) / div;
+ else
+ _value += (ev->delta() * lineStep()) / div;
if (_value < _minValue)
_value = _minValue;
else if (_value > _maxValue)
@@ -144,7 +146,10 @@ void AbstractSlider::keyPressEvent(QKeyEvent* ev)
_value = _minValue;
else if (_value > _maxValue)
_value = _maxValue;
+
if (oval != _value) {
+ if (_integer && (rint(oval) == rint(_value)))
+ return;
valueChange();
update();
}
@@ -165,6 +170,8 @@ void AbstractSlider::setValue(double val)
_value = _minValue;
}
}
+ else if (_integer)
+ _value = rint(val);
else
_value = val;
update();
@@ -185,10 +192,13 @@ void AbstractSlider::valueChange()
double AbstractSlider::value() const
{
- return _log ? pow(10.0, _value*0.05f) : _value;
+ if (_log)
+ return pow(10.0, _value*0.05f);
+ if (_integer)
+ return rint(_value);
+ return _value;
}
-
//---------------------------------------------------------
// minLogValue
//---------------------------------------------------------
diff --git a/muse/awl/aslider.h b/muse/awl/aslider.h
index adc462b4..32fc89f9 100644
--- a/muse/awl/aslider.h
+++ b/muse/awl/aslider.h
@@ -51,7 +51,8 @@ class AbstractSlider : public QWidget {
Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue)
Q_PROPERTY(double lineStep READ lineStep WRITE setLineStep)
Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep)
- Q_PROPERTY(bool log READ log WRITE setLog)
+ Q_PROPERTY(bool log READ log WRITE setLog)
+ Q_PROPERTY(bool integer READ integer WRITE setInteger)
protected:
int _id;
@@ -63,6 +64,7 @@ class AbstractSlider : public QWidget {
QColor _scaleColor;
QColor _scaleValueColor;
bool _log;
+ bool _integer;
virtual void wheelEvent(QWheelEvent*);
virtual void keyPressEvent(QKeyEvent*);
@@ -118,6 +120,8 @@ class AbstractSlider : public QWidget {
}
bool log() const { return _log; }
void setLog(bool v) { _log = v; }
+ bool integer() const { return _integer; }
+ void setInteger(bool v) { _integer = v; }
double lineStep() const { return _lineStep; }
void setLineStep(double v) { _lineStep = v; }
double pageStep() const { return _pageStep; }
diff --git a/muse/awl/drawbar.cpp b/muse/awl/drawbar.cpp
index bc58e4c3..18525ded 100644
--- a/muse/awl/drawbar.cpp
+++ b/muse/awl/drawbar.cpp
@@ -37,7 +37,9 @@ Drawbar::Drawbar(QWidget* parent)
setOrientation(Qt::Vertical);
setInvertedAppearance(true);
setRange(0.0, 8.0);
- setLineStep(0.3);
+ setLineStep(1.0);
+ setPageStep(1.0);
+ setInteger(true);
}
Drawbar::~Drawbar()
@@ -65,11 +67,10 @@ void Drawbar::paintEvent(QPaintEvent*)
int h = height();
int w = width();
- int kh = w * 2;
- int kw = w;
+ int kh = w * 2; // knob height
+ int kw = w;
int pixel = h - kh;
-// int ppos = pixel - int(pixel * _value / 8.0);
- int ppos = int(pixel * _value / 8.0);
+ int ppos = int(pixel * value() / 8.0);
QPainter p(this);
@@ -105,8 +106,8 @@ void Drawbar::paintEvent(QPaintEvent*)
int ch = pixel / 8;
QString num("%1");
- for (int i = 1; i < 9; ++i) {
- p.drawText(0, ch * (i-1) - (pixel - ppos), w, ch, Qt::AlignCenter, num.arg(9-i));
+ for (int i = 0; i < 8; ++i) {
+ p.drawText(0, i * pixel / 8 - (pixel - ppos), w, ch, Qt::AlignCenter, num.arg(8-i));
}
p.restore();