diff options
author | Florian Jung <flo@windfisch.org> | 2011-09-10 17:06:00 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-09-10 17:06:00 +0000 |
commit | 24f84a489364741eb3fc126a3f83d91a86b65e27 (patch) | |
tree | 63a4e20aaf4a2ebd2462c91b574eddceeac31170 /muse2/muse/arranger/pcanvas.cpp | |
parent | 38c5cccc7273247353264bb7dc97f42296d8e259 (diff) | |
parent | 2120ea4f083228dde0d7307203391a4ec8f57e2d (diff) |
merged the first bunch of orcans changes
STILL WAIT WITH COMMITTING NEW STUFF! i have to merge the rest as well!
this is a bit buggy (connect errors, not tested much), but doesn't
segfault immediately
Diffstat (limited to 'muse2/muse/arranger/pcanvas.cpp')
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 256 |
1 files changed, 137 insertions, 119 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 3cd1e18e..1dd4c44d 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -4,6 +4,21 @@ // $Id: pcanvas.cpp,v 1.48.2.26 2009/11/22 11:08:33 spamatica Exp $ // (C) Copyright 1999 Werner Schweer (ws@seh.de) // Additions, modifications (C) Copyright 2011 Tim E. Real (terminator356 on users DOT sourceforge DOT net) +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// //========================================================= #include <stdio.h> @@ -78,7 +93,7 @@ QIcon colorRect(const QColor& color, int width, int height) { // NPart //--------------------------------------------------------- -NPart::NPart(Part* e) : CItem(Event(), e) +NPart::NPart(Part* e) : MusEWidget::CItem(Event(), e) { leftBorderTouches = false; rightBorderTouches = false; @@ -93,7 +108,7 @@ NPart::NPart(Part* e) : CItem(Event(), e) //--------------------------------------------------------- PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy) - : Canvas(parent, sx, sy) + : MusEWidget::Canvas(parent, sx, sy) { setAcceptDrops(true); _raster = r; @@ -187,7 +202,7 @@ void PartCanvas::returnPressed() void PartCanvas::viewMouseDoubleClickEvent(QMouseEvent* event) { - if (_tool != PointerTool) { + if (_tool != MusEWidget::PointerTool) { viewMousePressEvent(event); return; } @@ -273,13 +288,13 @@ void PartCanvas::updateSong(DragType t, int flags) // moveCanvasItems //--------------------------------------------------------- -void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype) +void PartCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, DragType dtype) { Undo operations; - for(iCItem ici = items.begin(); ici != items.end(); ++ici) + for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) { - CItem* ci = ici->second; + MusEWidget::CItem* ci = ici->second; // If this item's part is in the parts2change list, change the item's part to the new part. //Part* pt = ci->part(); @@ -318,7 +333,7 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp //--------------------------------------------------------- // Changed by T356. -UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) +UndoOp PartCanvas::moveItem(MusEWidget::CItem* item, const QPoint& newpos, DragType t) { UndoOp result; NPart* npart = (NPart*) item; @@ -332,7 +347,7 @@ UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) } if (ntrack >= tracks->size()) { ntrack = tracks->size(); - if (debugMsg) + if (MusEGlobal::debugMsg) printf("PartCanvas::moveItem - add new track\n"); Track* newTrack = song->addTrack(int(type)); if (type == Track::WAVE) { @@ -465,7 +480,7 @@ void PartCanvas::partsChanged() void PartCanvas::updateSelection() { - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { NPart* part = (NPart*)(i->second); part->part()->setSelected(i->second->isSelected()); } @@ -477,7 +492,7 @@ void PartCanvas::updateSelection() // resizeItem //--------------------------------------------------------- -void PartCanvas::resizeItem(CItem* i, bool noSnap, bool ctrl) +void PartCanvas::resizeItem(MusEWidget::CItem* i, bool noSnap, bool ctrl) { Track* t = ((NPart*)(i))->track(); Part* p = ((NPart*)(i))->part(); @@ -499,7 +514,7 @@ void PartCanvas::resizeItem(CItem* i, bool noSnap, bool ctrl) // first create local Item //--------------------------------------------------------- -CItem* PartCanvas::newItem(const QPoint& pos, int) +MusEWidget::CItem* PartCanvas::newItem(const QPoint& pos, int) { int x = pos.x(); if (x < 0) @@ -543,7 +558,7 @@ CItem* PartCanvas::newItem(const QPoint& pos, int) // newItem //--------------------------------------------------------- -void PartCanvas::newItem(CItem* i, bool noSnap) +void PartCanvas::newItem(MusEWidget::CItem* i, bool noSnap) { Part* p = ((NPart*)(i))->part(); @@ -561,7 +576,7 @@ void PartCanvas::newItem(CItem* i, bool noSnap) // deleteItem //--------------------------------------------------------- -bool PartCanvas::deleteItem(CItem* i) +bool PartCanvas::deleteItem(MusEWidget::CItem* i) { Part* p = ((NPart*)(i))->part(); audio->msgRemovePart(p, true); //Invokes songChanged which calls partsChanged which makes it difficult to delete them there @@ -572,7 +587,7 @@ bool PartCanvas::deleteItem(CItem* i) // splitItem //--------------------------------------------------------- -void PartCanvas::splitItem(CItem* item, const QPoint& pt) +void PartCanvas::splitItem(MusEWidget::CItem* item, const QPoint& pt) { NPart* np = (NPart*) item; Track* t = np->track(); @@ -587,7 +602,7 @@ void PartCanvas::splitItem(CItem* item, const QPoint& pt) // glueItem //--------------------------------------------------------- -void PartCanvas::glueItem(CItem* item) +void PartCanvas::glueItem(MusEWidget::CItem* item) { NPart* np = (NPart*) item; Track* t = np->track(); @@ -599,7 +614,7 @@ void PartCanvas::glueItem(CItem* item) // genItemPopup //--------------------------------------------------------- -QMenu* PartCanvas::genItemPopup(CItem* item) +QMenu* PartCanvas::genItemPopup(MusEWidget::CItem* item) { NPart* npart = (NPart*) item; Track::TrackType trackType = npart->track()->type(); @@ -631,7 +646,7 @@ QMenu* PartCanvas::genItemPopup(CItem* item) // part color selection for (int i = 0; i < NUM_PARTCOLORS; ++i) { - QAction *act_color = colorPopup->addAction(colorRect(config.partColors[i], 80, 80), config.partColorNames[i]); + QAction *act_color = colorPopup->addAction(colorRect(MusEConfig::config.partColors[i], 80, 80), MusEConfig::config.partColorNames[i]); act_color->setData(20+i); } @@ -647,17 +662,17 @@ QMenu* PartCanvas::genItemPopup(CItem* item) partPopup->addSeparator(); switch(trackType) { case Track::MIDI: { - partPopup->addAction(muse->arranger->parentWin->startPianoEditAction); - partPopup->addMenu(muse->arranger->parentWin->scoreSubmenu); - partPopup->addAction(muse->arranger->parentWin->startScoreEditAction); - partPopup->addAction(muse->arranger->parentWin->startListEditAction); + partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startPianoEditAction); + partPopup->addMenu(MusEGlobal::muse->arranger->parentWin->scoreSubmenu); + partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startScoreEditAction); + partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startListEditAction); QAction *act_mexport = partPopup->addAction(tr("save part to disk")); act_mexport->setData(16); } break; case Track::DRUM: { - partPopup->addAction(muse->arranger->parentWin->startDrumEditAction); - partPopup->addAction(muse->arranger->parentWin->startListEditAction); + partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startDrumEditAction); + partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startListEditAction); QAction *act_dexport = partPopup->addAction(tr("save part to disk")); act_dexport->setData(16); } @@ -691,7 +706,7 @@ QMenu* PartCanvas::genItemPopup(CItem* item) // itemPopup //--------------------------------------------------------- -void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) +void PartCanvas::itemPopup(MusEWidget::CItem* item, int n, const QPoint& pt) { PartList* pl = new PartList; NPart* npart = (NPart*)(item); @@ -755,7 +770,7 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) { const Part* part = item->part(); bool popenFlag = false; - QString fn = getSaveFileName(QString(""), part_file_save_pattern, this, tr("MusE: save part")); + QString fn = getSaveFileName(QString(""), MusEGlobal::part_file_save_pattern, this, tr("MusE: save part")); if (!fn.isEmpty()) { FILE* fp = fileOpen(this, fn, ".mpt", "w", popenFlag, false, false); if (fp) { @@ -813,7 +828,7 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) curColorIndex = n - 20; bool selfound = false; //Loop through all parts and set color on selected: - for (iCItem i = items.begin(); i != items.end(); i++) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); i++) { if (i->second->isSelected()) { selfound = true; i->second->part()->setColorIndex(curColorIndex); @@ -845,7 +860,10 @@ void PartCanvas::mousePress(QMouseEvent* event) return; } QPoint pt = event->pos(); - CItem* item = items.find(pt); + MusEWidget::CItem* item = items.find(pt); + + //if (item == 0 && _tool!=MusEWidget::AutomationTool) // FINDMICHJETZT. neccessary? (flo93) + // return; switch (_tool) { default: @@ -854,13 +872,13 @@ void PartCanvas::mousePress(QMouseEvent* event) else emit trackChanged(NULL); break; - case CutTool: + case MusEWidget::CutTool: if (item) splitItem(item, pt); break; - case GlueTool: + case MusEWidget::GlueTool: if (item) glueItem(item); break; - case MuteTool: + case MusEWidget::MuteTool: { if (item) { NPart* np = (NPart*) item; @@ -870,7 +888,7 @@ void PartCanvas::mousePress(QMouseEvent* event) break; } } - case AutomationTool: + case MusEWidget::AutomationTool: if (automation.controllerState != doNothing) automation.moveController=true; break; @@ -902,7 +920,7 @@ void PartCanvas::mouseMove(QMouseEvent* event) if (x < 0) x = 0; - if (_tool == AutomationTool) + if (_tool == MusEWidget::AutomationTool) processAutomationMovements(event->pos(), event->modifiers() & Qt::ShiftModifier); emit timeChanged(AL::sigmap.raster(x, *_raster)); @@ -933,7 +951,7 @@ void PartCanvas::keyPress(QKeyEvent* event) { int key = event->key(); -// if (_tool == AutomationTool) { // can't get the cursor pos to work right, skipping for now +// if (_tool == MusEWidget::AutomationTool) { // can't get the cursor pos to work right, skipping for now // // clear all the automation parameters // automation.moveController=false; // automation.controllerState = doNothing; @@ -1005,30 +1023,30 @@ void PartCanvas::keyPress(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_TOOL_POINTER].key) { - emit setUsedTool(PointerTool); + emit setUsedTool(MusEWidget::PointerTool); return; } else if (key == shortcuts[SHRT_TOOL_PENCIL].key) { - emit setUsedTool(PencilTool); + emit setUsedTool(MusEWidget::PencilTool); return; } else if (key == shortcuts[SHRT_TOOL_RUBBER].key) { - emit setUsedTool(RubberTool); + emit setUsedTool(MusEWidget::RubberTool); return; } else if (key == shortcuts[SHRT_TOOL_SCISSORS].key) { - emit setUsedTool(CutTool); + emit setUsedTool(MusEWidget::CutTool); return; } else if (key == shortcuts[SHRT_TOOL_LINEDRAW].key) { - emit setUsedTool(AutomationTool); + emit setUsedTool(MusEWidget::AutomationTool); return; } else if (key == shortcuts[SHRT_TOOL_GLUE].key) { - emit setUsedTool(GlueTool); + emit setUsedTool(MusEWidget::GlueTool); return; } else if (key == shortcuts[SHRT_TOOL_MUTE].key) { - emit setUsedTool(MuteTool); + emit setUsedTool(MusEWidget::MuteTool); return; } else if (key == shortcuts[SHRT_SEL_TRACK_ABOVE].key) { @@ -1047,7 +1065,7 @@ void PartCanvas::keyPress(QKeyEvent* event) event->ignore(); // give global accelerators a chance return; } - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { NPart* part = (NPart*)(i->second); if (part->isSelected()) { curItem=part; @@ -1058,13 +1076,13 @@ void PartCanvas::keyPress(QKeyEvent* event) curItem = (NPart*)items.begin()->second; // just grab the first part } - CItem* newItem = 0; + MusEWidget::CItem* newItem = 0; bool singleSelection = isSingleSelection(); bool add = false; //Locators to selection if (key == shortcuts[SHRT_LOCATORS_TO_SELECTION].key) { - CItem *leftmost = 0, *rightmost = 0; - for (iCItem i = items.begin(); i != items.end(); i++) { + MusEWidget::CItem *leftmost = 0, *rightmost = 0; + for (MusEWidget::iCItem i = items.begin(); i != items.end(); i++) { if (i->second->isSelected()) { // Check leftmost: if (!leftmost) @@ -1100,7 +1118,7 @@ void PartCanvas::keyPress(QKeyEvent* event) Track* track = part->track(); unsigned int tick = part->tick(); bool afterthis = false; - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { NPart* npart = (NPart*)(i->second); Part* ipart = npart->part(); if (ipart->track() != track) @@ -1128,7 +1146,7 @@ void PartCanvas::keyPress(QKeyEvent* event) Track* track = part->track(); unsigned int tick = part->tick(); - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { NPart* npart = (NPart*)(i->second); Part* ipart = npart->part(); @@ -1157,7 +1175,7 @@ void PartCanvas::keyPress(QKeyEvent* event) return; } int middle = curItem->x() + curItem->part()->lenTick()/2; - CItem *aboveL = 0, *aboveR = 0; + MusEWidget::CItem *aboveL = 0, *aboveR = 0; //Upper limit: song end, lower limit: song start int ulimit = song->len(); int llimit = 0; @@ -1178,7 +1196,7 @@ void PartCanvas::keyPress(QKeyEvent* event) } if ((aboveL || aboveR) != 0) { //We've hit something - CItem* above = 0; + MusEWidget::CItem* above = 0; above = (aboveL !=0) ? aboveL : aboveR; newItem = above; } @@ -1204,7 +1222,7 @@ void PartCanvas::keyPress(QKeyEvent* event) if (!track) return; - CItem *belowL = 0, *belowR = 0; + MusEWidget::CItem *belowL = 0, *belowR = 0; //Upper limit: song end , lower limit: song start int ulimit = song->len(); int llimit = 0; @@ -1224,7 +1242,7 @@ void PartCanvas::keyPress(QKeyEvent* event) } if ((belowL || belowR) != 0) { //We've hit something - CItem* below = 0; + MusEWidget::CItem* below = 0; below = (belowL !=0) ? belowL : belowR; newItem = below; } @@ -1308,7 +1326,7 @@ void PartCanvas::keyPress(QKeyEvent* event) //--------------------------------------------------------- #if 0 -void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) +void PartCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item, const QRect& rect) { int from = rect.x(); int to = from + rect.width(); @@ -1393,7 +1411,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (item->isMoving()) { QColor c(Qt::gray); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); gradient.setColorAt(0, c); gradient.setColorAt(1, c.darker()); @@ -1403,12 +1421,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (part->selected()) { QColor c(Qt::black); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); - // Use a colour only about 20% lighter than black, rather than the 50% we use in gGradientFromQColor + // Use a colour only about 20% lighter than black, rather than the 50% we use in MusEUtil::gGradientFromQColor // and is used in darker()/lighter(), so that it is distinguished a bit better from grey non-part tracks. //c.setRgba(64, 64, 64, c.alpha()); - gradient.setColorAt(0, QColor(51, 51, 51, config.globalAlphaBlend)); + gradient.setColorAt(0, QColor(51, 51, 51, MusEConfig::config.globalAlphaBlend)); gradient.setColorAt(1, c); brush = QBrush(gradient); } @@ -1416,7 +1434,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (part->mute()) { QColor c(Qt::white); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(r.topLeft(), r.bottomLeft()); gradient.setColorAt(0, c); gradient.setColorAt(1, c.darker()); @@ -1431,9 +1449,9 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) } else { - QColor c(config.partColors[cidx]); - c.setAlpha(config.globalAlphaBlend); - brush = QBrush(gGradientFromQColor(c, r.topLeft(), r.bottomLeft())); + QColor c(MusEConfig::config.partColors[cidx]); + c.setAlpha(MusEConfig::config.globalAlphaBlend); + brush = QBrush(MusEUtil::gGradientFromQColor(c, r.topLeft(), r.bottomLeft())); } double h = r.height(); @@ -1501,7 +1519,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // int part_r, part_g, part_b, brightness, color_brightness; - config.partColors[cidx].getRgb(&part_r, &part_g, &part_b); + MusEConfig::config.partColors[cidx].getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; //if ((brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving()) // color_brightness=223; // too dark: use lighter color @@ -1511,8 +1529,8 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) color_brightness=32; // too light: use dark color else color_brightness=223; // too dark: use lighter color - QColor c(color_brightness,color_brightness,color_brightness, config.globalAlphaBlend); - p.setBrush(QBrush(gGradientFromQColor(c, r.topLeft(), r.bottomLeft()))); + QColor c(color_brightness,color_brightness,color_brightness, MusEConfig::config.globalAlphaBlend); + p.setBrush(QBrush(MusEUtil::gGradientFromQColor(c, r.topLeft(), r.bottomLeft()))); //p.setBrush(QBrush(c)); if(het & Part::RightEventsHidden) { @@ -1563,7 +1581,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // Works great but requires clones be drawn with the highest priority on top of all other parts, in Canvas::draw. // - QPen pen(part->selected() ? config.partColors[i] : Qt::black, 2.0, clone ? Qt::DotLine : Qt::SolidLine); + QPen pen(part->selected() ? MusEConfig::config.partColors[i] : Qt::black, 2.0, clone ? Qt::DotLine : Qt::SolidLine); pen.setCosmetic(true); p.setPen(pen); p.setBrush(Qt::NoBrush); @@ -1584,7 +1602,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.setBrush(Qt::NoBrush); - QColor pc((part->mute() || item->isMoving())? Qt::white : config.partColors[cidx]); + QColor pc((part->mute() || item->isMoving())? Qt::white : MusEConfig::config.partColors[cidx]); QPen penSelect1H(pc); QPen penSelect2H(pc, 2.0); QPen penSelect1V(pc); @@ -1699,7 +1717,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) //p.restore(); - if (config.canvasShowPartType & 1) { // show names + if (MusEConfig::config.canvasShowPartType & 1) { // show names // draw name // FN: Set text color depending on part color (black / white) int part_r, part_g, part_b, brightness; @@ -1707,12 +1725,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // get the lowest colour in the gradient used to draw the part. QRect rr = map(r); rr.setX(rr.x() + 3); - gGradientFromQColor(config.partColors[cidx], rr.topLeft(), rr.bottomLeft()).stops().last().second.getRgb(&part_r, &part_g, &part_b); + MusEUtil::gGradientFromQColor(MusEConfig::config.partColors[cidx], rr.topLeft(), rr.bottomLeft()).stops().last().second.getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; //bool rev = (brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving(); bool rev = brightness >= 12000 && !part->selected(); p.save(); - p.setFont(config.fonts[1]); + p.setFont(MusEConfig::config.fonts[1]); p.setWorldMatrixEnabled(false); if (rev) p.setPen(Qt::white); @@ -1729,7 +1747,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) } #endif -void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) +void PartCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item, const QRect& rect) { int from = rect.x(); int to = from + rect.width(); @@ -1818,7 +1836,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (item->isMoving()) { QColor c(Qt::gray); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(rr.topLeft(), rr.bottomLeft()); gradient.setColorAt(0, c); gradient.setColorAt(1, c.darker()); @@ -1828,12 +1846,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (part->selected()) { QColor c(Qt::black); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(rr.topLeft(), rr.bottomLeft()); - // Use a colour only about 20% lighter than black, rather than the 50% we use in gGradientFromQColor + // Use a colour only about 20% lighter than black, rather than the 50% we use in MusEUtil::gGradientFromQColor // and is used in darker()/lighter(), so that it is distinguished a bit better from grey non-part tracks. //c.setRgba(64, 64, 64, c.alpha()); - gradient.setColorAt(0, QColor(51, 51, 51, config.globalAlphaBlend)); + gradient.setColorAt(0, QColor(51, 51, 51, MusEConfig::config.globalAlphaBlend)); gradient.setColorAt(1, c); brush = QBrush(gradient); } @@ -1841,7 +1859,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if (part->mute()) { QColor c(Qt::white); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(rr.topLeft(), rr.bottomLeft()); gradient.setColorAt(0, c); gradient.setColorAt(1, c.darker()); @@ -1849,9 +1867,9 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) } else { - QColor c(config.partColors[cidx]); - c.setAlpha(config.globalAlphaBlend); - brush = QBrush(gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft())); + QColor c(MusEConfig::config.partColors[cidx]); + c.setAlpha(MusEConfig::config.globalAlphaBlend); + brush = QBrush(MusEUtil::gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft())); } int h = rr.height(); @@ -1941,7 +1959,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // int part_r, part_g, part_b, brightness, color_brightness; - config.partColors[cidx].getRgb(&part_r, &part_g, &part_b); + MusEConfig::config.partColors[cidx].getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; //if ((brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving()) // color_brightness=223; // too dark: use lighter color @@ -1951,8 +1969,8 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) color_brightness=96; //0; // too light: use dark color else color_brightness=180; //255; // too dark: use lighter color - QColor c(color_brightness,color_brightness,color_brightness, config.globalAlphaBlend); - p.setBrush(QBrush(gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft()))); + QColor c(color_brightness,color_brightness,color_brightness, MusEConfig::config.globalAlphaBlend); + p.setBrush(QBrush(MusEUtil::gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft()))); //p.setBrush(QBrush(c)); if(het & Part::RightEventsHidden) { @@ -2028,7 +2046,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // Works great but requires clones be drawn with the highest priority on top of all other parts, in Canvas::draw. // - QPen pen(part->selected() ? config.partColors[i] : Qt::black, 2.0, clone ? Qt::DotLine : Qt::SolidLine); + QPen pen(part->selected() ? MusEConfig::config.partColors[i] : Qt::black, 2.0, clone ? Qt::DotLine : Qt::SolidLine); pen.setCosmetic(true); p.setPen(pen); p.setBrush(Qt::NoBrush); @@ -2041,7 +2059,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.setBrush(Qt::NoBrush); - QColor pc((part->mute() || item->isMoving())? Qt::white : config.partColors[cidx]); + QColor pc((part->mute() || item->isMoving())? Qt::white : MusEConfig::config.partColors[cidx]); QPen penSelect1H(pc); QPen penSelect2H(pc, 2.0); QPen penSelect1V(pc); @@ -2162,7 +2180,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) #endif - if (config.canvasShowPartType & 1) { // show names + if (MusEConfig::config.canvasShowPartType & 1) { // show names // draw name // FN: Set text color depending on part color (black / white) int part_r, part_g, part_b, brightness; @@ -2171,11 +2189,11 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) //QRect rr = map(r); QRect tr = rr; tr.setX(tr.x() + 3); - gGradientFromQColor(config.partColors[cidx], tr.topLeft(), tr.bottomLeft()).stops().last().second.getRgb(&part_r, &part_g, &part_b); + MusEUtil::gGradientFromQColor(MusEConfig::config.partColors[cidx], tr.topLeft(), tr.bottomLeft()).stops().last().second.getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; //bool rev = (brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving(); bool rev = brightness >= 12000 && !part->selected(); - p.setFont(config.fonts[1]); + p.setFont(MusEConfig::config.fonts[1]); if (rev) p.setPen(Qt::white); else @@ -2197,12 +2215,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // draws moving items //--------------------------------------------------------- -void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&) +void PartCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const QRect&) { p.setPen( Qt::black); Part* part = ((NPart*)item)->part(); - QColor c(part->mute() ? Qt::white : config.partColors[part->colorIndex()]); - //c.setAlpha(config.globalAlphaBlend); + QColor c(part->mute() ? Qt::white : MusEConfig::config.partColors[part->colorIndex()]); + //c.setAlpha(MusEConfig::config.globalAlphaBlend); c.setAlpha(128); // Fix this regardless of global setting. Should be OK. p.setBrush(c); p.drawRect(item->mp().x(), item->mp().y(), item->width(), item->height()); @@ -2222,7 +2240,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi if(pt) { int part_r, part_g, part_b, brightness; - config.partColors[pt->colorIndex()].getRgb(&part_r, &part_g, &part_b); + MusEConfig::config.partColors[pt->colorIndex()].getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; //if ((brightness < 12000 || pt->selected()) && !pt->mute()) // color_brightness=192; // too dark: use lighter color @@ -2236,7 +2254,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi else color_brightness=80; - if (config.canvasShowPartType & 2) { // show events + if (MusEConfig::config.canvasShowPartType & 2) { // show events p.setPen(QColor(color_brightness,color_brightness,color_brightness)); // Do not allow this, causes segfault. if(from <= to) @@ -2246,11 +2264,11 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi for (iEvent i = events->lower_bound(from); i != ito; ++i) { EventType type = i->second.type(); if ( - ((config.canvasShowPartEvent & 1) && (type == Note)) - || ((config.canvasShowPartEvent & 2) && (type == PAfter)) - || ((config.canvasShowPartEvent & 4) && (type == Controller)) - || ((config.canvasShowPartEvent &16) && (type == CAfter)) - || ((config.canvasShowPartEvent &64) && (type == Sysex || type == Meta)) + ((MusEConfig::config.canvasShowPartEvent & 1) && (type == Note)) + || ((MusEConfig::config.canvasShowPartEvent & 2) && (type == PAfter)) + || ((MusEConfig::config.canvasShowPartEvent & 4) && (type == Controller)) + || ((MusEConfig::config.canvasShowPartEvent &16) && (type == CAfter)) + || ((MusEConfig::config.canvasShowPartEvent &64) && (type == Sysex || type == Meta)) ) { int t = i->first + pTick; int th = mt->height(); @@ -2345,7 +2363,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi int highest_pitch=0; map<int,int> y_mapper; - if (config.canvasShowPartType & 4) //y-stretch? + if (MusEConfig::config.canvasShowPartType & 4) //y-stretch? { for (iEvent i = events->begin(); i != events->end(); ++i) { @@ -2383,7 +2401,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi highest_pitch++; } - if (heavyDebugMsg) + if (MusEGlobal::heavyDebugMsg) { if (!isdrum) printf("DEBUG: arranger: cakewalk enabled, y-stretching from %i to %i. eventlist=%p\n",lowest_pitch, highest_pitch, events); @@ -2405,7 +2423,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi for (int cnt=0;cnt<127;cnt++) y_mapper[cnt]=cnt; - if (heavyDebugMsg) printf("DEBUG: arranger: cakewalk enabled, y-stretch disabled\n"); + if (MusEGlobal::heavyDebugMsg) printf("DEBUG: arranger: cakewalk enabled, y-stretch disabled\n"); } p.setPen(QColor(color_brightness,color_brightness,color_brightness)); @@ -2564,7 +2582,7 @@ void PartCanvas::drawWavePart(QPainter& p, void PartCanvas::cmd(int cmd) { PartList pl; - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { if (!i->second->isSelected()) continue; NPart* npart = (NPart*)(i->second); @@ -2577,7 +2595,7 @@ void PartCanvas::cmd(int cmd) Undo operations; - for (iCItem i = items.begin(); i != items.end(); ++i) { + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { if (i->second->isSelected()) { NPart* p = (NPart*)(i->second); Part* part = p->part(); @@ -2648,7 +2666,7 @@ void PartCanvas::copy_in_range(PartList* pl_) if (pl_->empty()) { - for (iCItem i = items.begin(); i != items.end(); ++i) + for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { Part* part=static_cast<NPart*>(i->second)->part(); if ( (part->track()->isMidiTrack()) || (part->track()->type() == Track::WAVE) ) @@ -3072,7 +3090,7 @@ void PartCanvas::paste(bool clone, paste_mode_t paste_mode, bool to_single_track // startDrag //--------------------------------------------------------- -void PartCanvas::startDrag(CItem* item, DragType t) +void PartCanvas::startDrag(MusEWidget::CItem* item, DragType t) { NPart* p = (NPart*)(item); Part* part = p->part(); @@ -3147,7 +3165,7 @@ void PartCanvas::dragEnterEvent(QDragEnterEvent* event) void PartCanvas::viewDropEvent(QDropEvent* event) { - if (debugMsg) + if (MusEGlobal::debugMsg) printf("void PartCanvas::viewDropEvent(QDropEvent* event)\n"); if (event->source() == this) { printf("local DROP\n"); @@ -3164,7 +3182,7 @@ void PartCanvas::viewDropEvent(QDropEvent* event) type = 2; else { - if(debugMsg && event->mimeData()->formats().size() != 0) + if(MusEGlobal::debugMsg && event->mimeData()->formats().size() != 0) printf("Drop with unknown format. First format:<%s>\n", event->mimeData()->formats()[0].toLatin1().constData()); //event->ignore(); // TODO CHECK Tim. return; @@ -3228,13 +3246,13 @@ void PartCanvas::viewDropEvent(QDropEvent* event) (text.endsWith(".ogg", Qt::CaseInsensitive)))) { unsigned tick = x; - muse->importWaveToTrack(text, tick, track); + MusEGlobal::muse->importWaveToTrack(text, tick, track); } // Changed by T356. Support mixed .mpt files. else if ((track->isMidiTrack() || track->type() == Track::WAVE) && text.endsWith(".mpt", Qt::CaseInsensitive)) { unsigned tick = x; - muse->importPartToTrack(text, tick, track); + MusEGlobal::muse->importPartToTrack(text, tick, track); } } else if(text.endsWith(".med",Qt::CaseInsensitive)) @@ -3287,13 +3305,13 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) ////////// // GRID // ////////// - QColor baseColor(config.partCanvasBg.light(104)); + QColor baseColor(MusEConfig::config.partCanvasBg.light(104)); p.setPen(baseColor); //-------------------------------- // vertical lines //------------------------------- - if (config.canvasShowGrid) { + if (MusEConfig::config.canvasShowGrid) { int bar, beat; unsigned tick; @@ -3314,17 +3332,17 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) // append int noDivisors=0; - if (*_raster == config.division *2) // 1/2 + if (*_raster == MusEConfig::config.division *2) // 1/2 noDivisors=2; - else if (*_raster== config.division) // 1/4 + else if (*_raster== MusEConfig::config.division) // 1/4 noDivisors=4; - else if (*_raster==config.division/2) // 1/8 + else if (*_raster==MusEConfig::config.division/2) // 1/8 noDivisors=8; - else if (*_raster==config.division/4) // 1/16 + else if (*_raster==MusEConfig::config.division/4) // 1/16 noDivisors=16; - else if (*_raster==config.division/8) // 1/16 + else if (*_raster==MusEConfig::config.division/8) // 1/16 noDivisors=32; - else if (*_raster==config.division/16) // 1/16 + else if (*_raster==MusEConfig::config.division/16) // 1/16 noDivisors=64; int r = *_raster; @@ -3363,7 +3381,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) th = track->height(); if (!th) continue; - if (config.canvasShowGrid && (track->isMidiTrack() || track->type() == Track::WAVE)) // Tim. + if (MusEConfig::config.canvasShowGrid && (track->isMidiTrack() || track->type() == Track::WAVE)) // Tim. { p.setPen(baseColor.dark(130)); //p.drawLine(x, yy + th, x + w, yy + th); @@ -3430,7 +3448,7 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) int mw = mr.width(); int mh = mr.height(); - QColor baseColor(config.partCanvasBg.light(104)); + QColor baseColor(MusEConfig::config.partCanvasBg.light(104)); //p.setPen(baseColor); p.save(); @@ -3495,8 +3513,8 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) if (track->recordFlag()) { QPen pen(Qt::black, 0, Qt::SolidLine); p.setPen(pen); - QColor c(config.partColors[0]); - c.setAlpha(config.globalAlphaBlend); + QColor c(MusEConfig::config.partColors[0]); + c.setAlpha(MusEConfig::config.globalAlphaBlend); QLinearGradient gradient(QPoint(startx,yPos), QPoint(startx,yPos+th)); gradient.setColorAt(0, c); gradient.setColorAt(1, c.darker()); @@ -3574,7 +3592,7 @@ void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox, p.setPen(Qt::black); QColor c(Qt::gray); - c.setAlpha(config.globalAlphaBlend); + c.setAlpha(MusEConfig::config.globalAlphaBlend); //QLinearGradient gradient(r.topLeft(), r.bottomLeft()); QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 1); // Inside the border gradient.setColorAt(0, c); @@ -3878,7 +3896,7 @@ void PartCanvas::controllerChanged(Track* t) void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) { - if (_tool == AutomationTool) { + if (_tool == MusEWidget::AutomationTool) { if (!automation.moveController) { // currently nothing going lets's check for some action. Track * t = y2Track(pos.y()); |