Skip to content

Commit

Permalink
Added mouse cursor position marker to all canvases
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxras committed Mar 27, 2012
1 parent 1afaa34 commit 1082a83
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 33 deletions.
22 changes: 14 additions & 8 deletions oom/Composer/Composer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ void Composer::posChanged(int idx, unsigned val, bool)
cursVal = val;
m_timeHeader->setTime(val);
time->setPos(3, val, false);
canvas->setPos(3, val, false);
m_tempoHeader->setPos(3, val, false);
//m_sigRuler->setPos(3, val, false);
}

Expand Down Expand Up @@ -585,27 +587,31 @@ void Composer::currentTabChanged(int tab)

void Composer::setTime(unsigned tick)/*{{{*/
{
if (tick == MAXINT)
/*if (tick == MAXINT)
return;
else
{
{*/
cursVal = tick;
m_timeHeader->setTime(tick);
time->setPos(3, tick, false);
m_sigRuler->setPos(3, tick, false);
}
canvas->setPos(3, tick, false);
m_tempoHeader->setPos(3, tick, false);
//}
}/*}}}*/

void Composer::setTimeFromSig(unsigned tick)/*{{{*/
{
if (tick == MAXINT)
return;
else
{
//if (tick == MAXINT)
// return;
//else
//{
cursVal = tick;
m_timeHeader->setTime(tick);
time->setPos(3, tick, false);
}
canvas->setPos(3, tick, false);
m_tempoHeader->setPos(3, tick, false);
//}
}/*}}}*/

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion oom/Composer/ComposerCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,7 @@ void ComposerCanvas::keyPress(QKeyEvent* event)/*{{{*/
}
else if (key == shortcuts[SHRT_POS_DEC].key)
{
int spos = _pos[0];
int spos = _pos[0];
if (spos > 0)
{
spos -= 1; // Nudge by -1, then snap down with raster1.
Expand Down
10 changes: 6 additions & 4 deletions oom/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,10 @@ void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
int channels;
for (ciTrack it = tl->begin(); it != tl->end(); ++it)
{
if ((*it)->isMidiTrack())
Track* t = *it;
if (!t || t->isMidiTrack())
continue;
track = (AudioTrack*) (*it);
track = (AudioTrack*) t;

// For audio track types, synths etc. which need some kind of non-audio
// (but possibly audio-affecting) processing always, even if their output path
Expand Down Expand Up @@ -578,9 +579,10 @@ void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
// processing is 'turned on', if there was a backlog of events while it was off, then they all happen at once.
for (ciTrack it = tl->begin(); it != tl->end(); ++it)
{
if ((*it)->isMidiTrack())
Track* t = *it;
if (!t || t->isMidiTrack())
continue;
track = (AudioTrack*) (*it);
track = (AudioTrack*) t;
// Ignore unprocessed tracks which have an output route, because they will be processed by
// whatever track(s) they are routed to.
if (!track->processed() && track->noOutRoute() && (track->type() != Track::AUDIO_OUTPUT))
Expand Down
25 changes: 17 additions & 8 deletions oom/ctrl/ctrlcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void CtrlCanvas::setPos(int idx, unsigned val, bool adjustScrollbar)/*{{{*/
w += npos - opos;
x = opos;
}
pos[idx] = val;
pos[idx] = val;

// FIXME: redrawing this rectangle wipes out the controller lane
// items when cursor passes over them.
Expand Down Expand Up @@ -1409,13 +1409,7 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)/*{{{*/
// draw marker
//---------------------------------------------------

int xp = mapx(pos[0]);
if (xp >= x && xp < x + w)
{
p.setPen(QColor(0, 186, 255));
p.drawLine(xp, y, xp, y + h);
}
xp = mapx(pos[1]);
int xp = mapx(pos[1]);
if ((song->loop() || song->punchin()) && xp >= x && xp < x + w)
{
p.setPen(QColor(139, 225, 69));
Expand All @@ -1428,6 +1422,21 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)/*{{{*/
p.drawLine(xp, y, xp, y + h);
}

p.setPen(QColor(156,75,219));
xp = mapx(pos[3]);
if (pos[3] != MAXINT)
{
if (xp >= x && xp < x + w)
p.drawLine(xp, y, xp, y+h);
}

xp = mapx(pos[0]);
if (xp >= x && xp < x + w)
{
p.setPen(QColor(0, 186, 255));
p.drawLine(xp, y, xp, y + h);
}

//---------------------------------------------------
// draw lasso
//---------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions oom/ctrl/ctrledit.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public slots:
{
canvas->update();
}
void setPos(int idx, unsigned x, bool adjustScrollbar)
{
canvas->setPos(idx, x, adjustScrollbar);
}
void setMinHeight(int);
void setMaxHeight(int);
void updateHeight(int);
Expand Down
13 changes: 12 additions & 1 deletion oom/midiedit/Performer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,12 @@ void Performer::setTime(unsigned tick)/*{{{*/
time->setPos(3, tick, false);
pcbar->setPos(3, tick, false);
m_sigRuler->setPos(3, tick, false);
canvas->setPos(3, tick, false);
foreach(CtrlEdit* ctrl, ctrlEditList)
{
if(ctrl)
ctrl->setPos(3, tick, false);
}
}/*}}}*/

