diff options
author | Florian Jung <flo@windfisch.org> | 2012-03-15 18:21:23 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2012-03-15 18:21:23 +0000 |
commit | 27b7bf6815cda7abb67026c37b3e44daee1803cb (patch) | |
tree | 0b9d1c0bc84ac7ff8032e707f2b5fb4e0aaabb5c /muse2/muse/arranger | |
parent | 2d6f113a10eb485694e20a78500f650776d701e3 (diff) |
merged with trunk
Diffstat (limited to 'muse2/muse/arranger')
-rw-r--r-- | muse2/muse/arranger/alayout.cpp | 26 | ||||
-rw-r--r-- | muse2/muse/arranger/alayout.h | 9 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.cpp | 158 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.h | 43 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.cpp | 10 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 164 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.h | 5 | ||||
-rw-r--r-- | muse2/muse/arranger/tlist.cpp | 225 | ||||
-rw-r--r-- | muse2/muse/arranger/tlist.h | 6 |
9 files changed, 218 insertions, 428 deletions
diff --git a/muse2/muse/arranger/alayout.cpp b/muse2/muse/arranger/alayout.cpp index 84923f12..509c84ac 100644 --- a/muse2/muse/arranger/alayout.cpp +++ b/muse2/muse/arranger/alayout.cpp @@ -41,12 +41,12 @@ void TLLayout::wadd(int idx, QWidget* w) addItem(li[idx]); } -#if 0 +#if 0 // DELETETHIS 36 //--------------------------------------------------------- // TLLayoutIterator //--------------------------------------------------------- -class TLLayoutIterator // : public QGLayoutIterator ddskrjo +class TLLayoutIterator { int idx; QList<QLayoutItem*> list; @@ -64,7 +64,7 @@ class TLLayoutIterator // : public QGLayoutIterator ddskrjo QLayoutIterator TLLayout::iterator() { - return QLayoutIterator(0); //new TLLayoutIterator(&ilist)); ddskrjo + return QLayoutIterator(0); } void TLLayout::addItem(QLayoutItem *item) @@ -99,10 +99,6 @@ TLLayout::~TLLayout() void TLLayout::setGeometry(const QRect &rect) { - //if(_inSetGeometry) // p4.0.11 Tim - // return; - //_inSetGeometry = true; - int w = rect.width(); int h = rect.height(); @@ -117,7 +113,7 @@ void TLLayout::setGeometry(const QRect &rect) QSize s1 = li[1]->sizeHint(); QSize s2 = li[2]->sizeHint(); - //QSize s3 = li[3]->sizeHint(); + //QSize s3 = li[3]->sizeHint(); DELETETHIS huh? QSize s4 = li[4]->sizeHint(); QSize s5 = li[5]->sizeHint(); @@ -136,15 +132,11 @@ void TLLayout::setGeometry(const QRect &rect) int range = s0.height() - y2; if (range < 0) range = 0; - // Note this appears to cause a single recursive call to this function - jumps to beginning, - // because now the scroll bar wants to be put in the layout. - // Moved below. p4.0.44 - ///sb->setVisible(range != 0); + if (range) sb->setMaximum(range); if (widget) { - //QSize r(s0.width(), y2); QSize r(s0.width(), y2 < s0.height() ? s0.height() : y2); // p4.0.11 Tim widget->setGeometry(0, 0, r.width(), r.height()); } @@ -155,10 +147,8 @@ void TLLayout::setGeometry(const QRect &rect) li[4]->setGeometry(QRect(0, y2, w, s4.height())); li[5]->setGeometry(QRect(3, y3, s5.width(), s5.height())); - /// Fix for non-appearing scrollbar. Yes, we must allow the recursive call, but try it here, not above. p4.0.44 Tim + // Fix for non-appearing scrollbar. Yes, we must allow the recursive call, but try it here, not above. p4.0.44 Tim sb->setVisible(range != 0); - - //_inSetGeometry = false; } //--------------------------------------------------------- @@ -168,8 +158,6 @@ void TLLayout::setGeometry(const QRect &rect) QSize TLLayout::sizeHint() const { return QSize(150, 100); - // p4.0.11 Tim. 100 was allowing vertically shrunk trackinfo widgets. Nope, no help. - //return minimumSize(); } //--------------------------------------------------------- @@ -182,8 +170,6 @@ QSize TLLayout::minimumSize() const w += li[1]->sizeHint().width(); return QSize(w, 50); - // p4.0.11 Tim. 50 was allowing vertically shrunk trackinfo widgets. Nope, no help. - //return QSize(w, stack->minimumSizeHint().height()); } //--------------------------------------------------------- diff --git a/muse2/muse/arranger/alayout.h b/muse2/muse/arranger/alayout.h index 2ffef621..8af26288 100644 --- a/muse2/muse/arranger/alayout.h +++ b/muse2/muse/arranger/alayout.h @@ -49,7 +49,6 @@ class TLLayout : public QLayout WidgetStack* stack; public: - //TLLayout(QWidget *parent) : QLayout(parent, 0, -1) {} TLLayout(QWidget *parent) : QLayout(parent) { _inSetGeometry = false; setContentsMargins(0, 0, 0, 0); setSpacing(-1); } ~TLLayout() { clear(); } @@ -63,16 +62,10 @@ class TLLayout : public QLayout virtual QSize sizeHint() const; virtual QSize minimumSize() const; virtual QSize maximumSize() const; - //QSize sizeHint() const; - //QSize minimumSize() const; - //QSize maximumSize() const; - ///QLayoutIterator iterator(); virtual void setGeometry(const QRect &rect); - //virtual QLayoutItem* itemAt(int) const { return 0;} // ddskrjo, is pure virtual, overridden virtual QLayoutItem* itemAt(int i) const { return ilist.value(i);} - virtual QLayoutItem* takeAt(int); // { return 0;} // ddskrjo, is pure virtual, overridden - ///virtual int count() const { return ilist.count(); } // ddskrjo, is pure virtual, overridden + virtual QLayoutItem* takeAt(int); }; } // namespace MusEGui diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index 41cbf06f..9048bb3c 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -37,9 +37,8 @@ #include <QVBoxLayout> #include <QWheelEvent> #include <QPainter> -//#include <QStackedWidget> -#include "arrangerview.h" +#include "arrangerview.h" #include "arranger.h" #include "song.h" #include "app.h" @@ -152,6 +151,13 @@ Arranger::custom_col_t Arranger::readOneCustomColumn(MusECore::Xml& xml) +void ScrollBar::redirectedWheelEvent(QWheelEvent* e) +{ + if(isVisible()) + wheelEvent(e); +} + + //--------------------------------------------------------- // Arranger::setHeaderToolTips //--------------------------------------------------------- @@ -200,18 +206,13 @@ Arranger::Arranger(ArrangerView* parent, const char* name) setObjectName(name); _raster = 0; // measure selected = 0; - // Since program covers 3 controls at once, it is in 'midi controller' units rather than 'gui control' units. - //program = -1; - ///program = CTRL_VAL_UNKNOWN; - ///pan = -65; - ///volume = -1; showTrackinfoFlag = true; cursVal = MAXINT; parentWin=parent; - //setFocusPolicy(Qt::StrongFocus); + setFocusPolicy(Qt::NoFocus); //--------------------------------------------------- // ToolBar @@ -246,7 +247,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name) MusEGlobal::song->setArrangerRaster(0); toolbar->addWidget(raster); connect(raster, SIGNAL(activated(int)), SLOT(_setRaster(int))); - ///raster->setFocusPolicy(Qt::NoFocus); raster->setFocusPolicy(Qt::TabFocus); // Song len @@ -257,8 +257,8 @@ Arranger::Arranger(ArrangerView* parent, const char* name) // song length is limited to 10000 bars; the real song len is limited // by overflows in tick computations - // lenEntry = new SpinBox(1, 10000, 1); + lenEntry->setFocusPolicy(Qt::StrongFocus); lenEntry->setValue(MusEGlobal::song->len()); lenEntry->setToolTip(tr("song length - bars")); lenEntry->setWhatsThis(tr("song length - bars")); @@ -273,7 +273,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name) typeBox->setCurrentIndex(0); typeBox->setToolTip(tr("midi song type")); typeBox->setWhatsThis(tr("midi song type")); - ///typeBox->setFocusPolicy(Qt::NoFocus); typeBox->setFocusPolicy(Qt::TabFocus); toolbar->addWidget(typeBox); connect(typeBox, SIGNAL(activated(int)), SLOT(modeChange(int))); @@ -284,6 +283,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name) toolbar->addWidget(label); globalPitchSpinBox = new SpinBox(-127, 127, 1); + globalPitchSpinBox->setFocusPolicy(Qt::StrongFocus); globalPitchSpinBox->setValue(MusEGlobal::song->globalPitchShift()); globalPitchSpinBox->setToolTip(tr("midi pitch")); globalPitchSpinBox->setWhatsThis(tr("global midi pitch shift")); @@ -296,6 +296,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name) toolbar->addWidget(label); globalTempoSpinBox = new SpinBox(50, 200, 1, toolbar); + globalTempoSpinBox->setFocusPolicy(Qt::StrongFocus); globalTempoSpinBox->setSuffix(QString("%")); globalTempoSpinBox->setValue(MusEGlobal::tempomap.globalTempo()); globalTempoSpinBox->setToolTip(tr("midi tempo")); @@ -305,16 +306,19 @@ Arranger::Arranger(ArrangerView* parent, const char* name) QToolButton* tempo50 = new QToolButton(); tempo50->setText(QString("50%")); + tempo50->setFocusPolicy(Qt::NoFocus); toolbar->addWidget(tempo50); connect(tempo50, SIGNAL(clicked()), SLOT(setTempo50())); QToolButton* tempo100 = new QToolButton(); tempo100->setText(tr("N")); + tempo100->setFocusPolicy(Qt::NoFocus); toolbar->addWidget(tempo100); connect(tempo100, SIGNAL(clicked()), SLOT(setTempo100())); QToolButton* tempo200 = new QToolButton(); tempo200->setText(QString("200%")); + tempo200->setFocusPolicy(Qt::NoFocus); toolbar->addWidget(tempo200); connect(tempo200, SIGNAL(clicked()), SLOT(setTempo200())); @@ -322,9 +326,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name) box->setContentsMargins(0, 0, 0, 0); box->setSpacing(0); box->addWidget(MusECore::hLine(this), Qt::AlignTop); - //QFrame* hline = MusECore::hLine(this); - //hline->setLineWidth(0); - //box->addWidget(hline, Qt::AlignTop); //--------------------------------------------------- // Tracklist @@ -336,12 +337,10 @@ Arranger::Arranger(ArrangerView* parent, const char* name) split = new Splitter(Qt::Horizontal, this, "split"); split->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); box->addWidget(split, 1000); - //split->setHandleWidth(10); tracklist = new QWidget(split); split->setStretchFactor(split->indexOf(tracklist), 0); - //tracklist->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding, 0, 100)); QSizePolicy tpolicy = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); tpolicy.setHorizontalStretch(0); tpolicy.setVerticalStretch(100); @@ -349,11 +348,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name) QWidget* editor = new QWidget(split); split->setStretchFactor(split->indexOf(editor), 1); - //editor->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding, - // Changed by T356. Was causing "large int implicitly truncated" warning. These are UCHAR values... - //1000, 100)); - //232, 100)); // 232 is what it was being truncated to, but what is the right value?... - //255, 100)); QSizePolicy epolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); epolicy.setHorizontalStretch(255); epolicy.setVerticalStretch(100); @@ -363,7 +357,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name) // Track Info //--------------------------------------------------- - infoScroll = new QScrollBar(Qt::Vertical, tracklist); + infoScroll = new ScrollBar(Qt::Vertical, tracklist); infoScroll->setObjectName("infoScrollBar"); //genTrackInfo(tracklist); // Moved below @@ -380,16 +374,14 @@ Arranger::Arranger(ArrangerView* parent, const char* name) tgrid=NULL; updateTListHeader(); list = new TList(header, tracklist, "tracklist"); - + // Do this now that the list is available. genTrackInfo(tracklist); - ///connect(list, SIGNAL(selectionChanged()), SLOT(trackSelectionChanged())); connect(list, SIGNAL(selectionChanged(MusECore::Track*)), SLOT(trackSelectionChanged())); connect(list, SIGNAL(selectionChanged(MusECore::Track*)), midiTrackInfo, SLOT(setTrack(MusECore::Track*))); connect(header, SIGNAL(sectionResized(int,int,int)), list, SLOT(redraw())); connect(header, SIGNAL(sectionMoved(int,int,int)), list, SLOT(redraw())); - connect(header, SIGNAL(sectionMoved(int,int,int)), this, SLOT(headerMoved())); // tracklist: // @@ -422,15 +414,11 @@ Arranger::Arranger(ArrangerView* parent, const char* name) hscroll->setFocusPolicy(Qt::NoFocus); ib->setFixedHeight(hscroll->sizeHint().height()); - // Changed p3.3.43 Too small steps for me... - //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(0); // Tim. + vscroll->setMinimum(0); vscroll->setMaximum(20*20); vscroll->setSingleStep(5); - vscroll->setPageStep(25); + vscroll->setPageStep(25); // FIXME: too small steps here for me (flo), better control via window height? vscroll->setValue(0); vscroll->setOrientation(Qt::Vertical); @@ -453,7 +441,8 @@ Arranger::Arranger(ArrangerView* parent, const char* name) canvas->setCanvasTools(arrangerTools); canvas->setOrigin(-offset, 0); canvas->setFocus(); - setFocusProxy(canvas); // once removed by Tim (r735), added by flo again + + list->setFocusProxy(canvas); // Make it easy for track list popup line editor to give focus back to canvas. connect(canvas, SIGNAL(setUsedTool(int)), this, SIGNAL(setUsedTool(int))); connect(canvas, SIGNAL(trackChanged(MusECore::Track*)), list, SLOT(selectTrack(MusECore::Track*))); @@ -462,12 +451,22 @@ Arranger::Arranger(ArrangerView* parent, const char* name) connect(canvas, SIGNAL(selectTrackBelow()), list, SLOT(selectTrackBelow())); connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); - - connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); - connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); + if(MusEGlobal::config.smartFocus) + { + connect(lenEntry, SIGNAL(returnPressed()), SLOT(focusCanvas())); + connect(lenEntry, SIGNAL(escapePressed()), SLOT(focusCanvas())); + connect(globalPitchSpinBox, SIGNAL(returnPressed()), SLOT(focusCanvas())); + connect(globalPitchSpinBox, SIGNAL(escapePressed()), SLOT(focusCanvas())); + connect(globalTempoSpinBox, SIGNAL(returnPressed()), SLOT(focusCanvas())); + connect(globalTempoSpinBox, SIGNAL(escapePressed()), SLOT(focusCanvas())); + connect(midiTrackInfo, SIGNAL(returnPressed()), SLOT(focusCanvas())); + connect(midiTrackInfo, SIGNAL(escapePressed()), SLOT(focusCanvas())); + } + + //connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); + connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*))); + connect(trackInfo, SIGNAL(redirectWheelEvent(QWheelEvent*)), infoScroll, SLOT(redirectedWheelEvent(QWheelEvent*))); - //egrid->addMultiCellWidget(time, 0, 0, 0, 1); - //egrid->addMultiCellWidget(MusECore::hLine(editor), 1, 1, 0, 1); egrid->addWidget(time, 0, 0, 1, 2); egrid->addWidget(MusECore::hLine(editor), 1, 0, 1, 2); @@ -479,7 +478,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name) connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int))); connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int))); connect(vscroll, SIGNAL(valueChanged(int)), list, SLOT(setYPos(int))); - connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int))); // + connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int))); connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int))); connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); connect(canvas, SIGNAL(verticalScroll(unsigned)),SLOT(verticalScrollSetYpos(unsigned))); @@ -492,7 +491,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name) connect(canvas, SIGNAL(startEditor(MusECore::PartList*,int)), SIGNAL(startEditor(MusECore::PartList*, int))); connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - //connect(MusEGlobal::song, SIGNAL(mTypeChanged(MType)), SLOT(setMode((int)MType))); // p4.0.7 Tim. connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int))); connect(canvas, SIGNAL(selectionChanged()), SIGNAL(selectionChanged())); connect(canvas, SIGNAL(dropSongFile(const QString&)), SIGNAL(dropSongFile(const QString&))); @@ -500,15 +498,10 @@ Arranger::Arranger(ArrangerView* parent, const char* name) connect(canvas, SIGNAL(toolChanged(int)), SIGNAL(toolChanged(int))); connect(MusEGlobal::song, SIGNAL(controllerChanged(MusECore::Track*)), SLOT(controllerChanged(MusECore::Track*))); -// connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(seek())); - // Removed p3.3.43 - // Song::addMarker() already emits a 'markerChanged'. - //connect(time, SIGNAL(addMarker(int)), SIGNAL(addMarker(int))); - configChanged(); // set configuration values if(canvas->part()) - midiTrackInfo->setTrack(canvas->part()->track()); // Tim. + midiTrackInfo->setTrack(canvas->part()->track()); showTrackInfo(showTrackinfoFlag); // Take care of some tabbies! @@ -521,7 +514,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name) } -void Arranger::updateTListHeader() +void Arranger::updateTListHeader() // TODO FIXME FINDMICHJETZT this doesn't work properly :/ { if (header) { @@ -580,6 +573,7 @@ void Arranger::updateTListHeader() } } +// DELETETHIS 20 //--------------------------------------------------------- // updateHScrollRange //--------------------------------------------------------- @@ -600,15 +594,6 @@ void Arranger::updateTListHeader() //} //--------------------------------------------------------- -// headerMoved -//--------------------------------------------------------- - -void Arranger::headerMoved() - { - //header->setResizeMode(COL_NAME, QHeaderView::Stretch); - } - -//--------------------------------------------------------- // setTime //--------------------------------------------------------- @@ -648,23 +633,26 @@ void Arranger::dclickPart(MusECore::Track* t) void Arranger::configChanged() { - //printf("Arranger::configChanged\n"); - if (MusEGlobal::config.canvasBgPixmap.isEmpty()) { canvas->setBg(MusEGlobal::config.partCanvasBg); canvas->setBg(QPixmap()); - //printf("Arranger::configChanged - no bitmap!\n"); } else { - - //printf("Arranger::configChanged - bitmap %s!\n", MusEGlobal::config.canvasBgPixmap.ascii()); canvas->setBg(QPixmap(MusEGlobal::config.canvasBgPixmap)); } - ///midiTrackInfo->setFont(MusEGlobal::config.fonts[2]); - //updateTrackInfo(type); } //--------------------------------------------------------- +// focusCanvas +//--------------------------------------------------------- + +void Arranger::focusCanvas() +{ + canvas->setFocus(); + canvas->activateWindow(); +} + +//--------------------------------------------------------- // songlenChanged //--------------------------------------------------------- @@ -714,8 +702,6 @@ void Arranger::songChanged(int type) SC_SIG | SC_TEMPO)) // Maybe sig. Requires tempo. canvas->partsChanged(); - //typeBox->setCurrentIndex(int(MusEGlobal::song->mtype())); // REMOVE Tim. Redundant. - if (type & SC_SIG) time->redraw(); if (type & SC_TEMPO) @@ -724,7 +710,6 @@ void Arranger::songChanged(int type) if(type & SC_TRACK_REMOVED) { AudioStrip* w = (AudioStrip*)(trackInfo->getWidget(2)); - //AudioStrip* w = (AudioStrip*)(trackInfo->widget(2)); if(w) { MusECore::Track* t = w->getTrack(); @@ -743,7 +728,7 @@ void Arranger::songChanged(int type) } } - // TEST p4.0.36 Try this + // TEST p4.0.36 Try this DELETETHIS and below and even more below if(type & ( //SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED | SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED)) //| @@ -783,6 +768,8 @@ void Arranger::modeChange(int mode) { MusEGlobal::song->setMType(MType(mode)); updateTrackInfo(-1); + if(MusEGlobal::config.smartFocus) + focusCanvas(); } //--------------------------------------------------------- @@ -791,10 +778,10 @@ void Arranger::modeChange(int mode) void Arranger::setMode(int mode) { - typeBox->blockSignals(true); // + typeBox->blockSignals(true); // This will only set if different. typeBox->setCurrentIndex(mode); - typeBox->blockSignals(false); // + typeBox->blockSignals(false); } //--------------------------------------------------------- @@ -904,6 +891,8 @@ void Arranger::_setRaster(int index) // Set the audio record part snapping. MusEGlobal::song->setArrangerRaster(_raster); canvas->redraw(); + if(MusEGlobal::config.smartFocus) + focusCanvas(); } //--------------------------------------------------------- @@ -1102,10 +1091,8 @@ QWidget* WidgetStack::visibleWidget() const QSize WidgetStack::minimumSizeHint() const { if (top == -1) - { - //printf("WidgetStack::minimumSizeHint top is -1\n"); return (QSize(0, 0)); - } + QSize s(0,0); for (unsigned int i = 0; i < stack.size(); ++i) { if (stack[i]) { @@ -1115,11 +1102,20 @@ QSize WidgetStack::minimumSizeHint() const s = s.expandedTo(ss); } } - //printf("WidgetStack::minimumSizeHint width:%d height:%d\n", s.width(), s.height()); + return s; } //--------------------------------------------------------- +// wheelEvent +//--------------------------------------------------------- + +void WidgetStack::wheelEvent(QWheelEvent* ev) + { + emit redirectWheelEvent(ev); + } + +//--------------------------------------------------------- // clear //--------------------------------------------------------- @@ -1133,10 +1129,10 @@ void Arranger::clear() midiTrackInfo->setTrack(0); } -void Arranger::wheelEvent(QWheelEvent* ev) - { - emit redirectWheelEvent(ev); - } +//void Arranger::wheelEvent(QWheelEvent* ev) +// { +// emit redirectWheelEvent(ev); +// } void Arranger::controllerChanged(MusECore::Track *t) { @@ -1162,12 +1158,10 @@ void Arranger::showTrackInfo(bool flag) void Arranger::genTrackInfo(QWidget* parent) { trackInfo = new WidgetStack(parent, "trackInfoStack"); - //trackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9 - //trackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); noTrackInfo = new QWidget(trackInfo); noTrackInfo->setAutoFillBackground(true); - QPixmap *noInfoPix = new QPixmap(160, 1000); //muse_leftside_logo_xpm); + QPixmap *noInfoPix = new QPixmap(160, 1000); const QPixmap *logo = new QPixmap(*museLeftSideLogo); noInfoPix->fill(noTrackInfo->palette().color(QPalette::Window) ); QPainter p(noInfoPix); @@ -1181,13 +1175,9 @@ void Arranger::genTrackInfo(QWidget* parent) midiTrackInfo = new MidiTrackInfo(trackInfo); - //midiTrackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9 - //midiTrackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); trackInfo->addWidget(noTrackInfo, 0); trackInfo->addWidget(midiTrackInfo, 1); trackInfo->addWidget(0, 2); - -/// genMidiTrackInfo(); } //--------------------------------------------------------- @@ -1249,7 +1239,7 @@ void Arranger::switchInfo(int n) tgrid->update(); // muse-2 Qt4 } -/* +/* DELETETHIS 12 QSize WidgetStack::minimumSize() const { printf("WidgetStack::minimumSize\n"); diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h index c2746ba7..6069c8b3 100644 --- a/muse2/muse/arranger/arranger.h +++ b/muse2/muse/arranger/arranger.h @@ -26,6 +26,9 @@ #include <vector> #include <QString> +#include <QScrollBar> +#include <QResizeEvent> + #include "midieditor.h" #include "pcanvas.h" #include "trackautomationview.h" @@ -34,11 +37,9 @@ class QAction; class QCheckBox; class QMainWindow; class QMenu; -class QScrollBar; class QToolButton; class QWheelEvent; class QKeyEvent; -//class QStackedWidget; namespace MusECore { class Track; @@ -60,6 +61,7 @@ class TLLayout; class TList; class WidgetStack; + //--------------------------------------------------------- // WidgetStack //--------------------------------------------------------- @@ -69,6 +71,12 @@ class WidgetStack : public QWidget { std::vector<QWidget*> stack; int top; + protected: + virtual void wheelEvent(QWheelEvent* e); + + signals: + void redirectWheelEvent(QWheelEvent*); + public: WidgetStack(QWidget* parent, const char* name = 0); void raiseWidget(int idx); @@ -77,11 +85,27 @@ class WidgetStack : public QWidget { QWidget* visibleWidget() const; int curIdx() const { return top; } virtual QSize minimumSizeHint() const; - //QSize minimumSize() const; - //int minimumHeight() const; }; //--------------------------------------------------------- +// ScrollBar +//--------------------------------------------------------- + +class ScrollBar : public QScrollBar { + Q_OBJECT + + public slots: + void redirectedWheelEvent(QWheelEvent*); + + protected: + virtual void resizeEvent(QResizeEvent* e) { setPageStep(e->size().height()); } + + public: + ScrollBar(Qt::Orientation orientation, QWidget * parent = 0 ) : QScrollBar(orientation, parent) {}; +}; + + +//--------------------------------------------------------- // Arranger //--------------------------------------------------------- @@ -100,9 +124,7 @@ class Arranger : public QWidget { SpinBox* lenEntry; bool showTrackinfoFlag; WidgetStack* trackInfo; - //QStackedWidget* trackInfo; - QScrollBar* infoScroll; - //MidiTrackInfoBase* midiTrackInfo; + ScrollBar* infoScroll; MidiTrackInfo* midiTrackInfo; AudioStrip* waveTrackInfo; QWidget* noTrackInfo; @@ -115,7 +137,6 @@ class Arranger : public QWidget { QToolButton* ib; int trackInfoType; Splitter* split; - ///QMenu* pop; int songType; PosLabel* cursorPos; SpinBox* globalTempoSpinBox; @@ -138,31 +159,27 @@ class Arranger : public QWidget { void songChanged(int); void modeChange(int); void setTime(unsigned); - void headerMoved(); void globalPitchChanged(int); void globalTempoChanged(int); void setTempo50(); void setTempo100(); void setTempo200(); - //void seek(); void verticalScrollSetYpos(unsigned); void horizontalZoomIn(); void horizontalZoomOut(); + void focusCanvas(); signals: - void redirectWheelEvent(QWheelEvent*); void editPart(MusECore::Track*); void selectionChanged(); void dropSongFile(const QString&); void dropMidiFile(const QString&); void startEditor(MusECore::PartList*, int); void toolChanged(int); - //void addMarker(int); void setUsedTool(int); protected: - virtual void wheelEvent(QWheelEvent* e); virtual void keyPressEvent(QKeyEvent* event); public slots: diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp index d38b5284..da510c0e 100644 --- a/muse2/muse/arranger/arrangerview.cpp +++ b/muse2/muse/arranger/arrangerview.cpp @@ -37,7 +37,6 @@ #include <QMessageBox> #include <QMimeData> #include <QPushButton> -//#include <QResizeEvent> #include <QScrollArea> #include <QScrollBar> #include <QSettings> @@ -59,7 +58,6 @@ #include "mtscale.h" #include "scoreedit.h" #include "shortcuts.h" -#include "sig.h" #include "song.h" #include "structure.h" #include "tb1.h" @@ -78,15 +76,12 @@ namespace MusEGui { ArrangerView::ArrangerView(QWidget* parent) : TopWin(TopWin::ARRANGER, parent, "arrangerview", Qt::Window) { - //using MusEGlobal::muse; - - //setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("MusE: Arranger")); - setFocusPolicy(Qt::StrongFocus); + setFocusPolicy(Qt::NoFocus); arranger = new Arranger(this, "arranger"); setCentralWidget(arranger); - setFocusProxy(arranger); + //setFocusProxy(arranger); scoreOneStaffPerTrackMapper = new QSignalMapper(this); scoreAllInOneMapper = new QSignalMapper(this); @@ -658,7 +653,6 @@ void ArrangerView::populateAddTrack() void ArrangerView::addNewTrack(QAction* action) { MusEGlobal::song->addNewTrack(action, MusEGlobal::muse->arranger()->curTrack()); // Insert at current selected track. - //MusEGlobal::song->addNewTrack(action); // Add at end. } void ArrangerView::updateShortcuts() diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 897ae1c8..f3e71916 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -34,7 +34,6 @@ #include <QLineEdit> #include <QMenu> #include <QMessageBox> -//#include <QPainter> #include <QUrl> #include <QPoint> @@ -48,7 +47,6 @@ #include "globals.h" #include "icons.h" #include "event.h" -//#include "xml.h" #include "wave.h" #include "audio.h" #include "shortcuts.h" @@ -65,8 +63,6 @@ #include "dialogs.h" #include "widgets/pastedialog.h" -//#define ABS(x) ((x) < 0) ? -(x) : (x)) -//#define ABS(x) (x>=0?x:-x) #define ABS(x) (abs(x)) #define EDITING_FINISHED_TIMEOUT 50 /* in milliseconds */ @@ -108,7 +104,6 @@ PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy) setMouseTracking(true); drag = DRAG_OFF; curColorIndex = 0; - //automation.currentCtrl = 0; automation.currentCtrlValid = false; automation.controllerState = doNothing; automation.moveController = false; @@ -117,7 +112,6 @@ PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy) PartCanvas::~PartCanvas() { - //items.clearDelete(); } //--------------------------------------------------------- @@ -131,7 +125,6 @@ int PartCanvas::y2pitch(int y) const int idx = 0; for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it, ++idx) { int h = (*it)->height(); - // if ((y >= yy) && (y < yy+h)) if (y < yy+h) break; yy += h; @@ -177,7 +170,6 @@ void PartCanvas::returnPressed() //twice. the second call would cause a crash, however! MusECore::Part* oldPart = editPart->part(); MusECore::Part* newPart = oldPart->clone(); - //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. @@ -290,6 +282,7 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp { CItem* ci = ici->second; + // DELETETHIS 5 // If this item's part is in the parts2change list, change the item's part to the new part. //MusECore::Part* pt = ci->part(); //iP2C ip2c = parts2change.find(pt); @@ -323,7 +316,6 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp // return false, if copy/move not allowed //--------------------------------------------------------- -// Changed by T356. bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& newpos, DragType t) { NPart* npart = (NPart*) item; @@ -380,12 +372,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& if(t == MOVE_MOVE) item->setPart(dpart); if (t == MOVE_COPY && !clone) { - //dpart->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it - // so we must decrement it first :/ - - // // Copy Events - // MusECore::EventList* se = spart->events(); MusECore::EventList* de = dpart->events(); for (MusECore::iEvent i = se->begin(); i != se->end(); ++i) { @@ -400,7 +387,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& dpart->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it // so we must decrement it first :/ // These will not increment ref count, and will not chain clones... - // TODO: is this comment still correct (by flo93)? i doubt it! + // TODO DELETETHIS: is the above comment still correct (by flo93)? i doubt it! operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddPart,dpart)); } else if (t == MOVE_MOVE) { @@ -412,7 +399,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& // so we must increment it first :/ dpart->setSelected(spart->selected()); // These will increment ref count if not a clone, and will chain clones... - // TODO: is this comment still correct (by flo93)? i doubt it! + // TODO DELETETHIS: is the above comment still correct (by flo93)? i doubt it! operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyPart,spart, dpart, true, false)); spart->setSelected(false); @@ -456,7 +443,6 @@ void PartCanvas::songIsClearing() void PartCanvas::partsChanged() { - //items.clear(); int sn = -1; if (curItem) sn=curItem->part()->sn(); curItem=NULL; @@ -975,7 +961,7 @@ MusECore::Track* PartCanvas::y2Track(int y) const void PartCanvas::keyPress(QKeyEvent* event) { int key = event->key(); - +// DELETETHIS 10 // if (_tool == AutomationTool) { // can't get the cursor pos to work right, skipping for now // // clear all the automation parameters // automation.moveController=false; @@ -992,7 +978,6 @@ void PartCanvas::keyPress(QKeyEvent* event) // to "false" some usec ago by returnPressed, called by editingFinished. if ( key == Qt::Key_Return || key == Qt::Key_Enter ) { - //returnPressed(); commented out by flo return; } // the below CAN indeed happen. @@ -1090,9 +1075,8 @@ void PartCanvas::keyPress(QKeyEvent* event) emit selectTrackBelow(); return; } - // + // Shortcuts that require selected parts from here - // if (!curItem) { if (items.size()==0) { event->ignore(); // give global accelerators a chance @@ -1202,11 +1186,10 @@ void PartCanvas::keyPress(QKeyEvent* event) MusECore::Track* track = curItem->part()->track();//top->part()->track(); track = y2Track(track->y() - 1); - //If we're at topmost, leave - if (!track) { - //printf("no track above!\n"); + //If we're at topmost (no track above), leave + if (!track) return; - } + int middle = curItem->x() + curItem->part()->lenTick()/2; CItem *aboveL = 0, *aboveR = 0; //Upper limit: song end, lower limit: song start @@ -1367,7 +1350,7 @@ void PartCanvas::keyPress(QKeyEvent* event) // draws a part //--------------------------------------------------------- -#if 0 +#if 0 // DELETETHIS 430 WHOA! void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) { int from = rect.x(); @@ -1794,7 +1777,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) int from = rect.x(); int to = from + rect.width(); - //printf("from %d to %d\n", from,to); MusECore::Part* part = ((NPart*)item)->part(); int pTick = part->tick(); from -= pTick; @@ -1817,17 +1799,13 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) // Item bounding box x is in tick coordinates, same as rectangle. if((rr & mr).isNull()) - { - //printf("PartCanvas::drawItem rectangle is null\n"); return; - } - //p.save(); p.setWorldMatrixEnabled(false); // NOTE: Optimization: For each item, hasHiddenEvents() is called once in Canvas::draw(), and we use cachedHasHiddenEvents(). // Not used for now. - //int het = part->cachedHasHiddenEvents(); + //int het = part->cachedHasHiddenEvents(); DELETETHIS or FIXME or whatever? int het = part->hasHiddenEvents(); int xs_0 = rr.x(); @@ -1923,18 +1901,13 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) int h = rr.height(); double s = double(h) / 4.0; int y0 = ys_0; - //int y1 = y0 + lrint(s); int y2 = y0 + lrint(s * 2.0); - //int y3 = y0 + lrint(s * 3.0); int y4 = y0 + h; - //QPoint points[12]; QPoint points[8]; int pts; - // // Fill the part rectangles, accounting for hidden events by using 'jagged' edges... - // p.setBrush(brush); p.setPen(Qt::NoPen); @@ -1946,7 +1919,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) pts = 0; if(het == (MusECore::Part::LeftEventsHidden | MusECore::Part::RightEventsHidden)) { - //points[pts++] = QPoint(xs_0, y0); + //points[pts++] = QPoint(xs_0, y0); DELETETHIS 11 //points[pts++] = QPoint(xe_0, y0); //points[pts++] = QPoint(xe_j, y1); //points[pts++] = QPoint(xe_0, y2); @@ -1969,7 +1942,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) else if(het == MusECore::Part::LeftEventsHidden) { - //points[pts++] = QPoint(xs_0, y0); + //points[pts++] = QPoint(xs_0, y0); DELETETHIS 7 //points[pts++] = QPoint(xe_0, y0); //points[pts++] = QPoint(xe_0, y4); //points[pts++] = QPoint(xs_0, y4); @@ -1988,7 +1961,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) else if(het == MusECore::Part::RightEventsHidden) { - //points[pts++] = QPoint(xs_0, y0); + //points[pts++] = QPoint(xs_0, y0); DELETETHIS 7 //points[pts++] = QPoint(xe_0, y0); //points[pts++] = QPoint(xe_j, y1); //points[pts++] = QPoint(xe_0, y2); @@ -2005,13 +1978,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.drawConvexPolygon(points, pts); } - // // Draw remaining 'hidden events' decorations with 'jagged' edges... - // int part_r, part_g, part_b, brightness, color_brightness; MusEGlobal::config.partColors[cidx].getRgb(&part_r, &part_g, &part_b); brightness = part_r*29 + part_g*59 + part_b*12; + // DELETETHIS 4 ?? //if ((brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving()) // color_brightness=223; // too dark: use lighter color //else @@ -2022,11 +1994,10 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) color_brightness=180; //255; // too dark: use lighter color QColor c(color_brightness,color_brightness,color_brightness, MusEGlobal::config.globalAlphaBlend); p.setBrush(QBrush(MusECore::gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft()))); - //p.setBrush(QBrush(c)); if(het & MusECore::Part::RightEventsHidden) { pts = 0; - //points[pts++] = QPoint(xe_0, y0); + //points[pts++] = QPoint(xe_0, y0); DELETETHIS 5 //points[pts++] = QPoint(xe_0, y4); //points[pts++] = QPoint(xe_j, y3); //points[pts++] = QPoint(xe_0, y2); @@ -2041,7 +2012,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if(het & MusECore::Part::LeftEventsHidden) { pts = 0; - //points[pts++] = QPoint(xs_0, y0); + //points[pts++] = QPoint(xs_0, y0); DELETETHIS 5 //points[pts++] = QPoint(xs_j, y1); //points[pts++] = QPoint(xs_0, y2); //points[pts++] = QPoint(xs_j, y3); @@ -2056,7 +2027,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) } else { - //p.fillRect(rr, brush); p.fillRect(rr & mr, brush); // Respect the requested drawing rectangle. Gives speed boost! } @@ -2064,11 +2034,8 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) if(part->mute()) { p.setPen(Qt::NoPen); - //brush.setStyle(Qt::DiagCrossPattern); brush.setStyle(Qt::Dense7Pattern); - //p.fillRect(rr, brush); // FIXME: Some shifting going on - //p.fillRect(QRect(rr.x(), rr.y(), rr.width() + 1, rr.height() + 1), brush); // Same here p.fillRect(rr & mr, brush); // Respect the requested drawing rectangle. Gives speed boost! } @@ -2093,7 +2060,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.setWorldMatrixEnabled(false); - #if 0 + #if 0 // DELETETHIS 13 // // Now draw the borders... // Works great but requires clones be drawn with the highest priority on top of all other parts, in Canvas::draw. @@ -2108,7 +2075,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) //#else #endif - #if 1 + #if 1 // DELETETHIS remove wrapping #if // // Now draw the borders, using custom segments... // @@ -2258,12 +2225,11 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) int part_r, part_g, part_b, brightness; // Since we'll draw the text on the bottom (to accommodate drum 'slivers'), // get the lowest colour in the gradient used to draw the part. - //QRect rr = map(r); QRect tr = rr; tr.setX(tr.x() + 3); MusECore::gGradientFromQColor(MusEGlobal::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()) && !part->mute() && !item->isMoving(); DELETETHIS bool rev = brightness >= 12000 && !part->selected(); p.setFont(MusEGlobal::config.fonts[4]); if (rev) @@ -2278,7 +2244,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect) p.drawText(tr, Qt::AlignBottom|Qt::AlignLeft, part->name()); } - //p.restore(); p.setWorldMatrixEnabled(true); } @@ -2292,7 +2257,7 @@ void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&) p.setPen( Qt::black); MusECore::Part* part = ((NPart*)item)->part(); QColor c(part->mute() ? Qt::white : MusEGlobal::config.partColors[part->colorIndex()]); - //c.setAlpha(MusEGlobal::config.globalAlphaBlend); + //c.setAlpha(MusEGlobal::config.globalAlphaBlend); DELETETHIS 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()); @@ -2314,7 +2279,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev int part_r, part_g, part_b, brightness; MusEGlobal::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()) + //if ((brightness < 12000 || pt->selected()) && !pt->mute()) DELETETHIS 4 // color_brightness=192; // too dark: use lighter color //else // color_brightness=64; // otherwise use dark color @@ -2506,8 +2471,6 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev if (te < (from + pTick)) continue; - //if (te > (to + pTick)) - // te = to + pTick; if (te >= (to + pTick)) te = lrint(rmapxDev_f(rmapx_f(to + pTick) - 1.0)); @@ -2537,9 +2500,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev void PartCanvas::drawWavePart(QPainter& p, const QRect& bb, MusECore::WavePart* wp, const QRect& _pr) { - //QRect rr = p.worldMatrix().mapRect(bb); // Gives inconsistent positions. Source shows wrong operation for our needs. QRect rr = map(bb); // Use our own map instead. - //QRect pr = p.worldMatrix().mapRect(_pr); QRect pr = map(_pr); p.save(); @@ -2592,10 +2553,7 @@ void PartCanvas::drawWavePart(QPainter& p, if(ex > x2) ex = x2; if (h < 20) { - // // combine multi channels into one waveform - // - //printf("PartCanvas::drawWavePart i:%d ex:%d\n", i, ex); for (; i < ex; i++) { MusECore::SampleV sa[channels]; @@ -2620,14 +2578,12 @@ void PartCanvas::drawWavePart(QPainter& p, } } else { - // // multi channel display - // int hm = hh / (channels * 2); int cc = hh % (channels * 2) ? 0 : 1; for (; i < ex; i++) { y = pr.y() + hm; - MusECore::SampleV sa[channels]; + MusECore::SampleV sa[channels]; xScale = MusEGlobal::tempomap.deltaTick2frame(postick, postick + tickstep); f.read(sa, xScale, pos); postick += tickstep; @@ -3147,10 +3103,6 @@ void PartCanvas::dragEnterEvent(QDragEnterEvent* event) } //--------------------------------------------------------- -// dragvent -//--------------------------------------------------------- - -//--------------------------------------------------------- // dropEvent //--------------------------------------------------------- @@ -3394,7 +3346,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) // does NOT depend on the update rectangle (except to check intersection). That's why this issue // does not show up there. Should probably try to make that routine more efficient, just like here. Tim. p4.0.30 QRect r(mx, yy, mw, th); - //if(r.intersects(mr)) + //if(r.intersects(mr)) DELETETHIS { if (!track->isMidiTrack() && (track->type() != MusECore::Track::WAVE)) { //QRect r = rect & QRect(x, yy, w, track->height()); @@ -3402,6 +3354,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) //p.setPen(baseColor); } + // DELETETHIS 13 // This was redundant drawing. Not required, done via drawTopItem in Canvas::draw /* //p.setWorldMatrixEnabled(true); @@ -3418,7 +3371,6 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) } p.restore(); - //p.setWorldMatrixEnabled(true); } //--------------------------------------------------------- @@ -3426,36 +3378,25 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect) //--------------------------------------------------------- void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) { - //int x = rect.x(); - //int y = rect.y(); - //int w = rect.width(); - //int h = rect.height(); - - // Changed to draw in device coordinate space instead of virtual, transformed space. Tim. p4.0.30 - //QRect mr = p.transform().mapRect(rect); // Gives inconsistent positions. Source shows wrong operation for our needs. QRect mr = map(rect); // Use our own map instead. - //printf("PartCanvas::drawTopItem x:%d y:%d w:%d h:%d\n", rect.x(), rect.y(), rect.width(), rect.height()); - int mx = mr.x(); int my = mr.y(); int mw = mr.width(); int mh = mr.height(); QColor baseColor(MusEGlobal::config.partCanvasBg.light(104)); - //p.setPen(baseColor); p.save(); p.setWorldMatrixEnabled(false); MusECore::TrackList* tl = MusEGlobal::song->tracks(); int yoff = -rmapy(yorg) - ypos; - //int yy = 0; int yy = yoff; int th; for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it) { - //if (yy > y + h) + //if (yy > y + h) DELETETHIS if (yy > my + mh) break; MusECore::Track* track = *it; @@ -3463,15 +3404,15 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) if (!th) continue; if (!track->isMidiTrack()) { // draw automation - //QRect r = rect & QRect(x, yy, w, track->height()); + //QRect r = rect & QRect(x, yy, w, track->height()); DELETETHIS QRect r(mx, yy, mw, th); if(r.intersects(mr)) { drawAutomation(p, r, (MusECore::AudioTrack*)track); - //p.setPen(baseColor); + //p.setPen(baseColor); DELETETHIS } } - //yy += track->height(); + //yy += track->height(); DELETETHIS yy += th; } @@ -3482,22 +3423,16 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) int width = mapx(MusEGlobal::song->cpos()) - mapx(startPos); if (MusEGlobal::song->cpos() < startPos) { - //p.setWorldMatrixEnabled(true); p.restore(); return; // no drawing if we are before punch out } if (MusEGlobal::song->punchout() && MusEGlobal::song->cpos() > MusEGlobal::song->rpos()) { - //p.setWorldMatrixEnabled(true); p.restore(); return; // no drawing if we are beyond punch out. } - ///p.save(); - ///p.resetTransform(); - // write recording while it happens to get feedback // should be enhanced with solution that draws waveform also - //int yPos=0; int yPos = yoff; if (MusEGlobal::song->record() && MusEGlobal::audio->isPlaying()) { for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it) { @@ -3522,7 +3457,6 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect) } } p.restore(); - //p.setWorldMatrixEnabled(true); // draw midi events on yPos=0; @@ -3588,13 +3522,13 @@ void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox, p.setPen(Qt::black); QColor c(Qt::gray); c.setAlpha(MusEGlobal::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); gradient.setColorAt(1, c.darker()); QBrush brush(gradient); p.fillRect(mr, brush); // p4.0.30 ... + // DELETETHIS 6 //int xx = -rmapx(xorg) - xpos; //printf("PartCanvas::drawAudioTrack x:%d y:%d w:%d h:%d th:%d xx:%d\n", r.x(), r.y(), r.width(), r.height(), t->height(), xx); //if(r.x() <= xx) @@ -3604,7 +3538,7 @@ void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox, if(mex >= mx && mex <= mx + mw) p.drawLine(mex, my, mex, my + mh - 1); // The left edge - //if(mex + mew >= mx && mex + mew <= mx + mw) + //if(mex + mew >= mx && mex + mew <= mx + mw) DELETETHIS 2 // p.drawLine(mex + mew, my, mex + mew, my + mh - 1); // The right edge. Not used - infinite to the right if(mey >= my && mey <= my + mh) p.drawLine(mx, mey, mx + mw - 1, mey); // The top edge @@ -3647,7 +3581,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra int ypixel = oldY; double min, max; cl->range(&min,&max); - //bool discrete = cl->valueType() == VAL_BOOL || cl->mode() == MusECore::CtrlList::DISCRETE; bool discrete = cl->mode() == MusECore::CtrlList::DISCRETE; QPen pen1(cl->color(), 0); QPen pen2(cl->color(), 2); @@ -3658,7 +3591,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra { double y; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max); y = logToVal(cl->curVal(), min, max); // represent volume between 0 and 1 if (y < 0) y = 0.0; } @@ -3672,7 +3604,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra { double y = ic->second.val; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max); y = logToVal(y, min, max); // represent volume between 0 and 1 if (y < 0) y = 0.0; } @@ -3684,7 +3615,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra if (oldY==-1) oldY = ypixel; - //printf(" line x1:%d x2:%d prevVal:%f nextVal:%f\n", leftX, currentPixel, prevVal, nextVal); p.setPen(pen1); if(discrete) { @@ -3712,12 +3642,10 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra } if (xpixel <= rr.right()) { - //printf(" endline prevVal:%f\n", prevVal); p.setPen(pen1); p.drawLine(xpixel, ypixel, rr.right(), ypixel); } } - //p.restore(); } @@ -3764,7 +3692,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo int ypixel = oldY; double min, max; cl->range(&min,&max); - //bool discrete = cl->valueType() == VAL_BOOL || cl->mode() == MusECore::CtrlList::DISCRETE; // Tim bool discrete = cl->mode() == MusECore::CtrlList::DISCRETE; // First check that there IS automation, ic == cl->end means no automation @@ -3795,12 +3722,9 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo xpixel = mapx(MusEGlobal::tempomap.frame2tick(ic->second.frame)); if (oldY==-1) oldY = ypixel; - //printf(" oldX:%d oldY:%d xpixel:%d ypixel:%d\n", oldX, oldY, xpixel, ypixel); bool foundIt=false; if (addNewCtrl) { - // check if we are reasonably close to a line - //printf("xpixel=%d oldX=%d\n", xpixel, oldX); double firstX=oldX; double lastX=xpixel; double firstY=oldY; @@ -3808,8 +3732,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo double proportion = (currX-firstX)/(lastX-firstX); - //if ( (currX > lastX && firstY!=lastY) // omit special cases. - // || firstX==lastX ) { if((currX < oldX) || (currX > lastX) || (firstX==lastX) ) { oldX = xpixel; @@ -3825,7 +3747,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo // / // 1 double calcY = (lastY-firstY)*proportion+firstY; - //printf("calcY=%f currY=%d\n", calcY, currY); if(ABS(calcY-currY) < circumference || (xpixel == oldX && ABS(currX-xpixel) < circumference)) foundIt=true; @@ -3847,9 +3768,7 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo automation.currentCtrlValid = false; automation.controllerState = addNewController; }else { - //automation.currentCtrl=&ic->second; automation.currentCtrlFrame = ic->second.frame; - //automation.currentCtrlVal = ic->second.val; automation.currentCtrlValid = true; automation.controllerState = movingController; } @@ -3869,7 +3788,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo automation.controllerState = addNewController; automation.currentCtrlList = cl; automation.currentTrack = t; - //automation.currentCtrl = 0; automation.currentCtrlValid = false; return; } @@ -3877,7 +3795,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo } // if there are no hits we default to clearing all the data automation.controllerState = doNothing; - //automation.currentCtrl = 0; automation.currentCtrlValid = false; automation.currentCtrlList = 0; automation.currentTrack = 0; @@ -3886,7 +3803,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo void PartCanvas::controllerChanged(MusECore::Track* t) { - //redraw(); redraw((QRect(0, mapy(t->y()), width(), rmapy(t->height())))); // TODO Check this - correct? } @@ -3911,19 +3827,15 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) if (automation.controllerState == addNewController) { - //printf("adding a new ctrler!\n"); int frame = MusEGlobal::tempomap.tick2frame(pos.x()); // FIXME Inefficient to add with wait here, then remove and add with wait again below. Tim. MusEGlobal::audio->msgAddACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), frame, 1.0 /*dummy value */); - //MusEGlobal::song->addACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), frame, 1.0 /*dummy value */); MusECore::iCtrl ic=automation.currentCtrlList->begin(); for (; ic !=automation.currentCtrlList->end(); ++ic) { MusECore::CtrlVal &cv = ic->second; if (cv.frame == frame) { - //automation.currentCtrl = &cv; automation.currentCtrlFrame = cv.frame; - //automation.currentCtrlVal = cv.val; automation.currentCtrlValid = true; automation.controllerState = movingController; break; @@ -3937,7 +3849,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) for (; ic !=automation.currentCtrlList->end(); ++ic) { MusECore::CtrlVal &cv = ic->second; - //if (&cv == automation.currentCtrl) if (cv.frame == automation.currentCtrlFrame) { currFrame = cv.frame; @@ -3958,9 +3869,7 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) // there is only one value at t, and the next value at t+1, and so on. // Also these are maps, not multimaps. p4.0.32 Tim. int newFrame = MusEGlobal::tempomap.tick2frame(pos.x()); - //if(currFrame == 0) - // newFrame = 0; // Force first item to stay at x = 0. - //else + if (newFrame <= prevFrame) newFrame=prevFrame + (icc == automation.currentCtrlList->begin() ? 0: 1); // Only first item is allowed to go to zero x. if (nextFrame!=-1 && newFrame >= nextFrame) newFrame=nextFrame-1; @@ -3968,7 +3877,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) int posy=mapy(pos.y()); int tracky = mapy(automation.currentTrack->y()); int trackHeight = automation.currentTrack->height(); - //printf("posy=%d tracky=%d trackHeight=%d\n", posy,tracky,trackHeight); int mouseY = trackHeight - (posy - tracky)-2; double yfraction = ((double)mouseY)/automation.currentTrack->height(); @@ -3979,7 +3887,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) if (automation.currentCtrlList->valueType() == MusECore::VAL_LOG ) { // use db scale for volume printf("log conversion val=%f min=%f max=%f\n", yfraction, min, max); cvval = valToLog(yfraction, min, max); - //printf("calc yfraction = %f v=%f ",yfraction,cvval); if (cvval< min) cvval=min; if (cvval>max) cvval=max; } @@ -3987,7 +3894,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) // we need to set val between 0 and 1 (unless integer) cvval = yfraction * (max-min) + min; // 'Snap' to integer or boolean - //if (automation.currentCtrlList->valueType() == VAL_INT || automation.currentCtrlList->valueType() == VAL_BOOL) if (automation.currentCtrlList->mode() == MusECore::CtrlList::DISCRETE) cvval = rint(cvval + 0.1); // LADSPA docs say add a slight bias to avoid rounding errors. Try this. if (cvval< min) cvval=min; @@ -3995,18 +3901,12 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) } automation.currentCtrlFrame = newFrame; - //automation.currentCtrlVal = cvval; automation.currentCtrlValid = true; if(icc != automation.currentCtrlList->end()) MusEGlobal::audio->msgChangeACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), icc->second.frame, newFrame, cvval); - //MusEGlobal::song->changeACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), icc->second.frame, newFrame, cvval); else MusEGlobal::audio->msgAddACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), newFrame, cvval); - //MusEGlobal::song->addACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), newFrame, cvval); - - // Not needed. Redraw is now handled by msgXXX(). - //controllerChanged(automation.currentTrack); } } @@ -4019,7 +3919,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) //--------------------------------------------------------- double PartCanvas::logToVal(double inLog, double min, double max) { - //printf("logToVal inLog %f :", inLog); if (inLog < min) inLog = min; if (inLog > max) inLog = max; double linMin = 20.0*MusECore::fast_log10(min); @@ -4027,7 +3926,6 @@ double PartCanvas::logToVal(double inLog, double min, double max) double linVal = 20.0*MusECore::fast_log10(inLog); double outVal = (linVal-linMin) / (linMax - linMin); - // printf("inLog %f outVal %f linVal %f min %f max %f dbMin %f dbMax %f\n", inLog, outVal, linVal, min, max, linMin, linMax); return outVal; } diff --git a/muse2/muse/arranger/pcanvas.h b/muse2/muse/arranger/pcanvas.h index 34395688..7882ee5c 100644 --- a/muse2/muse/arranger/pcanvas.h +++ b/muse2/muse/arranger/pcanvas.h @@ -71,7 +71,6 @@ class NPart : public CItem { enum ControllerVals { doNothing, movingController, addNewController }; struct AutomationObject { - //MusECore::CtrlVal *currentCtrl; int currentCtrlFrame; bool currentCtrlValid; MusECore::CtrlList *currentCtrlList; @@ -99,8 +98,6 @@ class PartCanvas : public Canvas { AutomationObject automation; - //std::vector<TrackAutomationView*> automationViews; - virtual void keyPress(QKeyEvent*); virtual void mousePress(QMouseEvent*); virtual void mouseMove(QMouseEvent* event); @@ -137,9 +134,7 @@ class PartCanvas : public Canvas { enum paste_mode_t { PASTEMODE_MIX, PASTEMODE_MOVEALL, PASTEMODE_MOVESOME }; void paste(bool clone = false, paste_mode_t paste_mode = PASTEMODE_MIX, bool to_single_track=false, int amount=1, int raster=1536); MusECore::Undo pasteAt(const QString&, MusECore::Track*, unsigned int, bool clone = false, bool toTrack = true, int* finalPosPtr = NULL, std::set<MusECore::Track*>* affected_tracks = NULL); - //MusECore::Part* readClone(MusECore::Xml&, MusECore::Track*, bool toTrack = true); void drawWavePart(QPainter&, const QRect&, MusECore::WavePart*, const QRect&); - //void drawMidiPart(QPainter&, const QRect& rect, MusECore::EventList* events, MusECore::MidiTrack*mt, const QRect& r, int pTick, int from, int to); void drawMidiPart(QPainter&, const QRect& rect, MusECore::EventList* events, MusECore::MidiTrack*mt, MusECore::MidiPart*pt, const QRect& r, int pTick, int from, int to); MusECore::Track* y2Track(int) const; void drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox, MusECore::AudioTrack* track); diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 0ed201bf..b5fa2a1a 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -20,13 +20,10 @@ // //========================================================= -//#include "config.h" - #include <cmath> #include <QKeyEvent> #include <QLineEdit> -//#include <QMenu> #include <QMessageBox> #include <QMouseEvent> #include <QPainter> @@ -95,7 +92,7 @@ TList::TList(Header* hdr, QWidget* parent, const char* name) ypos = 0; editMode = false; editJustFinished=false; - setFocusPolicy(Qt::StrongFocus); + setFocusPolicy(Qt::NoFocus); setMouseTracking(true); header = hdr; @@ -106,7 +103,7 @@ TList::TList(Header* hdr, QWidget* parent, const char* name) ctrl_edit = NULL; mode = NORMAL; - //setBackgroundMode(Qt::NoBackground); // ORCAN - FIXME + //setBackgroundMode(Qt::NoBackground); // ORCAN - FIXME. DELETETHIS? //setAttribute(Qt::WA_OpaquePaintEvent); resizeFlag = false; @@ -312,7 +309,6 @@ void TList::paint(const QRect& r) pm = addtrack_auxsendIcon; break; case MusECore::Track::AUDIO_SOFTSYNTH: - //pm = waveIcon; pm = synthIcon; break; } @@ -401,7 +397,6 @@ void TList::paint(const QRect& r) if (cl->isVisible()) countVisible++; } - //int count = ((MusECore::AudioTrack*)track)->controller()->size(); //commented out by flo: gives a "unused variable" warning s.sprintf(" %d(%d) %s",countVisible, countAll, tr("visible").toAscii().data()); } @@ -512,18 +507,14 @@ void TList::returnPressed() } } - //MusECore::Track* track = editTrack->clone(false); - //editTrack->setName(editor->text()); - //MusEGlobal::audio->msgChangeTrack(track, editTrack); - // p4.0.46 Tim... MusEGlobal::song->startUndo(); MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyTrackName, editTrack, editTrack->name().toLatin1().constData(), editor->text().toLatin1().constData())); editTrack->setName(editor->text()); - //MusEGlobal::song->update(SC_TRACK_MODIFIED); - MusEGlobal::song->endUndo(-1); + //MusEGlobal::song->update(SC_TRACK_MODIFIED); //DELETETHIS + MusEGlobal::song->endUndo(-1); //uagh, why "-1", why no proper flags? } } @@ -532,7 +523,7 @@ void TList::returnPressed() editMode = false; editJustFinished = true; - if(editor->isVisible()) + if(editor && editor->isVisible()) { editor->blockSignals(true); editor->hide(); @@ -541,13 +532,6 @@ void TList::returnPressed() setFocus(); } -void TList::chanValueChanged(int /*val*/) -{ - //MusECore::Track* track = editTrack->clone(false); - //((MusECore::MidiTrack*)editTrack)->setOutChannel(val-1); - //MusEGlobal::audio->msgChangeTrack(track, editTrack); -} - void TList::chanValueFinished() { if(editTrack) @@ -569,7 +553,7 @@ void TList::chanValueFinished() editTrack, mt->outChannel(), channel)); - //mt->setOutChannel(channel); + //mt->setOutChannel(channel); DELETETHIS 10 (only the comments of course) MusEGlobal::audio->msgIdle(true); //MusEGlobal::audio->msgSetTrackOutChannel(mt, channel); mt->setOutChanAndUpdate(channel); @@ -750,15 +734,11 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev) editTrack = t; if (editor == 0) { editor = new QLineEdit(this); - /*connect(editor, SIGNAL(returnPressed()), - SLOT(returnPressed()));*/ - editor->setFrame(true); + editor->setFrame(false); connect(editor, SIGNAL(editingFinished()), SLOT(returnPressed())); } - //editor->blockSignals(true); editor->setText(editTrack->name()); - //editor->blockSignals(false); - editor->end(false); + editor->selectAll(); editor->setGeometry(colx, coly, colw, colh); editMode = true; editor->show(); @@ -772,16 +752,21 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev) return; } - //if(t->type() != MusECore::Track::DRUM && t->type() != MusECore::Track::AUDIO_SOFTSYNTH) + // A disabled spinbox up or down button will pass the event to the parent! Causes pseudo 'wrapping'. Eat it up. + if(chan_edit && chan_edit->hasFocus()) + { + ev->accept(); + return; + } + else { editTrack=t; if (chan_edit==0) { chan_edit=new QSpinBox(this); + chan_edit->setFrame(false); chan_edit->setMinimum(1); - //connect(chan_edit, SIGNAL(valueChanged(int)), SLOT(chanValueChanged(int))); connect(chan_edit, SIGNAL(editingFinished()), SLOT(chanValueFinished())); } - //chan_edit->blockSignals(true); if (t->isMidiTrack()) { chan_edit->setMaximum(MIDI_CHANNELS); @@ -792,10 +777,10 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev) chan_edit->setMaximum(MAX_CHANNELS); chan_edit->setValue(((MusECore::AudioTrack*)editTrack)->channels()); } - //chan_edit->blockSignals(false); int w=colw; if (w < chan_edit->sizeHint().width()) w=chan_edit->sizeHint().width(); chan_edit->setGeometry(colx, coly, w, colh); + chan_edit->selectAll(); editMode = true; chan_edit->show(); chan_edit->setFocus(); @@ -855,13 +840,11 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) { MusECore::MidiTrack* track = (MusECore::MidiTrack*)t; - //QPopupMenu* p = MusECore::midiPortsPopup(0); MusECore::MidiDevice* md = 0; int potential_new_port_no=-1; int port = -1; if(t->type() == MusECore::Track::AUDIO_SOFTSYNTH) { - //MusECore::MidiDevice* md = dynamic_cast<MusECore::MidiDevice*>((MusECore::SynthI*)t); md = dynamic_cast<MusECore::MidiDevice*>(t); if(md) port = md->midiPort(); @@ -869,7 +852,7 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) else port = track->outPort(); - QMenu* p = MusECore::midiPortsPopup(this, port); // 0, port); + QMenu* p = MusECore::midiPortsPopup(this, port); if (t->isMidiTrack()) { @@ -1021,8 +1004,10 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[potential_new_port_no], sdev); n=potential_new_port_no; + + MusEGlobal::song->update(); } - // Changed by T356. + // Changed by T356. DELETETHIS 5 //track->setOutPort(n); //MusEGlobal::audio->msgSetTrackOutPort(track, n); @@ -1035,27 +1020,23 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) if (!change) { // Delete all port controller events. - //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false); MusEGlobal::song->changeAllPortDrumCtrlEvents(false); track->setOutPort(n); for (int i=0; i<DRUM_MAPSIZE; i++) //Remap all drum instruments to this port MusEGlobal::drumMap[i].port = track->outPort(); // Add all port controller events. - //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true); MusEGlobal::song->changeAllPortDrumCtrlEvents(true); } else { - //MusEGlobal::audio->msgSetTrackOutPort(track, n); track->setOutPortAndUpdate(n); } MusEGlobal::audio->msgIdle(false); MusEGlobal::audio->msgUpdateSoloStates(); // (p4.0.14) p4.0.17 MusEGlobal::song->update(); } - else - if (t->type() == MusECore::Track::AUDIO_SOFTSYNTH) + else if (t->type() == MusECore::Track::AUDIO_SOFTSYNTH) { if(md != 0) { @@ -1066,17 +1047,14 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[n], (MusEGlobal::midiPorts[n].device() == md) ? 0 : md); MusEGlobal::muse->changeConfig(true); // save configuration file - //MusEGlobal::audio->msgIdle(false); MusEGlobal::song->update(); } } else { MusEGlobal::audio->msgIdle(true); - //MusEGlobal::audio->msgSetTrackOutPort(track, n); track->setOutPortAndUpdate(n); MusEGlobal::audio->msgIdle(false); - //MusEGlobal::song->update(); MusEGlobal::audio->msgUpdateSoloStates(); // (p4.0.14) p4.0.17 MusEGlobal::song->update(SC_MIDI_TRACK_PROP); // } @@ -1103,22 +1081,13 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) MusECore::SynthI* synth = (MusECore::SynthI*)t; QMenu* p = new QMenu; - //QAction* act = p->addAction(tr("Show Gui")); QAction* gact = p->addAction(tr("show gui")); - //act->setCheckable(true); gact->setCheckable(true); - //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); - //act->setEnabled(synth->hasGui()); - //act->setChecked(synth->guiVisible()); gact->setEnabled(synth->hasGui()); gact->setChecked(synth->guiVisible()); QAction* nact = p->addAction(tr("show native gui")); - //act->setCheckable(true); nact->setCheckable(true); - //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); - //act->setEnabled(synth->hasGui()); - //act->setChecked(synth->guiVisible()); nact->setEnabled(synth->hasNativeGui()); nact->setChecked(synth->nativeGuiVisible()); @@ -1127,8 +1096,6 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) #ifdef DSSI_SUPPORT if(dynamic_cast<MusECore::DssiSynthIF*>(synth->sif())) { - //act->setChecked(false); - //act->setEnabled(false); nact->setChecked(false); nact->setEnabled(false); } @@ -1136,15 +1103,12 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) #endif QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0); - //if (ract == act) { if (ract == gact) { bool show = !synth->guiVisible(); - //MusEGlobal::audio->msgShowInstrumentGui(synth, show); synth->showGui(show); } else if (ract == nact) { bool show = !synth->nativeGuiVisible(); - //MusEGlobal::audio->msgShowInstrumentNativeGui(synth, show); synth->showNativeGui(show); } delete p; @@ -1158,19 +1122,13 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) MusECore::MidiPort* port = &MusEGlobal::midiPorts[oPort]; QMenu* p = new QMenu; - //QAction* act = p->addAction(tr("Show Gui")); QAction* gact = p->addAction(tr("show gui")); - //act->setCheckable(true); gact->setCheckable(true); - //printf("synth hasgui %d, gui visible %d\n",port->hasGui(), port->guiVisible()); - //act->setEnabled(port->hasGui()); - //act->setChecked(port->guiVisible()); gact->setEnabled(port->hasGui()); gact->setChecked(port->guiVisible()); QAction* nact = p->addAction(tr("show native gui")); nact->setCheckable(true); - //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); nact->setEnabled(port->hasNativeGui()); nact->setChecked(port->nativeGuiVisible()); @@ -1180,8 +1138,6 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) MusECore::MidiDevice* dev = port->device(); if(dev && dev->isSynti() && (dynamic_cast<MusECore::DssiSynthIF*>(((MusECore::SynthI*)dev)->sif()))) { - //act->setChecked(false); - //act->setEnabled(false); nact->setChecked(false); nact->setEnabled(false); } @@ -1189,15 +1145,12 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y) #endif QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0); - //if (ract == act) { if (ract == gact) { bool show = !port->guiVisible(); - //MusEGlobal::audio->msgShowInstrumentGui(port->instrument(), show); port->instrument()->showGui(show); } else if (ract == nact) { bool show = !port->nativeGuiVisible(); - //MusEGlobal::audio->msgShowInstrumentNativeGui(port->instrument(), show); port->instrument()->showNativeGui(show); } delete p; @@ -1219,16 +1172,14 @@ void TList::tracklistChanged() void TList::keyPressEvent(QKeyEvent* e) { + if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) + { + e->accept(); + return; + } + if (editMode) { - // First time we get a keypress event when lineedit is open is on the return key: - // -- Not true for Qt4. Modifier keys also send key events - Orcan - //if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) // Removed p4.0.46 Tim. - // { - // returnPressed(); - // return; - // } - //else if ( e->key() == Qt::Key_Escape ) { if(editor && editor->isVisible()) @@ -1254,6 +1205,7 @@ void TList::keyPressEvent(QKeyEvent* e) setFocus(); return; } + return; } else if (!editJustFinished) { @@ -1263,24 +1215,24 @@ void TList::keyPressEvent(QKeyEvent* e) editJustFinished=false; - // p4.0.10 Removed by Tim. keyPressExt are sent to part canvas, where they are - // ignored *only* if necessary. - //e->ignore(); - + // Works OK (if focusing allowed). But instead we won't allow focus. Part canvas has Ctrl+up/down which moves selected track only. /* int key = e->key(); switch (key) { - case Key_Up: + case Qt::Key_Up: moveSelection(-1); - break; - case Key_Down: + return; + case Qt::Key_Down: moveSelection(1); - break; + return; default: - break; - } - */ + } */ + + // keyPressExt are sent to part canvas, where they are ignored *only* if necessary. + //e->ignore(); + + emit keyPressExt(e); //redirect keypress events to main app } //--------------------------------------------------------- @@ -1302,7 +1254,6 @@ void TList::moveSelection(int n) for (MusECore::iTrack t = tracks->begin(); t != tracks->end(); ++t) { MusECore::iTrack s = t; if ((*t)->selected()) { - selTrack = *t; if (n > 0) { while (n--) { ++t; @@ -1313,7 +1264,10 @@ void TList::moveSelection(int n) // skip over hidden tracks if (!(*t)->isVisible()) { n++; + continue; } + selTrack = *t; + break; } } else { @@ -1324,40 +1278,42 @@ void TList::moveSelection(int n) // skip over hidden tracks if (!(*t)->isVisible()) { n--; + continue; } + selTrack = *t; + break; } } - (*s)->setSelected(false); - (*t)->setSelected(true); - - // rec enable track if expected - MusECore::TrackList recd = getRecEnabledTracks(); - if (recd.size() == 1 && MusEGlobal::config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection - MusEGlobal::song->setRecordFlag((MusECore::Track*)recd.front(),false); - MusEGlobal::song->setRecordFlag((*t),true); - } + if(selTrack) + { + (*s)->setSelected(false); + selTrack->setSelected(true); + + // rec enable track if expected + MusECore::TrackList recd = getRecEnabledTracks(); + if (recd.size() == 1 && MusEGlobal::config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection + MusEGlobal::song->setRecordFlag((MusECore::Track*)recd.front(),false); + MusEGlobal::song->setRecordFlag((selTrack),true); + } - if (editTrack && editTrack != *t) - returnPressed(); - - redraw(); - break; + if (editTrack && editTrack != selTrack) + returnPressed(); + redraw(); } + break; + } } - ///emit selectionChanged(); - emit selectionChanged(selTrack); + if(selTrack) + emit selectionChanged(selTrack); } MusECore::TrackList TList::getRecEnabledTracks() { - //printf("getRecEnabledTracks\n"); MusECore::TrackList recEnabled; MusECore::TrackList* tracks = MusEGlobal::song->tracks(); for (MusECore::iTrack t = tracks->begin(); t != tracks->end(); ++t) { - if ((*t)->recordFlag()) { - //printf("rec enabled track\n"); + if ((*t)->recordFlag()) recEnabled.push_back(*t); - } } return recEnabled; } @@ -1368,7 +1324,6 @@ MusECore::TrackList TList::getRecEnabledTracks() void TList::changeAutomation(QAction* act) { - //printf("changeAutomation %d\n", act->data().toInt()); if ( (editAutomation->type() == MusECore::Track::MIDI) || (editAutomation->type() == MusECore::Track::DRUM) || (editAutomation->type() == MusECore::Track::NEW_DRUM) ) { printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n"); return; @@ -1407,8 +1362,6 @@ void TList::changeAutomationColor(QAction* act) // one of these days I'll rewrite this so it's understandable // this is just to get it up and running... - //printf("change automation color %d %d\n", id, colindex); - MusECore::CtrlListList* cll = ((MusECore::AudioTrack*)editAutomation)->controller(); for(MusECore::CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) { MusECore::CtrlList *cl = icll->second; @@ -1421,12 +1374,9 @@ void TList::changeAutomationColor(QAction* act) //--------------------------------------------------------- // colorMenu //--------------------------------------------------------- -//QMenu* TList::colorMenu(QColor c, int id) PopupMenu* TList::colorMenu(QColor c, int id, QWidget* parent) { - //QMenu * m = new QMenu(this); - //PopupMenu * m = new PopupMenu(this); //, true); TODO - PopupMenu * m = new PopupMenu(parent); //, true); // + PopupMenu * m = new PopupMenu(parent); //, true); //TODO for (int i = 0; i< 6; i++) { QPixmap pix(10,10); QPainter p(&pix); @@ -1490,7 +1440,7 @@ void TList::mousePressEvent(QMouseEvent* ev) //delete synp; delete p; } - /*else if (button == Qt::LeftButton) { + /*else if (button == Qt::LeftButton) { DELETETHIS if (!ctrl) { MusEGlobal::song->deselectTracks(); @@ -1514,7 +1464,7 @@ void TList::mousePressEvent(QMouseEvent* ev) ty += h; if (y >= (ty-2)) { - if ( (*it) == tracks->back() && y > ty ) { + if ( (*it) == tracks->back() && y > ty ) { // DELETETHIS, only retain if(foo) break;? //printf("tracks->back() && y > ty\n"); } else if ( y > (ty+2) ) { @@ -1527,7 +1477,7 @@ void TList::mousePressEvent(QMouseEvent* ev) } - //&& y < (ty)) + //&& y < (ty)) DELETETHIS // break; } } @@ -1578,7 +1528,6 @@ void TList::mousePressEvent(QMouseEvent* ev) QAction* act = 0; for(MusECore::CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) { MusECore::CtrlList *cl = icll->second; - //printf("id = %d", cl->id()); if (cl->dontShow()) continue; act = p->addAction(cl->name()); @@ -1587,8 +1536,6 @@ void TList::mousePressEvent(QMouseEvent* ev) int data = cl->id() * 256; // shift 8 bits data += 150; // illegal color > 100 act->setData(data); - //QMenu *m = colorMenu(cl->color(), cl->id()); - //PopupMenu *m = colorMenu(cl->color(), cl->id()); PopupMenu *m = colorMenu(cl->color(), cl->id(), p); act->setMenu(m); } @@ -1649,7 +1596,7 @@ void TList::mousePressEvent(QMouseEvent* ev) classesPopupMenu(t, x, t->y() - ypos); break; case COL_OPORT: - // Changed by Tim. p3.3.9 + // Changed by Tim. p3.3.9 DELETETHIS 15 // Reverted. if (button == Qt::LeftButton) portsPopupMenu(t, x, t->y() - ypos); @@ -1703,13 +1650,11 @@ void TList::mousePressEvent(QMouseEvent* ev) t->setSelected(!t->selected()); if (editTrack && editTrack != t) returnPressed(); - ///emit selectionChanged(); emit selectionChanged(t->selected() ? t : 0); } else if (button == Qt::RightButton) { mode = NORMAL; QMenu* p = new QMenu; - //p->clear(); // Leave room for normal track IDs - base these at AUDIO_SOFTSYNTH. p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(1001); p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(1002); @@ -1753,7 +1698,6 @@ void TList::mousePressEvent(QMouseEvent* ev) { TrackComment* tc = new TrackComment(t, 0); tc->show(); - //QToolTip::add( this, "FOOOOOOOOOOOOO" ); } break; @@ -1845,16 +1789,14 @@ void TList::mousePressEvent(QMouseEvent* ev) channel = MIDI_CHANNELS - 1; if(channel < 0) channel = 0; - //if (channel != ((MusECore::MidiTrack*)t)->outChannel()) if (channel != mt->outChannel()) { // Changed by T356. - //mt->setOutChannel(channel); MusEGlobal::audio->msgIdle(true); - //MusEGlobal::audio->msgSetTrackOutChannel(mt, channel); mt->setOutChanAndUpdate(channel); MusEGlobal::audio->msgIdle(false); + // DELETETHIS 15? /* --- I really don't like this, you can mess up the whole map "as easy as dell" if (mt->type() == MusECore::MidiTrack::DRUM) {//Change channel on all drum instruments for (int i=0; i<DRUM_MAPSIZE; i++) @@ -2179,7 +2121,7 @@ void TList::mouseMoveEvent(QMouseEvent* ev) int h = (*it)->height(); ty += h; if (y >= (ty-2)) { - if ( (*it) == tracks->back() && y >= ty ) { + if ( (*it) == tracks->back() && y >= ty ) { // DELETETHIS and cleanup // outside last track don't change to splitVCursor } else if ( y > (ty+2) ) { @@ -2267,7 +2209,7 @@ void TList::mouseReleaseEvent(QMouseEvent* ev) if (editTrack && editor && editor->isVisible()) editor->setFocus(); //else // DELETETHIS or add the same for ctrl_edit! - //if (editTrack && chan_edit && chan_edit->isVisible()) // p4.0.46 + //if (editTrack && chan_edit && chan_edit->isVisible()) // p4.0.46 DELETETHIS? // chan_edit->setFocus(); adjustScrollbar(); } @@ -2329,15 +2271,11 @@ void TList::wheelEvent(QWheelEvent* ev) else if (port < 0) port = 0; if (port != ((MusECore::MidiTrack*)t)->outPort()) { - // Changed by T356. - //mt->setOutPort(port); MusEGlobal::audio->msgIdle(true); - //MusEGlobal::audio->msgSetTrackOutPort(mt, port); mt->setOutPortAndUpdate(port); MusEGlobal::audio->msgIdle(false); MusEGlobal::audio->msgUpdateSoloStates(); // p4.0.14 - //MusEGlobal::song->update(SC_ROUTE); MusEGlobal::song->update(SC_MIDI_TRACK_PROP); // p4.0.17 } } @@ -2356,10 +2294,7 @@ void TList::wheelEvent(QWheelEvent* ev) else if (channel < 0) channel = 0; if (channel != ((MusECore::MidiTrack*)t)->outChannel()) { - // Changed by T356. - //mt->setOutChannel(channel); MusEGlobal::audio->msgIdle(true); - //MusEGlobal::audio->msgSetTrackOutChannel(mt, channel); mt->setOutChanAndUpdate(channel); MusEGlobal::audio->msgIdle(false); @@ -2473,15 +2408,6 @@ void TList::setYPos(int y) } //--------------------------------------------------------- -// resizeEvent -//--------------------------------------------------------- - -//void TList::resizeEvent(QResizeEvent* /*ev*/) -// { -// -// } - -//--------------------------------------------------------- // classesPopupMenu //--------------------------------------------------------- @@ -2514,7 +2440,7 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y) int pitch = ev.pitch(); // Changed by T356. // Tested: Notes were being mixed up switching back and forth between midi and drum. - //pitch = MusEGlobal::drumMap[pitch].anote; + //pitch = MusEGlobal::drumMap[pitch].anote; DELETETHIS pitch = MusEGlobal::drumMap[pitch].enote; ev.setPitch(pitch); @@ -2546,7 +2472,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y) MusEGlobal::audio->msgIdle(true); // Delete all port controller events. - //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false); MusEGlobal::song->changeAllPortDrumCtrlEvents(false); if (!change) { @@ -2557,7 +2482,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y) } } - //MusEGlobal::audio->msgIdle(true); MusECore::PartList* pl = t->parts(); MusECore::MidiTrack* m = (MusECore::MidiTrack*) t; for (MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) { @@ -2589,7 +2513,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y) t->setType(MusECore::Track::DRUM); // Add all port controller events. - //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true); MusEGlobal::song->changeAllPortDrumCtrlEvents(true); MusEGlobal::audio->msgIdle(false); MusEGlobal::song->update(SC_EVENT_MODIFIED); diff --git a/muse2/muse/arranger/tlist.h b/muse2/muse/arranger/tlist.h index a113d221..ae50058a 100644 --- a/muse2/muse/arranger/tlist.h +++ b/muse2/muse/arranger/tlist.h @@ -33,10 +33,8 @@ class QLineEdit; class QSpinBox; class QMouseEvent; class QPaintEvent; -class QResizeEvent; class QScrollBar; class QWheelEvent; -//class QMenu; namespace MusECore { class Track; @@ -107,18 +105,15 @@ class TList : public QWidget { void moveSelection(int n); void adjustScrollbar(); void paint(const QRect& r); - //virtual void resizeEvent(QResizeEvent*); void redraw(const QRect& r); MusECore::Track* y2Track(int) const; void classesPopupMenu(MusECore::Track*, int x, int y); MusECore::TrackList getRecEnabledTracks(); void setHeaderToolTips(); - //QMenu* colorMenu(QColor c, int id); PopupMenu* colorMenu(QColor c, int id, QWidget* parent); private slots: void returnPressed(); - void chanValueChanged(int); void chanValueFinished(); void ctrlValueFinished(); void instrPopupActivated(QAction*); @@ -130,7 +125,6 @@ class TList : public QWidget { void copyTrackDrummap(MusECore::MidiTrack*, bool full); signals: - ///void selectionChanged(); void selectionChanged(MusECore::Track*); void keyPressExt(QKeyEvent*); void redirectWheelEvent(QWheelEvent*); |