From da3f75d306f528caccefd738c7912dc09d4320d6 Mon Sep 17 00:00:00 2001 From: Robert Jonsson Date: Mon, 17 Sep 2007 21:55:45 +0000 Subject: ~just waking up~ --- muse/ChangeLog | 5 +++ muse/README | 6 ++- muse/awl/tcanvas.cpp | 12 +++++- muse/awl/tcanvas.h | 45 ++++++++++++---------- muse/muse/arranger/arranger.cpp | 62 ++++++++++++++++--------------- muse/muse/arranger/canvas.cpp | 82 +++++++++++++++++++++++++++-------------- muse/muse/arranger/canvas.h | 6 +++ muse/muse/midiedit/ecanvas.cpp | 2 +- muse/muse/midiedit/prcanvas.cpp | 4 ++ muse/muse/muse.cpp | 26 +++++++------ muse/muse/shortcuts.cpp | 2 +- 11 files changed, 158 insertions(+), 94 deletions(-) diff --git a/muse/ChangeLog b/muse/ChangeLog index 5cb159ed..e2746c9d 100644 --- a/muse/ChangeLog +++ b/muse/ChangeLog @@ -1,3 +1,8 @@ +17.9. (rj) + - changed to start/stop toggle without rewinding since this seems + like the popular choice (actually I have to agree) + - some keyboard navigation beginnings...nothing working yet + - added some debug messages 17.6. (ws) - organ synthesizer plugin update 9.6. (ws) diff --git a/muse/README b/muse/README index f41149d4..06adeb2f 100644 --- a/muse/README +++ b/muse/README @@ -37,7 +37,7 @@ details. - libsamplerate - - JACK + - JACK >= 0.103 http://jackit.sourceforge.net/download/ Optional: @@ -46,6 +46,10 @@ details. http://savannah.nongnu.org/download/fluid - DSSI + + - ConTeXt (for building documentation, by default the build + script tries to build documentation, can be + disabled by setting ENABLE_DOCUMENTATION to OFF) ============================= Compiling: diff --git a/muse/awl/tcanvas.cpp b/muse/awl/tcanvas.cpp index e08c349a..d0da4c7f 100644 --- a/muse/awl/tcanvas.cpp +++ b/muse/awl/tcanvas.cpp @@ -83,7 +83,7 @@ TimeCanvas::TimeCanvas(TimeCanvasType t) setLayout(grid); _widget = new QWidget; - _widget->setAttribute(Qt::WA_NoSystemBackground); + _widget->setAttribute(Qt::WA_NoSystemBackground); _widget->setAttribute(Qt::WA_StaticContents); _widget->installEventFilter(this); _widget->setMouseTracking(true); @@ -411,7 +411,6 @@ bool TimeCanvas::eventFilter(QObject* obj, QEvent* event) } } return true; - default: // printf("event %d missed\n", event->type()); break; @@ -419,6 +418,15 @@ bool TimeCanvas::eventFilter(QObject* obj, QEvent* event) return false; } + + +void TimeCanvas::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down || + e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) + keyboardNavigate(e); +} + //--------------------------------------------------------- // moveX //--------------------------------------------------------- diff --git a/muse/awl/tcanvas.h b/muse/awl/tcanvas.h index a00e387b..50e6085e 100644 --- a/muse/awl/tcanvas.h +++ b/muse/awl/tcanvas.h @@ -140,28 +140,33 @@ class TimeCanvas : public QFrame { bool eventFilter(QObject*, QEvent*); - virtual void paint(QPainter&, QRect) {} - virtual void mousePress(QMouseEvent*) {} - virtual void mouseMove(QPoint) {} - virtual void mouseRelease(QMouseEvent*) {} - virtual void mouseDoubleClick(QMouseEvent*) {} + virtual void paint(QPainter&, QRect) { printf("paint method not overloaded\n"); } + virtual void mousePress(QMouseEvent*) { printf("mousePress method not overloaded\n"); } + virtual void mouseMove(QPoint) { printf("mouseMove method not overloaded\n"); } + virtual void mouseRelease(QMouseEvent*) { printf("mouseRelease method not overloaded\n"); } + virtual void mouseDoubleClick(QMouseEvent*) { printf("mouseDoubleClick method not overloaded\n"); } virtual void paintDrumList(QPainter&, QRect) {} - virtual void layout() {} - virtual void enterB() {} - virtual void leaveB() {} + virtual void layout() { printf("layout method not overloaded\n"); } + virtual void enterB() { printf("enterB method not overloaded\n"); } + virtual void leaveB() { printf("leaveB method not overloaded\n"); } + virtual void setCursor(); - virtual void timeTypeChanged() {} - virtual void magChanged() {} - - virtual void paintControllerCanvas(QPainter&, QRect) {} - virtual void paintControllerPanel(QPainter&, QRect) {} - - virtual void dragEnter(QDragEnterEvent*) {} - virtual void drop(QDropEvent*) {} - virtual void dragMove(QDragMoveEvent*) {} - virtual void dragLeave(QDragLeaveEvent*) {} - - virtual void addController() {} + + virtual void timeTypeChanged() { printf("timeTypeChanged method not overloaded\n");} + virtual void magChanged() { printf("magChanged method not overloaded\n");} + + virtual void paintControllerCanvas(QPainter&, QRect) { printf("paintControllerCanvas method not overloaded\n"); } + virtual void paintControllerPanel(QPainter&, QRect) { printf("paintControllerPanel method not overloaded\n"); } + + virtual void dragEnter(QDragEnterEvent*) { printf("dragEnter method not overloaded\n"); } + virtual void drop(QDropEvent*) { printf("drop method not overloaded\n"); } + virtual void dragMove(QDragMoveEvent*) { printf("dragMove method not overloaded\n"); } + virtual void dragLeave(QDragLeaveEvent*) { printf("dragLeave method not overloaded\n"); } + + virtual void addController() { printf("addController method not overloaded\n"); } + + virtual void keyPressEvent(QKeyEvent *e); + virtual void keyboardNavigate(QKeyEvent *) { printf("keyboardNavigate method not overloaded\n"); } // map logical coordinates to physical coordinates (pixel) int mapx(int x) const; diff --git a/muse/muse/arranger/arranger.cpp b/muse/muse/arranger/arranger.cpp index d0ad466e..359f6580 100644 --- a/muse/muse/arranger/arranger.cpp +++ b/muse/muse/arranger/arranger.cpp @@ -258,7 +258,7 @@ QMenu* newAddTrackMenu(QWidget* parent) Arranger::Arranger(QMainWindow* parent) : QWidget(parent) { - setFocusPolicy(Qt::StrongFocus); +// setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); for (int i = 0; i < Track::TRACK_TYPES; ++i) @@ -622,8 +622,8 @@ void Arranger::startDrag(int trackIdx) TrackListWidget::TrackListWidget(QWidget* parent) : QWidget(parent) - { - setAttribute(Qt::WA_NoSystemBackground); + { + setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_StaticContents); } @@ -632,9 +632,9 @@ TrackListWidget::TrackListWidget(QWidget* parent) //--------------------------------------------------------- void TrackListWidget::paintEvent(QPaintEvent* ev) - { - QPainter p(this); - p.eraseRect(ev->rect()); + { + QPainter p(this); + p.eraseRect(ev->rect()); } //--------------------------------------------------------- @@ -665,11 +665,11 @@ void TrackListWidget::wheelEvent(QWheelEvent* e) void Arranger::mouseWheel(QWheelEvent* e) { - if (e->orientation() != Qt::Vertical) - return; + if (e->orientation() != Qt::Vertical) + return; QScrollBar* sb = canvas->verticalScrollBar(); - int step = qMin(QApplication::wheelScrollLines() * sb->singleStep(), sb->pageStep()); - if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) + int step = qMin(QApplication::wheelScrollLines() * sb->singleStep(), sb->pageStep()); + if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) step = sb->pageStep(); int offset = e->delta() * step / 120; if (sb->invertedControls()) @@ -1226,6 +1226,7 @@ void Arranger::moveTrack(Track* src, Track* dst) void Arranger::keyPressEvent(QKeyEvent* e) { + printf("Arranger::keyPressEvent\n"); #if 0 //TODOB int key = e->key(); bool keypress_handled = false; @@ -1315,7 +1316,7 @@ void Arranger::keyPressEvent(QKeyEvent* e) e->ignore(); } #endif - e->ignore(); +// e->ignore(); } @@ -1327,25 +1328,26 @@ void Arranger::keyPressEvent(QKeyEvent* e) */ void Arranger::kbdMovementUpdate(Track* t, Part* p) { - if (t && p ) { - // If other track selected: - if (t != shortcutsKbdMovement.track()) { - TrackList* stl = song->tracks(); - for (iTrack i = stl->begin(); i != stl->end(); ++i) { - if (*i == t) { - // Set focus and select current track - t->arrangerTrack.tw->setFocus(); - song->selectTrack(t); - } - } - } - shortcutsKbdMovement.setTrack(t); - shortcutsKbdMovement.setPart(p); - shortcutsKbdMovement.setPos(p->tick(), p->tick() + p->lenTick()); - } - else { // Deselected - shortcutsKbdMovement.reset(); - } + printf("kbdMovementUpdate\n"); +// if (t && p ) { +// // If other track selected: +// if (t != shortcutsKbdMovement.track()) { +// TrackList* stl = song->tracks(); +// for (iTrack i = stl->begin(); i != stl->end(); ++i) { +// if (*i == t) { +// // Set focus and select current track +// t->arrangerTrack.tw->setFocus(); +// song->selectTrack(t); +// } +// } +// } +// shortcutsKbdMovement.setTrack(t); +// shortcutsKbdMovement.setPart(p); +// shortcutsKbdMovement.setPos(p->tick(), p->tick() + p->lenTick()); +// } +// else { // Deselected +// shortcutsKbdMovement.reset(); +// } } //--------------------------------------------------------- diff --git a/muse/muse/arranger/canvas.cpp b/muse/muse/arranger/canvas.cpp index 34329542..614cf3e3 100644 --- a/muse/muse/arranger/canvas.cpp +++ b/muse/muse/arranger/canvas.cpp @@ -47,11 +47,13 @@ enum { HIT_NOTHING, HIT_TRACK, HIT_PART, HIT_SUBTRACK }; PartCanvas::PartCanvas() : TimeCanvas(TIME_CANVAS) { + setFocusPolicy(Qt::StrongFocus); state = S_NORMAL; _drawBackground = true; lselected = -1; starty = -1; setMarkerList(song->marker()); + rubberBand=NULL; connect(song, SIGNAL(markerChanged(int)), SLOT(markerChanged(int))); } @@ -443,22 +445,22 @@ void PartCanvas::contextMenu(const QPoint& pos) a->setData("autofill"); } pop->addSeparator(); - if (track->type() == Track::MIDI) { + if (track->type() == Track::MIDI) { MidiTrack* track = (MidiTrack*)part->track(); if (track->useDrumMap()) { - a = pop->addAction(*edit_drummsIcon, tr("drums")); + a = pop->addAction(*edit_drummsIcon, tr("drums")); a->setData("editdrums"); } else { a = pop->addAction(QIcon(":/xpm/piano.xpm"), tr("pianoroll")); a->setData("editpiano"); } - a = pop->addAction(*edit_listIcon, tr("miditracker")); - a->setData("miditracker"); + a = pop->addAction(*edit_listIcon, tr("miditracker")); + a->setData("miditracker"); pop->addAction(getAction("listedit", this)); } else { - a = pop->addAction(*waveIcon, tr("wave edit")); + a = pop->addAction(*waveIcon, tr("wave edit")); a->setData("waveedit"); } @@ -550,6 +552,13 @@ void PartCanvas::mousePress(QMouseEvent* me) state = S_SUBTRACK; return; } + else if ( hit == HIT_NOTHING ) { // nothing here we put up a rubberband + rubberBandStartPos = me->pos(); + if (!rubberBand) + rubberBand = new QRubberBand(QRubberBand::Rectangle, this); + rubberBand->setGeometry(QRect(rubberBandStartPos, QSize())); + rubberBand->show(); + } if (button & Qt::RightButton) { contextMenu(me->pos()); @@ -561,33 +570,33 @@ void PartCanvas::mousePress(QMouseEvent* me) int xpos = 0, y = 0, len = 0, h = 0; if (hit == HIT_PART) { - h = track->arrangerTrack.tw->height(); - len = rmapx(part->lenTick()); - y = track->arrangerTrack.tw->y() - splitWidth/2; - xpos = mapx(part->tick()); - - r1 = QRect(xpos, y, handleWidth, h); - r2 = QRect(xpos + len - handleWidth, y, handleWidth, h); - pos2 = QPoint(pos.x(), pos.y() + wpos.y()); + h = track->arrangerTrack.tw->height(); + len = rmapx(part->lenTick()); + y = track->arrangerTrack.tw->y() - splitWidth/2; + xpos = mapx(part->tick()); + + r1 = QRect(xpos, y, handleWidth, h); + r2 = QRect(xpos + len - handleWidth, y, handleWidth, h); + pos2 = QPoint(pos.x(), pos.y() + wpos.y()); } switch (_tool) { case PencilTool: - if (r1.contains(pos2)) - state = S_START_DRAG1; - else if (r2.contains(pos2)) - state = S_START_DRAG2; - else - state = S_START_DRAG5; - ppos = pos2pix(pix2pos(startDrag.x()).downSnaped(raster())); - psize = pos2pix(pix2pos(ppos+1).upSnaped(raster())) - ppos; - startDragTime = QTime::currentTime(); - setCursor(); - break; + if (r1.contains(pos2)) + state = S_START_DRAG1; + else if (r2.contains(pos2)) + state = S_START_DRAG2; + else + state = S_START_DRAG5; + ppos = pos2pix(pix2pos(startDrag.x()).downSnaped(raster())); + psize = pos2pix(pix2pos(ppos+1).upSnaped(raster())) - ppos; + startDragTime = QTime::currentTime(); + setCursor(); + break; case RubberTool: - if (part) - song->cmdRemovePart(part); - break; + if (part) + song->cmdRemovePart(part); + break; case GlueTool: if (part) song->cmdGluePart(part); @@ -635,6 +644,10 @@ void PartCanvas::mousePress(QMouseEvent* me) void PartCanvas::mouseMove(QPoint pos) { + + if(rubberBand) + rubberBand->setGeometry(QRect(rubberBandStartPos, pos).normalized()); + if (state == S_SUBTRACK) { TLSWidget* w = (TLSWidget*)(at->tw); int y = wpos.y() + pos.y() - w->y() - rulerHeight; @@ -760,6 +773,10 @@ void PartCanvas::mouseMove(QPoint pos) void PartCanvas::mouseRelease(QMouseEvent* me) { + + if (rubberBand) + rubberBand->hide(); // TODO robert, nothing more happens for the moment/ + if (state == S_SUBTRACK) { ((TLSWidget*)(at->tw))->mouseRelease(); state = S_NORMAL; @@ -830,6 +847,17 @@ void PartCanvas::mouseDoubleClick(QMouseEvent* me) emit createLRPart(track); } + +//--------------------------------------------------------- +// keyboardNavigate +//--------------------------------------------------------- + +void PartCanvas::keyboardNavigate(QKeyEvent *e) + { + printf("nothing here go away\n"); + } + + //--------------------------------------------------------- // setCursor //--------------------------------------------------------- diff --git a/muse/muse/arranger/canvas.h b/muse/muse/arranger/canvas.h index 032292af..911936c2 100644 --- a/muse/muse/arranger/canvas.h +++ b/muse/muse/arranger/canvas.h @@ -83,6 +83,9 @@ class PartCanvas : public TimeCanvas { virtual void drop(QDropEvent*); virtual void dragMove(QDragMoveEvent*); virtual void dragLeave(QDragLeaveEvent*); + + virtual void keyboardNavigate(QKeyEvent *e); + int searchPart(const QPoint& p); @@ -98,6 +101,9 @@ class PartCanvas : public TimeCanvas { p.fillRect(x-HANDLE2, y-HANDLE2, HANDLE1, HANDLE1, x == lselected ? Qt::red : Qt::yellow); } void contextMenu(const QPoint&); + + QRubberBand *rubberBand; + QPoint rubberBandStartPos; private slots: void markerChanged(int); diff --git a/muse/muse/midiedit/ecanvas.cpp b/muse/muse/midiedit/ecanvas.cpp index ccfc5540..d12ce743 100644 --- a/muse/muse/midiedit/ecanvas.cpp +++ b/muse/muse/midiedit/ecanvas.cpp @@ -303,8 +303,8 @@ void EventCanvas::keyPress(QKeyEvent* event) modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster()); } else -#endif event->ignore(); +#endif } //--------------------------------------------------------- diff --git a/muse/muse/midiedit/prcanvas.cpp b/muse/muse/midiedit/prcanvas.cpp index 0207a070..f6890b02 100644 --- a/muse/muse/midiedit/prcanvas.cpp +++ b/muse/muse/midiedit/prcanvas.cpp @@ -179,6 +179,10 @@ void PianoCanvas::paint(QPainter& p, QRect cr) p.setPen(Qt::blue); p.setBrush(Qt::NoBrush); p.drawRect(lasso); + QColor fillColor(Qt::blue); + fillColor.setAlpha(40); + QBrush fillBrush(fillColor); + p.fillRect(lasso,fillBrush); } } diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 90a1a4f7..2b061c31 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -177,10 +177,10 @@ bool MusE::seqStart() } audioState = AUDIO_START1; if (!audio->start()) { - QMessageBox::critical( muse, tr("Failed to start audio!"), + QMessageBox::critical( muse, tr("Failed to start audio!"), tr("Was not able to start audio, check if jack is running.\n")); - return false; - } + return false; + } // // wait for jack callback // @@ -190,14 +190,14 @@ bool MusE::seqStart() sleep(1); } if (audioState != AUDIO_START2) { - QMessageBox::critical( muse, tr("Failed to start audio!"), + QMessageBox::critical( muse, tr("Failed to start audio!"), tr("Was not able to start audio, check if jack is running.\n")); } // // now its safe to ask the driver for realtime // priority - realTimePriority = audioDriver->realtimePriority(); + realTimePriority = audioDriver->realtimePriority(); // // create midi thread with a higher priority than JACK @@ -1002,7 +1002,7 @@ MusE::MusE() transport = new Transport; transport->hide(); - connect(transport, SIGNAL(closed()), SLOT(transportClosed())); + connect(transport, SIGNAL(closed()), SLOT(transportClosed())); QClipboard* cb = QApplication::clipboard(); connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged())); @@ -1718,12 +1718,14 @@ void MusE::playToggle() { if (audio->isPlaying()) song->setStop(true); - else if (song->cpos() != song->lpos()) - song->setPos(0, song->lPos()); - else { - Pos p(0, AL::TICKS); - song->setPos(0, p); - } + else + song->setPlay(true); +// else if (song->cpos() != song->lpos()) +// song->setPos(0, song->lPos()); +// else { +// Pos p(0, AL::TICKS); +// song->setPos(0, p); +// } } //--------------------------------------------------------- diff --git a/muse/muse/shortcuts.cpp b/muse/muse/shortcuts.cpp index 40806dc0..9a0d6a7f 100644 --- a/muse/muse/shortcuts.cpp +++ b/muse/muse/shortcuts.cpp @@ -79,7 +79,7 @@ Shortcut MuseApplication::sc[] = { ), Shortcut( "play_toggle", - QT_TR_NOOP("Transport: Play, Stop, Rewind"), + QT_TR_NOOP("Transport: Play, Stop"), GLOBAL_SHRT, Qt::Key_Space, Qt::ApplicationShortcut -- cgit v1.2.3