summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/dcanvas.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-09-10 17:06:00 +0000
committerFlorian Jung <flo@windfisch.org>2011-09-10 17:06:00 +0000
commit24f84a489364741eb3fc126a3f83d91a86b65e27 (patch)
tree63a4e20aaf4a2ebd2462c91b574eddceeac31170 /muse2/muse/midiedit/dcanvas.cpp
parent38c5cccc7273247353264bb7dc97f42296d8e259 (diff)
parent2120ea4f083228dde0d7307203391a4ec8f57e2d (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/midiedit/dcanvas.cpp')
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp99
1 files changed, 57 insertions, 42 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 6abaaa51..783a72f5 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -3,6 +3,21 @@
// Linux Music Editor
// $Id: dcanvas.cpp,v 1.16.2.10 2009/10/15 22:45:50 terminator356 Exp $
// (C) Copyright 1999 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 <QPainter>
@@ -100,7 +115,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
// moveCanvasItems
//---------------------------------------------------------
-Undo DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype)
+Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, DragType dtype)
{
if(editor->parts()->empty())
return Undo(); //return empty list
@@ -115,9 +130,9 @@ Undo DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp
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;
@@ -168,12 +183,12 @@ Undo DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp
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();
@@ -223,7 +238,7 @@ Undo DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp
// moveItem
//---------------------------------------------------------
-UndoOp DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
+UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype)
{
DEvent* nevent = (DEvent*) item;
@@ -257,7 +272,7 @@ UndoOp DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
// newItem
//---------------------------------------------------------
-CItem* DrumCanvas::newItem(const QPoint& p, int state)
+MusEWidget::CItem* DrumCanvas::newItem(const QPoint& p, int state)
{
int instr = y2pitch(p.y()); //drumInmap[y2pitch(p.y())];
int velo = drumMap[instr].lv4;
@@ -275,7 +290,7 @@ CItem* DrumCanvas::newItem(const QPoint& p, int state)
// newItem
//---------------------------------------------------------
-CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
+MusEWidget::CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
{
tick -= curPart->tick();
Event e(Note);
@@ -290,7 +305,7 @@ CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
// resizeItem
//---------------------------------------------------------
-void DrumCanvas::resizeItem(CItem* item, bool, bool)
+void DrumCanvas::resizeItem(MusEWidget::CItem* item, bool, bool)
{
DEvent* nevent = (DEvent*) item;
Event ev = nevent->event();
@@ -301,11 +316,11 @@ void DrumCanvas::resizeItem(CItem* item, bool, bool)
//---------------------------------------------------------
// newItem
//---------------------------------------------------------
-void DrumCanvas::newItem(CItem* item, bool noSnap) {
+void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap) {
newItem(item, noSnap,false);
}
-void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace)
+void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace)
{
DEvent* nevent = (DEvent*) item;
Event event = nevent->event();
@@ -366,7 +381,7 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace)
// deleteItem
//---------------------------------------------------------
-bool DrumCanvas::deleteItem(CItem* item)
+bool DrumCanvas::deleteItem(MusEWidget::CItem* item)
{
Event ev = ((DEvent*)item)->event();
// Indicate do undo, and do not do port controller values and clone parts.
@@ -378,7 +393,7 @@ bool DrumCanvas::deleteItem(CItem* item)
// drawItem
//---------------------------------------------------------
-void DrumCanvas::drawItem(QPainter&p, const CItem*item, const QRect& rect)
+void DrumCanvas::drawItem(QPainter&p, const MusEWidget::CItem*item, const QRect& rect)
{
DEvent* e = (DEvent*) item;
int x = 0, y = 0;
@@ -436,7 +451,7 @@ void DrumCanvas::drawItem(QPainter&p, const CItem*item, const QRect& rect)
// draws moving items
//---------------------------------------------------------
-void DrumCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect)
+void DrumCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const QRect& rect)
{
QPolygon pa(4);
QPoint pt = map(item->mp());
@@ -489,7 +504,7 @@ void DrumCanvas::drawCanvas(QPainter& p, const QRect& rect)
void DrumCanvas::drawTopItem(QPainter& p, const QRect&)
{
// draw cursor
- if (_tool == CursorTool) {
+ if (_tool == MusEWidget::CursorTool) {
p.setPen(Qt::black);
int y = mapy(TH * cursorPos.y());
@@ -528,7 +543,7 @@ void DrumCanvas::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);
}
@@ -537,12 +552,12 @@ void DrumCanvas::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) {
DEvent* nevent =(DEvent*)(k->second);
Part* part = nevent->part();
Event event = nevent->event();
@@ -554,7 +569,7 @@ void DrumCanvas::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) {
DEvent* nevent = (DEvent*)(k->second);
Part* part = nevent->part();
Event event = nevent->event();
@@ -611,7 +626,7 @@ void DrumCanvas::cmd(int cmd)
if (!selectionSize())
break;
song->startUndo();
- for (iCItem k = items.begin(); k != items.end(); ++k) {
+ for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) {
if (k->second->isSelected()) {
DEvent* devent = (DEvent*)(k->second);
Event event = devent->event();
@@ -670,7 +685,7 @@ void DrumCanvas::cmd(int cmd)
// startDrag
//---------------------------------------------------------
-void DrumCanvas::startDrag(CItem* /* item*/, bool copymode)
+void DrumCanvas::startDrag(MusEWidget::CItem* /* item*/, bool copymode)
{
QMimeData* md = selected_events_to_mime(partlist_to_set(editor->parts()), 1);
@@ -730,7 +745,7 @@ void DrumCanvas::keyPressed(int index, int velocity)
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,index,drumMap[index].len,editor->raster(),velocity,globalKeyState&Qt::ControlModifier,globalKeyState&Qt::ShiftModifier);
+ steprec->record(curPart,index,drumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier);
}
@@ -851,11 +866,11 @@ void DrumCanvas::resizeEvent(QResizeEvent* ev)
// modifySelected
//---------------------------------------------------------
-void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
+void DrumCanvas::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;
DEvent* e = (DEvent*)(i->second);
@@ -867,7 +882,7 @@ void DrumCanvas::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)
@@ -875,16 +890,16 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
newEvent.setTick(newTime);
}
break;
- case NoteInfo::VAL_LEN:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_LEN not implemented\n");
+ case MusEWidget::NoteInfo::VAL_LEN:
+ printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_LEN not implemented\n");
break;
- case NoteInfo::VAL_VELON:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELON not implemented\n");
+ case MusEWidget::NoteInfo::VAL_VELON:
+ printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_VELON not implemented\n");
break;
- case NoteInfo::VAL_VELOFF:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELOFF not implemented\n");
+ case MusEWidget::NoteInfo::VAL_VELOFF:
+ printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_VELOFF not implemented\n");
break;
- case NoteInfo::VAL_PITCH:
+ case MusEWidget::NoteInfo::VAL_PITCH:
{
int pitch = event.pitch() - delta; // Reversing order since the drumlist is displayed in increasing order
if (pitch > 127)
@@ -940,7 +955,7 @@ int DrumCanvas::getNextStep(unsigned int pos, int basicStep, int stepSize)
//---------------------------------------------------------
void DrumCanvas::keyPress(QKeyEvent* event)
{
- if (_tool == CursorTool) {
+ if (_tool == MusEWidget::CursorTool) {
int key = event->key();
if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier)
@@ -1019,7 +1034,7 @@ void DrumCanvas::keyPress(QKeyEvent* event)
//---------------------------------------------------------
void DrumCanvas::setTool2(int)
{
- if (_tool == CursorTool)
+ if (_tool == MusEWidget::CursorTool)
deselectAll();
if (unsigned(cursorPos.x()) < curPart->tick())
cursorPos.setX(curPart->tick());
@@ -1047,7 +1062,7 @@ void DrumCanvas::setStep(int v)
//---------------------------------------------------------
Event *DrumCanvas::getEventAtCursorPos()
{
- if (_tool != CursorTool)
+ if (_tool != MusEWidget::CursorTool)
return 0;
EventList* el = curPart->events();
iEvent lower = el->lower_bound(cursorPos.x()-curPart->tick());
@@ -1067,7 +1082,7 @@ Event *DrumCanvas::getEventAtCursorPos()
//---------------------------------------------------------
void DrumCanvas::selectCursorEvent(Event *ev)
{
- for (iCItem i = items.begin(); i != items.end(); ++i)
+ for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i)
{
Event e = i->second->event();
@@ -1086,7 +1101,7 @@ void DrumCanvas::moveAwayUnused()
using std::set;
set<int> used;
- for (iCItem it=items.begin(); it!=items.end(); it++)
+ for (MusEWidget::iCItem it=items.begin(); it!=items.end(); it++)
{
const Event& ev=it->second->event();
@@ -1114,12 +1129,12 @@ void DrumCanvas::moveAwayUnused()
//---------------------------------------------------------
void DrumCanvas::midiNote(int pitch, int velo)
{
- if (debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo);
+ if (MusEGlobal::debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, 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,drumInmap[pitch],drumMap[(int)drumInmap[pitch]].len,editor->raster(),velo,globalKeyState&Qt::ControlModifier,globalKeyState&Qt::ShiftModifier);
+ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) {
+ steprec->record(curPart,drumInmap[pitch],drumMap[(int)drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier);
}
}