summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-12-01 13:55:20 +0000
committerWerner Schweer <ws.seh.de>2006-12-01 13:55:20 +0000
commit436723adc7de2e7e0662ff8275c3ef0ecf495ac9 (patch)
treed93d198b3e3e4f9588c83a7939c836c3cc3f5f61
parentc268c615297cfc4f8861e4aba2870353a459547d (diff)
updates
-rw-r--r--muse/muse/ctrl/ctrledit.cpp191
1 files changed, 191 insertions, 0 deletions
diff --git a/muse/muse/ctrl/ctrledit.cpp b/muse/muse/ctrl/ctrledit.cpp
new file mode 100644
index 00000000..06b28472
--- /dev/null
+++ b/muse/muse/ctrl/ctrledit.cpp
@@ -0,0 +1,191 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2002-2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "ctrledit.h"
+#include "midictrl.h"
+#include "widgets/simplebutton.h"
+#include "widgets/utils.h"
+#include "ctrl/configmidictrl.h"
+#include "ctrl/ctrldialog.h"
+#include "widgets/tools.h"
+#include "miditrack.h"
+#include "midioutport.h"
+
+//---------------------------------------------------------
+// CtrlEdit
+//---------------------------------------------------------
+
+CtrlEdit::CtrlEdit(QWidget* parent, TimeCanvas* timeCanvas, Track* t)
+ : QObject(parent), _track(t)
+ {
+ y = 0;
+ _height = 0;
+ setDrawCtrlName(true);
+
+ _tc = timeCanvas;
+ _ctrl = &veloList;
+ if (t->type() == Track::MIDI) {
+ ctrlId = CTRL_VELOCITY;
+ _ctrl = &veloList;
+ }
+ else {
+ ctrlId = AC_VOLUME;
+ _ctrl = t->getController(ctrlId);
+ }
+
+ sel = new SimpleButton(tr("Sel"), parent);
+ sel->setToolTip(tr("select controller"));
+ sel->setAutoRaise(false);
+
+ minus = newMinusButton();
+ minus->setParent(parent);
+ minus->setToolTip(tr("remove controller view"));
+ minus->setAutoRaise(false);
+
+ connect(_track, SIGNAL(controllerChanged(int)), SLOT(controllerListChanged(int)));
+ connect(sel, SIGNAL(clicked()), SLOT(showControllerList()));
+ }
+
+//---------------------------------------------------------
+// CtrlEdit
+//---------------------------------------------------------
+
+CtrlEdit::~CtrlEdit()
+ {
+ delete sel;
+ delete minus;
+ }
+
+//---------------------------------------------------------
+// setCtrl
+//---------------------------------------------------------
+
+void CtrlEdit::setCtrl(int id)
+ {
+ _ctrl = 0;
+
+ if (_track->type() == Track::MIDI) {
+ if (id == CTRL_VELOCITY)
+ _ctrl = &veloList;
+ else if (id == CTRL_SVELOCITY)
+ _ctrl = &sveloList;
+ else
+ _ctrl = _track->getController(id);
+ }
+ else
+ _ctrl = _track->getController(id);
+
+ if (!_ctrl)
+ printf("CtrlEdit::setCtrl(%d): not found for track <%s>\n", id,
+ _track->name().toLocal8Bit().data());
+ }
+
+//---------------------------------------------------------
+// showControllerList
+//---------------------------------------------------------
+
+void CtrlEdit::showControllerList()
+ {
+ Ctrl* c = ctrl();
+ int id;
+ if (c)
+ id = c->id();
+ else
+ id = CTRL_NO_CTRL;
+ for (;;) {
+ CtrlDialog cd(_track, id);
+ int rv = cd.exec();
+ if (rv != 1)
+ return;
+ id = cd.curId();
+ if (id == CTRL_NO_CTRL)
+ return;
+ if (id != CTRL_OTHER)
+ break;
+ ConfigMidiCtrl* mce = new ConfigMidiCtrl((MidiTrack*)_track);
+ mce->exec();
+ delete mce;
+ }
+ changeController(id);
+ }
+
+//---------------------------------------------------------
+// changeController
+//---------------------------------------------------------
+
+void CtrlEdit::changeController(int id)
+ {
+ if (id == CTRL_VELOCITY) {
+ ctrlId = id;
+ _ctrl = &veloList;
+ }
+ else if (id == CTRL_SVELOCITY) {
+ ctrlId = id;
+ _ctrl = &sveloList;
+ }
+ else if (id == CTRL_OTHER) { // "other"
+ if (track()->type() == Track::MIDI) {
+ ConfigMidiCtrl* mce = new ConfigMidiCtrl((MidiTrack*)track());
+ mce->exec();
+ sel->showMenu();
+ }
+ else
+ printf("CtrlEdit::changeController: not impl.\n");
+ }
+ else {
+ ctrlId = id;
+ _ctrl = track()->getController(ctrlId);
+ }
+ _tc->updateCanvasB();
+ }
+
+//---------------------------------------------------------
+// controllerListChanged
+//---------------------------------------------------------
+
+void CtrlEdit::controllerListChanged(int id)
+ {
+ if (id != ctrlId)
+ return;
+ tc()->widget()->update(tc()->rCanvasB);
+ }
+
+//---------------------------------------------------------
+// pixel2val
+//---------------------------------------------------------
+
+int CtrlEdit::pixel2val(int y) const
+ {
+ if (ctrl() == 0)
+ return 0;
+ CVal val = ctrl()->pixel2val(y, _height - splitWidth);
+ return val.i;
+ }
+
+
+//---------------------------------------------------------
+// setSinglePitch
+//---------------------------------------------------------
+
+void CtrlEdit::setSinglePitch(int val)
+ {
+ singlePitch = val;
+ }
+