diff options
Diffstat (limited to 'muse_qt4_evolution/muse/ctrl')
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/CMakeLists.txt | 46 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/configmidictrl.cpp | 202 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/configmidictrl.h | 51 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/configmidictrl.ui | 204 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrldialog.cpp | 191 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrldialog.h | 49 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrldialog.ui | 126 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrledit.cpp | 184 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrledit.h | 76 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrleditor.cpp | 492 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/ctrleditor.h | 76 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/definemidictrl.cpp | 110 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/definemidictrl.h | 51 | ||||
-rw-r--r-- | muse_qt4_evolution/muse/ctrl/definemidictrl.ui | 285 |
14 files changed, 2143 insertions, 0 deletions
diff --git a/muse_qt4_evolution/muse/ctrl/CMakeLists.txt b/muse_qt4_evolution/muse/ctrl/CMakeLists.txt new file mode 100644 index 00000000..0bdb5be6 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/CMakeLists.txt @@ -0,0 +1,46 @@ +#============================================================================= +# 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. +#============================================================================= + +QT4_WRAP_CPP (ctrl_mocs + configmidictrl.h + definemidictrl.h + ctrldialog.h + ctrledit.h + ) + +QT4_WRAP_UI (ctrl_ui_headers + configmidictrl.ui + definemidictrl.ui + ctrldialog.ui + ) + +add_library ( ctrl STATIC + configmidictrl.cpp + definemidictrl.cpp + ctrldialog.cpp + ctrleditor.cpp + ctrledit.cpp + ${ctrl_mocs} + ${ctrl_ui_headers} + ) +set_target_properties( ctrl + PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h" + ) + diff --git a/muse_qt4_evolution/muse/ctrl/configmidictrl.cpp b/muse_qt4_evolution/muse/ctrl/configmidictrl.cpp new file mode 100644 index 00000000..395518a8 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/configmidictrl.cpp @@ -0,0 +1,202 @@ +//============================================================================= +// 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 "configmidictrl.h" +#include "definemidictrl.h" +#include "miditrack.h" +#include "midioutport.h" +#include "midictrl.h" +#include "midiout.h" +#include "instruments/minstrument.h" + +//--------------------------------------------------------- +// ConfigMidiCtrl +//--------------------------------------------------------- + +ConfigMidiCtrl::ConfigMidiCtrl(MidiTrack* t) + { + setupUi(this); + track = t; + + //--------------------------------------------------- + // populate list of managed controllers + //--------------------------------------------------- + + ControllerNameList* cn = track->controllerNames(); + for (iControllerName i = cn->begin(); i != cn->end(); ++i) + managedController->addItem(i->name); + + //--------------------------------------------------- + // populate list of available controllers + //--------------------------------------------------- + + if (track->type() == Track::MIDI) { + MidiTrack* mc = (MidiTrack*)track; + portName->setText(track->name()); + instrumentName->setText(mc->instrument()->iname()); + // + // populate popup with all controllers available for + // current instrument + // + MidiControllerList* mcl = mc->instrument()->controller(); + for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) { + iControllerName i; + for (i = cn->begin(); i != cn->end(); ++i) { + if (i->name == (*ci)->name()) + break; + } + if (i == cn->end()) + availableController->addItem((*ci)->name()); + } + } + + delete cn; + buttonAdd->setEnabled(false); + buttonRemove->setEnabled(false); + + connect(buttonAdd, SIGNAL(clicked()), SLOT(addClicked())); + connect(buttonRemove, SIGNAL(clicked()), SLOT(removeClicked())); + connect(availableController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(availableSelected(QListWidgetItem*))); + connect(managedController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(managedSelected(QListWidgetItem*))); + connect(defineButton, SIGNAL(clicked()), SLOT(defineClicked())); + } + +//--------------------------------------------------------- +// addClicked +//--------------------------------------------------------- + +void ConfigMidiCtrl::addClicked() + { + QListWidgetItem* n = availableController->currentItem(); + if (n == 0) + return; + QString s(n->text()); + for (int i = 0; i < managedController->count(); ++i) { + if (s == managedController->item(i)->text()) + return; + } + managedController->addItem(s); + managedController->setCurrentItem(managedController->item(managedController->count()-1)); + delete n; + buttonAdd->setEnabled(false); + } + +//--------------------------------------------------------- +// removeClicked +//--------------------------------------------------------- + +void ConfigMidiCtrl::removeClicked() + { + QListWidgetItem* n = managedController->currentItem(); + if (n == 0) + return; + availableController->addItem(n->text()); + delete n; + buttonRemove->setEnabled(false); + } + +//--------------------------------------------------------- +// availableSelected +//--------------------------------------------------------- + +void ConfigMidiCtrl::availableSelected(QListWidgetItem* item) + { + buttonAdd->setEnabled(item != 0); + } + +//--------------------------------------------------------- +// managedSelected +//--------------------------------------------------------- + +void ConfigMidiCtrl::managedSelected(QListWidgetItem* item) + { + buttonRemove->setEnabled(item != 0); + } + +//--------------------------------------------------------- +// done +//--------------------------------------------------------- + +void ConfigMidiCtrl::done(int code) + { + if (!code) { + QDialog::done(code); + return; + } + if (track->type() == Track::MIDI) { + ControllerNameList* cn = track->controllerNames(); + MidiInstrument* instr = track->instrument(); + MidiControllerList* mcl = instr->controller(); + + // + // search for new, added controller + // + int n = managedController->count(); + for (int i = 0; i < n; ++i) { + QString name(managedController->item(i)->text()); + iControllerName ii = cn->begin(); + for (; ii != cn->end(); ++ii) { + if (ii->name == name) + break; + } + if (ii == cn->end()) { + // add controller "name" to list of managed controller + // + for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) { + if ((*ci)->name() == name) { + Ctrl* ctrl = new Ctrl(*ci); + track->addController(ctrl); + break; + } + } + } + } + + // + // search for removed controller + // + for (iControllerName ii = cn->begin(); ii != cn->end(); ++ii) { + int i; + for (i = 0; i < n; ++i) { + if (managedController->item(i)->text() == ii->name) + break; + } + if (i == n) + track->removeController(ii->id); + } + delete cn; + } + QDialog::done(code); + } + +//--------------------------------------------------------- +// defineClicked +//--------------------------------------------------------- + +void ConfigMidiCtrl::defineClicked() + { + DefineMidiCtrl dc(track, this); + if (dc.exec()) { + Ctrl* ctrl = new Ctrl(dc.midiController()); + track->addController(ctrl); + QDialog::done(0); + } + } + diff --git a/muse_qt4_evolution/muse/ctrl/configmidictrl.h b/muse_qt4_evolution/muse/ctrl/configmidictrl.h new file mode 100644 index 00000000..0af11e36 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/configmidictrl.h @@ -0,0 +1,51 @@ +//============================================================================= +// 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. +//============================================================================= + +#ifndef __CONFIGMIDICTRL_H__ +#define __CONFIGMIDICTRL_H__ + +#include "ui_configmidictrl.h" + +class MidiTrack; + +//--------------------------------------------------------- +// ConfigMidiCtrl +//--------------------------------------------------------- + +class ConfigMidiCtrl : public QDialog, public Ui::ConfigMidiCtrlBase { + Q_OBJECT + + MidiTrack* track; + + private slots: + void addClicked(); + void removeClicked(); + void availableSelected(QListWidgetItem*); + void managedSelected(QListWidgetItem*); + virtual void done(int); + void defineClicked(); + + public: + ConfigMidiCtrl(MidiTrack*); + }; + +#endif + + diff --git a/muse_qt4_evolution/muse/ctrl/configmidictrl.ui b/muse_qt4_evolution/muse/ctrl/configmidictrl.ui new file mode 100644 index 00000000..1960c490 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/configmidictrl.ui @@ -0,0 +1,204 @@ +<ui version="4.0" > + <class>ConfigMidiCtrlBase</class> + <widget class="QDialog" name="ConfigMidiCtrlBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>506</width> + <height>355</height> + </rect> + </property> + <property name="windowTitle" > + <string>MusE: Config Midi Controller</string> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" colspan="3" > + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="1" column="0" > + <widget class="QLabel" name="label_4" > + <property name="text" > + <string>Midi Instrument:</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLineEdit" name="portName" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QLineEdit" name="instrumentName" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Midi Port:</p></body></html></string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="2" > + <widget class="QLabel" name="label_2" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Automated Controller:</p></body></html></string> + </property> + </widget> + </item> + <item rowspan="3" row="2" column="2" > + <widget class="QListWidget" name="managedController" /> + </item> + <item rowspan="2" row="1" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>75</width> + <height>81</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Available Controller:</p></body></html></string> + </property> + </widget> + </item> + <item rowspan="3" row="2" column="0" > + <widget class="QListWidget" name="availableController" /> + </item> + <item row="4" column="1" > + <widget class="QPushButton" name="buttonRemove" > + <property name="text" > + <string>Remove</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QPushButton" name="buttonAdd" > + <property name="text" > + <string>Add</string> + </property> + </widget> + </item> + <item row="5" column="0" colspan="3" > + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QPushButton" name="defineButton" > + <property name="text" > + <string>Define new Controller</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>131</width> + <height>31</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="buttonOk" > + <property name="text" > + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonCancel" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>ConfigMidiCtrlBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>278</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>96</x> + <y>254</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>ConfigMidiCtrlBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>369</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>179</x> + <y>282</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/muse_qt4_evolution/muse/ctrl/ctrldialog.cpp b/muse_qt4_evolution/muse/ctrl/ctrldialog.cpp new file mode 100644 index 00000000..fd8a073c --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrldialog.cpp @@ -0,0 +1,191 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 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 "ctrldialog.h" +#include "midictrl.h" +#include "track.h" +#include "miditrack.h" +#include "audiotrack.h" +#include "plugin.h" +#include "pipeline.h" +#include "ctrl/configmidictrl.h" + +//--------------------------------------------------------- +// CtrlDialog +//--------------------------------------------------------- + +CtrlDialog::CtrlDialog(Track* track, int ci, QWidget* parent) + : QDialog(parent) + { + t = track; + currentId = ci; + setupUi(this); + QTreeWidgetItem* header = tw->headerItem(); + header->setTextAlignment(0, Qt::AlignLeft); + header->setTextAlignment(1, Qt::AlignHCenter); + + tw->header()->setResizeMode(0, QHeaderView::Stretch); + header->setToolTip(0, tr("controller name")); + header->setToolTip(1, tr("flag if controller contains data")); + + updateController(); + otherButton->setEnabled(track->type() == Track::MIDI); + connect(tw, + SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), + SLOT(itemDoubleClicked(QTreeWidgetItem*, int))); + connect(otherButton, SIGNAL(clicked()), SLOT(otherClicked())); + } + +//--------------------------------------------------------- +// updateController +//--------------------------------------------------------- + +void CtrlDialog::updateController() + { + tw->clear(); + QTreeWidgetItem* ci; + if (t->type() == Track::MIDI) { + // + // add special controll for midi tracks + // + ci = new QTreeWidgetItem(tw, CTRL_VELOCITY); + ci->setText(0, "Velocity"); + if (CTRL_VELOCITY == currentId) { + tw->setCurrentItem(ci); + tw->setItemSelected(ci, true); + } + if (((MidiTrack*)(t))->drumMap()) { + ci = new QTreeWidgetItem(tw, CTRL_SVELOCITY); + ci->setText(0, "Single Velocity"); + + if (CTRL_SVELOCITY == currentId) { + tw->setCurrentItem(ci); + tw->setItemSelected(ci, true); + } + } + } + else if (!t->isMidiTrack()) { + + // + // present plugin parameter + // + Pipeline* pl = ((AudioTrack*)t)->prePipe(); + int idx = 0; + foreach (PluginI* plugin, *pl) { + ci = new QTreeWidgetItem(tw, CTRL_NO_CTRL); + ci->setText(0, plugin->name()); + int ncontroller = plugin->plugin()->parameter(); + for (int i = 0; i < ncontroller; ++i) { + QString name(plugin->getParameterName(i)); + int id = genACnum(idx, i, true); + QTreeWidgetItem* cci = new QTreeWidgetItem(ci, id); + cci->setText(0, name); + Ctrl* ctrl = t->getController(id); + if (ctrl) { + if (!ctrl->empty()) + cci->setText(1, "*"); + if (id == currentId) { + tw->setCurrentItem(cci); + tw->setItemSelected(cci, true); + } + } + else + printf("updateController: controller %x not found\n", id); + } + } + pl = ((AudioTrack*)t)->postPipe(); + idx = 0; + foreach (PluginI* plugin, *pl) { + ci = new QTreeWidgetItem(tw, CTRL_NO_CTRL); + ci->setText(0, plugin->name()); + int ncontroller = plugin->plugin()->parameter(); + for (int i = 0; i < ncontroller; ++i) { + QString name(plugin->getParameterName(i)); + int id = genACnum(idx, i, false); + QTreeWidgetItem* cci = new QTreeWidgetItem(ci, id); + cci->setText(0, name); + Ctrl* ctrl = t->getController(id); + if (!ctrl->empty()) + cci->setText(1, "*"); + if (id == currentId) { + tw->setCurrentItem(cci); + tw->setItemSelected(cci, true); + } + } + } + } + + ControllerNameList* cn = t->controllerNames(); + for (iControllerName i = cn->begin(); i != cn->end(); ++i) { + ci = new QTreeWidgetItem(tw, i->id); + ci->setText(0, i->name); + Ctrl* ctrl = t->getController(i->id); + if (!ctrl->empty()) + ci->setText(1, "*"); + + if (i->id == currentId) { + tw->setCurrentItem(ci); + tw->setItemSelected(ci, true); + } + } + } + +//--------------------------------------------------------- +// itemDoubleClicked +//--------------------------------------------------------- + +void CtrlDialog::itemDoubleClicked(QTreeWidgetItem* item, int) + { + if (item->type() != CTRL_NO_CTRL) + accept(); + } + +//--------------------------------------------------------- +// CtrlDialog +//--------------------------------------------------------- + +int CtrlDialog::curId() const + { + QTreeWidgetItem* item = tw->currentItem(); + if (item == 0) + return CTRL_NO_CTRL; + return item->type(); + } + +//--------------------------------------------------------- +// otherClicked +// Add another controller to the list of "managed" +// controllers. +//--------------------------------------------------------- + +void CtrlDialog::otherClicked() + { + QTreeWidgetItem* item = tw->currentItem(); + if (item) + currentId = item->type(); + // + // present the list of available controller for + // the selected midi instrument + // + ConfigMidiCtrl mce((MidiTrack*)t); + mce.exec(); + updateController(); + } + diff --git a/muse_qt4_evolution/muse/ctrl/ctrldialog.h b/muse_qt4_evolution/muse/ctrl/ctrldialog.h new file mode 100644 index 00000000..3cb51ef2 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrldialog.h @@ -0,0 +1,49 @@ +//============================================================================= +// 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. +//============================================================================= + +#ifndef __CTRL_DIALOG_H__ +#define __CTRL_DIALOG_H__ + +#include "ui_ctrldialog.h" + +class Track; + +//--------------------------------------------------------- +// CtrlDialog +//--------------------------------------------------------- + +class CtrlDialog : public QDialog, public Ui_CtrlDialogBase { + Q_OBJECT + + Track* t; + int currentId; + void updateController(); + + private slots: + void itemDoubleClicked(QTreeWidgetItem*, int); + void otherClicked(); + + public: + CtrlDialog(Track*, int, QWidget* parent = 0); + int curId() const; + }; + +#endif + diff --git a/muse_qt4_evolution/muse/ctrl/ctrldialog.ui b/muse_qt4_evolution/muse/ctrl/ctrldialog.ui new file mode 100644 index 00000000..178cf1d3 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrldialog.ui @@ -0,0 +1,126 @@ +<ui version="4.0" > + <class>CtrlDialogBase</class> + <widget class="QDialog" name="CtrlDialogBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>390</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle" > + <string>MusE: Select Controller</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeWidget" name="tw" > + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <property name="uniformRowHeights" > + <bool>true</bool> + </property> + <property name="columnCount" > + <number>3</number> + </property> + <column> + <property name="text" > + <string>Controller</string> + </property> + </column> + <column> + <property name="text" > + <string>A</string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QPushButton" name="otherButton" > + <property name="text" > + <string>Other</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>131</width> + <height>31</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="okButton" > + <property name="text" > + <string>OK</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>clicked()</signal> + <receiver>CtrlDialogBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>278</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>96</x> + <y>254</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>CtrlDialogBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>369</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>179</x> + <y>282</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/muse_qt4_evolution/muse/ctrl/ctrledit.cpp b/muse_qt4_evolution/muse/ctrl/ctrledit.cpp new file mode 100644 index 00000000..20022f47 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrledit.cpp @@ -0,0 +1,184 @@ +//============================================================================= +// 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; + CtrlDialog cd(_track, id); + int rv = cd.exec(); + if (rv != 1) + return; + id = cd.curId(); + if (id == CTRL_NO_CTRL) + return; + 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; + } + diff --git a/muse_qt4_evolution/muse/ctrl/ctrledit.h b/muse_qt4_evolution/muse/ctrl/ctrledit.h new file mode 100644 index 00000000..d942c84f --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrledit.h @@ -0,0 +1,76 @@ +//============================================================================= +// 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. +//============================================================================= + +#ifndef __CTRL_EDIT_H__ +#define __CTRL_EDIT_H__ + +#include "ctrleditor.h" +#include "gui.h" + +class SimpleButton; +class TimeCanvas; + +//--------------------------------------------------------- +// CtrlEdit +//--------------------------------------------------------- + +class CtrlEdit : public QObject, public CtrlEditor { + Q_OBJECT + + Track* const _track; + Ctrl* _ctrl; + TimeCanvas* _tc; + int _height; + + virtual Ctrl* ctrl() const { return _ctrl; } + virtual TimeCanvas* tc() const { return _tc; } + virtual Track* track() const { return _track; } + + public: + int ctrlId; + int y; + SimpleButton* minus; + SimpleButton* sel; + QMenu* ctrlList; + + private slots: + void showControllerList(); + void changeController(int); + void controllerListChanged(int); + + public: + CtrlEdit(QWidget*, TimeCanvas*, Track*); + ~CtrlEdit(); + int pixel2val(int) const; + void setHeight(int val) { _height = val; } + int height() const { return _height; } + virtual int cheight() const { return _height - splitWidth; } + void setCtrl(Ctrl* c) { _ctrl = c; } + void setCtrl(int id); + Ctrl* ctrl() { return _ctrl; } + void setSinglePitch(int); + }; + + +typedef std::vector<CtrlEdit*> CtrlEditList; +typedef CtrlEditList::iterator iCtrlEdit; +typedef CtrlEditList::const_iterator ciCtrlEdit; +#endif + diff --git a/muse_qt4_evolution/muse/ctrl/ctrleditor.cpp b/muse_qt4_evolution/muse/ctrl/ctrleditor.cpp new file mode 100644 index 00000000..cc89c4c6 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrleditor.cpp @@ -0,0 +1,492 @@ +//============================================================================= +// 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 "ctrleditor.h" +#include "track.h" +#include "awl/tcanvas.h" +#include "ctrl.h" +#include "midictrl.h" +#include "gconfig.h" +#include "song.h" +#include "part.h" +#include "tools.h" +#include "muse.h" +#include "gui.h" + +static const int HANDLE1 = 6; +static const int HANDLE2 = 3; +static const int veloWidth = 3; + +Ctrl veloList(CTRL_VELOCITY, "velocity", Ctrl::DISCRETE |Ctrl::INT, 0.0, 127.0); // dummy +Ctrl sveloList(CTRL_SVELOCITY, "single velocity", Ctrl::DISCRETE |Ctrl::INT, 0.0, 127.0); // dummy + +//--------------------------------------------------------- +// CtrlEditor +//--------------------------------------------------------- + +CtrlEditor::CtrlEditor() + { + _drawCtrlName = false; + dragy = -1; + lselected = 0; + singlePitch = -1; + drawRuler = false; + } + +//--------------------------------------------------------- +// drawHandle +//--------------------------------------------------------- + +inline static void drawHandle(QPainter& p, int x, int y, int lselected) + { + p.fillRect(x-HANDLE2, y-HANDLE2, HANDLE1, HANDLE1, + x == lselected ? Qt::red : Qt::yellow); + } + +//--------------------------------------------------------- +// ctrlY +//--------------------------------------------------------- + +int CtrlEditor::ctrlY(int x, const CVal& val) const + { + if (dragy != -1 && lselected == x) + return dragy; + return ctrl()->val2pixelR(val, th) + HANDLE2; + } + +//--------------------------------------------------------- +// paint +//--------------------------------------------------------- + +void CtrlEditor::paint(QPainter& p, const QRect& r) + { + if (!ctrl()) + return; + int from = r.x() - HANDLE1; + if (from < 0) + from = 0; + int to = r.x() + r.width() + HANDLE1; + th = cheight() - HANDLE1 + splitWidth; + + p.save(); + bool aR = track()->autoRead(); + p.setPen(QPen(aR ? Qt::white : Qt::gray, 2)); + + TType tt = track()->timeType(); + + if (ctrl()->id() == CTRL_VELOCITY) { + p.setRenderHint(QPainter::Antialiasing, false); + p.setPen(QPen(Qt::blue, veloWidth)); + PartList* pl = track()->parts(); + for (iPart ip = pl->begin(); ip != pl->end(); ++ip) { + Part* part = ip->second; + int pos1 = tc()->pos2pix(*part); + int pos2 = tc()->pos2pix(part->end()); + + if (pos2 <= from) + continue; + if (pos1 > to) + break; + + EventList* events = part->events(); + for (iEvent e = events->begin(); e != events->end(); ++e) { + const Event& ev = e->second; + if (ev.type() != Note) + continue; + int pos = tc()->pos2pix(ev.pos() + *part); + if (pos <= from) + continue; + if (pos > to) + break; + int id = ctrl()->id(); + if (id == CTRL_VELOCITY || + (id == CTRL_SVELOCITY && ev.pitch() == singlePitch)) { + int y1 = ctrl()->val2pixelR(ev.velo(), th+3) + 1; + p.drawLine(pos, th+3, pos, y1); + } + } + } + } + else { + p.setRenderHint(QPainter::Antialiasing, true); + if (ctrl()->empty()) { + if (aR) { + int y = ctrl()->cur2pixel(th) + HANDLE2; + p.drawLine(r.x(), y, r.x() + r.width(), y); + } + } + else { + int x1, y1, x2, y2; + int hx = -1; + int hy = 0; + + Pos pos1 = tc()->pix2pos(from); + ciCtrlVal i = ctrl()->lowerBound(pos1.time(tt)); + + if (i == ctrl()->end()) { + --i; + int x = tc()->pos2pix(Pos(i.key(), tt)); + int y = ctrlY(x, i.value()); + p.drawLine(r.x(), y, r.x() + r.width(), y); + } + else { + if (i == ctrl()->begin()) { + x1 = tc()->pos2pix(Pos(i.key(), tt)); + y1 = ctrlY(x1, i.value()); + x1 = r.x(); + } + else { + --i; + x1 = tc()->pos2pix(Pos(i.key(), tt)); + y1 = ctrlY(x1, i.value()); + hx = x1; + hy = y1; + ++i; + } + do { + x2 = tc()->pos2pix(Pos(i.key(), tt)); + y2 = ctrlY(x2, i.value()); + if (ctrl()->type() & Ctrl::DISCRETE) { + p.drawLine(x1, y1, x2, y1); + p.drawLine(x2, y1, x2, y2); + } + else + p.drawLine(x1, y1, x2, y2); + if (x2 >= to) + break; + if (hx != -1) + drawHandle(p, hx, hy, lselected); + hx = x2; + hy = y2; + x1 = x2; + y1 = y2; + ++i; + } while (i != ctrl()->end()); + if (x2 < to) + p.drawLine(x2, y1, to, y1); + if (hx != -1) + drawHandle(p, hx, hy, lselected); + } + } + if (!aR) { + int y = ctrl()->cur2pixel(th) + HANDLE2; + p.drawLine(r.x(), y, r.x() + r.width(), y); + } + } + + if (drawRuler) { + p.setPen(QPen(Qt::white, 2)); + p.setRenderHint(QPainter::Antialiasing, true); + p.drawLine(ruler1, ruler2); + } + // + // this does not work well a.t.m: + // + if (_drawCtrlName) { + QString s(ctrl()->name()); + QFont f(tc()->font()); +// p.setFont(config.fonts[3]); + p.setPen(Qt::black); + QFontMetrics fm(f); + int ly = fm.lineSpacing() + 2; + p.drawText(2, ly, s); + } + p.restore(); + } + +//--------------------------------------------------------- +// mousePress +//--------------------------------------------------------- + +void CtrlEditor::mousePress(const QPoint& pos, QMouseEvent* me) + { + int button = me->button(); + Qt::KeyboardModifiers modifiers = me->modifiers(); + Tool tool = tc()->tool(); + if (button & Qt::RightButton) { + QMenu pop(tc()); + QAction* a; + for (int i = 0; i < TOOLS; ++i) { + int id = 1 << i; + if ((arrangerTools & id) == 0) + continue; + a = getAction(toolList[i], &pop); + pop.addAction(a); + a->setCheckable(true); + if (id == (int)tool) + a->setChecked(true); + } + a = pop.addSeparator(); + a = pop.addAction("List Editor"); + a->setData(1 << (TOOLS+1)); + + a = pop.exec(me->globalPos()); + if (a) { + int n = a->data().toInt(); + if (n == (1 << (TOOLS+1))) { + Pos t(tc()->pix2pos(pos.x())); + muse->showListEditor(t, track(), 0, ctrl()); + } + else + muse->setTool(n); + } + return; + } + + int wh = cheight(); + int y = pos.y(); + int x = pos.x(); + + int cid = ctrl()->id(); + + if (tool == PencilTool || (modifiers & Qt::ShiftModifier)) { + selected = tc()->pix2pos(x); + lselected = x; + dragy = y; + dragx = x; + dragYoffset = 0; + if (cid == CTRL_VELOCITY || cid == CTRL_SVELOCITY) + song->startUndo(); + else { + // add controller: + CVal val = ctrl()->pixel2val(dragy-HANDLE2, wh - HANDLE1 + splitWidth); + song->cmdAddControllerVal(track(), ctrl(), selected, val); + tc()->widget()->update(); + } + } + else if (tool == PointerTool || tool == RubberTool) { + if (cid == CTRL_VELOCITY || cid == CTRL_SVELOCITY) { + dragx = x; + song->startUndo(); + return; + } + + Pos pos1(tc()->pix2pos(x - HANDLE2)); + Pos pos2(tc()->pix2pos(x + HANDLE2)); + + TType tt = track()->timeType(); + ciCtrlVal s = ctrl()->upperBound(pos1.time(tt)); + ciCtrlVal e = ctrl()->upperBound(pos2.time(tt)); + for (ciCtrlVal i = s; i != e; ++i) { + int yy = ctrl()->val2pixelR(i.value(), wh - HANDLE1 + splitWidth) + HANDLE2; + startY = yy; + if ((yy >= (y-HANDLE2)) && (yy < (y + HANDLE2))) { + if (tt == AL::TICKS) + selected.setTick(i.key()); + else + selected.setFrame(i.key()); + lselected = tc()->pos2pix(selected); + if (tool == RubberTool || button == Qt::RightButton + || modifiers & Qt::ControlModifier) { + song->cmdRemoveControllerVal(track(), ctrl()->id(), i.key()); + dragy = -1; + } + else { + dragy = yy; + dragYoffset = dragy - y; + } + tc()->widget()->update(); + break; + } + } + } + else if (tool == DrawTool) { + ruler1 = ruler2 = pos; + drawRuler = true; + } + } + +//--------------------------------------------------------- +// mouseRelease +//--------------------------------------------------------- + +void CtrlEditor::mouseRelease() + { + if (tc()->tool() == DrawTool) { + song->startUndo(); + drawRuler = false; + int from, to, y1, y2; + if (ruler1.x() > ruler2.x()) { + from = ruler2.x(); + to = ruler1.x(); + y1 = ruler2.y(); + y2 = ruler1.y(); + } + else { + from = ruler1.x(); + to = ruler2.x(); + y1 = ruler1.y(); + y2 = ruler2.y(); + } + MidiController::ControllerType type = midiControllerType(ctrl()->id()); + if (type == MidiController::Velo) { + PartList* pl = track()->parts(); + for (iPart ip = pl->begin(); ip != pl->end(); ++ip) { + Part* part = ip->second; + int pos1 = tc()->pos2pix(*part); + int pos2 = tc()->pos2pix(part->end()); + + if (pos2 <= from) + continue; + if (pos1 > to) + break; + + EventList* events = part->events(); + for (iEvent e = events->begin(); e != events->end(); ++e) { + if (e->second.type() != Note) + continue; + int pos = tc()->pos2pix(e->second.pos() + *part); + if (pos <= from) + continue; + if (pos > to) + break; + int id = ctrl()->id(); + if (id == CTRL_VELOCITY || + (CTRL_SVELOCITY && e->second.pitch() == singlePitch)) { + int y = y1 + (y2 - y1) * (pos - from) / (to - from); + int val = (ctrl()->pixel2val(y+HANDLE2, cheight()-HANDLE1+splitWidth)).i; + Event clone = e->second.clone(); + clone.setB(val); + song->changeEvent(e->second, clone, part); + song->undoOp(UndoOp::ModifyEvent, clone, e->second, part); + } + } + } + } + else { + printf("ctrleditor:: not implemented\n"); + } + song->endUndo(SC_EVENT_MODIFIED); + tc()->widget()->update(); + return; + } + if (ctrl()->id() == CTRL_VELOCITY || ctrl()->id() == CTRL_SVELOCITY) + song->endUndo(SC_EVENT_MODIFIED); + else { + if (dragy != -1 && dragy != startY) { + int wh = cheight() + splitWidth - HANDLE1; + CVal val = ctrl()->pixel2val(dragy - HANDLE2, wh); + // modify controller: + song->cmdAddControllerVal(track(), ctrl(), selected, val); + } + dragy = -1; + } + } + +//--------------------------------------------------------- +// mouseMove +// called only with mouse button pressed +//--------------------------------------------------------- + +void CtrlEditor::mouseMove(const QPoint& pos) + { + Tool tool = tc()->tool(); + int cid = ctrl()->id(); + + if (tool == DrawTool) { + ruler2 = pos; + tc()->widget()->update(); + return; + } + if (cid == CTRL_VELOCITY || cid == CTRL_SVELOCITY) { + AL::Pos p1(tc()->pix2pos(dragx)); + AL::Pos p2(tc()->pix2pos(pos.x())); + dragx = pos.x(); + + int wh = cheight() - HANDLE1 + splitWidth; + int val = (ctrl()->pixel2val(pos.y() - HANDLE2, wh)).i; + unsigned tick1 = p1.tick(); + Part* part = track()->parts()->findPart(tick1); + if (part == 0) + return; + unsigned tick2 = p2.tick(); + if (tick1 > tick2) { + int tmp = tick2; + tick2 = tick1; + tick1 = tmp; + } + if (part->tick() > tick1) + tick1 = 0; + else + tick1 -= part->tick(); // event time is relative to part + if (part->tick() > tick2) + tick2 = 0; + else + tick2 -= part->tick(); + + // + // change velocity for all notes at tick time + // + EventList* el = part->events(); + EventList tel; + for (iEvent ie = el->lower_bound(tick1); ie != el->lower_bound(tick2); ie++) { + Event e = ie->second; + if (!e.isNote() || e.dataB() == val) + continue; + tel.add(e); + } + for (iEvent ie = tel.begin(); ie != tel.end(); ++ie) { + Event e = ie->second; + Event clone = e.clone(); + clone.setB(val); + song->changeEvent(e, clone, part); + song->undoOp(UndoOp::ModifyEvent, clone, e, part); + } + } + else { + if (tool == RubberTool) { + int wh = cheight(); + int y = pos.y(); + int x = pos.x(); + + Pos pos1(tc()->pix2pos(x - HANDLE2)); + Pos pos2(tc()->pix2pos(x + HANDLE2)); + + TType tt = track()->timeType(); + ciCtrlVal s = ctrl()->upperBound(pos1.time(tt)); + ciCtrlVal e = ctrl()->upperBound(pos2.time(tt)); + for (ciCtrlVal i = s; i != e; ++i) { + int yy = ctrl()->val2pixelR(i.value(), wh); + startY = yy; + if ((yy >= (y-HANDLE2)) && (yy < (y + HANDLE2))) { + if (tt == AL::TICKS) + selected.setTick(i.key()); + else + selected.setFrame(i.key()); + lselected = tc()->pos2pix(selected); + song->cmdRemoveControllerVal(track(), ctrl()->id(), i.key()); + dragy = -1; + break; + } + } + } + if (dragy != -1) { + int th = cheight() + splitWidth - HANDLE2 - 1; + dragy = pos.y() + dragYoffset; + if (dragy < HANDLE2) + dragy = HANDLE2; + else if (dragy > th) { + dragy = th; + } + } + } + tc()->widget()->update(); + } + diff --git a/muse_qt4_evolution/muse/ctrl/ctrleditor.h b/muse_qt4_evolution/muse/ctrl/ctrleditor.h new file mode 100644 index 00000000..e33a8b29 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/ctrleditor.h @@ -0,0 +1,76 @@ +//============================================================================= +// 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. +//============================================================================= + +#ifndef __CTRL_EDITOR_H__ +#define __CTRL_EDITOR_H__ + +#include "al/pos.h" + +class Ctrl; +class TimeCanvas; +class Track; +struct CVal; + +//--------------------------------------------------------- +// CtrlEditor +//--------------------------------------------------------- + +class CtrlEditor { + bool _drawCtrlName; + int dragx, dragy; + int dragYoffset; + int startY; + + int th; // effective track height, temp value + + int lselected; // cached pixel position of current value + AL::Pos selected; // current selected controller value + + bool drawRuler; + QPoint ruler1; + QPoint ruler2; + + virtual Ctrl* ctrl() const = 0; + virtual TimeCanvas* tc() const = 0; + virtual int cheight() const = 0; + virtual Track* track() const = 0; + + bool searchHandle(unsigned* time) const; + + int ctrlY(int x, const CVal&) const; + + protected: + int singlePitch; + + public: + CtrlEditor(); + virtual ~CtrlEditor() {} + void paint(QPainter& p, const QRect& r); + void setDrawCtrlName(bool val) { _drawCtrlName = val; } + void mousePress(const QPoint&, QMouseEvent*); + void mouseRelease(); + void mouseMove(const QPoint& pos); + }; + + +extern Ctrl veloList; +extern Ctrl sveloList; +#endif + diff --git a/muse_qt4_evolution/muse/ctrl/definemidictrl.cpp b/muse_qt4_evolution/muse/ctrl/definemidictrl.cpp new file mode 100644 index 00000000..197d7572 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/definemidictrl.cpp @@ -0,0 +1,110 @@ +//============================================================================= +// 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 "definemidictrl.h" +#include "miditrack.h" +#include "instruments/minstrument.h" + +//--------------------------------------------------------- +// DefineMidiCtrlDialog +// controllerName QLineEdit +// controllerType QComboBox +// msbId lsbId minVal maxVal initVal QSpinBox +// moveWithPart QCheckBox +//--------------------------------------------------------- + +DefineMidiCtrl::DefineMidiCtrl(MidiTrack* t, QWidget* parent) + : QDialog(parent) + { + setupUi(this); + track = t; + connect(controllerType, SIGNAL(currentIndexChanged(int)), SLOT(typeChanged(int))); + } + +//--------------------------------------------------------- +// done +// val == 1 -> OK +//--------------------------------------------------------- + +void DefineMidiCtrl::done(int val) + { + if (val) { + ctrl.setName(controllerName->text()); + ctrl.setComment(controllerComment->toPlainText()); + int num = MidiController::genNum( + MidiController::ControllerType(controllerType->currentIndex()), + msbId->value(), lsbId->value()); + ctrl.setNum(num); + ctrl.setMinVal(minVal->value()); + ctrl.setMaxVal(maxVal->value()); + ctrl.setInitVal(initVal->value()); + ctrl.setMoveWithPart(moveWithPart->isChecked()); + + // + // add controller to instrument + // + MidiInstrument* instrument = track->instrument(); + MidiControllerList* mcl = instrument->controller(); + MidiController* c = new MidiController(ctrl); + mcl->append(c); + } + + QDialog::done(val); + } + +//--------------------------------------------------------- +// typeChanged +//--------------------------------------------------------- + +void DefineMidiCtrl::typeChanged(int val) + { + MidiController::ControllerType t = (MidiController::ControllerType)val; + switch (t) { + case MidiController::RPN: + case MidiController::NRPN: + case MidiController::Controller7: + msbId->setEnabled(false); + lsbId->setEnabled(true); + maxVal->setRange(0, 127); + maxVal->setValue(127); + initVal->setRange(0, 127); + break; + case MidiController::Controller14: + case MidiController::RPN14: + case MidiController::NRPN14: + msbId->setEnabled(true); + lsbId->setEnabled(true); + maxVal->setRange(0, 128*128-1); + maxVal->setValue(128*128-1); + initVal->setRange(0, 128*128-1); + break; + case MidiController::Pitch: + case MidiController::Program: + msbId->setEnabled(false); + lsbId->setEnabled(false); + maxVal->setRange(0, 128*128-1); + initVal->setRange(0, 128*128-1); + maxVal->setValue(128*128-1); + break; + default: + break; + } + } + diff --git a/muse_qt4_evolution/muse/ctrl/definemidictrl.h b/muse_qt4_evolution/muse/ctrl/definemidictrl.h new file mode 100644 index 00000000..bc0df6a9 --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/definemidictrl.h @@ -0,0 +1,51 @@ +//============================================================================= +// 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. +//============================================================================= + +#ifndef __DEFINEMIDICTRL_H__ +#define __DEFINEMIDICTRL_H__ + +#include "ui_definemidictrl.h" +#include "midictrl.h" + +class MidiTrack; + +//--------------------------------------------------------- +// DefineMidiCtrl +//--------------------------------------------------------- + +class DefineMidiCtrl : public QDialog, public Ui::DefineMidiCtrlBase { + Q_OBJECT + + MidiTrack* track; + MidiController ctrl; + + private slots: + virtual void done(int); + void typeChanged(int); + + public: + DefineMidiCtrl(MidiTrack* t, QWidget* parent = 0); + const MidiController* midiController() const { return &ctrl; } + }; + +#endif + + + diff --git a/muse_qt4_evolution/muse/ctrl/definemidictrl.ui b/muse_qt4_evolution/muse/ctrl/definemidictrl.ui new file mode 100644 index 00000000..a66e55cb --- /dev/null +++ b/muse_qt4_evolution/muse/ctrl/definemidictrl.ui @@ -0,0 +1,285 @@ +<ui version="4.0" > + <class>DefineMidiCtrlBase</class> + <widget class="QDialog" name="DefineMidiCtrlBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>558</width> + <height>344</height> + </rect> + </property> + <property name="windowTitle" > + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item rowspan="2" row="0" column="0" > + <widget class="QLabel" name="label_13" > + <property name="font" > + <font> + <pointsize>24</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <property name="lineWidth" > + <number>5</number> + </property> + <property name="text" > + <string><html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:24pt; font-weight:600; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400;"> </span><span style=" font-weight:400;">CTRL </span></p></body></html></string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Controller Name:</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLineEdit" name="controllerName" /> + </item> + <item row="1" column="1" > + <widget class="QLabel" name="label" > + <property name="text" > + <string>Controller Type:</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QComboBox" name="controllerType" > + <item> + <property name="text" > + <string>7-Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>14-Bit</string> + </property> + </item> + <item> + <property name="text" > + <string>7-Bit RPN</string> + </property> + </item> + <item> + <property name="text" > + <string>14-Bit RPN</string> + </property> + </item> + <item> + <property name="text" > + <string>7-Bit NRPN</string> + </property> + </item> + <item> + <property name="text" > + <string>14-Bit NRPN</string> + </property> + </item> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label_14" > + <property name="text" > + <string>Comment:</string> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="controllerComment" /> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="2" > + <widget class="QLabel" name="label_8" > + <property name="text" > + <string>0x00</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QSpinBox" name="lsbId" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_4" > + <property name="text" > + <string>Id LSB</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QLabel" name="label_9" > + <property name="text" > + <string>0x00</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QSpinBox" name="msbId" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label_3" > + <property name="text" > + <string>Id MSB</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2" > + <widget class="QCheckBox" name="moveWithPart" > + <property name="text" > + <string>Move with Part</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QGridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="2" column="1" > + <widget class="QSpinBox" name="initVal" /> + </item> + <item row="2" column="2" > + <widget class="QLabel" name="label_12" > + <property name="text" > + <string>0x00</string> + </property> + </widget> + </item> + <item row="1" column="2" > + <widget class="QLabel" name="label_11" > + <property name="text" > + <string>0x00</string> + </property> + </widget> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="label_7" > + <property name="text" > + <string>Init Value</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QSpinBox" name="maxVal" /> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label_5" > + <property name="text" > + <string>Min.Value</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QSpinBox" name="minVal" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_6" > + <property name="text" > + <string>Max.Value</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="label_10" > + <property name="text" > + <string>0x00</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="okButton" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>okButton</sender> + <signal>accepted()</signal> + <receiver>DefineMidiCtrlBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>okButton</sender> + <signal>rejected()</signal> + <receiver>DefineMidiCtrlBase</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |