summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/prcanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/muse/midiedit/prcanvas.cpp')
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp89
1 files changed, 52 insertions, 37 deletions
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index 43edc7f5..b96cb47f 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -3,6 +3,21 @@
// Linux Music Editor
// $Id: prcanvas.cpp,v 1.20.2.19 2009/11/16 11:29:33 lunar_shuttle Exp $
// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//
+// 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 <QApplication>
@@ -45,7 +60,7 @@
// NEvent
//---------------------------------------------------------
-NEvent::NEvent(Event& e, Part* p, int y) : CItem(e, p)
+NEvent::NEvent(Event& e, Part* p, int y) : MusEWidget::CItem(e, p)
{
y = y - KH/4;
unsigned tick = e.tick() + p->tick();
@@ -141,7 +156,7 @@ int PianoCanvas::y2pitch(int y) const
// draws a note
//---------------------------------------------------------
-void PianoCanvas::drawItem(QPainter& p, const CItem* item,
+void PianoCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item,
const QRect& rect)
{
QRect r = item->bbox();
@@ -246,7 +261,7 @@ void PianoCanvas::drawItem(QPainter& p, const CItem* item,
//int mfh = mh;
//if(mfh == meh) mfh -= 1;
//if(mfy == mey) mfh -= 1;
- color.setAlpha(config.globalAlphaBlend);
+ color.setAlpha(MusEConfig::config.globalAlphaBlend);
//QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 2); // Inside the border
//gradient.setColorAt(0, color);
//gradient.setColorAt(1, color.darker());
@@ -280,7 +295,7 @@ void PianoCanvas::drawTopItem(QPainter& , const QRect&)
// draws moving items
//---------------------------------------------------------
-void PianoCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect)
+void PianoCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const QRect& rect)
{
//if(((NEvent*)item)->part() != curPart)
// return;
@@ -301,7 +316,7 @@ void PianoCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect)
void PianoCanvas::viewMouseDoubleClickEvent(QMouseEvent* event)
{
- if ((_tool != PointerTool) && (event->button() != Qt::LeftButton)) {
+ if ((_tool != MusEWidget::PointerTool) && (event->button() != Qt::LeftButton)) {
mousePress(event);
return;
}
@@ -311,7 +326,7 @@ void PianoCanvas::viewMouseDoubleClickEvent(QMouseEvent* event)
// moveCanvasItems
//---------------------------------------------------------
-Undo PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype)
+Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, DragType dtype)
{
if(editor->parts()->empty())
return Undo(); //return empty list
@@ -326,9 +341,9 @@ Undo PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dty
continue;
int npartoffset = 0;
- 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(ci->part() != part)
continue;
@@ -379,12 +394,12 @@ Undo PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dty
if (!forbidden)
{
- std::vector< CItem* > doneList;
- typedef std::vector< CItem* >::iterator iDoneList;
+ std::vector< MusEWidget::CItem* > doneList;
+ typedef std::vector< MusEWidget::CItem* >::iterator iDoneList;
- 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;
int x = ci->pos().x();
int y = ci->pos().y();
@@ -435,7 +450,7 @@ Undo PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dty
// called after moving an object
//---------------------------------------------------------
-UndoOp PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
+UndoOp PianoCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype)
{
NEvent* nevent = (NEvent*) item;
Event event = nevent->event();
@@ -480,7 +495,7 @@ UndoOp PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
// newItem(p, state)
//---------------------------------------------------------
-CItem* PianoCanvas::newItem(const QPoint& p, int)
+MusEWidget::CItem* PianoCanvas::newItem(const QPoint& p, int)
{
//printf("newItem point\n");
int pitch = y2pitch(p.y());
@@ -497,7 +512,7 @@ CItem* PianoCanvas::newItem(const QPoint& p, int)
return new NEvent(e, curPart, pitch2y(pitch));
}
-void PianoCanvas::newItem(CItem* item, bool noSnap)
+void PianoCanvas::newItem(MusEWidget::CItem* item, bool noSnap)
{
//printf("newItem citem\n");
NEvent* nevent = (NEvent*) item;
@@ -543,7 +558,7 @@ void PianoCanvas::newItem(CItem* item, bool noSnap)
// resizeItem
//---------------------------------------------------------
-void PianoCanvas::resizeItem(CItem* item, bool noSnap, bool) // experimental changes to try dynamically extending parts
+void PianoCanvas::resizeItem(MusEWidget::CItem* item, bool noSnap, bool) // experimental changes to try dynamically extending parts
{
//printf("resizeItem!\n");
NEvent* nevent = (NEvent*) item;
@@ -587,7 +602,7 @@ void PianoCanvas::resizeItem(CItem* item, bool noSnap, bool) // experime
// deleteItem
//---------------------------------------------------------
-bool PianoCanvas::deleteItem(CItem* item)
+bool PianoCanvas::deleteItem(MusEWidget::CItem* item)
{
NEvent* nevent = (NEvent*) item;
if (nevent->part() == curPart) {
@@ -714,7 +729,7 @@ void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift)
audio->msgPlayMidiEvent(&e);
if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart)
- steprec->record(curPart,pitch,editor->raster(),editor->raster(),velocity,globalKeyState&Qt::ControlModifier,shift);
+ steprec->record(curPart,pitch,editor->raster(),editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,shift);
}
//---------------------------------------------------------
@@ -811,7 +826,7 @@ void PianoCanvas::cmd(int cmd)
{
switch (cmd) {
case CMD_SELECT_ALL: // select all
- for (iCItem k = items.begin(); k != items.end(); ++k) {
+ for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) {
if (!k->second->isSelected())
selectItem(k->second, true);
}
@@ -820,12 +835,12 @@ void PianoCanvas::cmd(int cmd)
deselectAll();
break;
case CMD_SELECT_INVERT: // invert selection
- for (iCItem k = items.begin(); k != items.end(); ++k) {
+ for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) {
selectItem(k->second, !k->second->isSelected());
}
break;
case CMD_SELECT_ILOOP: // select inside loop
- for (iCItem k = items.begin(); k != items.end(); ++k) {
+ for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) {
NEvent* nevent = (NEvent*)(k->second);
Part* part = nevent->part();
Event event = nevent->event();
@@ -837,7 +852,7 @@ void PianoCanvas::cmd(int cmd)
}
break;
case CMD_SELECT_OLOOP: // select outside loop
- for (iCItem k = items.begin(); k != items.end(); ++k) {
+ for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) {
NEvent* nevent = (NEvent*)(k->second);
Part* part = nevent->part();
Event event = nevent->event();
@@ -910,14 +925,14 @@ void PianoCanvas::cmd(int cmd)
//---------------------------------------------------------
void PianoCanvas::midiNote(int pitch, int velo)
{
- if (debugMsg) printf("PianoCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo);
+ if (MusEGlobal::debugMsg) printf("PianoCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo);
if (velo)
noteHeldDown[pitch]=true;
else
noteHeldDown[pitch]=false;
- if (heavyDebugMsg)
+ if (MusEGlobal::heavyDebugMsg)
{
printf(" held down notes are: ");
for (int i=0;i<128;i++)
@@ -929,8 +944,8 @@ void PianoCanvas::midiNote(int pitch, int velo)
if (_midiin && _steprec && curPart
&& !audio->isPlaying() && velo && pos[0] >= start_tick
/* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */
- && !(globalKeyState & Qt::AltModifier)) {
- steprec->record(curPart,pitch,editor->raster(),editor->raster(),velo,globalKeyState&Qt::ControlModifier,globalKeyState&Qt::ShiftModifier);
+ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) {
+ steprec->record(curPart,pitch,editor->raster(),editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier);
}
}
@@ -939,7 +954,7 @@ void PianoCanvas::midiNote(int pitch, int velo)
// startDrag
//---------------------------------------------------------
-void PianoCanvas::startDrag(CItem* /* item*/, bool copymode)
+void PianoCanvas::startDrag(MusEWidget::CItem* /* item*/, bool copymode)
{
QMimeData* md = selected_events_to_mime(partlist_to_set(editor->parts()), 1);
@@ -991,7 +1006,7 @@ void PianoCanvas::dragLeaveEvent(QDragLeaveEvent*)
// itemPressed
//---------------------------------------------------------
-void PianoCanvas::itemPressed(const CItem* item)
+void PianoCanvas::itemPressed(const MusEWidget::CItem* item)
{
if (!_playEvents)
return;
@@ -1012,7 +1027,7 @@ void PianoCanvas::itemPressed(const CItem* item)
// itemReleased
//---------------------------------------------------------
-void PianoCanvas::itemReleased(const CItem*, const QPoint&)
+void PianoCanvas::itemReleased(const MusEWidget::CItem*, const QPoint&)
{
if (!_playEvents)
return;
@@ -1029,7 +1044,7 @@ void PianoCanvas::itemReleased(const CItem*, const QPoint&)
// itemMoved
//---------------------------------------------------------
-void PianoCanvas::itemMoved(const CItem* item, const QPoint& pos)
+void PianoCanvas::itemMoved(const MusEWidget::CItem* item, const QPoint& pos)
{
int npitch = y2pitch(pos.y());
if ((playedPitch != -1) && (playedPitch != npitch)) {
@@ -1061,11 +1076,11 @@ void PianoCanvas::curPartChanged()
// modifySelected
//---------------------------------------------------------
-void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
+void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta)
{
audio->msgIdle(true);
song->startUndo();
- for (iCItem i = items.begin(); i != items.end(); ++i) {
+ for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) {
if (!(i->second->isSelected()))
continue;
NEvent* e = (NEvent*)(i->second);
@@ -1077,7 +1092,7 @@ void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
Event newEvent = event.clone();
switch (type) {
- case NoteInfo::VAL_TIME:
+ case MusEWidget::NoteInfo::VAL_TIME:
{
int newTime = event.tick() + delta;
if (newTime < 0)
@@ -1085,7 +1100,7 @@ void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
newEvent.setTick(newTime);
}
break;
- case NoteInfo::VAL_LEN:
+ case MusEWidget::NoteInfo::VAL_LEN:
{
int len = event.lenTick() + delta;
if (len < 1)
@@ -1093,7 +1108,7 @@ void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
newEvent.setLenTick(len);
}
break;
- case NoteInfo::VAL_VELON:
+ case MusEWidget::NoteInfo::VAL_VELON:
{
int velo = event.velo() + delta;
if (velo > 127)
@@ -1103,7 +1118,7 @@ void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
newEvent.setVelo(velo);
}
break;
- case NoteInfo::VAL_VELOFF:
+ case MusEWidget::NoteInfo::VAL_VELOFF:
{
int velo = event.veloOff() + delta;
if (velo > 127)
@@ -1113,7 +1128,7 @@ void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
newEvent.setVeloOff(velo);
}
break;
- case NoteInfo::VAL_PITCH:
+ case MusEWidget::NoteInfo::VAL_PITCH:
{
int pitch = event.pitch() + delta;
if (pitch > 127)