diff options
author | Florian Jung <flo@windfisch.org> | 2012-02-24 19:32:40 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2012-02-24 19:32:40 +0000 |
commit | f97dd6a44d1050aa2f4c300c9ad32e2c5453ed98 (patch) | |
tree | 097c0e032d1fa5e5c5104759353974398debf381 | |
parent | 3ffd0dacdd7447c6c377f95c1fa7fc45a2612d98 (diff) |
made custom columns editable.
TODO FIXME: you need to restart MusE to apply them
-rw-r--r-- | muse2/muse/arranger/arranger.cpp | 13 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.h | 3 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.cpp | 12 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.h | 3 | ||||
-rw-r--r-- | muse2/muse/widgets/CMakeLists.txt | 3 | ||||
-rw-r--r-- | muse2/muse/widgets/arrangercolumns.cpp | 168 | ||||
-rw-r--r-- | muse2/muse/widgets/arrangercolumns.h | 53 | ||||
-rw-r--r-- | muse2/muse/widgets/arrangercolumnsbase.ui | 258 |
8 files changed, 507 insertions, 6 deletions
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index d572aadd..ccb3353f 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -72,18 +72,19 @@ namespace MusEGui { -std::vector<Arranger::custom_col_t> Arranger::custom_columns; +std::vector<Arranger::custom_col_t> Arranger::custom_columns; //FINDMICH TODO: eliminate all usage of new_custom_columns +std::vector<Arranger::custom_col_t> Arranger::new_custom_columns; //and instead let the arranger update without restarting muse! QString Arranger::header_state; void Arranger::writeCustomColumns(int level, MusECore::Xml& xml) { xml.tag(level++, "custom_columns"); - for (unsigned i=0;i<custom_columns.size();i++) + for (unsigned i=0;i<new_custom_columns.size();i++) { xml.tag(level++, "column"); - xml.strTag(level, "name", custom_columns[i].name); - xml.intTag(level, "ctrl", custom_columns[i].ctrl); + xml.strTag(level, "name", new_custom_columns[i].name); + xml.intTag(level, "ctrl", new_custom_columns[i].ctrl); xml.etag(--level, "column"); } @@ -100,6 +101,7 @@ void Arranger::readCustomColumns(MusECore::Xml& xml) switch (token) { case MusECore::Xml::Error: case MusECore::Xml::End: + new_custom_columns=custom_columns; return; case MusECore::Xml::TagStart: if (tag == "column") @@ -109,7 +111,10 @@ void Arranger::readCustomColumns(MusECore::Xml& xml) break; case MusECore::Xml::TagEnd: if (tag == "custom_columns") + { + new_custom_columns=custom_columns; return; + } default: break; } diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h index a49829c8..c2746ba7 100644 --- a/muse2/muse/arranger/arranger.h +++ b/muse2/muse/arranger/arranger.h @@ -188,7 +188,8 @@ class Arranger : public QWidget { name=n; } }; - static std::vector<custom_col_t> custom_columns; + static std::vector<custom_col_t> custom_columns; //FINDMICH TODO: eliminate all usage of new_custom_columns + static std::vector<custom_col_t> new_custom_columns; //and instead let the arranger update without restarting muse! Arranger(ArrangerView* parent, const char* name = 0); diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp index afc0da8c..d38b5284 100644 --- a/muse2/muse/arranger/arrangerview.cpp +++ b/muse2/muse/arranger/arrangerview.cpp @@ -67,6 +67,7 @@ #include "ttoolbar.h" #include "visibletracks.h" #include "xml.h" +#include "arrangercolumns.h" namespace MusEGui { @@ -272,6 +273,8 @@ ArrangerView::ArrangerView(QWidget* parent) QMenu* menuSettings = menuBar()->addMenu(tr("Window &Config")); + menuSettings->addAction(tr("Configure &custom columns"), this, SLOT(configCustomColumns())); + menuSettings->addSeparator(); menuSettings->addAction(subwinAction); menuSettings->addAction(shareAction); menuSettings->addAction(fullscreenAction); @@ -746,4 +749,13 @@ void ArrangerView::globalCutSel() { MusECore::globalCut(true); } void ArrangerView::globalInsertSel() { MusECore::globalInsert(true); } void ArrangerView::globalSplitSel() { MusECore::globalSplit(true); } +void ArrangerView::configCustomColumns() +{ + ArrangerColumns* dialog = new ArrangerColumns(this); + dialog->exec(); + delete dialog; + + QMessageBox::information(this, tr("Changed Settings"), tr("Unfortunately, the changed arranger column settings\ncannot be applied while MusE is running.\nTo apply the changes, please restart MusE. Sorry.\n(we'll try to fix that)")); +} + } // namespace MusEGui diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h index 2e128c1d..98e7f01c 100644 --- a/muse2/muse/arranger/arrangerview.h +++ b/muse2/muse/arranger/arrangerview.h @@ -125,7 +125,8 @@ class ArrangerView : public TopWin void globalInsertSel(); void globalSplitSel(); void cmd(int); - void addNewTrack(QAction* action); + void addNewTrack(QAction* action); + void configCustomColumns(); signals: void isDeleting(MusEGui::TopWin*); diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt index 934caa6a..d037f06e 100644 --- a/muse2/muse/widgets/CMakeLists.txt +++ b/muse2/muse/widgets/CMakeLists.txt @@ -32,6 +32,7 @@ subdirs (${SubDirs}) ## QT4_WRAP_CPP (widget_mocs aboutbox_impl.h + arrangercolumns.h action.h bigtime.h canvas.h @@ -106,6 +107,7 @@ QT4_WRAP_CPP (widget_mocs ## file (GLOB widgets_ui_files aboutbox.ui + arrangercolumnsbase.ui appearancebase.ui cliplisteditorbase.ui commentbase.ui @@ -140,6 +142,7 @@ QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files}) ## file (GLOB widgets_source_files aboutbox_impl.cpp + arrangercolumns.cpp bigtime.cpp canvas.cpp checkbox.cpp diff --git a/muse2/muse/widgets/arrangercolumns.cpp b/muse2/muse/widgets/arrangercolumns.cpp new file mode 100644 index 00000000..883ba08c --- /dev/null +++ b/muse2/muse/widgets/arrangercolumns.cpp @@ -0,0 +1,168 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: arrangercolumns.cpp, flo93 $ +// +// (C) Copyright 2012 Florian Jung (florian.a.jung@web.de) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2 of +// the License, or (at your option) any later version. +// +// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//========================================================= + +#include "arrangercolumns.h" +#include "midictrl.h" +#include "arranger.h" + +namespace MusEGui { + +ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent) +{ + setupUi(this); + + initList(); + + connect(ctrlType,SIGNAL(activated(int)), SLOT(ctrlTypeChanged(int))); + // connect(ctrlType,SIGNAL(activated(int)), SLOT(somethingChanged())); // called by ctrlTypeChanged + connect(nameEdit,SIGNAL(textEdited(const QString&)), SLOT(somethingChanged())); + connect(spinBoxHCtrlNo,SIGNAL(valueChanged(int)), SLOT(somethingChanged())); + connect(spinBoxLCtrlNo,SIGNAL(valueChanged(int)), SLOT(somethingChanged())); + connect(listWidget,SIGNAL(currentRowChanged(int)), SLOT(itemSelected(int))); + connect(addBtn,SIGNAL(clicked()), SLOT(addEntry())); + connect(delBtn,SIGNAL(clicked()), SLOT(delEntry())); + + somethingChanged(); + ctrlTypeChanged(ctrlType->currentIndex()); +} + +void ArrangerColumns::ctrlTypeChanged(int idx) +{ + MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)idx; + + switch (t) + { + case MusECore::MidiController::Controller7: + spinBoxHCtrlNo->setEnabled(false); + spinBoxLCtrlNo->setEnabled(true); + break; + + case MusECore::MidiController::RPN: + case MusECore::MidiController::NRPN: + case MusECore::MidiController::Controller14: + case MusECore::MidiController::RPN14: + case MusECore::MidiController::NRPN14: + spinBoxHCtrlNo->setEnabled(true); + spinBoxLCtrlNo->setEnabled(true); + break; + + default: + spinBoxHCtrlNo->setEnabled(false); + spinBoxLCtrlNo->setEnabled(false); + break; + } + + somethingChanged(); +} + +void ArrangerColumns::somethingChanged() +{ + int row=listWidget->currentRow(); + if (row!=-1) + { + int hnum = spinBoxHCtrlNo->value(); + int lnum = spinBoxLCtrlNo->value(); + MusECore::MidiController::ControllerType t = (MusECore::MidiController::ControllerType)ctrlType->currentIndex(); + int ctrl_number = MusECore::MidiController::genNum(t, hnum, lnum); + + Arranger::new_custom_columns[row].name=nameEdit->text(); + Arranger::new_custom_columns[row].ctrl=ctrl_number; + + listWidget->currentItem()->setText(getListEntryString(row)); + } +} + +QString ArrangerColumns::getListEntryString(int row) +{ + return "\""+Arranger::new_custom_columns[row].name+"\": "+MusECore::midiCtrlNumString(Arranger::new_custom_columns[row].ctrl, true); +} + +void ArrangerColumns::initList() +{ + listWidget->clear(); + + for (unsigned int i=0;i<Arranger::new_custom_columns.size(); i++) + listWidget->addItem(getListEntryString(i)); +} + +void ArrangerColumns::itemSelected(int i) +{ + if (i==-1) + { + frame->setEnabled(false); + delBtn->setEnabled(false); + } + else + { + frame->setEnabled(true); + delBtn->setEnabled(true); + + nameEdit->setText(Arranger::new_custom_columns[i].name); + int num=Arranger::new_custom_columns[i].ctrl; + ctrlType->setCurrentIndex(MusECore::midiControllerType(num)); + if (spinBoxHCtrlNo->isEnabled()) + spinBoxHCtrlNo->setValue((num & 0xFF00)>>8); + else + spinBoxHCtrlNo->setValue(0); + + if (spinBoxLCtrlNo->isEnabled()) + spinBoxLCtrlNo->setValue(num & 0xFF); + else + spinBoxLCtrlNo->setValue(0); + } +} + +void ArrangerColumns::addEntry() +{ + Arranger::new_custom_columns.push_back(Arranger::custom_col_t(0,QString("?"))); + listWidget->addItem(getListEntryString(listWidget->count())); + listWidget->setCurrentRow(listWidget->count()-1); +} + +void ArrangerColumns::delEntry() +{ + int row=listWidget->currentRow(); + + if (row!=-1) + { + std::vector<Arranger::custom_col_t>::iterator it=Arranger::new_custom_columns.begin(); + advance(it, row); + Arranger::new_custom_columns.erase(it); + + initList(); + + if (listWidget->count()>0) + { + if (listWidget->count()<=row) + row=listWidget->count()-1; + + listWidget->setCurrentRow(row); + itemSelected(row); + } + else + itemSelected(-1); + } +} + +} // namespace MusEGui + diff --git a/muse2/muse/widgets/arrangercolumns.h b/muse2/muse/widgets/arrangercolumns.h new file mode 100644 index 00000000..02fbff9c --- /dev/null +++ b/muse2/muse/widgets/arrangercolumns.h @@ -0,0 +1,53 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: arrangercolumns.h, flo93 $ +// +// (C) Copyright 2012 Florian Jung (florian.a.jung@web.de) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2 of +// the License, or (at your option) any later version. +// +// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//========================================================= + +#ifndef __ARRANGERCOLUMNS_H__ +#define __ARRANGERCOLUMNS_H__ + +#include "ui_arrangercolumnsbase.h" +#include <QDialog> + +namespace MusEGui { + +class ArrangerColumns : public QDialog, private Ui::ArrangerColumnsBase +{ + Q_OBJECT + + public: + ArrangerColumns(QWidget* parent); + + private slots: + void ctrlTypeChanged(int idx); + void somethingChanged(); + void initList(); + void itemSelected(int idx); + void addEntry(); + void delEntry(); + + QString getListEntryString(int idx); +}; + +} // namespace MusEGui + +#endif + diff --git a/muse2/muse/widgets/arrangercolumnsbase.ui b/muse2/muse/widgets/arrangercolumnsbase.ui new file mode 100644 index 00000000..d8ea9f5f --- /dev/null +++ b/muse2/muse/widgets/arrangercolumnsbase.ui @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ArrangerColumnsBase</class> + <widget class="QDialog" name="ArrangerColumnsBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>319</width> + <height>407</height> + </rect> + </property> + <property name="windowTitle"> + <string>Configure arranger columns</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Columns:</string> + </property> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget"/> + </item> + <item> + <widget class="QFrame" name="frame"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="nameEdit"/> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="TextLabel2_4"> + <property name="text"> + <string>Controller type:</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="ctrlType"> + <property name="toolTip"> + <string>Midi controller type</string> + </property> + <property name="whatsThis"> + <string>Midi controller type</string> + </property> + <item> + <property name="text"> + <string>Control7</string> + </property> + </item> + <item> + <property name="text"> + <string>Control14</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN</string> + </property> + </item> + <item> + <property name="text"> + <string>RPN14</string> + </property> + </item> + <item> + <property name="text"> + <string>NRPN14</string> + </property> + </item> + <item> + <property name="text"> + <string>Pitch</string> + </property> + </item> + <item> + <property name="text"> + <string>Program</string> + </property> + </item> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="TextLabel3_2"> + <property name="text"> + <string>H-Ctrl</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxHCtrlNo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Midi controller number high byte</string> + </property> + <property name="whatsThis"> + <string>Midi controller number high byte</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>127</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="TextLabel2_3_2"> + <property name="text"> + <string>L-Ctrl</string> + </property> + <property name="wordWrap"> + <bool>false</bool> + </property> + <property name="indent"> + <number>10</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxLCtrlNo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Midi controller number low byte (* means drum controller)</string> + </property> + <property name="whatsThis"> + <string>Midi controller number low byte. +If low byte is * then the controller is a + 'drum controller'. For drum tracks and + GS/XG type songs and instruments. +Allows controllers for each instrument in + Muse's drum map. The low byte will be + replaced by the 'ANote' in the drum map. +Examples: The GS and XG instruments' + Drum controllers.</string> + </property> + <property name="specialValueText"> + <string comment="wild card">*</string> + </property> + <property name="minimum"> + <number>-1</number> + </property> + <property name="maximum"> + <number>127</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QPushButton" name="addBtn"> + <property name="text"> + <string>&Add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="delBtn"> + <property name="text"> + <string>&Delete</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="doneBtn"> + <property name="text"> + <string>Done</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>doneBtn</sender> + <signal>clicked()</signal> + <receiver>ArrangerColumnsBase</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>260</x> + <y>383</y> + </hint> + <hint type="destinationlabel"> + <x>159</x> + <y>203</y> + </hint> + </hints> + </connection> + </connections> +</ui> |