summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/ChangeLog4
-rw-r--r--muse2/muse/ctrl/ctrlcanvas.cpp91
-rw-r--r--muse2/muse/widgets/view.cpp42
3 files changed, 119 insertions, 18 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 568dc147..5e3c444f 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,7 @@
+26.02.2011:
+ - Fixed some piano roll controller graph drawing issues. (Tim)
+ Draw velocities on top of grid, but draw non-velocity items behind grid.
+ Working on text overlay smearing...
24.02.2011:
- Improved default midi auto-connections. (Tim p4.0.17)
Midi ports list default input routes column now shows 'all' by default.
diff --git a/muse2/muse/ctrl/ctrlcanvas.cpp b/muse2/muse/ctrl/ctrlcanvas.cpp
index 0eb51363..d8281b1e 100644
--- a/muse2/muse/ctrl/ctrlcanvas.cpp
+++ b/muse2/muse/ctrl/ctrlcanvas.cpp
@@ -1390,35 +1390,80 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)
int h = rect.height();
//---------------------------------------------------
- // draw the grid
- //---------------------------------------------------
-
- p.save();
- View::pdraw(p, rect);
- p.restore();
-
- //---------------------------------------------------
// draw Canvas Items
//---------------------------------------------------
bool velo = (midiControllerType(_controller->num()) == MidiController::Velo);
- if(!velo)
+ if(velo)
{
+ //---------------------------------------------------
+ // draw the grid and markers now - before velocity items
+ //---------------------------------------------------
+ p.save();
+ View::pdraw(p, rect);
+ p.restore();
+
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::red);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ }
+ else
+ // Draw non-fg non-velocity items for the current part
pdrawItems(p, rect, curPart, false, false);
- }
+
for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
{
MidiPart* part = (MidiPart*)(ip->second);
//if((velo && part == curPart) || (!velo && part != curPart))
if(part == curPart)
continue;
+ // Draw items for all parts - other than current part
pdrawItems(p, rect, part, velo, !velo);
}
if(velo)
{
+ // Draw fg velocity items for the current part
pdrawItems(p, rect, curPart, true, true);
}
+ else
+ {
+ //---------------------------------------------------
+ // draw the grid and markers now - after non-velocity items
+ //---------------------------------------------------
+ p.save();
+ View::pdraw(p, rect);
+ p.restore();
+
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::red);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ }
+ /*
//---------------------------------------------------
// draw marker
//---------------------------------------------------
@@ -1438,7 +1483,8 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)
p.setPen(Qt::blue);
p.drawLine(xp, y, xp, y+h);
}
-
+ */
+
//---------------------------------------------------
// draw lasso
//---------------------------------------------------
@@ -1457,15 +1503,17 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)
void CtrlCanvas::drawOverlay(QPainter& p)
{
- QString s(_controller->name());
+ //QString s(_controller->name());
+ QString s(_controller ? _controller->name() : QString(""));
p.setFont(config.fonts[3]);
p.setPen(Qt::black);
QFontMetrics fm(config.fonts[3]);
int y = fm.lineSpacing() + 2;
+ //printf("CtrlCanvas::drawOverlay fm w:%d h:%d\n", fm.width(_controller ? _controller->name() : QString("")), fm.height());
p.drawText(2, y, s);
if (noEvents) {
- p.setFont(config.fonts[3]);
- p.setPen(Qt::black);
+ //p.setFont(config.fonts[3]);
+ //p.setPen(Qt::black);
p.drawText(width()/2-100,height()/2-10, "Use shift + pencil or line tool to draw new events");
//p.drawText(2 , y * 2, "Use shift + pencil or line tool to draw new events");
}
@@ -1477,12 +1525,21 @@ void CtrlCanvas::drawOverlay(QPainter& p)
//---------------------------------------------------------
QRect CtrlCanvas::overlayRect() const
- {
+{
QFontMetrics fm(config.fonts[3]);
QRect r(fm.boundingRect(_controller ? _controller->name() : QString("")));
- r.translate(2, 2); // top/left margin
- return r;
+ //QRect r(0, 0, fm.width(_controller ? _controller->name() : QString("")), fm.height());
+ //r.translate(2, 2); // top/left margin
+ r.translate(2, fm.lineSpacing() + 2); //
+ if (noEvents)
+ {
+ QRect r2(fm.boundingRect(QString("Use shift + pencil or line tool to draw new events")));
+ r2.translate(width()/2-100, height()/2-10);
+ r |= r2;
}
+
+ return r;
+}
//---------------------------------------------------------
// draw
diff --git a/muse2/muse/widgets/view.cpp b/muse2/muse/widgets/view.cpp
index c5109017..3637e320 100644
--- a/muse2/muse/widgets/view.cpp
+++ b/muse2/muse/widgets/view.cpp
@@ -141,6 +141,12 @@ void View::setXPos(int x)
#else
scroll(delta, 0);
+ QRect olr = overlayRect().translated(delta, 0);
+ //olr.setHeight(height());
+ //olr.setWidth(olr.width() * 2);
+ //printf("scroll update: x:%d y:%d w:%d h:%d\n", olr.x(), olr.y(), olr.width(), olr.height());
+ //repaint(overlayRect().translated(delta, 0));
+ update(olr);
#endif
}
@@ -195,6 +201,8 @@ void View::setYPos(int y)
#else
scroll(0, delta);
+ //repaint(overlayRect().translate(0, delta));
+ update(overlayRect().translated(0, delta));
#endif
}
@@ -202,7 +210,7 @@ void View::setYPos(int y)
// resizeEvent
//---------------------------------------------------------
-void View::resizeEvent(QResizeEvent* ev)
+void View::resizeEvent(QResizeEvent* /*ev*/)
{
#ifdef VIEW_USE_DOUBLE_BUFFERING
//pm.resize(ev->size());
@@ -239,7 +247,39 @@ void View::paintEvent(QPaintEvent* ev)
p.drawPixmap(ev->rect().topLeft(), pm, ev->rect());
#else
+
+ /*
+ QRect er = ev->rect();
+ QRect or = overlayRect();
+ // Is there an overlay to be drawn? Is it not already fully contained by the requested paint rectangle?
+ if(!or.isNull() && !er.contains(or))
+ {
+ // Is at least part of the overlay contained by the paint rectangle?
+ if(!(er & or).isNull())
+ {
+ // Then we only need one paint pass...
+ // TODO: Controller canvas ignores paint rectangle height.
+ // So we can get away with just uniting the rectangles.
+ // When controller canvas is finally optimized to respect height,
+ // this should be more optimized by drawing only 'subtraction'
+ // of intersection result from the overlay rectangle.
+ // Something like: paint(er); paint(or - (er & or));
+ // But there's no '-' operator. Hmm how to do that...
+ paint(er | or);
+ }
+ else
+ {
+ // Then we need two separate paint passes...
+ // Paint the requested rectangle as usual.
+ paint(er);
+ // Paint the overlay rectangle portion as well.
+ paint(or);
+ }
+ }
+ */
+
paint(ev->rect());
+ //paint(er);
#endif
}