summaryrefslogtreecommitdiff
path: root/muse2/awl
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2012-11-17 10:03:17 +0000
committerTim E. Real <termtech@rogers.com>2012-11-17 10:03:17 +0000
commit09ac0c4c9a32cdba453812c4ac1199414fcc2719 (patch)
tree88147e3b93dfd17142d0c80f2117cc3c313ac518 /muse2/awl
parent499c8bfc244f631304fe0c15449a31b442ebe0d7 (diff)
Improved: Deicsonze soft synthesizer: Fixed crash, bugs, added ladspa plugins.
TODO: No plugin control automation. Log slider/entry ranges. Add delay wet/dry?
Diffstat (limited to 'muse2/awl')
-rw-r--r--muse2/awl/floatentry.cpp106
-rw-r--r--muse2/awl/floatentry.h9
2 files changed, 103 insertions, 12 deletions
diff --git a/muse2/awl/floatentry.cpp b/muse2/awl/floatentry.cpp
index 9b4b3e99..37b35152 100644
--- a/muse2/awl/floatentry.cpp
+++ b/muse2/awl/floatentry.cpp
@@ -26,6 +26,7 @@
#include <QLineEdit>
#include <QMouseEvent>
+#include <QContextMenuEvent>
#include <QTimer>
#define TIMER1 400
@@ -53,12 +54,43 @@ FloatEntry::FloatEntry(QWidget* parent)
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(repeat()));
_value = 0.0f;
- connect(this, SIGNAL(returnPressed()), SLOT(endEdit()));
+ //connect(this, SIGNAL(returnPressed()), SLOT(endEdit()));
+ connect(this, SIGNAL(editingFinished()), SLOT(endEdit()));
setCursor(QCursor(Qt::ArrowCursor));
updateValue();
}
//---------------------------------------------------------
+// calcIncrement()
+//---------------------------------------------------------
+
+double FloatEntry::calcIncrement() const
+{
+ double dif;
+ if(_maxValue - _minValue > 0)
+ dif = _maxValue - _minValue;
+ else
+ dif = _minValue - _maxValue;
+
+ if(dif <= 10.0)
+ return 0.1;
+ else
+ if(dif <= 100.0)
+ return 1.0;
+ else
+ return 10.0;
+}
+
+//---------------------------------------------------------
+// contextMenuEvent
+//---------------------------------------------------------
+
+void FloatEntry::contextMenuEvent(QContextMenuEvent * e)
+{
+ e->accept();
+}
+
+//---------------------------------------------------------
// setString
//---------------------------------------------------------
@@ -114,11 +146,16 @@ void FloatEntry::valueChange()
void FloatEntry::incValue(double)
{
- if (_value + 1.0 < _maxValue) {
- _value = _value + 1.0;
- updateValue();
- valueChange();
- }
+ if(_value >= _maxValue)
+ return;
+ double inc = calcIncrement();
+ if(_value + inc >= _maxValue)
+ //setValue(_maxValue);
+ _value = _maxValue;
+ else
+ //setValue(_value + inc);
+ _value += inc;
+ valueChange();
}
//---------------------------------------------------------
@@ -127,11 +164,16 @@ void FloatEntry::incValue(double)
void FloatEntry::decValue(double)
{
- if (_value - 1.0 > _minValue) {
- _value = _value - 1.0;
- updateValue();
- valueChange();
- }
+ if(_value <= _minValue)
+ return;
+ double inc = calcIncrement();
+ if(_value - inc <= _minValue)
+ //setValue(_minValue);
+ _value = _minValue;
+ else
+ //setValue(_value - inc);
+ _value -= inc;
+ valueChange();
}
//---------------------------------------------------------
@@ -188,8 +230,8 @@ void FloatEntry::mousePressEvent(QMouseEvent* event)
void FloatEntry::wheelEvent(QWheelEvent* event)
{
+ event->accept();
int delta = event->delta();
-
if (delta < 0)
decValue(-1.0);
else if (delta > 0)
@@ -322,5 +364,45 @@ double FloatEntry::value() const
rv = _value;
return rv;
}
+
+//---------------------------------------------------------
+// minLogValue
+//---------------------------------------------------------
+
+//double FloatEntry::minValue() const {
+// return _log ? pow(10.0, _minValue*0.05f) : _minValue;
+//}
+
+//---------------------------------------------------------
+// setMinLogValue
+//---------------------------------------------------------
+
+void FloatEntry::setMinLogValue(double val) {
+ if (_log) {
+ if (val == 0.0f) _minValue = -100;
+ else _minValue = fast_log10(val) * 20.0f;
+ }
+ else _minValue = val;
+}
+
+//---------------------------------------------------------
+// maxLogValue
+//---------------------------------------------------------
+
+//double FloatEntry::maxValue() const {
+// return _log ? pow(10.0, _maxValue*0.05f) : _maxValue;
+//}
+
+//---------------------------------------------------------
+// setMaxLogValue
+//---------------------------------------------------------
+
+void FloatEntry::setMaxLogValue(double val) {
+ if (_log) {
+ _maxValue = fast_log10(val) * 20.0f;
+ }
+ else _maxValue = val;
+}
+
}
diff --git a/muse2/awl/floatentry.h b/muse2/awl/floatentry.h
index 53d53bff..7d31498f 100644
--- a/muse2/awl/floatentry.h
+++ b/muse2/awl/floatentry.h
@@ -58,6 +58,8 @@ class FloatEntry : public QLineEdit {
int _precision;
bool _log;
+ double calcIncrement() const;
+
virtual void wheelEvent(QWheelEvent*);
virtual void mousePressEvent(QMouseEvent*);
virtual void mouseMoveEvent(QMouseEvent*);
@@ -67,6 +69,7 @@ class FloatEntry : public QLineEdit {
virtual bool setString(double);
virtual void incValue(double);
virtual void decValue(double);
+ void contextMenuEvent(QContextMenuEvent*);
void updateValue();
@@ -96,11 +99,17 @@ class FloatEntry : public QLineEdit {
double minValue() const { return _minValue; }
double maxValue() const { return _maxValue; }
void setMinValue(double v) { _minValue = v; }
+ void setMinLogValue(double v);
void setMaxValue(double v) { _maxValue = v; }
+ void setMaxLogValue(double v);
void setRange(double a, double b) {
_minValue = a;
_maxValue = b;
}
+ void setLogRange(double a, double b) {
+ setMinLogValue(a);
+ setMaxLogValue(b);
+ }
int precision() const { return _precision; }
void setPrecision(int val);
QString specialText() const { return _specialText; }