From e5a7a6f186c458e3c7087dbc5604959b519bdba9 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Mon, 20 Dec 2010 05:00:55 +0000 Subject: Fixed arranger grid h-line drawing, track, and part drawing alignment, border issues. --- muse2/ChangeLog | 2 + muse2/muse/arranger/arranger.cpp | 3 +- muse2/muse/arranger/pcanvas.cpp | 103 +++++++++++++++++++++++---------- muse2/muse/gconfig.cpp | 2 +- muse2/muse/widgets/musewidgetsplug.cpp | 2 +- muse2/share/templates/audio.med | 2 +- muse2/share/templates/default.med | 2 +- muse2/share/templates/midiGM.med | 2 +- muse2/share/templates/monorecord.med | 2 +- muse2/share/templates/synti.med | 2 +- 10 files changed, 84 insertions(+), 38 deletions(-) (limited to 'muse2') diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 2b608260..47ac662c 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,5 @@ +20.12.2010: + - Fixed arranger grid h-line drawing, track, and part drawing alignment, border issues. (Tim) 19.12.2010: - Fixed not saving part colours and part canvas background appearance settings. (Tim) *Feature: Added 'global opaqueness' (transparency) appearance setting. (Tim) diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index c9e9a8db..5272ee75 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -330,7 +330,8 @@ Arranger::Arranger(QMainWindow* parent, const char* name) //vscroll = new QScrollBar(1, 20*20, 1, 5, 0, Vertical, editor); //vscroll = new QScrollBar(1, 20*20, 5, 25, 0, Qt::Vertical, editor); vscroll = new QScrollBar(editor); - vscroll->setMinimum(1); + ///vscroll->setMinimum(1); + vscroll->setMinimum(0); // Tim. vscroll->setMaximum(20*20); vscroll->setSingleStep(5); vscroll->setPageStep(25); diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index ddc7dfff..d9c3880e 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -106,7 +106,15 @@ NPart::NPart(Part* e) : CItem(Event(), e) { int th = track()->height(); int y = track()->y(); - setPos(QPoint(e->tick(), y + 1)); + //printf("NPart::NPart track name:%s, y:%d h:%d\n", track()->name().toLatin1().constData(), y, th); // REMOVE Tim. + + ///setPos(QPoint(e->tick(), y + 1)); + setPos(QPoint(e->tick(), y)); + + ///setBBox(QRect(e->tick(), y + 1, e->lenTick(), th)); + // NOTE: For adjustable border size: If using a two-pixel border width while drawing, use second line. + // If one-pixel width, use first line. Tim. + //setBBox(QRect(e->tick(), y, e->lenTick(), th)); setBBox(QRect(e->tick(), y + 1, e->lenTick(), th)); } @@ -186,14 +194,12 @@ void PartCanvas::returnPressed() lineEditor->hide(); Part* oldPart = editPart->part(); Part* newPart = oldPart->clone(); - // Added by Tim. p3.3.6 //printf("PartCanvas::returnPressed before msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount()); newPart->setName(lineEditor->text()); // Indicate do undo, and do port controller values but not clone parts. //audio->msgChangePart(oldPart, newPart); audio->msgChangePart(oldPart, newPart, true, true, false); - // Added by Tim. p3.3.6 //printf("PartCanvas::returnPressed after msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount()); editMode = false; @@ -483,7 +489,6 @@ bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) dpart->setTick(dtick); - // Added by Tim. p3.3.6 //printf("PartCanvas::moveItem before add/changePart clone:%d spart:%p events:%p refs:%d Arefs:%d sn:%d dpart:%p events:%p refs:%d Arefs:%d sn:%d\n", clone, spart, spart->events(), spart->events()->refCount(), spart->events()->arefCount(), spart->sn(), dpart, dpart->events(), dpart->events()->refCount(), dpart->events()->arefCount(), dpart->sn()); if(t == MOVE_MOVE) @@ -522,7 +527,6 @@ bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) spart->setSelected(false); } - // Added by Tim. p3.3.6 //printf("PartCanvas::moveItem after add/changePart spart:%p events:%p refs:%d Arefs:%d dpart:%p events:%p refs:%d Arefs:%d\n", spart, spart->events(), spart->events()->refCount(), spart->events()->arefCount(), dpart, dpart->events(), dpart->events()->refCount(), dpart->events()->arefCount()); if (song->len() < (dpart->lenTick() + dpart->tick())) @@ -874,7 +878,6 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) Part* spart = npart->part(); Track* track = npart->track(); Part* dpart = track->newPart(spart, false); - // Added by Tim. p3.3.6 //printf("PartCanvas::itemPopup: #1 spart %s %p next:%s %p prev:%s %p\n", spart->name().toLatin1().constData(), spart, spart->nextClone()->name().toLatin1().constData(), spart->nextClone(), spart->prevClone()->name().toLatin1().constData(), spart->prevClone()); //printf("PartCanvas::itemPopup: #1 dpart %s %p next:%s %p prev:%s %p\n", dpart->name().toLatin1().constData(), dpart, dpart->nextClone()->name().toLatin1().constData(), dpart->nextClone(), dpart->prevClone()->name().toLatin1().constData(), dpart->prevClone()); @@ -889,7 +892,6 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) // Indicate no undo, and do port controller values but not clone parts. //audio->msgChangePart(spart, dpart, false); audio->msgChangePart(spart, dpart, false, true, false); - // Added by Tim. p3.3.6 //printf("PartCanvas::itemPopup: #2 spart %s %p next:%s %p prev:%s %p\n", spart->name().toLatin1().constData(), spart, spart->nextClone()->name().toLatin1().constData(), spart->nextClone(), spart->prevClone()->name().toLatin1().constData(), spart->prevClone()); //printf("PartCanvas::itemPopup: #2 dpart %s %p next:%s %p prev:%s %p\n", dpart->name().toLatin1().constData(), dpart, dpart->nextClone()->name().toLatin1().constData(), dpart->nextClone(), dpart->prevClone()->name().toLatin1().constData(), dpart->prevClone()); @@ -946,7 +948,6 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) { for(int i = 0; i < j; ++i) { - // Added by Tim. p3.3.6 //printf("PartCanvas::itemPopup i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j); p->setSelected(true); @@ -1422,9 +1423,9 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) //printf("part start tick %d part start pixel %d\n", part->tick(), r.x()); - // Added by Tim. p3.3.6 //printf("PartCanvas::drawItem %s evRefs:%d pTick:%d pLen:%d bb.x:%d bb.w:%d rect.x:%d rect.w:%d r.x:%d r.w:%d\n", part->name().toLatin1().constData(), part->events()->arefCount(), pTick, part->lenTick(), item->bbox().x(), item->bbox().width(), rect.x(), rect.width(), r.x(), r.width()); + // THIS WAS IN MUSE-1: // Must be reasonable about very low negative x values! With long songs > 15min // and with high horizontal magnification, 'ghost' drawings appeared, // apparently the result of truncation later (xp = -65006 caused ghosting @@ -1438,45 +1439,56 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.setPen(Qt::black); if (part->mute()) { - p.setBrush(Qt::gray); - p.drawRect(r); + QColor c(Qt::white); + c.setAlpha(config.globalAlphaBlend); + p.setBrush(c); + + // NOTE: For one-pixel border use first line For two-pixel border use second. + p.drawRect(QRect(r.x(), r.y()-1, r.width(), r.height())); + //p.drawRect(r); + return; } if (item->isMoving()) { - p.setBrush(Qt::gray); - p.drawRect(r); + QColor c(Qt::gray); + c.setAlpha(config.globalAlphaBlend); + p.setBrush(c); + + // NOTE: For one-pixel border use first line. For two-pixel border use second. + p.drawRect(QRect(r.x(), r.y()-1, r.width(), r.height())); + //p.drawRect(r); + } //else if (part->mute()) // return; else if (part->selected()) { bool clone = part->events()->arefCount() > 1; - //p.setPen(config.partColors[i]); - //p.setPen(QPen(config.partColors[i], 2, clone ? Qt::DashLine : Qt::SolidLine)); + + // NOTE: For one-pixel border use first line and don't bother with setCosmetic. + // For a two-pixel border use second line and MUST use setCosmetic! Tim. + //p.setPen(QPen(config.partColors[i], 0, clone ? Qt::DashLine : Qt::SolidLine)); QPen pen(config.partColors[i], 2, clone ? Qt::DashLine : Qt::SolidLine); pen.setCosmetic(true); + p.setPen(pen); - //p.setBrush(Qt::black); - QColor c(Qt::black); // Hm, put some kind of lower limit? If so do that globally to the adjustment. - c.setAlpha(config.globalAlphaBlend); + QColor c(Qt::black); + c.setAlpha(config.globalAlphaBlend); p.setBrush(c); p.drawRect(r); } else { bool clone = part->events()->arefCount() > 1; + + // NOTE: Pixel width: See above note. //p.setPen(QPen(Qt::black, 0, clone ? Qt::DashLine : Qt::SolidLine)); QPen pen(Qt::black, 2, clone ? Qt::DashLine : Qt::SolidLine); pen.setCosmetic(true); - p.setPen(pen); - //p.setBrush(config.partColors[i]); + p.setPen(pen); QColor c(config.partColors[i]); c.setAlpha(config.globalAlphaBlend); p.setBrush(c); - //p.setBrush(QColor(config.partColors[i].red(), - // config.partColors[i].green(), - // config.partColors[i].blue(), - // 127)); p.drawRect(r); } @@ -1589,8 +1601,20 @@ void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&) //if(!item->isMoving()) // return; p.setPen( Qt::black); - p.setBrush( Qt::NoBrush); - p.drawRect(item->mp().x(), item->mp().y()+1, item->width(), item->height()); + + //p.setBrush( Qt::NoBrush); + //QColor c(Qt::gray); + Part* part = ((NPart*)item)->part(); + QColor c(config.partColors[part->colorIndex()]); + + ///c.setAlpha(config.globalAlphaBlend); + c.setAlpha(128); // Fix this regardless of global setting. Should be OK. + + p.setBrush(c); + + // NOTE: For one-pixel border use second line. For two-pixel border use first. + //p.drawRect(item->mp().x(), item->mp().y()+1, item->width(), item->height()); + p.drawRect(item->mp().x(), item->mp().y(), item->width(), item->height()); } //--------------------------------------------------------- @@ -2765,13 +2789,19 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) TrackList* tl = song->tracks(); int yy = 0; + int th; for (iTrack it = tl->begin(); it != tl->end(); ++it) { if (yy > y + h) break; Track* track = *it; - if (/*config.canvasShowGrid ||*/ !track->isMidiTrack()) { + th = track->height(); + ///if (/*config.canvasShowGrid ||*/ !track->isMidiTrack()) { + if (config.canvasShowGrid && (track->isMidiTrack() || track->type() == Track::WAVE)) // Tim. + { + //printf("PartCanvas::drawCanvas track name:%s, y:%d h:%d\n", track->name().toLatin1().constData(), yy, th); // REMOVE Tim. p.setPen(baseColor.dark(130)); - p.drawLine(x, yy, x + w, yy); + ///p.drawLine(x, yy, x + w, yy); + p.drawLine(x, yy + th, x + w, yy + th); // Tim. p.setPen(baseColor); } if (!track->isMidiTrack() && (track->type() != Track::WAVE)) { @@ -2795,8 +2825,21 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, AudioTrack* /* t */) { - p.setPen(QPen(Qt::black, 2, Qt::SolidLine)); - p.setBrush(Qt::gray); + // NOTE: For one-pixel border use first line and don't bother with setCosmetic. + // For a two-pixel border use second line and MUST use setCosmetic! Tim. + QPen pen(Qt::black, 0, Qt::SolidLine); + //p.setPen(QPen(Qt::black, 2, Qt::SolidLine)); + //pen.setCosmetic(true); + p.setPen(pen); + //p.setBrush(Qt::gray); + QColor c(Qt::gray); + c.setAlpha(config.globalAlphaBlend); + p.setBrush(c); + + // Factor in pen stroking size: + //QRect rr(r); + //rr.setHeight(rr.height() -1); + p.drawRect(r); } diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index 79807cd8..ec44ec3f 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -9,7 +9,7 @@ #include "gconfig.h" GlobalConfigValues config = { - 150, // globalAlphaBlend + 190, // globalAlphaBlend { QColor(0xff, 0xff, 0xff), // palette QColor(0xff, 0xff, 0xff), diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp index cd4cb18a..e5858bd4 100644 --- a/muse2/muse/widgets/musewidgetsplug.cpp +++ b/muse2/muse/widgets/musewidgetsplug.cpp @@ -39,7 +39,7 @@ static const char* valu[] = { }; GlobalConfigValues config = { - 150, // globalAlphaBlend + 190, // globalAlphaBlend { QColor(0xff, 0xff, 0xff), // palette QColor(0xff, 0xff, 0xff), diff --git a/muse2/share/templates/audio.med b/muse2/share/templates/audio.med index 208313ff..e74f3a91 100644 --- a/muse2/share/templates/audio.med +++ b/muse2/share/templates/audio.med @@ -33,7 +33,7 @@ 0 266 - 1 + 0 diff --git a/muse2/share/templates/default.med b/muse2/share/templates/default.med index 9bfb56c9..3ffe562d 100644 --- a/muse2/share/templates/default.med +++ b/muse2/share/templates/default.med @@ -33,7 +33,7 @@ 0 266 - 1 + 0 diff --git a/muse2/share/templates/midiGM.med b/muse2/share/templates/midiGM.med index ebd6333b..1314effb 100644 --- a/muse2/share/templates/midiGM.med +++ b/muse2/share/templates/midiGM.med @@ -33,7 +33,7 @@ 0 266 - 1 + 0 diff --git a/muse2/share/templates/monorecord.med b/muse2/share/templates/monorecord.med index 07ab6997..21a36900 100644 --- a/muse2/share/templates/monorecord.med +++ b/muse2/share/templates/monorecord.med @@ -33,7 +33,7 @@ 0 266 - 1 + 0 diff --git a/muse2/share/templates/synti.med b/muse2/share/templates/synti.med index a4eec239..1f2fa7bf 100644 --- a/muse2/share/templates/synti.med +++ b/muse2/share/templates/synti.med @@ -33,7 +33,7 @@ 0 266 - 1 + 0 -- cgit v1.2.3