void Performer::setTimeFromSig(unsigned tick)/*{{{*/
Expand All @@ -1705,7 +1711,12 @@ void Performer::setTimeFromSig(unsigned tick)/*{{{*/
posLabel->setValue(tick);
time->setPos(3, tick, false);
pcbar->setPos(3, tick, false);
//m_sigRuler->setPos(3, tick, false);
canvas->setPos(3, tick, false);
foreach(CtrlEdit* ctrl, ctrlEditList)
{
if(ctrl)
ctrl->setPos(3, tick, false);
}
}/*}}}*/

//---------------------------------------------------------
Expand Down
19 changes: 14 additions & 5 deletions oom/widgets/TempoCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,31 @@ void TempoCanvas::pdraw(QPainter& p, const QRect& rect)/*{{{*/
// draw marker
//---------------------------------------------------

int xp = mapx(pos[0]);
int xp = mapx(pos[1]);
if (xp >= x && xp < x + w)
{
p.setPen(QColor(0, 186, 255));
p.setPen(QColor(139, 225, 69));
p.drawLine(xp, y, xp, y + h);
}
xp = mapx(pos[1]);
xp = mapx(pos[2]);
if (xp >= x && xp < x + w)
{
p.setPen(QColor(139, 225, 69));
p.drawLine(xp, y, xp, y + h);
}
xp = mapx(pos[2]);

xp = mapx(pos[3]);
if (pos[3] != MAXINT)
{
p.setPen(QColor(156,75,219));
if (xp >= x && xp < x + w)
p.drawLine(xp, y, xp, y+h);
}

xp = mapx(pos[0]);
if (xp >= x && xp < x + w)
{
p.setPen(QColor(139, 225, 69));
p.setPen(QColor(0, 186, 255));
p.drawLine(xp, y, xp, y + h);
}
}/*}}}*/
Expand Down
7 changes: 7 additions & 0 deletions oom/widgets/TempoHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ void TempoHeader::setOrigin(int x, int y)
if(m_canvas)
m_canvas->setOrigin(x, y);
}

void TempoHeader::setPos(int idx, unsigned x, bool sb)
{
if(m_canvas)
m_canvas->setPos(idx, x, sb);
}

1 change: 1 addition & 0 deletions oom/widgets/TempoHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public slots:
void setStartTempo(double);
void setEndTempo(double);
void setOrigin(int x, int y);
void setPos(int idx, unsigned x, bool adjustScrollbar);

signals:
void updateXMag(float);
Expand Down
19 changes: 13 additions & 6 deletions oom/widgets/canvas.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//=========================================================
// OOMidi
// OOStudio
// OpenOctave Midi and Audio Editor
// $Id: canvas.cpp,v 1.10.2.17 2009/05/03 04:14:01 terminator356 Exp $
// (C) Copyright 1999 Werner Schweer ([email protected])
// (C) Copyright 2011 - 2012 Andrew Williams and Christopher Cherrett
//=========================================================

#include <stdio.h>
#include <values.h>

#include "canvas.h"

Expand Down Expand Up @@ -428,11 +429,15 @@ void Canvas::draw(QPainter& p, const QRect& rect)/*{{{*/
if(_drawPartEndLine)
p.drawLine(_curPart->endTick(), y, _curPart->endTick(), y2);
}
//QPen playbackPen(QColor(8,193,156), 1);
//p.setPen(playbackPen);
//p.setPen(Qt::green);
p.setPen(QColor(0, 186, 255));

p.setPen(QColor(156,75,219));
if (_pos[3] != MAXINT)
{
if (_pos[3] >= unsigned(x) && _pos[3] < unsigned(x2))
p.drawLine(_pos[3], y, _pos[3], y2);
}

p.setPen(QColor(0, 186, 255));
if (_pos[0] >= unsigned(x) && _pos[0] < unsigned(x2))
{
p.drawLine(_pos[0], y, _pos[0], y2);
Expand Down Expand Up @@ -1304,6 +1309,8 @@ void Canvas::viewMouseMoveEvent(QMouseEvent* event)/*{{{*/
break;
}

_pos[3] = _evPos.x();
redraw();
mouseMove(event);
}/*}}}*/

Expand Down

0 comments on commit 1082a83

Please sign in to comment.