summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2011-03-28 01:57:10 +0000
committerTim E. Real <termtech@rogers.com>2011-03-28 01:57:10 +0000
commite483bb31b393203b944b8eb533723be88d502224 (patch)
tree0b554ad5298117086451eeb75dfbb2dfe8a24e2f
parent9d3d2cbbe21ebed7cb7ddfcd4eb1fb6079582f04 (diff)
Fixed midi controller graphs' velocity items selections.
-rw-r--r--muse2/ChangeLog1
-rw-r--r--muse2/muse/ctrl/ctrlcanvas.cpp27
-rw-r--r--muse2/muse/ctrl/ctrlcanvas.h2
3 files changed, 24 insertions, 6 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 847b0e4c..38047516 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -3,6 +3,7 @@
- Reverted Midi Track Info ui layout more or less to pre- Mar 5, with some improvements. (Tim)
- Added: placeholder for Score editor (rj)
- Reclaim some screen real estate. Set zero margin and spacing in ScrollScale constructor. (Tim)
+ - Fixed midi controller graphs' velocity items selections. (Tim)
24.03.2011:
- Fixed: Problems with midi event list editor. (p4.0.18 Tim)
For ex. problems selecting items while pianroll open. Changed ListEdit::songChanged().
diff --git a/muse2/muse/ctrl/ctrlcanvas.cpp b/muse2/muse/ctrl/ctrlcanvas.cpp
index 0b50b3ef..03c96986 100644
--- a/muse2/muse/ctrl/ctrlcanvas.cpp
+++ b/muse2/muse/ctrl/ctrlcanvas.cpp
@@ -109,7 +109,7 @@ CEvent::CEvent(Event e, MidiPart* pt, int v)
// intersects
//---------------------------------------------------------
-bool CEvent::intersects(const MidiController* mc, const QRect& r, const int wh) const
+bool CEvent::intersects(const MidiController* mc, const QRect& r, const int tickstep, const int wh) const
{
if(_event.empty())
return false;
@@ -125,9 +125,25 @@ bool CEvent::intersects(const MidiController* mc, const QRect& r, const int wh)
}
int tick2 = ex + _part->tick();
+
+ // Velocities don't use EX (set equal to event tick, giving zero width here),
+ // and velocities are drawn three pixels wide, so adjust the width now.
+ // Remember, each drawn pixel represents one tickstep which varies with zoom.
+ // So that's 3 x tickstep for each velocity line.
+ // Hmm, actually, for better pin-point accuracy just use one tickstep for now.
+ if(midiControllerType(mc->num()) == MidiController::Velo)
+ {
+ //tick1 -= tickstep;
+ //if(tick1 <= 0)
+ // tick1 = 0;
+ //tick2 += 2 * tickstep;
+
+ tick2 += tickstep;
+ }
+
QRect er(tick1, y1, tick2 - tick1, wh - y1);
- //printf("ex:%d r.x:%d r.y:%d r.w:%d r.h:%d er.x:%d er.y:%d er.w:%d er.h:%d\n",
- // ex, r.x(), r.y(), r.width(), r.height(), er.x(), er.y(), er.width(), er.height());
+ printf("t1:%d t2:%d ex:%d r.x:%d r.y:%d r.w:%d r.h:%d er.x:%d er.y:%d er.w:%d er.h:%d\n",
+ tick1, tick2, ex, r.x(), r.y(), r.width(), r.height(), er.x(), er.y(), er.width(), er.height()); // REMOVE Tim.
return r.intersects(er);
}
@@ -762,7 +778,7 @@ void CtrlCanvas::viewMousePressEvent(QMouseEvent* event)
// continue;
if (ax >= endTick)
break;
- if (ev->intersects(_controller, r, h))
+ if (ev->intersects(_controller, r, tickstep, h))
{
if (shift && ev->selected())
deselectItem(ev);
@@ -911,10 +927,11 @@ void CtrlCanvas::viewMouseReleaseEvent(QMouseEvent* event)
lasso = lasso.normalized();
int h = height();
//bool do_redraw = false;
+ int tickstep = rmapxDev(1);
for (iCEvent i = items.begin(); i != items.end(); ++i) {
if((*i)->part() != curPart)
continue;
- if ((*i)->intersects(_controller, lasso, h)) {
+ if ((*i)->intersects(_controller, lasso, tickstep, h)) {
if (shift && (*i)->selected())
{
//if (!shift) // Shift p4.0.18
diff --git a/muse2/muse/ctrl/ctrlcanvas.h b/muse2/muse/ctrl/ctrlcanvas.h
index ba986b0b..300cac19 100644
--- a/muse2/muse/ctrl/ctrlcanvas.h
+++ b/muse2/muse/ctrl/ctrlcanvas.h
@@ -57,7 +57,7 @@ class CEvent {
void setEX(int v) { ex = v; }
MidiPart* part() const { return _part; }
bool contains(int /*x1*/, int /*x2*/) const;
- bool intersects(const MidiController*, const QRect&, const int /*windowHeight*/) const;
+ bool intersects(const MidiController*, const QRect&, const int /*tickstep*/, const int /*windowHeight*/) const;
int x() { return ex; }
};