summaryrefslogtreecommitdiff
path: root/muse2/awl
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/awl')
-rw-r--r--muse2/awl/CMakeLists.txt2
-rw-r--r--muse2/awl/floatentry.cpp2
-rw-r--r--muse2/awl/pitchedit.cpp4
-rw-r--r--muse2/awl/posedit.cpp22
-rw-r--r--muse2/awl/posedit.h8
-rw-r--r--muse2/awl/sigedit.cpp46
-rw-r--r--muse2/awl/sigedit.h9
-rw-r--r--muse2/awl/sigspinbox.cpp57
-rw-r--r--muse2/awl/sigspinbox.h25
-rw-r--r--muse2/awl/tcanvas.cpp2
10 files changed, 145 insertions, 32 deletions
diff --git a/muse2/awl/CMakeLists.txt b/muse2/awl/CMakeLists.txt
index f84194a8..7586b1c2 100644
--- a/muse2/awl/CMakeLists.txt
+++ b/muse2/awl/CMakeLists.txt
@@ -45,6 +45,7 @@ QT4_WRAP_CPP (awl_mocs
posedit.h
# poslabel.h
sigedit.h
+ sigspinbox.h
slider.h
# tcanvas.h
tempoedit.h
@@ -80,6 +81,7 @@ file (GLOB awl_source_files
posedit.cpp
# poslabel.cpp
sigedit.cpp
+ sigspinbox.cpp
slider.cpp
# tcanvas.cpp
tempoedit.cpp
diff --git a/muse2/awl/floatentry.cpp b/muse2/awl/floatentry.cpp
index 573420df..9b4b3e99 100644
--- a/muse2/awl/floatentry.cpp
+++ b/muse2/awl/floatentry.cpp
@@ -220,7 +220,7 @@ void FloatEntry::repeat()
switch (button) {
case Qt::LeftButton:
- if (!MusEConfig::config.leftMouseButtonCanDecrease)
+ if (!MusEGlobal::config.leftMouseButtonCanDecrease)
return;
// else fall through
case Qt::MidButton:
diff --git a/muse2/awl/pitchedit.cpp b/muse2/awl/pitchedit.cpp
index e0ede87b..3d9f1037 100644
--- a/muse2/awl/pitchedit.cpp
+++ b/muse2/awl/pitchedit.cpp
@@ -27,7 +27,9 @@
#include <QKeyEvent>
+namespace MusEGlobal {
extern QObject* song; // TODO FINDME this is a really dirty hack!
+}
namespace Awl {
@@ -40,7 +42,7 @@ PitchEdit::PitchEdit(QWidget* parent)
{
setRange(0, 127);
deltaMode = false;
- connect(song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int)));
+ connect(MusEGlobal::song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int)));
}
//---------------------------------------------------------
diff --git a/muse2/awl/posedit.cpp b/muse2/awl/posedit.cpp
index 5666f39f..049b59bd 100644
--- a/muse2/awl/posedit.cpp
+++ b/muse2/awl/posedit.cpp
@@ -32,7 +32,9 @@
#include <QLineEdit>
#include <QStyle>
+namespace MusEGlobal {
extern int mtcType;
+}
namespace Awl {
@@ -217,7 +219,7 @@ void PosEdit::setSmpte(bool f)
// setValue
//---------------------------------------------------------
-void PosEdit::setValue(const Pos& time)
+void PosEdit::setValue(const MusECore::Pos& time)
{
if(_pos == time)
return;
@@ -227,13 +229,13 @@ void PosEdit::setValue(const Pos& time)
void PosEdit::setValue(const QString& s)
{
- Pos time(s);
+ MusECore::Pos time(s);
setValue(time);
}
void PosEdit::setValue(int t)
{
- Pos time(t);
+ MusECore::Pos time(t);
setValue(time);
}
@@ -287,7 +289,7 @@ QAbstractSpinBox::StepEnabled PosEdit::stepEnabled() const
else
{
int nf = 23; // 24 frames sec
- switch(mtcType) {
+ switch(MusEGlobal::mtcType) {
//case 0: // 24 frames sec
// nf = 23;
// break;
@@ -398,7 +400,7 @@ QValidator::State PosEdit::validate(QString& s,int& /*i*/) const
rv = state;
int nf = 23; // 24 frames sec
- switch(mtcType) {
+ switch(MusEGlobal::mtcType) {
//case 0: // 24 frames sec
// nf = 23;
// break;
@@ -541,7 +543,7 @@ void PosEdit::stepBy(int steps)
case 2:
{
int nf = 23; // 24 frames sec
- switch(mtcType) {
+ switch(MusEGlobal::mtcType) {
//case 0: // 24 frames sec
// nf = 23;
// break;
@@ -578,7 +580,7 @@ void PosEdit::stepBy(int steps)
default:
return;
}
- Pos newPos(minute, sec, frame, subframe);
+ MusECore::Pos newPos(minute, sec, frame, subframe);
if (!(newPos == _pos)) {
changed = true;
_pos = newPos;
@@ -623,7 +625,7 @@ void PosEdit::stepBy(int steps)
default:
return;
}
- Pos newPos(bar, beat, tick);
+ MusECore::Pos newPos(bar, beat, tick);
if (!(newPos == _pos)) {
changed = true;
_pos = newPos;
@@ -666,7 +668,7 @@ void PosEdit::finishEdit()
return;
}
- Pos newPos(sl[0].toInt(), sl[1].toInt(), sl[2].toInt(), sl[3].toInt());
+ MusECore::Pos newPos(sl[0].toInt(), sl[1].toInt(), sl[2].toInt(), sl[3].toInt());
if (!(newPos == _pos))
{
changed = true;
@@ -681,7 +683,7 @@ void PosEdit::finishEdit()
return;
}
- Pos newPos(sl[0].toInt() - 1, sl[1].toInt() - 1, sl[2].toInt());
+ MusECore::Pos newPos(sl[0].toInt() - 1, sl[1].toInt() - 1, sl[2].toInt());
if (!(newPos == _pos))
{
changed = true;
diff --git a/muse2/awl/posedit.h b/muse2/awl/posedit.h
index 2da74d41..29692124 100644
--- a/muse2/awl/posedit.h
+++ b/muse2/awl/posedit.h
@@ -42,7 +42,7 @@ class PosEdit : public QAbstractSpinBox
Q_PROPERTY(bool smpte READ smpte WRITE setSmpte)
bool _smpte;
- Pos _pos;
+ MusECore::Pos _pos;
bool initialized;
QIntValidator* validator;
@@ -58,7 +58,7 @@ class PosEdit : public QAbstractSpinBox
void finishEdit();
signals:
- void valueChanged(const Pos&);
+ void valueChanged(const MusECore::Pos&);
// Choose these three carefully, watch out for focusing recursion.
void returnPressed();
@@ -67,7 +67,7 @@ class PosEdit : public QAbstractSpinBox
void editingFinished();
public slots:
- void setValue(const Pos& time);
+ void setValue(const MusECore::Pos& time);
void setValue(int t);
void setValue(const QString& s);
@@ -76,7 +76,7 @@ class PosEdit : public QAbstractSpinBox
~PosEdit();
QSize sizeHint() const;
- Pos pos() const { return _pos; }
+ MusECore::Pos pos() const { return _pos; }
void setSmpte(bool);
bool smpte() const { return _smpte; }
// void* operator new(size_t); // What was this for? Tim.
diff --git a/muse2/awl/sigedit.cpp b/muse2/awl/sigedit.cpp
index 74e4b060..d3685a53 100644
--- a/muse2/awl/sigedit.cpp
+++ b/muse2/awl/sigedit.cpp
@@ -43,20 +43,26 @@ SigEdit::SigEdit(QWidget* parent)
{
initialized = false;
slash = new QLabel("/",this);
- zSpin = new QSpinBox(this);
- nSpin = new QSpinBox(this);
+ zSpin = new SigSpinBox(this);
+ nSpin = new SigSpinBox(this);
zSpin->setRange(1,100);
- nSpin->setRange(1,100);
+ nSpin->setDenominator();
+ nSpin->setRange(1,128);
layout = new QHBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(1);
layout->addWidget(zSpin);
layout->addWidget(slash);
layout->addWidget(nSpin);
- layout->addSpacing(40);
+ layout->addSpacing(30);
connect(zSpin, SIGNAL(valueChanged(int)), SLOT(setZ(int)));
connect(nSpin, SIGNAL(valueChanged(int)), SLOT(setN(int)));
+ connect(nSpin, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(zSpin, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(zSpin, SIGNAL(moveFocus()), SLOT(moveFocus()));
+ connect(nSpin, SIGNAL(moveFocus()), SLOT(moveFocus()));
+ zSpin->selectAll();
}
SigEdit::~SigEdit()
@@ -68,18 +74,29 @@ SigEdit::~SigEdit()
//---------------------------------------------------------
+// moveFocus
+//---------------------------------------------------------
+
+void SigEdit::moveFocus()
+{
+ if (zSpin->hasFocus()) {
+ nSpin->setFocus();
+ nSpin->selectAll();
+ }
+ else {
+ zSpin->setFocus();
+ zSpin->selectAll();
+ }
+}
+
+//---------------------------------------------------------
// setZ
//---------------------------------------------------------
void SigEdit::setZ(const int z)
{
_sig.z=z;
- if (_sig.isValid()) {
- zSpin->setStyleSheet("");
- emit valueChanged(_sig);
- }
- else
- zSpin->setStyleSheet("QSpinBox { background-color: red; }");
+ emit valueChanged(_sig);
}
//---------------------------------------------------------
// setN
@@ -118,13 +135,18 @@ void SigEdit::updateValue()
nSpin->setValue(_sig.n);
}
- void SigEdit::paintEvent(QPaintEvent* event) {
+void SigEdit::paintEvent(QPaintEvent* event) {
if (!initialized)
updateValue();
initialized = true;
QPainter p(this);
- p.fillRect(event->rect(), Qt::white);
+ p.fillRect(event->rect(), p.background());
QWidget::paintEvent(event);
}
+void SigEdit::setFocus()
+{
+ zSpin->setFocus();
+}
+
}
diff --git a/muse2/awl/sigedit.h b/muse2/awl/sigedit.h
index acb0b9d8..5fe8186d 100644
--- a/muse2/awl/sigedit.h
+++ b/muse2/awl/sigedit.h
@@ -25,9 +25,9 @@
#include "al/sig.h"
//#include "sig.h"
+#include <awl/sigspinbox.h>
#include <QWidget>
-#include <QSpinBox>
#include <QHBoxLayout>
#include <QLabel>
@@ -48,8 +48,8 @@ class SigEdit : public QWidget
AL::TimeSignature _sig;
bool initialized;
QLabel *slash;
- QSpinBox *zSpin;
- QSpinBox *nSpin;
+ SigSpinBox *zSpin;
+ SigSpinBox *nSpin;
QHBoxLayout *layout;
virtual void paintEvent(QPaintEvent* event);
@@ -57,13 +57,16 @@ class SigEdit : public QWidget
signals:
void valueChanged(const AL::TimeSignature&);
+ void returnPressed();
private slots:
void setN(const int n);
void setZ(const int z);
+ void moveFocus();
public slots:
void setValue(const AL::TimeSignature&);
+ void setFocus();
public:
SigEdit(QWidget* parent = 0);
diff --git a/muse2/awl/sigspinbox.cpp b/muse2/awl/sigspinbox.cpp
new file mode 100644
index 00000000..6e38b164
--- /dev/null
+++ b/muse2/awl/sigspinbox.cpp
@@ -0,0 +1,57 @@
+#include "sigspinbox.h"
+#include "al/sig.h"
+#include <QKeyEvent>
+#include <stdio.h>
+
+SigSpinBox::SigSpinBox(QWidget *parent) :
+ QSpinBox(parent)
+{
+ _denominator=false;
+}
+void SigSpinBox::keyPressEvent(QKeyEvent*ev)
+{
+ switch (ev->key()) {
+ case Qt::Key_Return:
+ emit returnPressed();
+ return;
+ break;
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Slash:
+ emit moveFocus();
+ return;
+ break;
+ default:
+ break;
+ }
+ QSpinBox::keyPressEvent(ev);
+}
+
+void SigSpinBox::setDenominator()
+{
+ _denominator=true;
+}
+
+void SigSpinBox::stepBy(int step)
+{
+ if (!_denominator) {
+ setValue(value() + step);
+ return;
+ }
+
+ AL::TimeSignature sig(4, value());
+ if (step == 1) {
+ // make sure that sig is valid then increase
+ if (sig.isValid())
+ setValue(value() * 2);
+ }
+ else if (step == -1) {
+ // make sure that sig is valid then increase
+ if (sig.isValid()) {
+ int v = value() / 2;
+ if (v < 2)
+ v = 2;
+ setValue(v);
+ }
+ }
+}
diff --git a/muse2/awl/sigspinbox.h b/muse2/awl/sigspinbox.h
new file mode 100644
index 00000000..92fd1cbc
--- /dev/null
+++ b/muse2/awl/sigspinbox.h
@@ -0,0 +1,25 @@
+#ifndef SIGSPINBOX_H
+#define SIGSPINBOX_H
+
+#include <QSpinBox>
+
+class SigSpinBox : public QSpinBox
+{
+ Q_OBJECT
+ bool _denominator;
+protected:
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void stepBy(int);
+public:
+ explicit SigSpinBox(QWidget *parent = 0);
+ void setDenominator();
+
+signals:
+ void returnPressed();
+ void moveFocus();
+
+public slots:
+
+};
+
+#endif // SIGSPINBOX_H
diff --git a/muse2/awl/tcanvas.cpp b/muse2/awl/tcanvas.cpp
index d39080e2..70fe909f 100644
--- a/muse2/awl/tcanvas.cpp
+++ b/muse2/awl/tcanvas.cpp
@@ -300,7 +300,7 @@ bool TimeCanvas::eventFilter(QObject* obj, QEvent* event)
//else if (b & Qt::RightButton)
// i = 2;
else if (b & Qt::RightButton) {
- if ((MusEConfig::config.rangeMarkerWithoutMMB) && (event->modifiers() & Qt::ControlModifier))
+ if ((MusEGlobal::config.rangeMarkerWithoutMMB) && (event->modifiers() & Qt::ControlModifier))
i = 1;
else
i = 2;