summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-03-17 16:55:22 +0000
committerFlorian Jung <flo@windfisch.org>2012-03-17 16:55:22 +0000
commit2800c0e742bdc9d141f6e8c77dbfba1831e8efb2 (patch)
tree3cfafe86a5f07f0059d64b353d9d06e28e7d272d /muse2
parent8f7ed6ab503f7f1befae937bdc33e6907f3a1868 (diff)
- custom columns can now also store their values to song->cpos(), not
only to tick0 - hopefully fixed a bug in the custom columns setup dialog
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/arranger/arranger.cpp3
-rw-r--r--muse2/muse/arranger/arranger.h6
-rw-r--r--muse2/muse/arranger/tlist.cpp81
-rw-r--r--muse2/muse/arranger/tlist.h6
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp2
-rw-r--r--muse2/muse/widgets/arrangercolumns.cpp16
-rw-r--r--muse2/muse/widgets/arrangercolumns.h3
-rw-r--r--muse2/muse/widgets/arrangercolumnsbase.ui53
9 files changed, 162 insertions, 11 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 219ea5ed..fc77c6b1 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+17.03.2012:
+ - Custom columns can now either affect tick0 or song->cpos() (flo)
+ - hopefully fixed a big in the custom columns dialog (flo)
16.03.2012:
- Custom columns now send their controller changes to the device
automatically if appropriate (flo)
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp
index 9048bb3c..55275ddc 100644
--- a/muse2/muse/arranger/arranger.cpp
+++ b/muse2/muse/arranger/arranger.cpp
@@ -84,6 +84,7 @@ void Arranger::writeCustomColumns(int level, MusECore::Xml& xml)
xml.tag(level++, "column");
xml.strTag(level, "name", new_custom_columns[i].name);
xml.intTag(level, "ctrl", new_custom_columns[i].ctrl);
+ xml.intTag(level, "affected_pos", new_custom_columns[i].affected_pos);
xml.etag(--level, "column");
}
@@ -136,6 +137,8 @@ Arranger::custom_col_t Arranger::readOneCustomColumn(MusECore::Xml& xml)
temp.name=xml.parse1();
else if (tag == "ctrl")
temp.ctrl=xml.parseInt();
+ else if (tag == "affected_pos")
+ temp.affected_pos=(custom_col_t::affected_pos_t)xml.parseInt();
else
xml.unknown("Arranger::readOneCustomColumn");
break;
diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h
index 6069c8b3..8873e2af 100644
--- a/muse2/muse/arranger/arranger.h
+++ b/muse2/muse/arranger/arranger.h
@@ -196,13 +196,17 @@ class Arranger : public QWidget {
struct custom_col_t
{
+ enum affected_pos_t {AFFECT_BEGIN, AFFECT_CPOS};
+
int ctrl;
QString name;
+ affected_pos_t affected_pos;
- custom_col_t(int c, QString n)
+ custom_col_t(int c, QString n, affected_pos_t a=AFFECT_BEGIN)
{
ctrl=c;
name=n;
+ affected_pos=a;
}
};
static std::vector<custom_col_t> custom_columns; //FINDMICH TODO: eliminate all usage of new_custom_columns
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp
index 0c14bf7b..be997504 100644
--- a/muse2/muse/arranger/tlist.cpp
+++ b/muse2/muse/arranger/tlist.cpp
@@ -109,6 +109,7 @@ TList::TList(Header* hdr, QWidget* parent, const char* name)
connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(redraw()));
+ connect(MusEGlobal::heartBeatTimer, SIGNAL(timeout()), SLOT(maybeUpdateVolatileCustomColumns()));
}
//---------------------------------------------------------
@@ -425,7 +426,16 @@ void TList::paint(const QRect& r)
MusECore::MidiTrack* mt=dynamic_cast<MusECore::MidiTrack*>(track);
MusECore::MidiPort* mp = &MusEGlobal::midiPorts[mt->outPort()];
MusECore::MidiController* mctl = mp->midiController(col_ctrl_no);
- int val=mt->getControllerChangeAtTick(0,col_ctrl_no,MusECore::CTRL_VAL_UNKNOWN);
+ int val;
+ if (Arranger::custom_columns[section-COL_CUSTOM_MIDICTRL_OFFSET].affected_pos ==
+ Arranger::custom_col_t::AFFECT_BEGIN)
+ val=mt->getControllerChangeAtTick(0,col_ctrl_no,MusECore::CTRL_VAL_UNKNOWN);
+ else
+ {
+ val=mp->hwCtrlState(mt->outChannel(), col_ctrl_no);
+ old_ctrl_hw_states[mt][section]=val;
+ }
+
if (val!=MusECore::CTRL_VAL_UNKNOWN)
val-=mctl->bias();
@@ -477,6 +487,46 @@ void TList::paint(const QRect& r)
}
}
+void TList::maybeUpdateVolatileCustomColumns()
+{
+ MusECore::TrackList* l = MusEGlobal::song->tracks();
+ int idx = 0;
+ int yy = -ypos;
+ for (MusECore::iTrack i = l->begin(); i != l->end(); ++idx, yy += (*i)->height(), ++i)
+ {
+ MusECore::Track* track = *i;
+ int trackHeight = track->height();
+ if (trackHeight==0) // not visible
+ continue;
+
+
+ int x = 0;
+ for (int index = 0; index < header->count(); ++index)
+ {
+ int section = header->logicalIndex(index);
+
+ if (section>=COL_CUSTOM_MIDICTRL_OFFSET && track->isMidiTrack() &&
+ (Arranger::custom_columns[section-COL_CUSTOM_MIDICTRL_OFFSET].affected_pos ==
+ Arranger::custom_col_t::AFFECT_CPOS) )
+ {
+ int w = header->sectionSize(section);
+ QRect r = QRect(x+2, yy, w-4, trackHeight);
+
+ int ctrl_no = Arranger::custom_columns[section-COL_CUSTOM_MIDICTRL_OFFSET].ctrl;
+
+ MusECore::MidiTrack* mt=(MusECore::MidiTrack*)track;
+ MusECore::MidiPort* mp = &MusEGlobal::midiPorts[mt->outPort()];
+ int new_val = mp->hwCtrlState(mt->outChannel(), ctrl_no);
+
+ if (new_val != old_ctrl_hw_states[track][section])
+ update(r);
+ }
+
+ x += header->sectionSize(section);
+ }
+ }
+}
+
//---------------------------------------------------------
// returnPressed
//---------------------------------------------------------
@@ -627,7 +677,7 @@ void TList::ctrlValueFinished()
if (val!=MusECore::CTRL_VAL_UNKNOWN)
{
- record_controller_change_and_maybe_send(0, ctrl_num, val, mt);
+ record_controller_change_and_maybe_send(ctrl_at_tick, ctrl_num, val, mt);
}
else
{
@@ -797,6 +847,12 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev)
if (ctrl_num!=MusECore::CTRL_PROGRAM)
{
+ if (Arranger::custom_columns[section-COL_CUSTOM_MIDICTRL_OFFSET].affected_pos ==
+ Arranger::custom_col_t::AFFECT_BEGIN)
+ ctrl_at_tick=0;
+ else
+ ctrl_at_tick=MusEGlobal::song->cpos();
+
if (ctrl_edit==0)
{
ctrl_edit=new QSpinBox(this);
@@ -1834,6 +1890,12 @@ void TList::mousePressEvent(QMouseEvent* ev)
mode = START_DRAG;
if (col>=COL_CUSTOM_MIDICTRL_OFFSET && t->isMidiTrack())
{
+ if (Arranger::custom_columns[col-COL_CUSTOM_MIDICTRL_OFFSET].affected_pos ==
+ Arranger::custom_col_t::AFFECT_BEGIN)
+ ctrl_at_tick=0;
+ else
+ ctrl_at_tick=MusEGlobal::song->cpos();
+
int delta = 0;
if (button == Qt::RightButton)
delta = 1;
@@ -1876,7 +1938,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
{
if (val!=minval-1)
{
- record_controller_change_and_maybe_send(0, ctrl_num, val, mt);
+ record_controller_change_and_maybe_send(ctrl_at_tick, ctrl_num, val, mt);
}
else
{
@@ -1929,7 +1991,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
{
int val = act->data().toInt();
if(val != -1)
- record_controller_change_and_maybe_send(0, MusECore::CTRL_PROGRAM, val, mt);
+ record_controller_change_and_maybe_send(ctrl_at_tick, MusECore::CTRL_PROGRAM, val, mt);
}
delete pup;
@@ -2342,7 +2404,14 @@ void TList::wheelEvent(QWheelEvent* ev)
{
if (val!=minval-1)
{
- record_controller_change_and_maybe_send(0, ctrl_num, val, mt);
+ int at_tick;
+ if (Arranger::custom_columns[col-COL_CUSTOM_MIDICTRL_OFFSET].affected_pos ==
+ Arranger::custom_col_t::AFFECT_BEGIN)
+ at_tick=0;
+ else
+ at_tick=MusEGlobal::song->cpos();
+
+ record_controller_change_and_maybe_send(at_tick, ctrl_num, val, mt);
}
else
{
@@ -2514,7 +2583,7 @@ void TList::instrPopupActivated(QAction* act)
{
int val = act->data().toInt();
if(val != -1)
- record_controller_change_and_maybe_send(0, MusECore::CTRL_PROGRAM, val, mt);
+ record_controller_change_and_maybe_send(ctrl_at_tick, MusECore::CTRL_PROGRAM, val, mt);
}
}
diff --git a/muse2/muse/arranger/tlist.h b/muse2/muse/arranger/tlist.h
index ae50058a..ff25f16c 100644
--- a/muse2/muse/arranger/tlist.h
+++ b/muse2/muse/arranger/tlist.h
@@ -24,7 +24,7 @@
#define __TLIST_H__
#include "track.h"
-
+#include <map>
#include <QWidget>
class QWidget;
@@ -71,6 +71,8 @@ class TList : public QWidget {
int ypos;
bool editMode;
bool editJustFinished;
+
+ std::map<MusECore::Track*, std::map<int, int> > old_ctrl_hw_states;
QPixmap bgPixmap; // background Pixmap
bool resizeFlag; // true if resize cursor is shown
@@ -81,6 +83,7 @@ class TList : public QWidget {
QSpinBox* chan_edit;
QSpinBox* ctrl_edit;
int ctrl_num;
+ unsigned ctrl_at_tick;
MusECore::Track* editTrack;
MusECore::Track* editAutomation;
@@ -113,6 +116,7 @@ class TList : public QWidget {
PopupMenu* colorMenu(QColor c, int id, QWidget* parent);
private slots:
+ void maybeUpdateVolatileCustomColumns(); // updates AFFECT_CPOS-columns when and only when the hwState has changed
void returnPressed();
void chanValueFinished();
void ctrlValueFinished();
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 11ccf445..d8529794 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4704,8 +4704,6 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* o test old- and new drumtrack recording, steprecording
*
* CURRENT TODO
- * o custom columns should also be able to store at cpos, not only at tick0
- *
* o column's widths aren't stored into configuration. fix that.
* o storing <no_toplevels /> into a template file seems to ignore
* the arranger's "MDI-ness", sets is at subwin all the time!
diff --git a/muse2/muse/widgets/arrangercolumns.cpp b/muse2/muse/widgets/arrangercolumns.cpp
index 5510e69c..08a9580e 100644
--- a/muse2/muse/widgets/arrangercolumns.cpp
+++ b/muse2/muse/widgets/arrangercolumns.cpp
@@ -29,6 +29,8 @@ namespace MusEGui {
ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent)
{
+ ignoreSomethingChanged=true;
+
setupUi(this);
initList();
@@ -38,6 +40,8 @@ ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent)
connect(nameEdit,SIGNAL(textEdited(const QString&)), SLOT(somethingChanged()));
connect(spinBoxHCtrlNo,SIGNAL(valueChanged(int)), SLOT(somethingChanged()));
connect(spinBoxLCtrlNo,SIGNAL(valueChanged(int)), SLOT(somethingChanged()));
+ connect(affectBeginButton,SIGNAL(toggled(bool)), SLOT(somethingChanged()));
+ connect(affectCposButton,SIGNAL(toggled(bool)), SLOT(somethingChanged()));
connect(listWidget,SIGNAL(currentRowChanged(int)), SLOT(itemSelected(int)));
connect(addBtn,SIGNAL(clicked()), SLOT(addEntry()));
connect(delBtn,SIGNAL(clicked()), SLOT(delEntry()));
@@ -48,6 +52,8 @@ ArrangerColumns::ArrangerColumns(QWidget* parent) : QDialog(parent)
itemSelected(-1);
ctrlTypeChanged(ctrlType->currentIndex());
+
+ ignoreSomethingChanged=false;
}
void ArrangerColumns::ctrlTypeChanged(int idx)
@@ -81,6 +87,8 @@ void ArrangerColumns::ctrlTypeChanged(int idx)
void ArrangerColumns::somethingChanged()
{
+ if (ignoreSomethingChanged) return;
+
int row=listWidget->currentRow();
if (row!=-1)
{
@@ -91,6 +99,7 @@ void ArrangerColumns::somethingChanged()
Arranger::new_custom_columns[row].name=nameEdit->text();
Arranger::new_custom_columns[row].ctrl=ctrl_number;
+ Arranger::new_custom_columns[row].affected_pos=(affectBeginButton->isChecked() ? Arranger::custom_col_t::AFFECT_BEGIN : Arranger::custom_col_t::AFFECT_CPOS);
listWidget->currentItem()->setText(getListEntryString(row));
}
@@ -111,6 +120,8 @@ void ArrangerColumns::initList()
void ArrangerColumns::itemSelected(int i)
{
+ ignoreSomethingChanged=true;
+
if (i==-1)
{
frame->setEnabled(false);
@@ -133,7 +144,12 @@ void ArrangerColumns::itemSelected(int i)
spinBoxLCtrlNo->setValue(num & 0xFF);
else
spinBoxLCtrlNo->setValue(0);
+
+ affectBeginButton->setChecked(Arranger::new_custom_columns[i].affected_pos == Arranger::custom_col_t::AFFECT_BEGIN);
+ affectCposButton->setChecked(Arranger::new_custom_columns[i].affected_pos == Arranger::custom_col_t::AFFECT_CPOS);
}
+
+ ignoreSomethingChanged=false;
}
void ArrangerColumns::addEntry()
diff --git a/muse2/muse/widgets/arrangercolumns.h b/muse2/muse/widgets/arrangercolumns.h
index 02fbff9c..109fec2a 100644
--- a/muse2/muse/widgets/arrangercolumns.h
+++ b/muse2/muse/widgets/arrangercolumns.h
@@ -45,6 +45,9 @@ class ArrangerColumns : public QDialog, private Ui::ArrangerColumnsBase
void delEntry();
QString getListEntryString(int idx);
+
+ private:
+ bool ignoreSomethingChanged;
};
} // namespace MusEGui
diff --git a/muse2/muse/widgets/arrangercolumnsbase.ui b/muse2/muse/widgets/arrangercolumnsbase.ui
index d8ea9f5f..bfa07e49 100644
--- a/muse2/muse/widgets/arrangercolumnsbase.ui
+++ b/muse2/muse/widgets/arrangercolumnsbase.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>319</width>
- <height>407</height>
+ <height>485</height>
</rect>
</property>
<property name="windowTitle">
@@ -204,6 +204,57 @@ Examples: The GS and XG instruments'
</item>
</layout>
</item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="horizontalGroupBox">
+ <property name="title">
+ <string>affect CCs at</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="affectBeginButton">
+ <property name="text">
+ <string>begin of song</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="affectCposButton">
+ <property name="text">
+ <string>current position</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</item>
</layout>