summaryrefslogtreecommitdiff
path: root/muse2/muse/master/masteredit.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
committerFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
commit27b7bf6815cda7abb67026c37b3e44daee1803cb (patch)
tree0b9d1c0bc84ac7ff8032e707f2b5fb4e0aaabb5c /muse2/muse/master/masteredit.cpp
parent2d6f113a10eb485694e20a78500f650776d701e3 (diff)
merged with trunk
Diffstat (limited to 'muse2/muse/master/masteredit.cpp')
-rw-r--r--muse2/muse/master/masteredit.cpp88
1 files changed, 61 insertions, 27 deletions
diff --git a/muse2/muse/master/masteredit.cpp b/muse2/muse/master/masteredit.cpp
index 571d3c83..82ac697b 100644
--- a/muse2/muse/master/masteredit.cpp
+++ b/muse2/muse/master/masteredit.cpp
@@ -35,9 +35,10 @@
#include "xml.h"
#include "lcombo.h"
#include "doublelabel.h"
-///#include "sigedit.h"
#include "globals.h"
#include "app.h"
+#include "gconfig.h"
+#include "audio.h"
#include <values.h>
@@ -76,7 +77,7 @@ void MasterEdit::songChanged(int type)
return;
if (type & SC_TEMPO) {
- int tempo = MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos());
+ int tempo = MusEGlobal::tempomap.tempoAt(MusEGlobal::song->cpos()); // Bypass the useList flag and read from the list.
curTempo->blockSignals(true);
curTempo->setValue(double(60000000.0/tempo));
@@ -105,12 +106,10 @@ MasterEdit::MasterEdit()
: MidiEditor(TopWin::MASTER, _rasterInit, 0)
{
setWindowTitle(tr("MusE: Mastertrack"));
+ setFocusPolicy(Qt::NoFocus);
_raster = 0; // measure
//---------Pulldown Menu----------------------------
-// QPopupMenu* file = new QPopupMenu(this);
-// menuBar()->insertItem("&File", file);
-
QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config"));
settingsMenu->addAction(subwinAction);
settingsMenu->addAction(shareAction);
@@ -123,6 +122,7 @@ MasterEdit::MasterEdit()
QToolBar* enableMaster = addToolBar(tr("Enable master"));
enableMaster->setObjectName("Enable master");
enableButton = new QToolButton();
+ enableButton->setFocusPolicy(Qt::NoFocus);
enableButton->setCheckable(true);
enableButton->setText(tr("Enable"));
enableButton->setToolTip(tr("Enable usage of master track"));
@@ -150,7 +150,7 @@ MasterEdit::MasterEdit()
QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Off"), QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Bar"), "1/2", "1/4", "1/8", "1/16"
};
rasterLabel = new MusEGui::LabelCombo(tr("Snap"), 0);
- rasterLabel->setFocusPolicy(Qt::NoFocus);
+ rasterLabel->setFocusPolicy(Qt::TabFocus);
for (int i = 0; i < 6; i++)
rasterLabel->insertItem(i, tr(rastval[i]));
rasterLabel->setCurrentIndex(1);
@@ -160,17 +160,16 @@ MasterEdit::MasterEdit()
//---------values for current position---------------
info->addWidget(new QLabel(tr("CurPos ")));
curTempo = new MusEGui::TempoEdit(0);
- curSig = new SigEdit(0);
+ curSig = new SigEdit(0); // SigEdit is already StrongFocus.
+ curTempo->setFocusPolicy(Qt::StrongFocus);
curSig->setValue(AL::TimeSignature(4, 4));
curTempo->setToolTip(tr("tempo at current position"));
curSig->setToolTip(tr("time signature at current position"));
info->addWidget(curTempo);
info->addWidget(curSig);
- ///connect(curSig, SIGNAL(valueChanged(int,int)), song, SLOT(setSig(int,int)));
- connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&)));
-
- ///connect(curTempo, SIGNAL(valueChanged(double)), song, SLOT(setTempo(double)));
- connect(curTempo, SIGNAL(tempoChanged(double)), MusEGlobal::song, SLOT(setTempo(double)));
+
+ connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), SLOT(sigChange(const AL::TimeSignature&)));
+ connect(curTempo, SIGNAL(tempoChanged(double)), SLOT(tempoChange(double)));
//---------------------------------------------------
// master
@@ -183,7 +182,7 @@ MasterEdit::MasterEdit()
vscroll->setRange(30000, 250000);
time1 = new MusEGui::MTScale(&_raster, mainw, xscale);
sign = new MusEGui::SigScale(&_raster, mainw, xscale);
-// thits = new MusEGui::HitScale(&_raster, mainw, xscale);
+// thits = new MusEGui::HitScale(&_raster, mainw, xscale); DELETETHIS what IS this? delete zhits as well
canvas = new Master(this, mainw, xscale, yscale);
@@ -196,8 +195,6 @@ MasterEdit::MasterEdit()
// Rest
//---------------------------------------------------
-// QSizeGrip* corner = new QSizeGrip(mainw);
-
mainGrid->setRowStretch(5, 100);
mainGrid->setColumnStretch(1, 100);
@@ -206,19 +203,18 @@ MasterEdit::MasterEdit()
mainGrid->addWidget(MusECore::hLine(mainw), 2, 1);
mainGrid->addWidget(sign, 3, 1);
mainGrid->addWidget(MusECore::hLine(mainw), 4, 1);
-// mainGrid->addWidget(thits, 5, 1);
+// mainGrid->addWidget(thits, 5, 1); DELETETHIS
// mainGrid->addWidget(MusECore::hLine(mainw), 6, 1);
mainGrid->addWidget(canvas, 5, 1);
mainGrid->addWidget(tscale, 5, 0);
mainGrid->addWidget(MusECore::hLine(mainw), 6, 1);
-// mainGrid->addWidget(zhits, 9, 1);
+// mainGrid->addWidget(zhits, 9, 1); DELETETHIS
// mainGrid->addWidget(MusECore::hLine(mainw), 7, 1);
mainGrid->addWidget(time2, 7, 1);
mainGrid->addWidget(hscroll, 8, 1);
mainGrid->addWidget(vscroll, 0, 2, 10, 1);
-// mainGrid->addWidget(corner, 9, 2, AlignBottom | AlignRight);
- canvas->setFocus(); // Tim.
+ canvas->setFocus();
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
@@ -229,20 +225,20 @@ MasterEdit::MasterEdit()
connect(hscroll, SIGNAL(scrollChanged(int)), time1, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scrollChanged(int)), sign, SLOT(setXPos(int)));
-// connect(hscroll, SIGNAL(scrollChanged(int)), thits, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), thits, SLOT(setXPos(int))); DELETETHIS
connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
-// connect(hscroll, SIGNAL(scrollChanged(int)), zhits, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), zhits, SLOT(setXPos(int)));DELETETHIS
connect(hscroll, SIGNAL(scrollChanged(int)), time2, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), time1, SLOT(setXMag(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), sign, SLOT(setXMag(int)));
-// connect(hscroll, SIGNAL(scaleChanged(int)), thits, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), thits, SLOT(setXMag(int)));DELETETHIS
connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
-// connect(hscroll, SIGNAL(scaleChanged(int)), zhits, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), zhits, SLOT(setXMag(int))); DELETETHIS
connect(hscroll, SIGNAL(scaleChanged(int)), time2, SLOT(setXMag(int)));
connect(time1, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
-// connect(sign, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+// connect(sign, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned))); DELETETHIS
// connect(thits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
// connect(canvas, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
// connect(zhits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
@@ -256,6 +252,14 @@ MasterEdit::MasterEdit()
connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(curSig, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(curSig, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(curTempo, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(curTempo, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
+
initTopwinState();
MusEGlobal::muse->topwinMenuInited(this);
}
@@ -266,7 +270,6 @@ MasterEdit::MasterEdit()
MasterEdit::~MasterEdit()
{
- //undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -297,7 +300,7 @@ void MasterEdit::readStatus(MusECore::Xml& xml)
break;
case MusECore::Xml::TagEnd:
if (tag == "master") {
- // raster setzen
+ // set raster
int item = 0;
switch(_raster) {
case 1: item = 0; break;
@@ -373,6 +376,16 @@ void MasterEdit::writeConfiguration(int level, MusECore::Xml& xml)
}
//---------------------------------------------------------
+// focusCanvas
+//---------------------------------------------------------
+
+void MasterEdit::focusCanvas()
+{
+ canvas->setFocus();
+ canvas->activateWindow();
+}
+
+//---------------------------------------------------------
// _setRaster
//---------------------------------------------------------
@@ -383,6 +396,8 @@ void MasterEdit::_setRaster(int index)
};
_raster = rasterTable[index];
_rasterInit = _raster;
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
}
//---------------------------------------------------------
@@ -393,7 +408,7 @@ void MasterEdit::posChanged(int idx, unsigned val, bool)
{
if (idx == 0) {
int z, n;
- int tempo = MusEGlobal::tempomap.tempo(val);
+ int tempo = MusEGlobal::tempomap.tempoAt(val); // Bypass the useList flag and read from the list.
AL::sigmap.timesig(val, z, n);
curTempo->blockSignals(true);
curSig->blockSignals(true);
@@ -435,5 +450,24 @@ void MasterEdit::setTempo(int val)
tempo->setValue(val);
}
}
+
+void MasterEdit::sigChange(const AL::TimeSignature& sig)
+{
+ // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here...
+ MusEGlobal::audio->msgAddSig(MusEGlobal::song->cPos().tick(), sig.z, sig.n); // Add will replace if found.
+}
+
+void MasterEdit::tempoChange(double t)
+{
+ if(int(t) == 0)
+ return;
+
+ // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here... Also in transport.
+ //MusEGlobal::song->startUndo();
+ //iTEvent e = find(tick);
+ //MusEGlobal::audio->msgDeleteTempo(it->first, it->second, false);
+ MusEGlobal::audio->msgAddTempo(MusEGlobal::song->cPos().tick(), int(60000000.0/t), true); // Add will replace if found.
+ //MusEGlobal::song->endUndo(SC_TEMPO);
+}
} // namespace MusEGui