summaryrefslogtreecommitdiff
path: root/muse2/muse/arranger
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/muse/arranger
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/muse/arranger')
-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
4 files changed, 88 insertions, 8 deletions
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();