From: werner s. <wsc...@us...> - 2005-10-18 19:42:00
|
Update of /cvsroot/lmuse/muse/awl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9360/awl Modified Files: tcanvas.cpp tcanvas.h Log Message: updates Index: tcanvas.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/awl/tcanvas.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** tcanvas.cpp 13 Oct 2005 20:53:04 -0000 1.19 --- tcanvas.cpp 18 Oct 2005 19:41:40 -0000 1.20 *************** *** 38,41 **** --- 38,42 ---- keyDown = -1; showCursor = false; + ctrlHeight = 0; if (clockIcon == 0) { *************** *** 81,100 **** setTimeType(AL::TICKS); if (type == TIME_CANVAS_PIANOROLL) { _ymagMin = 0.5; _ymagMax = 3.0; _ymag = 1.0; vmag->setValue(lrint((_ymag-_ymagMin)*100.0/(_ymagMax-_ymagMin))); initPianoroll(); addCtrlButton = new QPushButton(tr("Ctrl"), _widget); ! addCtrlButton->setGeometry(0, 0, pianoWidth, rulerHeight); addCtrlButton->setToolTip(tr("Add Controller View")); ! connect(addCtrlButton, SIGNAL(clicked()), SLOT(addCtrl())); } else if (type == TIME_CANVAS_DRUMEDIT) { _ymagMin = 1.0; _ymagMax = 1.0; view.setHeight(drumHeight * 128); } grid->addWidget(_widget, 0, 0, 3, 2); --- 82,110 ---- setTimeType(AL::TICKS); + int w = 0; if (type == TIME_CANVAS_PIANOROLL) { _ymagMin = 0.5; _ymagMax = 3.0; _ymag = 1.0; + w = pianoWidth; vmag->setValue(lrint((_ymag-_ymagMin)*100.0/(_ymagMax-_ymagMin))); initPianoroll(); addCtrlButton = new QPushButton(tr("Ctrl"), _widget); ! addCtrlButton->setGeometry(0, 0, w, rulerHeight); addCtrlButton->setToolTip(tr("Add Controller View")); ! connect(addCtrlButton, SIGNAL(clicked()), SLOT(addCtrlClicked())); } else if (type == TIME_CANVAS_DRUMEDIT) { _ymagMin = 1.0; _ymagMax = 1.0; + w = drumWidth; view.setHeight(drumHeight * 128); } + if (type == TIME_CANVAS_PIANOROLL || type == TIME_CANVAS_DRUMEDIT) { + addCtrlButton = new QPushButton(tr("Ctrl"), _widget); + addCtrlButton->setGeometry(0, 0, w, rulerHeight-1); + addCtrlButton->setToolTip(tr("Add Controller View")); + connect(addCtrlButton, SIGNAL(clicked()), SLOT(addCtrlClicked())); + } grid->addWidget(_widget, 0, 0, 3, 2); *************** *** 120,123 **** --- 130,147 ---- //--------------------------------------------------------- + // showController + //--------------------------------------------------------- + + void TimeCanvas::resizeController(int h) + { + if (h == ctrlHeight) + return; + int updateH = h > ctrlHeight ? h : ctrlHeight; + ctrlHeight = h; + updateGeometry(); + widget()->update(0, widget()->height() - updateH, widget()->width(), updateH); + } + + //--------------------------------------------------------- // eventFilter //--------------------------------------------------------- *************** *** 128,147 **** return QFrame::eventFilter(obj, event); - int wh = _widget->height(); - int ww = _widget->width(); - - QRect rPiano(0, rulerHeight, pianoWidth, wh - rulerHeight); - QRect rRuler(0, 0, ww, rulerHeight); - QRect rCanvas(0, rulerHeight, ww, wh - rulerHeight); - - if (type == TIME_CANVAS_PIANOROLL) { - rRuler.setLeft(pianoWidth); - rCanvas.setLeft(pianoWidth); - } - else if (type == TIME_CANVAS_DRUMEDIT) { - rRuler.setLeft(drumWidth); - rCanvas.setLeft(drumWidth); - } - switch(event->type()) { case QEvent::Paint: --- 152,155 ---- *************** *** 150,153 **** --- 158,162 ---- case QEvent::Resize: + updateGeometry(); updateScrollBars(); return false; *************** *** 171,175 **** else { if (type == TIME_CANVAS_PIANOROLL) { ! if (rCanvas.contains(me->pos())) { QPoint p( lrint((x - MAP_OFFSET - pianoWidth + wpos.x()) / _xmag), --- 180,184 ---- else { if (type == TIME_CANVAS_PIANOROLL) { ! if (rCanvasA.contains(me->pos())) { QPoint p( lrint((x - MAP_OFFSET - pianoWidth + wpos.x()) / _xmag), *************** *** 177,181 **** ); } ! else if (rPiano.contains(me->pos())) { if (keyDown != -1) { pianoReleased(keyDown, shift); --- 186,190 ---- ); } ! else if (rPanelA.contains(me->pos())) { if (keyDown != -1) { pianoReleased(keyDown, shift); *************** *** 207,211 **** if (curPitch != pitch) { curPitch = pitch; ! widget()->update(0, 0, pianoWidth, wh); emit pitchChanged(curPitch); if (button != Qt::NoButton) { --- 216,220 ---- if (curPitch != pitch) { curPitch = pitch; ! widget()->update(rPanelA); emit pitchChanged(curPitch); if (button != Qt::NoButton) { *************** *** 247,251 **** return true; } ! else if (rCanvas.contains(me->pos())) { if (!(cursor == pos)) { cursor = pos; --- 256,260 ---- return true; } ! else if (rCanvasA.contains(me->pos())) { if (!(cursor == pos)) { cursor = pos; *************** *** 269,273 **** int x = me->pos().x(); if (type == TIME_CANVAS_PIANOROLL) { ! if (rCanvas.contains(me->pos())) { QPoint p( lrint((x - MAP_OFFSET - pianoWidth + wpos.x()) / _xmag), --- 278,282 ---- int x = me->pos().x(); if (type == TIME_CANVAS_PIANOROLL) { ! if (rCanvasA.contains(me->pos())) { QPoint p( lrint((x - MAP_OFFSET - pianoWidth + wpos.x()) / _xmag), *************** *** 276,280 **** mouseRelease(p); } ! else if (rPiano.contains(me->pos())) { if (keyDown != -1) { pianoReleased(keyDown, shift); --- 285,289 ---- mouseRelease(p); } ! else if (rPanelA.contains(me->pos())) { if (keyDown != -1) { pianoReleased(keyDown, shift); *************** *** 329,333 **** showCursor = false; emit pitchChanged(-1); ! widget()->update(rPiano); curPitch = -1; return false; --- 338,342 ---- showCursor = false; emit pitchChanged(-1); ! widget()->update(rPanelA); curPitch = -1; return false; *************** *** 376,380 **** int ww = _widget->width(); int wh = _widget->height(); ! QRect r(0, rulerHeight, ww, wh - rulerHeight); _widget->scroll(0, dy, r); --- 385,389 ---- int ww = _widget->width(); int wh = _widget->height(); ! QRect r(0, rulerHeight, ww, wh - rulerHeight - ctrlHeight); _widget->scroll(0, dy, r); *************** *** 640,682 **** QRect r(ev->rect()); - // printf("canvasPaintEvent %d %d %d %d\n", r.x(), r.y(), r.width(), r.height()); - QPainter p(_widget); p.setRenderHint(QPainter::TextAntialiasing, true); p.setRenderHint(QPainter::SmoothPixmapTransform, true); ! int wh = _widget->height(); ! int ww = _widget->width(); ! QRect rPiano (0, rulerHeight, pianoWidth, wh - rulerHeight); ! QRect rRuler (0, 0, ww, rulerHeight); ! QRect rCanvas(0, rulerHeight, ww, wh - rulerHeight); ! QRect rDrum (0, 0, drumWidth, wh); ! ! //--------------------------------------------------- ! // draw Drum Instrument List ! // draw Piano ! //--------------------------------------------------- ! ! if (type == TIME_CANVAS_DRUMEDIT) { ! QRect pr = r & rDrum; ! if (!pr.isEmpty()) { ! p.fillRect(pr, QColor(0xe0, 0xe0, 0xe0)); ! paintDrumList(p, pr); } - rRuler.setLeft(drumWidth); - rCanvas.setLeft(drumWidth); - } - else if (type == TIME_CANVAS_PIANOROLL) { - QRect pr = r & rPiano; - if (!pr.isEmpty()) - paintPiano(p, pr); - rRuler.setLeft(pianoWidth); - rCanvas.setLeft(pianoWidth); } ! QRect cr(r & rCanvas); ! bool drawCanvas = !cr.isEmpty(); ! if (drawCanvas) ! p.fillRect(cr, QColor(0x71, 0x8d, 0xbe)); //--------------------------------------------------- --- 649,687 ---- QRect r(ev->rect()); QPainter p(_widget); p.setRenderHint(QPainter::TextAntialiasing, true); p.setRenderHint(QPainter::SmoothPixmapTransform, true); ! QRect par = r & rPanelA; ! if (!(par.isEmpty() || rPanelA.isEmpty())) { ! p.setClipRect(par); ! if (type == TIME_CANVAS_DRUMEDIT) { ! p.fillRect(par, QColor(0xe0, 0xe0, 0xe0)); ! paintDrumList(p, par); ! } ! else if (type == TIME_CANVAS_PIANOROLL) { ! paintPiano(p, par); } } ! QRect pbr(r & rPanelB); ! QRect hor(r & (rRuler | rCanvasA | rCanvasB)); ! QRect car(r & rCanvasA); ! QRect cbr(r & rCanvasB); ! ! bool drawPanelB = !(pbr.isEmpty() || rPanelB.isEmpty()); ! bool drawRuler = !(hor.isEmpty() || (rRuler.isEmpty() && rCanvasA.isEmpty() && rCanvasB.isEmpty())); ! bool drawCanvasA = !(car.isEmpty() || rCanvasA.isEmpty()); ! bool drawCanvasB = !(cbr.isEmpty() || rCanvasB.isEmpty()); ! ! p.setClipRect(r); ! ! // ! // draw canvas background ! // ! if (drawCanvasA) ! p.fillRect(car, QColor(0x71, 0x8d, 0xbe)); ! if (drawCanvasB) ! p.fillRect(cbr, QColor(0x71, 0x8d, 0xbe)); //--------------------------------------------------- *************** *** 684,698 **** //--------------------------------------------------- - QRect rr(r & (rRuler | rCanvas)); - bool drawRuler = !rr.isEmpty(); - if (drawRuler) { QRect rrr(r & rRuler); if (!rrr.isEmpty()) p.fillRect(rrr, QColor(0xe0, 0xe0, 0xe0)); ! p.setClipRect(rr); ! int x1 = rr.x(); ! int x2 = x1 + rr.width(); int y1 = rulerHeight - 17; int y2 = rulerHeight - 1; --- 689,700 ---- //--------------------------------------------------- if (drawRuler) { QRect rrr(r & rRuler); if (!rrr.isEmpty()) p.fillRect(rrr, QColor(0xe0, 0xe0, 0xe0)); ! p.setClipRect(hor); ! int x1 = hor.x(); ! int x2 = x1 + hor.width(); int y1 = rulerHeight - 17; int y2 = rulerHeight - 1; *************** *** 704,718 **** if (_timeType == AL::TICKS) ! paintMetronomRuler(p, rr); else ! paintClockRuler(p, rr); } ! if (drawCanvas) { ! // p.setClipRect(cr); ! paintCanvas(p, cr); } ! p.setClipRect(cr | rr); int w = r.width(); int x = r.x(); --- 706,735 ---- if (_timeType == AL::TICKS) ! paintMetronomRuler(p, hor); else ! paintClockRuler(p, hor); } ! if (drawCanvasA) { ! p.setClipRect(car); ! paintCanvas(p, car); ! } ! p.setRenderHint(QPainter::Antialiasing, false); ! if (drawPanelB) { ! p.setClipRect(pbr); ! QPoint off(rPanelB.topLeft()); ! p.translate(off); ! paintControllerPanel(p, pbr.translated(-off)); ! p.translate(-off); ! } ! if (drawCanvasB) { ! p.setClipRect(cbr); ! QPoint off(rCanvasB.topLeft()); ! p.translate(off); ! paintControllerCanvas(p, cbr.translated(-off)); ! p.translate(-off); } ! p.setClipRect(hor); int w = r.width(); int x = r.x(); *************** *** 1355,1367 **** //--------------------------------------------------------- - // addCtrl - //--------------------------------------------------------- - - void TimeCanvas::addCtrl() - { - printf("add Ctrl\n"); - } - - //--------------------------------------------------------- // paintPiano //--------------------------------------------------------- --- 1372,1375 ---- *************** *** 1371,1380 **** // printf("paint piano %d %d %d %d\n", r.x(), r.y(), r.width(), r.height()); ! int d = int(_ymag + 1); qreal x = qreal(r.x()); qreal y = (r.y()-rulerHeight-d) / _ymag; if (y < 0.0) y = 0.0; ! qreal h = (r.height()+d+d) / _ymag; QPointF offset(x, wpos.y() / _ymag + keyHeight * 2 + y); --- 1379,1389 ---- // printf("paint piano %d %d %d %d\n", r.x(), r.y(), r.width(), r.height()); ! // p.setClipRect(r); ! int d = int(_ymag)+1; qreal x = qreal(r.x()); qreal y = (r.y()-rulerHeight-d) / _ymag; if (y < 0.0) y = 0.0; ! qreal h = (r.height()+d) / _ymag; QPointF offset(x, wpos.y() / _ymag + keyHeight * 2 + y); *************** *** 1480,1481 **** --- 1489,1525 ---- } + //--------------------------------------------------------- + // addCtrlClicked + //--------------------------------------------------------- + + void TimeCanvas::addCtrlClicked() + { + addController(); + } + + //--------------------------------------------------------- + // updateGeometry + //--------------------------------------------------------- + + void TimeCanvas::updateGeometry() + { + int wh = _widget->height(); + int ww = _widget->width(); + int ch = (wh < ctrlHeight) ? wh : ctrlHeight; + + int x1 = 0; + if (type == TIME_CANVAS_PIANOROLL) + x1 = pianoWidth; + else if (type == TIME_CANVAS_DRUMEDIT) + x1 = drumWidth; + int y2 = wh - ctrlHeight; + + rPanelA.setRect(0, rulerHeight, x1, wh - rulerHeight - ch); + rPanelB.setRect(0, y2, x1, ch); + + int cw = ww - x1; + rRuler.setRect( x1, 0, cw, rulerHeight); + rCanvasA.setRect(x1, rulerHeight, cw, wh - rulerHeight - ch); + rCanvasB.setRect(x1, y2, cw, ch); + } + Index: tcanvas.h =================================================================== RCS file: /cvsroot/lmuse/muse/awl/tcanvas.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcanvas.h 13 Oct 2005 20:53:04 -0000 1.18 --- tcanvas.h 18 Oct 2005 19:41:40 -0000 1.19 *************** *** 27,30 **** --- 27,42 ---- //--------------------------------------------------------- // TimeCanvas + // + // Layout: + // Button Ruler + // panelA canvasA + // panelB canvasB + // + // Pianoroll: + // panelA -> keyboard + // + // Drumeditor: + // panelA -> instrument list + // //--------------------------------------------------------- *************** *** 32,37 **** Q_OBJECT - TimeCanvasType type; - QRect view; // virtual viewport of "widget" // used to calculate scroll bars --- 44,47 ---- *************** *** 68,78 **** void paintMetronomRuler(QPainter&, const QRect&); void paintClockRuler(QPainter&, const QRect&); - void initPianoroll(); void paintPiano(QPainter&, QRect); void paintPianorollHorizontalGrid(QPainter&, QRect); void paintDrumeditHorizontalGrid(QPainter&, QRect); protected: AL::Pos pos[3]; bool showCursor; --- 78,90 ---- void paintMetronomRuler(QPainter&, const QRect&); void paintClockRuler(QPainter&, const QRect&); void initPianoroll(); void paintPiano(QPainter&, QRect); void paintPianorollHorizontalGrid(QPainter&, QRect); void paintDrumeditHorizontalGrid(QPainter&, QRect); + void updateGeometry(); protected: + TimeCanvasType type; + QRect rPanelA, rPanelB, rRuler, rCanvasA, rCanvasB; AL::Pos pos[3]; bool showCursor; *************** *** 84,87 **** --- 96,101 ---- double _xmag, _ymag; + int ctrlHeight; + int raster; int button; *************** *** 99,102 **** --- 113,119 ---- virtual void paintDrumList(QPainter&, QRect) {} + virtual void paintControllerCanvas(QPainter&, QRect) {} + virtual void paintControllerPanel(QPainter&, QRect) {} + virtual void dragEnter(QDragEnterEvent*, const QPoint&) {} virtual void drop(QDropEvent*, const QPoint&) {} *************** *** 104,107 **** --- 121,126 ---- virtual void dragLeave(QDragLeaveEvent*) {} + virtual void addController() {} + // map logical coordinates to physical coordinates (pixel) int mapx(int x) const; *************** *** 143,147 **** void scaleY(int); void toggleTimeType(); ! void addCtrl(); signals: --- 162,166 ---- void scaleY(int); void toggleTimeType(); ! void addCtrlClicked(); signals: *************** *** 174,177 **** --- 193,197 ---- void setMarkerList(AL::MarkerList*); void setCornerWidget(QWidget* w); + void resizeController(int); }; |