From: terminator356 <ter...@us...> - 2008-01-26 07:23:32
|
Update of /cvsroot/lmuse/muse/muse/widgets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13094/muse/widgets Modified Files: Tag: REL07 bigtime.cpp bigtime.h canvas.cpp canvas.h citem.cpp mtscale.cpp scrollscale.cpp scrollscale.h view.h Log Message: By terminator356. See ChangeLog Index: bigtime.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/bigtime.cpp,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** bigtime.cpp 17 Jan 2004 16:56:25 -0000 1.4 --- bigtime.cpp 26 Jan 2008 07:23:21 -0000 1.4.2.1 *************** *** 6,9 **** --- 6,10 ---- #include <values.h> + #include <qtooltip.h> #include "globals.h" #include "bigtime.h" *************** *** 26,44 **** : QWidget(parent, 0, WType_TopLevel | WStyle_StaysOnTop) { ! barLabel = new QLabel(this); ! beatLabel = new QLabel(this); ! tickLabel = new QLabel(this); ! hourLabel = new QLabel(this); ! minLabel = new QLabel(this); ! secLabel = new QLabel(this); ! frameLabel = new QLabel(this); ! sep1 = new QLabel(QString("."), this); ! sep2 = new QLabel(QString("."), this); ! sep3 = new QLabel(QString(":"), this); ! sep4 = new QLabel(QString(":"), this); ! sep5 = new QLabel(QString(":"), this); ! oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; ! setString(MAXINT); --- 27,65 ---- : QWidget(parent, 0, WType_TopLevel | WStyle_StaysOnTop) { ! ! tickmode = true; ! dwin = new QWidget(this, "bigtime-dwin", WStyle_StaysOnTop); ! dwin->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); ! fmtButton = new QCheckBox(QString(""), this); ! fmtButton->resize(18,18); ! fmtButton->setChecked(true); ! QToolTip::add(fmtButton, tr("format display")); ! barLabel = new QLabel(dwin); ! beatLabel = new QLabel(dwin); ! tickLabel = new QLabel(dwin); ! hourLabel = new QLabel(dwin); ! minLabel = new QLabel(dwin); ! secLabel = new QLabel(dwin); ! frameLabel = new QLabel(dwin); ! sep1 = new QLabel(QString("."), dwin); ! sep2 = new QLabel(QString("."), dwin); ! sep3 = new QLabel(QString(":"), dwin); ! sep4 = new QLabel(QString(":"), dwin); ! sep5 = new QLabel(QString(":"), dwin); ! absTickLabel = new QLabel(dwin); ! absFrameLabel = new QLabel(dwin); ! QToolTip::add(barLabel, tr("bar")); ! QToolTip::add(beatLabel, tr("beat")); ! QToolTip::add(tickLabel, tr("tick")); ! QToolTip::add(hourLabel, tr("hour")); ! QToolTip::add(minLabel, tr("minute")); ! QToolTip::add(secLabel, tr("second")); ! QToolTip::add(frameLabel, tr("frame")); ! QToolTip::add(absTickLabel, tr("tick")); ! QToolTip::add(absFrameLabel, tr("frame")); ! fmtButtonToggled(true); ! connect(fmtButton, SIGNAL(toggled(bool)), SLOT(fmtButtonToggled(bool))); oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; ! oldAbsTick = oldAbsFrame = -1; setString(MAXINT); *************** *** 47,54 **** QFont f(QString("Courier")); f.setPixelSize(10); ! setFont(f); setCaption(tr("MusE: Bigtime")); } //--------------------------------------------------------- // configChanged --- 68,153 ---- QFont f(QString("Courier")); f.setPixelSize(10); ! ! dwin->setFont(f); setCaption(tr("MusE: Bigtime")); } + + //--------------------------------------------------------- + // fmtButtonToggled + //--------------------------------------------------------- + + void BigTime::fmtButtonToggled(bool v) + { + if(v) + { + tickmode = true; + + barLabel->setEnabled(true); + beatLabel->setEnabled(true); + tickLabel->setEnabled(true); + hourLabel->setEnabled(true); + minLabel->setEnabled(true); + secLabel->setEnabled(true); + frameLabel->setEnabled(true); + sep1->setEnabled(true); + sep2->setEnabled(true); + sep3->setEnabled(true); + sep4->setEnabled(true); + sep5->setEnabled(true); + absTickLabel->setEnabled(false); + absFrameLabel->setEnabled(false); + + barLabel->show(); + beatLabel->show(); + tickLabel->show(); + hourLabel->show(); + minLabel->show(); + secLabel->show(); + frameLabel->show(); + sep1->show(); + sep2->show(); + sep3->show(); + sep4->show(); + sep5->show(); + absTickLabel->hide(); + absFrameLabel->hide(); + } + else + { + tickmode = false; + + barLabel->setEnabled(false); + beatLabel->setEnabled(false); + tickLabel->setEnabled(false); + hourLabel->setEnabled(false); + minLabel->setEnabled(false); + secLabel->setEnabled(false); + frameLabel->setEnabled(false); + sep1->setEnabled(false); + sep2->setEnabled(false); + sep3->setEnabled(false); + sep4->setEnabled(false); + sep5->setEnabled(false); + absTickLabel->setEnabled(true); + absFrameLabel->setEnabled(true); + + barLabel->hide(); + beatLabel->hide(); + tickLabel->hide(); + hourLabel->hide(); + minLabel->hide(); + secLabel->hide(); + frameLabel->hide(); + sep1->hide(); + sep2->hide(); + sep3->hide(); + sep4->hide(); + sep5->hide(); + absTickLabel->show(); + absFrameLabel->show(); + } + } + //--------------------------------------------------------- // configChanged *************** *** 85,97 **** secLabel->setText(QString("--")); frameLabel->setText(QString("--")); oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; return true; } int bar, beat; unsigned tick; sigmap.tickValues(v, &bar, &beat, &tick); ! ! double time = double(tempomap.tick2frame(v))/double(sampleRate); int hour = int(time) / 3600; int min = (int(time) / 60) % 60; --- 184,200 ---- secLabel->setText(QString("--")); frameLabel->setText(QString("--")); + + absTickLabel->setText(QString("----------")); + absFrameLabel->setText(QString("----------")); + oldAbsTick = oldAbsFrame = -1; oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1; return true; } + unsigned absFrame = tempomap.tick2frame(v); int bar, beat; unsigned tick; sigmap.tickValues(v, &bar, &beat, &tick); ! double time = double(absFrame)/double(sampleRate); int hour = int(time) / 3600; int min = (int(time) / 60) % 60; *************** *** 117,120 **** --- 220,233 ---- QString s; + if(oldAbsTick != v) { + s.sprintf("%012d", v); + absTickLabel->setText(s); + oldAbsTick = v; + } + if(oldAbsFrame != absFrame) { + s.sprintf("%012d", absFrame); + absFrameLabel->setText(s); + oldAbsFrame = absFrame; + } if(oldbar != bar) { s.sprintf("%04d", bar+1); *************** *** 178,188 **** void BigTime::resizeEvent(QResizeEvent *ev) { ! QFont f = font(); QFontMetrics fm(f); int fs = f.pixelSize(); int hspace = 20; int tw = fm.width(QString("00:00:00:00")); fs = ((ev->size().width() - hspace*2)*fs) / tw; - // printf("resize BigTime %d -> %d, w %d\n", fs, nfs, ev->size().width()); --- 291,302 ---- void BigTime::resizeEvent(QResizeEvent *ev) { ! dwin->resize(ev->size()); ! QFont f = dwin->font(); QFontMetrics fm(f); int fs = f.pixelSize(); int hspace = 20; int tw = fm.width(QString("00:00:00:00")); + fs = ((ev->size().width() - hspace*2)*fs) / tw; // printf("resize BigTime %d -> %d, w %d\n", fs, nfs, ev->size().width()); *************** *** 193,204 **** fs = 256; f.setPixelSize(fs); - setFont(f); - - int digitWidth = fontMetrics().width(QString("0")); int vspace = (ev->size().height() - (fs*2)) / 3; ! int tickY = vspace; int timeY = vspace*2 + fs; ! barLabel->resize(digitWidth*4, fs); beatLabel->resize(digitWidth*2, fs); --- 307,320 ---- fs = 256; f.setPixelSize(fs); + + dwin->setFont(f); + int digitWidth = dwin->fontMetrics().width(QString("0")); int vspace = (ev->size().height() - (fs*2)) / 3; ! int tickY = vspace; ! int timeY = vspace*2 + fs; ! int absTickY = tickY; ! int absFrameY = timeY; barLabel->resize(digitWidth*4, fs); beatLabel->resize(digitWidth*2, fs); *************** *** 209,213 **** frameLabel->resize(digitWidth*2, fs); ! sep1->resize(digitWidth, fs); sep2->resize(digitWidth, fs); sep3->resize(digitWidth, fs); --- 325,331 ---- frameLabel->resize(digitWidth*2, fs); ! absTickLabel->resize(digitWidth*10, fs); ! absFrameLabel->resize(digitWidth*10, fs); ! sep1->resize(digitWidth, fs); sep2->resize(digitWidth, fs); sep3->resize(digitWidth, fs); *************** *** 228,231 **** --- 346,352 ---- sep5->move( hspace + (digitWidth*8), timeY); frameLabel->move( hspace + (digitWidth*9), timeY); + + absTickLabel->move( hspace + (digitWidth*0), absTickY); + absFrameLabel->move( hspace + (digitWidth*0), absFrameY); } *************** *** 249,252 **** --- 370,375 ---- frameLabel->setPalette(newpalette); + absTickLabel->setPalette(newpalette); + absFrameLabel->setPalette(newpalette); sep1->setPalette(newpalette); sep2->setPalette(newpalette); *************** *** 275,278 **** --- 398,403 ---- frameLabel->setPalette(newpalette); + absTickLabel->setPalette(newpalette); + absFrameLabel->setPalette(newpalette); sep1->setPalette(newpalette); sep2->setPalette(newpalette); Index: scrollscale.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/scrollscale.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** scrollscale.h 11 Jan 2004 21:59:40 -0000 1.2 --- scrollscale.h 26 Jan 2008 07:23:21 -0000 1.2.2.1 *************** *** 48,51 **** --- 48,52 ---- public slots: void setPos(unsigned); + void setPosNoLimit(unsigned); // Added by Tim. p3.2.9 void setMag(int); void setOffset(int val); *************** *** 75,78 **** --- 76,82 ---- int getScaleValue() const { return scaleVal; } void range(int* b, int* e) const { *b = minVal; *e = maxVal; } + + int offset(); + int pos2offset(int pos); }; Index: canvas.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/canvas.h,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -C2 -d -r1.3.2.6 -r1.3.2.7 *** canvas.h 10 Nov 2006 22:12:05 -0000 1.3.2.6 --- canvas.h 26 Jan 2008 07:23:21 -0000 1.3.2.7 *************** *** 23,30 **** int canvasTools; QTimer *scrollTimer; ! bool scrollRight; bool doScroll; int scrollSpeed; protected: enum DragMode { --- 23,35 ---- int canvasTools; QTimer *scrollTimer; ! bool doScroll; int scrollSpeed; + QPoint ev_pos; + bool canScrollLeft; + bool canScrollRight; + bool canScrollUp; + bool canScrollDown; protected: enum DragMode { *************** *** 44,47 **** --- 49,58 ---- }; + enum HScrollDir { + HSCROLL_NONE, HSCROLL_LEFT, HSCROLL_RIGHT + }; + enum VScrollDir { + VSCROLL_NONE, VSCROLL_UP, VSCROLL_DOWN + }; CItemList items; CItemList moving; *************** *** 55,59 **** Tool _tool; unsigned pos[3]; ! int yOffset; int keyState; QPopupMenu* itemPopupMenu; --- 66,72 ---- Tool _tool; unsigned pos[3]; ! ! HScrollDir hscrollDir; ! VScrollDir vscrollDir; int keyState; QPopupMenu* itemPopupMenu; *************** *** 74,77 **** --- 87,91 ---- virtual void drawCanvas(QPainter&, const QRect&) = 0; virtual void drawItem(QPainter&, const CItem*, const QRect&) = 0; + virtual void drawMoving(QPainter&, const CItem*, const QRect&) = 0; virtual void updateSelection() = 0; virtual QPoint raster(const QPoint&) const = 0; *************** *** 79,83 **** virtual int pitch2y(int) const = 0; //CDW ! virtual bool moveItem(CItem*, const QPoint&, DragType) = 0; virtual CItem* newItem(const QPoint&, int state) = 0; virtual void resizeItem(CItem*, bool noSnap=false) = 0; --- 93,97 ---- virtual int pitch2y(int) const = 0; //CDW ! virtual bool moveItem(CItem*, const QPoint&, DragType, int*) = 0; virtual CItem* newItem(const QPoint&, int state) = 0; virtual void resizeItem(CItem*, bool noSnap=false) = 0; *************** *** 85,89 **** virtual bool deleteItem(CItem*) = 0; virtual void startUndo(DragType) = 0; ! virtual void endUndo(DragType) = 0; int getCurrentDrag(); --- 99,104 ---- virtual bool deleteItem(CItem*) = 0; virtual void startUndo(DragType) = 0; ! ! virtual void endUndo(DragType, int flags) = 0; int getCurrentDrag(); *************** *** 126,130 **** // moving void startMoving(const QPoint&, DragType); ! void moveItems(const QPoint&, int dir); void endMoveItems(const QPoint&, DragType, int dir); --- 141,146 ---- // moving void startMoving(const QPoint&, DragType); ! ! void moveItems(const QPoint&, int dir, bool rasterize = true); void endMoveItems(const QPoint&, DragType, int dir); *************** *** 147,151 **** void verticalScroll(unsigned); void horizontalScroll(unsigned); ! public: Canvas(QWidget* parent, int sx, int sy, const char* name = 0); --- 163,167 ---- void verticalScroll(unsigned); void horizontalScroll(unsigned); ! void horizontalScrollNoLimit(unsigned); public: Canvas(QWidget* parent, int sx, int sy, const char* name = 0); Index: citem.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/citem.cpp,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** citem.cpp 21 Aug 2007 01:00:57 -0000 1.2.2.2 --- citem.cpp 26 Jan 2008 07:23:21 -0000 1.2.2.3 *************** *** 57,75 **** CItem* CItemList::find(const QPoint& pos) const { - // Added by Tim. p3.2.5 rciCItem ius; bool usfound = false; - for (rciCItem i = rbegin(); i != rend(); ++i) { if (i->second->contains(pos)) { - // Added by Tim. p3.2.5 - // Prefer selected over non-selected. if(i->second->isSelected()) - return i->second; - // Added by Tim. p3.2.5 - // Remember the first unselected item in case no selected found. else { --- 57,68 ---- *************** *** 82,91 **** } } - - // Added by Tim. p3.2.5 if(usfound) return ius->second; else - return 0; } --- 75,81 ---- Index: canvas.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/canvas.cpp,v retrieving revision 1.10.2.12 retrieving revision 1.10.2.13 diff -C2 -d -r1.10.2.12 -r1.10.2.13 *** canvas.cpp 20 Jan 2008 21:05:41 -0000 1.10.2.12 --- canvas.cpp 26 Jan 2008 07:23:21 -0000 1.10.2.13 *************** *** 32,38 **** canvasTools = 0; itemPopupMenu = 0; ! scrollTimer=NULL; ! scrollRight=true; // scrolling to the right is default scrollSpeed=10; // hardcoded scroll jump --- 32,44 ---- canvasTools = 0; itemPopupMenu = 0; ! ! canScrollLeft = true; ! canScrollRight = true; ! canScrollUp = true; ! canScrollDown = true; ! hscrollDir = HSCROLL_NONE; ! vscrollDir = VSCROLL_NONE; scrollTimer=NULL; ! scrollSpeed=10; // hardcoded scroll jump *************** *** 142,172 **** iCItem to(items.lower_bound(x2)); ! for (iCItem i = items.begin(); i != to; ++i) { ! // Added by Tim. p3.2.5 ! // To draw selected parts in front. ! if (i->second->isSelected()) ! continue; ! ! if (i->second->intersects(rect)) ! drawItem(p, i->second, i->second->bbox().intersect(rect)); ! } ! // Added by Tim. p3.2.5 ! // To draw selected parts in front. ! for (iCItem i = items.begin(); i != to; ++i) { ! if (i->second->isSelected() && i->second->intersects(rect)) ! drawItem(p, i->second, i->second->bbox().intersect(rect)); ! } ! to = moving.lower_bound(x2); ! for (iCItem i = moving.begin(); i != to; ++i) { ! if (i->second->intersects(rect)) ! drawItem(p, i->second, i->second->bbox().intersect(rect)); } - } ! else { p.save(); setPainter(p); ! if (xmag <= 0) { x -= 1; --- 148,192 ---- iCItem to(items.lower_bound(x2)); ! ! // Draw items from other parts behind all others. ! // Only for items with events (not arranger parts). ! for(iCItem i = items.begin(); i != to; ++i) ! { ! CItem* ci = i->second; ! if(!ci->event().empty() && ci->part() != curPart) ! { ! drawItem(p, ci, rect); ! } ! } ! ! for (iCItem i = items.begin(); i != to; ++i) ! { ! CItem* ci = i->second; ! // Draw unselected parts behind selected. ! if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) ! { ! drawItem(p, ci, rect); ! } ! } ! ! // Draw selected parts in front of unselected. ! for (iCItem i = items.begin(); i != to; ++i) ! { ! CItem* ci = i->second; ! if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) ! { ! drawItem(p, ci, rect); ! } ! } to = moving.lower_bound(x2); ! for (iCItem i = moving.begin(); i != to; ++i) ! { ! drawItem(p, i->second, rect); } } ! else { p.save(); setPainter(p); ! if (xmag <= 0) { x -= 1; *************** *** 206,240 **** // draw Canvas Items //--------------------------------------------------- ! for (iCItem i = items.begin(); i != items.end(); ++i) { CItem* ci = i->second; ! // Added by Tim. p3.2.5 ! // To draw selected parts in front. ! if(ci->isSelected()) ! continue; ! ! QRect r(ci->bbox()); ! r.moveCenter(map((ci->pos()))); ! if (r.intersects(rect)) drawItem(p, ci, rect); } ! // Added by Tim. p3.2.5 ! // To draw selected parts in front. for (iCItem i = items.begin(); i != items.end(); ++i) { CItem* ci = i->second; ! if(!ci->isSelected()) ! continue; ! QRect r(ci->bbox()); ! r.moveCenter(map((ci->pos()))); ! if (r.intersects(rect)) drawItem(p, ci, rect); ! } ! ! for (iCItem i = moving.begin(); i != moving.end(); ++i) { ! QRect r(i->second->bbox()); ! r.moveCenter(map(i->second->pos())); ! if (r.intersects(rect)) drawItem(p, i->second, rect); } setPainter(p); } --- 226,263 ---- // draw Canvas Items //--------------------------------------------------- ! ! // Draw items from other parts behind all others. ! // Only for items with events (not arranger parts). ! for(iCItem i = items.begin(); i != items.end(); ++i) ! { ! CItem* ci = i->second; ! if(!ci->event().empty() && ci->part() != curPart) ! { ! drawItem(p, ci, rect); ! } ! } ! for (iCItem i = items.begin(); i != items.end(); ++i) { CItem* ci = i->second; ! // Draw unselected parts behind selected. ! if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) ! { drawItem(p, ci, rect); + } } ! ! // Draw selected parts in front of unselected. for (iCItem i = items.begin(); i != items.end(); ++i) { CItem* ci = i->second; ! if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart)) ! { drawItem(p, ci, rect); ! } ! } ! for (iCItem i = moving.begin(); i != moving.end(); ++i) ! { drawItem(p, i->second, rect); } + p.save(); setPainter(p); } *************** *** 268,272 **** p.drawLine(pos[0], y, pos[0], y2); } ! //--------------------------------------------------- // draw lasso --- 291,295 ---- p.drawLine(pos[0], y, pos[0], y2); } ! //--------------------------------------------------- // draw lasso *************** *** 278,281 **** --- 301,321 ---- p.drawRect(lasso); } + + //--------------------------------------------------- + // draw moving items + //--------------------------------------------------- + + if(virt()) + { + for(iCItem i = moving.begin(); i != moving.end(); ++i) + drawMoving(p, i->second, rect); + } + else + { + p.restore(); + for(iCItem i = moving.begin(); i != moving.end(); ++i) + drawMoving(p, i->second, rect); + setPainter(p); + } } *************** *** 355,361 **** //--------------------------------------------------------- ! void Canvas::moveItems(const QPoint& pos, int dir = 0) { ! int dp = y2pitch(pos.y()) - y2pitch(start.y()); int dx = pos.x() - start.x(); if (dir == 1) --- 395,405 ---- //--------------------------------------------------------- ! void Canvas::moveItems(const QPoint& pos, int dir = 0, bool rasterize) { ! int dp; ! if(rasterize) ! dp = y2pitch(pos.y()) - y2pitch(start.y()); ! else ! dp = pos.y() - start.y(); int dx = pos.x() - start.x(); if (dir == 1) *************** *** 367,372 **** int y = i->second->pos().y(); int nx = x + dx; ! int ny = pitch2y(y2pitch(y) + dp); ! QPoint mp(raster(QPoint(nx, ny))); if (i->second->mp() != mp) { i->second->setMp(mp); --- 411,426 ---- int y = i->second->pos().y(); int nx = x + dx; ! int ny; ! QPoint mp; ! if(rasterize) ! { ! ny = pitch2y(y2pitch(y) + dp); ! mp = raster(QPoint(nx, ny)); ! } ! else ! { ! ny = y + dp; ! mp = QPoint(nx, ny); ! } if (i->second->mp() != mp) { i->second->setMp(mp); *************** *** 429,436 **** else { curItem = 0; - // Added by Tim. p3.2.5 iCItem ius; bool usfound = false; - for (iCItem i = items.begin(); i != items.end(); ++i) { QRect box = i->second->bbox(); --- 483,488 ---- *************** *** 442,455 **** r.moveBy(i->second->pos().x(), i->second->pos().y()); if (r.contains(start)) { - // Added by Tim. p3.2.5 - // Prefer selected over non-selected items. if(i->second->isSelected()) { - curItem = i->second; break; } - // Added by Tim. p3.2.5 - // Remember the first unselected item in case no selected found. else if(!usfound) --- 494,502 ---- *************** *** 460,469 **** } } - // Added by Tim. p3.2.5 if(!curItem && usfound) curItem = ius->second; } - if (curItem && (event->button() == QMouseEvent::MidButton)) { if (!curItem->isSelected()) { --- 507,514 ---- *************** *** 582,593 **** { if (drag != DRAG_OFF && doScroll){ ! int zeroOffsetValue = rmapx(xOffset())+mapx(xorg)-1; ! if (scrollRight) ! emit horizontalScroll(zeroOffsetValue +scrollSpeed); ! else if (zeroOffsetValue > scrollSpeed){ ! emit horizontalScroll(zeroOffsetValue -scrollSpeed); } ! scrollTimer->start( 40, TRUE ); // X ms single-shot timer } else { delete scrollTimer; --- 627,796 ---- { if (drag != DRAG_OFF && doScroll){ ! bool doHMove = false; ! bool doVMove = false; ! int hoff = rmapx(xOffset())+mapx(xorg)-1; ! int curxpos; ! switch(hscrollDir) ! { ! case HSCROLL_RIGHT: ! hoff += scrollSpeed; ! switch(drag) ! { ! case DRAG_NEW: ! case DRAG_RESIZE: ! case DRAGX_MOVE: ! case DRAGX_COPY: ! case DRAGX_CLONE: ! case DRAGY_MOVE: ! case DRAGY_COPY: ! case DRAGY_CLONE: ! case DRAG_MOVE: ! case DRAG_COPY: ! case DRAG_CLONE: ! emit horizontalScrollNoLimit(hoff); ! canScrollLeft = true; ! ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed)); ! doHMove = true; ! break; ! default: ! if(canScrollRight) ! { ! curxpos = xpos; ! emit horizontalScroll(hoff); ! if(xpos <= curxpos) ! { ! canScrollRight = false; ! } ! else ! { ! canScrollLeft = true; ! ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed)); ! doHMove = true; ! } ! } ! else ! { ! } ! break; ! } ! break; ! case HSCROLL_LEFT: ! if(canScrollLeft) ! { ! curxpos = xpos; ! hoff -= scrollSpeed; ! emit horizontalScroll(hoff); ! if(xpos >= curxpos) ! { ! canScrollLeft = false; ! } ! else ! { ! canScrollRight = true; ! ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) - scrollSpeed)); ! doHMove = true; ! } ! } ! else ! { ! } ! break; ! default: ! break; } ! int voff = rmapy(yOffset())+mapy(yorg); ! int curypos; ! switch(vscrollDir) ! { ! case VSCROLL_DOWN: ! if(canScrollDown) ! { ! curypos = ypos; ! voff += scrollSpeed; ! emit verticalScroll(voff); ! if(ypos <= curypos) ! { ! canScrollDown = false; ! } ! else ! { ! canScrollUp = true; ! ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) + scrollSpeed)); ! doVMove = true; ! } ! } ! else ! { ! } ! break; ! case VSCROLL_UP: ! if(canScrollUp) ! { ! curypos = ypos; ! voff -= scrollSpeed; ! emit verticalScroll(voff); ! if(ypos >= curypos) ! { ! canScrollUp = false; ! } ! else ! { ! canScrollDown = true; ! ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) - scrollSpeed)); ! doVMove = true; ! } ! } ! else ! { ! } ! break; ! default: ! break; ! } ! ! if(!doHMove && !doVMove) ! { ! delete scrollTimer; ! scrollTimer=NULL; ! doScroll = false; ! return; ! } ! QPoint dist = ev_pos - start; ! switch(drag) ! { ! case DRAG_MOVE: ! case DRAG_COPY: ! case DRAG_CLONE: ! moveItems(ev_pos, 0, false); ! break; ! case DRAGX_MOVE: ! case DRAGX_COPY: ! case DRAGX_CLONE: ! moveItems(ev_pos, 1, false); ! break; ! case DRAGY_MOVE: ! case DRAGY_COPY: ! case DRAGY_CLONE: ! moveItems(ev_pos, 2, false); ! break; ! case DRAG_LASSO: ! lasso = QRect(start.x(), start.y(), dist.x(), dist.y()); ! redraw(); ! break; ! case DRAG_NEW: ! case DRAG_RESIZE: ! if (dist.x()) { ! if (dist.x() < 1) ! curItem->setWidth(1); ! else ! curItem->setWidth(dist.x()); ! redraw(); ! } ! break; ! default: ! break; } + scrollTimer->start( 40, TRUE ); // X ms single-shot timer + } else { delete scrollTimer; *************** *** 603,608 **** void Canvas::viewMouseMoveEvent(QMouseEvent* event) { ! QPoint pos = event->pos(); ! QPoint dist = pos - start; int ax = ABS(rmapx(dist.x())); int ay = ABS(rmapy(dist.y())); --- 806,812 ---- void Canvas::viewMouseMoveEvent(QMouseEvent* event) { ! ! ev_pos = event->pos(); ! QPoint dist = ev_pos - start; int ax = ABS(rmapx(dist.x())); int ay = ABS(rmapy(dist.y())); *************** *** 611,631 **** // set scrolling variables: doScroll, scrollRight if (drag != DRAG_OFF) { ! if ((rmapx(event->x())+mapx(0)) > ( width()-40 ) || (rmapx(event->x())+mapx(0)) < 40) { ! scrollRight=true; ! if ((rmapx(event->x())+mapx(0)) < 40) ! scrollRight=false; ! doScroll=true; ! if (!scrollTimer) { ! scrollTimer= new QTimer(this); ! connect( scrollTimer, SIGNAL(timeout()), SLOT(scrollTimerDone()) ); ! scrollTimer->start( 0, TRUE ); // single-shot timer ! } ! } else doScroll=false; ! } else ! doScroll=false; ! switch (drag) { --- 815,880 ---- // set scrolling variables: doScroll, scrollRight if (drag != DRAG_OFF) { ! ! ! int ex = rmapx(event->x())+mapx(0); ! if(ex < 40 && canScrollLeft) ! hscrollDir = HSCROLL_LEFT; ! else ! if(ex > (width() - 40)) ! switch(drag) ! { ! case DRAG_NEW: ! case DRAG_RESIZE: ! case DRAGX_MOVE: ! case DRAGX_COPY: ! case DRAGX_CLONE: ! case DRAGY_MOVE: ! case DRAGY_COPY: ! case DRAGY_CLONE: ! case DRAG_MOVE: ! case DRAG_COPY: ! case DRAG_CLONE: ! hscrollDir = HSCROLL_RIGHT; ! break; ! default: ! if(canScrollRight) ! hscrollDir = HSCROLL_RIGHT; ! else ! hscrollDir = HSCROLL_NONE; ! break; ! } ! else ! hscrollDir = HSCROLL_NONE; ! int ey = rmapy(event->y())+mapy(0); ! if(ey < 15 && canScrollUp) ! vscrollDir = VSCROLL_UP; ! else ! if(ey > (height() - 15) && canScrollDown) ! vscrollDir = VSCROLL_DOWN; ! else ! vscrollDir = VSCROLL_NONE; ! if(hscrollDir != HSCROLL_NONE || vscrollDir != VSCROLL_NONE) ! { ! doScroll=true; ! if (!scrollTimer) ! { ! scrollTimer= new QTimer(this); ! connect( scrollTimer, SIGNAL(timeout()), SLOT(scrollTimerDone()) ); ! scrollTimer->start( 0, TRUE ); // single-shot timer ! } ! } else doScroll=false; ! ! } else ! { ! doScroll=false; ! ! canScrollLeft = true; ! canScrollRight = true; ! canScrollUp = true; ! canScrollDown = true; ! } switch (drag) { *************** *** 694,698 **** else dt = MOVE_CLONE; ! startMoving(pos, dt); break; --- 943,948 ---- else dt = MOVE_CLONE; ! ! startMoving(ev_pos, dt); break; *************** *** 700,704 **** case DRAG_COPY: case DRAG_CLONE: ! moveItems(pos, 0); break; --- 950,956 ---- case DRAG_COPY: case DRAG_CLONE: ! ! if(!scrollTimer) ! moveItems(ev_pos, 0); break; *************** *** 706,710 **** case DRAGX_COPY: case DRAGX_CLONE: ! moveItems(pos, 1); break; --- 958,963 ---- case DRAGX_COPY: case DRAGX_CLONE: ! if(!scrollTimer) ! moveItems(ev_pos, 1); break; *************** *** 712,716 **** case DRAGY_COPY: case DRAGY_CLONE: ! moveItems(pos, 2); break; --- 965,970 ---- case DRAGY_COPY: case DRAGY_CLONE: ! if(!scrollTimer) ! moveItems(ev_pos, 2); break; *************** *** 726,730 **** break; case DRAG_DELETE: ! deleteItem(pos); break; --- 980,984 ---- break; case DRAG_DELETE: ! deleteItem(ev_pos); break; *************** *** 732,736 **** break; } ! mouseMove(pos); } --- 986,991 ---- break; } ! ! mouseMove(ev_pos); } *************** *** 743,746 **** --- 998,1006 ---- // printf("release %x %x\n", event->state(), event->button()); + doScroll = false; + canScrollLeft = true; + canScrollRight = true; + canScrollUp = true; + canScrollDown = true; if (event->state() & (LeftButton|RightButton|MidButton) & ~(event->button())) { printf("ignore %x %x\n", keyState, event->button()); *************** *** 882,885 **** --- 1142,1147 ---- else if (dir == 2) dx = 0; + + int modified = 0; for (iCItem i = moving.begin(); i != moving.end(); ++i) { int x = i->second->pos().x(); *************** *** 889,893 **** QPoint newpos = raster(QPoint(nx, ny)); selectItem(i->second, true); ! if (moveItem(i->second, newpos, dragtype)) i->second->move(newpos); if (moving.size() == 1) { --- 1151,1156 ---- QPoint newpos = raster(QPoint(nx, ny)); selectItem(i->second, true); ! ! if (moveItem(i->second, newpos, dragtype, &modified)) i->second->move(newpos); if (moving.size() == 1) { *************** *** 897,901 **** selectItem(i->second, false); } ! endUndo(dragtype); moving.clear(); updateSelection(); --- 1160,1165 ---- selectItem(i->second, false); } ! ! endUndo(dragtype, modified); moving.clear(); updateSelection(); Index: bigtime.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/bigtime.h,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** bigtime.h 17 Jan 2004 16:56:25 -0000 1.4 --- bigtime.h 26 Jan 2008 07:23:21 -0000 1.4.2.1 *************** *** 5,8 **** --- 5,9 ---- #include <qlabel.h> + #include <qcheckbox.h> class MusE; *************** *** 18,27 **** bool setString(unsigned); QLabel *barLabel, *beatLabel, *tickLabel, *hourLabel, *minLabel, *secLabel, *frameLabel, *sep1, *sep2, *sep3, *sep4, *sep5; int oldbar, oldbeat, oldhour, oldmin, oldsec, oldframe; unsigned oldtick; ! void setFgColor(QColor c); void setBgColor(QColor c); --- 19,33 ---- bool setString(unsigned); + QWidget *dwin; + QCheckBox *fmtButton; + QLabel *absTickLabel; + QLabel *absFrameLabel; QLabel *barLabel, *beatLabel, *tickLabel, *hourLabel, *minLabel, *secLabel, *frameLabel, *sep1, *sep2, *sep3, *sep4, *sep5; + int oldbar, oldbeat, oldhour, oldmin, oldsec, oldframe; unsigned oldtick; ! unsigned oldAbsTick, oldAbsFrame; void setFgColor(QColor c); void setBgColor(QColor c); *************** *** 34,38 **** void setPos(int, unsigned, bool); void configChanged(); ! signals: void closed(); --- 40,44 ---- void setPos(int, unsigned, bool); void configChanged(); ! void fmtButtonToggled(bool); signals: void closed(); Index: mtscale.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/mtscale.cpp,v retrieving revision 1.8.2.4 retrieving revision 1.8.2.5 diff -C2 -d -r1.8.2.4 -r1.8.2.5 *** mtscale.cpp 27 Jan 2007 14:52:43 -0000 1.8.2.4 --- mtscale.cpp 26 Jan 2008 07:23:21 -0000 1.8.2.5 *************** *** 214,218 **** MarkerList* marker = song->marker(); for (iMarker m = marker->begin(); m != marker->end(); ++m) { ! int xp = mapx(m->second.tick()); if (xp > x+w) break; --- 214,223 ---- MarkerList* marker = song->marker(); for (iMarker m = marker->begin(); m != marker->end(); ++m) { ! ! int xp; ! if(waveMode) ! xp = mapx(m->second.frame()); ! else ! xp = mapx(m->second.tick()); if (xp > x+w) break; *************** *** 221,225 **** ++mm; if (mm != marker->end()) { ! xe = mapx(mm->first); } QRect tr(xp, 0, xe-xp, 13); --- 226,234 ---- ++mm; if (mm != marker->end()) { ! ! if(waveMode) ! xe = mapx(tempomap.tick2frame(mm->first)); ! else ! xe = mapx(mm->first); } QRect tr(xp, 0, xe-xp, 13); *************** *** 232,236 **** ++mm; if (mm != marker->end()) ! x2 = mapx(mm->first); else x2 = xp+200; --- 241,251 ---- ++mm; if (mm != marker->end()) ! ! { ! if(waveMode) ! x2 = mapx(tempomap.tick2frame(mm->first)); ! else ! x2 = mapx(mm->first); ! } else x2 = xp+200; *************** *** 311,315 **** } if (tpix < 64) { ! // don´t show beats if measure is this small int n = 1; if (tpix < 32) --- 326,330 ---- } if (tpix < 64) { ! // don�t show beats if measure is this small int n = 1; if (tpix < 32) Index: view.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/view.h,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** view.h 12 May 2004 21:41:07 -0000 1.2 --- view.h 26 Jan 2008 07:23:21 -0000 1.2.2.1 *************** *** 88,91 **** --- 88,93 ---- int xOffset() const { return mapxDev(xpos)-xorg; } int xOffsetDev() const { return xpos-rmapx(xorg); } + + int yOffset() const { return mapyDev(ypos)-yorg; } int getXScale() const { return xmag; } int getYScale() const { return ymag; } Index: scrollscale.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/widgets/Attic/scrollscale.cpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** scrollscale.cpp 11 Jan 2004 21:59:40 -0000 1.2 --- scrollscale.cpp 26 Jan 2008 07:23:21 -0000 1.2.2.1 *************** *** 24,79 **** //--------------------------------------------------------- ! void ScrollScale::setScale(int val) ! { ! if (invers) ! val = 1024 - val; ! double min, max; ! if (scaleMin < 0) ! min = 1.0/(-scaleMin); ! else ! min = double(scaleMin); ! if (scaleMax < 0) ! max = 1.0/(-scaleMax); ! else ! max = double(scaleMax); ! double diff = max-min; ! double fkt = double(val)/1024.0; ! double v = (pow(logbase, fkt)-1)/(logbase-1); ! double scale; ! if (invers) ! scale = max - v * diff; ! else ! scale = min + v * diff; ! if (scale < 1.0) ! scaleVal = -(int(1.0 / scale)); ! else ! scaleVal = int(scale); ! if (scaleVal == -1) // nur so ! scaleVal = 1; #if 0 ! if (scaleMax > scaleMin) { ! if (scale < scaleMin) ! scale = scaleMin; ! else if (scale > scaleMax) ! scale = scaleMax; ! } ! else { ! if (scale < scaleMax) ! scale = scaleMax; ! else if (scale > scaleMin) ! scale = scaleMin; ! } #endif ! int sval = scroll->value(); ! emit scaleChanged(scaleVal); ! if (!noScale) ! setRange(minVal, maxVal); ! setPos(sval); ! } //--------------------------------------------------------- --- 24,96 ---- //--------------------------------------------------------- ! void ScrollScale::setScale ( int val ) ! { ! int off = offset(); ! if ( invers ) ! val = 1024 - val; ! double min, max; ! if ( scaleMin < 0 ) ! min = 1.0/ ( -scaleMin ); ! else ! min = double ( scaleMin ); ! if ( scaleMax < 0 ) ! max = 1.0/ ( -scaleMax ); ! else ! max = double ( scaleMax ); ! double diff = max-min; ! double fkt = double ( val ) /1024.0; ! double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 ); ! double scale; ! if ( invers ) ! scale = max - v * diff; ! else ! scale = min + v * diff; ! if ( scale < 1.0 ) ! scaleVal = - ( int ( 1.0 / scale ) ); ! else ! scaleVal = int ( scale ); ! if ( scaleVal == -1 ) // nur so ! scaleVal = 1; #if 0 ! if ( scaleMax > scaleMin ) ! { ! if ( scale < scaleMin ) ! scale = scaleMin; ! else if ( scale > scaleMax ) ! scale = scaleMax; ! } ! else ! { ! if ( scale < scaleMax ) ! scale = scaleMax; ! else if ( scale > scaleMin ) ! scale = scaleMin; ! } #endif ! emit scaleChanged ( scaleVal ); ! if ( !noScale ) ! setRange ( minVal, maxVal ); ! ! int i = ( scroll->orientation() == Horizontal ) ? width() : height(); ! int pos, pmax; ! if ( scaleVal < 1 ) ! { ! pos = ( off-scaleVal/2 ) / ( -scaleVal ); ! pmax = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i; ! } ! else ! { ! pos = off * scaleVal; ! pmax = maxVal * scaleVal - i; ! } ! if(pos > pmax) ! pos = pmax; ! setPos(pos); ! } //--------------------------------------------------------- *************** *** 81,89 **** //--------------------------------------------------------- ! void ScrollScale::setMag(int cs) ! { ! scale->setValue(cs); ! setScale(cs); ! } //--------------------------------------------------------- --- 98,106 ---- //--------------------------------------------------------- ! void ScrollScale::setMag ( int cs ) ! { ! scale->setValue ( cs ); ! setScale ( cs ); ! } //--------------------------------------------------------- *************** *** 92,130 **** //--------------------------------------------------------- ! void ScrollScale::setRange(int min, int max) ! { // if ((min != minVal) && (max != maxVal)) // return; ! minVal = min; ! maxVal = max; ! int i = (scroll->orientation() == Horizontal) ? width() : height(); ! if (!noScale) { ! if (scaleVal < 1) { ! min = minVal / (-scaleVal); ! max = (maxVal-scaleVal-1) / (-scaleVal) - i; ! } ! else { ! min = minVal * scaleVal; ! max = maxVal * scaleVal - i; ! } ! } ! else ! max -= i; ! if (max < 0) ! max = 0; ! if (min < 0) ! min = 0; ! if (min > max) ! max = min; ! scroll->setRange(min, max); ! // qt doesn't check this... ! if (scroll->value() < min) ! scroll->setValue(min); ! if (scroll->value() > max) ! scroll->setValue(max); ! scroll->setSteps(20, i); ! } //--------------------------------------------------------- --- 109,151 ---- //--------------------------------------------------------- ! void ScrollScale::setRange ( int min, int max ) ! { // if ((min != minVal) && (max != maxVal)) // return; ! minVal = min; ! maxVal = max; ! int i = ( scroll->orientation() == Horizontal ) ? width() : height(); ! if ( !noScale ) ! { ! if ( scaleVal < 1 ) ! { ! min = minVal / ( -scaleVal ); ! max = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i; ! } ! else ! { ! min = minVal * scaleVal; ! max = maxVal * scaleVal - i; ! } ! } ! else ! max -= i; ! if ( max < 0 ) ! max = 0; ! if ( min < 0 ) ! min = 0; ! if ( min > max ) ! max = min; ! ! scroll->setRange ( min, max ); ! // qt doesn't check this... ! if ( scroll->value() < min ) ! scroll->setValue ( min ); ! if ( scroll->value() > max ) ! scroll->setValue ( max ); ! scroll->setSteps ( 20, i ); ! } //--------------------------------------------------------- *************** *** 133,140 **** //--------------------------------------------------------- ! void ScrollScale::setPos(unsigned pos) ! { ! scroll->setValue(pos); ! } //--------------------------------------------------------- --- 154,176 ---- //--------------------------------------------------------- ! void ScrollScale::setPos ( unsigned pos ) ! { ! ! scroll->setValue ( pos ); ! } ! ! //--------------------------------------------------------- ! // setPosNoLimit ! // pos in pixel ! //--------------------------------------------------------- ! ! void ScrollScale::setPosNoLimit ( unsigned pos ) ! { ! //printf ( "ScrollScale::setPosNoLimit pos:%d scaleVal:%d offset ticks:%d\n", pos, scaleVal, pos2offset ( pos ) ); ! ! if((int)pos > scroll->maxValue()) ! scroll->setMaxValue(pos); ! scroll->setValue(pos); ! } //--------------------------------------------------------- *************** *** 142,149 **** //--------------------------------------------------------- ! void ScrollScale::resizeEvent(QResizeEvent*) ! { ! setScale(scale->value()); ! } //--------------------------------------------------------- --- 178,185 ---- //--------------------------------------------------------- ! void ScrollScale::resizeEvent ( QResizeEvent* ) ! { ! setScale ( scale->value() ); ! } //--------------------------------------------------------- *************** *** 151,224 **** //--------------------------------------------------------- ! ScrollScale::ScrollScale(int s1, int s2, int cs, int max_, Orientation o, ! QWidget* parent, int min_, bool inv, double bas) ! : QWidget(parent) ! { ! noScale = false; ! _page = 0; ! _pages = 1; ! pageButtons = false; ! showMagFlag = true; ! scaleMin = s1; ! scaleMax = s2; ! minVal = min_; ! maxVal = max_; ! up = 0; ! down = 0; ! logbase = bas; ! invers = inv; ! double min, max; ! if (scaleMin < 0) ! min = 1.0/(-scaleMin); ! else ! min = double(scaleMin); ! if (scaleMax < 0) ! max = 1.0/(-scaleMax); ! else ! max = double(scaleMax); ! double cmag = (cs < 0) ? (1.0/(-cs)) : double(cs); ! double diff = max-min; ! // ! // search initial value for slider ! // ! int cur = 512; ! int delta = 256; ! for (int i = 0; i < 8; ++i) { ! int tryVal = invers ? 1025 - cur : cur; ! double fkt = double(tryVal)/1024.0; ! double v = (pow(logbase, fkt)-1)/(logbase-1); ! double scale = invers ? (max - v * diff) : (min + v * diff); ! if (scale == cmag) // not very likely ! break; // printf("iteration %d invers:%d soll %f(cur:%d) - ist %f\n", i, invers, scale, cur, cmag); ! int dd = invers ? -delta : delta; ! cur += (scale < cmag) ? dd : -dd; ! delta/=2; ! } ! scale = new QSlider(0, 1024, 1, cur, o, this); ! scroll = new QScrollBar(o, this); ! setScale(cur); ! if (o == Horizontal) { ! box = new QBoxLayout(this, QBoxLayout::LeftToRight); ! scale->setMaximumWidth(70); ! scroll->setMinimumWidth(50); ! } ! else { ! box = new QBoxLayout(this, QBoxLayout::Down); ! scroll->setMinimumHeight(50); ! scale->setMaximumHeight(70); ! } ! box->addWidget(scroll, 10); ! box->addWidget(scale, 5); ! connect(scale, SIGNAL(valueChanged(int)), SLOT(setScale(int))); ! connect(scale, SIGNAL(valueChanged(int)), SIGNAL(lscaleChanged(int))); ! connect(scroll, SIGNAL(valueChanged(int)), SIGNAL(scrollChanged(int))); ! } //--------------------------------------------------------- --- 187,263 ---- //--------------------------------------------------------- ! ScrollScale::ScrollScale ( int s1, int s2, int cs, int max_, Orientation o, ! QWidget* parent, int min_, bool inv, double bas ) ! : QWidget ( parent ) ! { ! noScale = false; ! _page = 0; ! _pages = 1; ! pageButtons = false; ! showMagFlag = true; ! scaleMin = s1; ! scaleMax = s2; ! minVal = min_; ! maxVal = max_; ! up = 0; ! down = 0; ! logbase = bas; ! invers = inv; ! double min, max; ! if ( scaleMin < 0 ) ! min = 1.0/ ( -scaleMin ); ! else ! min = double ( scaleMin ); ! if ( scaleMax < 0 ) ! max = 1.0/ ( -scaleMax ); ! else ! max = double ( scaleMax ); ! double cmag = ( cs < 0 ) ? ( 1.0/ ( -cs ) ) : double ( cs ); ! double diff = max-min; ! // ! // search initial value for slider ! // ! int cur = 512; ! int delta = 256; ! for ( int i = 0; i < 8; ++i ) ! { ! int tryVal = invers ? 1025 - cur : cur; ! double fkt = double ( tryVal ) /1024.0; ! double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 ); ! double scale = invers ? ( max - v * diff ) : ( min + v * diff ); ! if ( scale == cmag ) // not very likely ! break; // printf("iteration %d invers:%d soll %f(cur:%d) - ist %f\n", i, invers, scale, cur, cmag); ! int dd = invers ? -delta : delta; ! cur += ( scale < cmag ) ? dd : -dd; ! delta/=2; ! } ! scale = new QSlider ( 0, 1024, 1, cur, o, this ); ! scroll = new QScrollBar ( o, this ); ! setScale ( cur ); ! if ( o == Horizontal ) ! { ! box = new QBoxLayout ( this, QBoxLayout::LeftToRight ); ! scale->setMaximumWidth ( 70 ); ! scroll->setMinimumWidth ( 50 ); ! } ! else ! { ! box = new QBoxLayout ( this, QBoxLayout::Down ); ! scroll->setMinimumHeight ( 50 ); ! scale->setMaximumHeight ( 70 ); ! } ! box->addWidget ( scroll, 10 ); ! box->addWidget ( scale, 5 ); ! connect ( scale, SIGNAL ( valueChanged ( int ) ), SLOT ( setScale ( int ) ) ); ! connect ( scale, SIGNAL ( valueChanged ( int ) ), SIGNAL ( lscaleChanged ( int ) ) ); ! connect ( scroll, SIGNAL ( valueChanged ( int ) ), SIGNAL ( scrollChanged ( int ) ) ); ! } //--------------------------------------------------------- *************** *** 226,269 **** //--------------------------------------------------------- ! void ScrollScale::setPageButtons(bool flag) ! { ! if (flag == pageButtons) ! return; ! if (flag) { ! if (up == 0) { ! up = new QToolButton(this); ! up->setPixmap(*(upIcon)); ! down = new QToolButton(this); ! down->setPixmap(*(downIcon)); ! pageNo = new QLabel(this); ! QString s; ! s.setNum(_page+1); ! pageNo->setText(s); ! QToolTip::add(down, tr("next page")); ! QToolTip::add(up, tr("previous page")); ! QToolTip::add(pageNo, tr("current page number")); ! box->insertWidget(1, up); ! box->insertWidget(2, down); ! box->insertSpacing(3, 5); ! box->insertWidget(4, pageNo); ! box->insertSpacing(5, 5); ! connect(up, SIGNAL(clicked()), SLOT(pageUp())); ! connect(down, SIGNAL(clicked()), SLOT(pageDown())); ! } ! up->show(); ! down->show(); ! pageNo->show(); ! if (_page == (_pages-1)) ! down->setEnabled(false); ! if (_page == 0) ! up->setEnabled(false); ! } ! else { ! up->hide(); ! down->hide(); ! } ! pageButtons = flag; ! } //--------------------------------------------------------- --- 265,311 ---- //--------------------------------------------------------- ! void ScrollScale::setPageButtons ( bool flag ) ! { ! if ( flag == pageButtons ) ! return; ! if ( flag ) ! { ! if ( up == 0 ) ! { ! up = new QToolButton ( this ); ! up->setPixmap ( * ( upIcon ) ); ! down = new QToolButton ( this ); ! down->setPixmap ( * ( downIcon ) ); ! pageNo = new QLabel ( this ); ! QString s; ! s.setNum ( _page+1 ); ! pageNo->setText ( s ); ! QToolTip::add ( down, tr ( "next page" ) ); ! QToolTip::add ( up, tr ( "previous page" ) ); ! QToolTip::add ( pageNo, tr ( "current page number" ) ); ! box->insertWidget ( 1, up ); ! box->insertWidget ( 2, down ); ! box->insertSpacing ( 3, 5 ); ! box->insertWidget ( 4, pageNo ); ! box->insertSpacing ( 5, 5 ); ! connect ( up, SIGNAL ( clicked() ), SLOT ( pageUp() ) ); ! connect ( down, SIGNAL ( clicked() ), SLOT ( pageDown() ) ); ! } ! up->show(); ! down->show(); ! pageNo->show(); ! if ( _page == ( _pages-1 ) ) ! down->setEnabled ( false ); ! if ( _page == 0 ) ! up->setEnabled ( false ); ! } ! else ! { ! up->hide(); ! down->hide(); ! } ! pageButtons = flag; ! } //--------------------------------------------------------- *************** *** 271,283 **** //--------------------------------------------------------- ! void ScrollScale::showMag(bool flag) ! { ! showMagFlag = flag; ! if (flag) ! scale->show(); ! else ! scale->hide(); ! box->activate(); ! } //--------------------------------------------------------- --- 313,344 ---- //--------------------------------------------------------- ! void ScrollScale::showMag ( bool flag ) ! { ! showMagFlag = flag; ! if ( flag ) ! scale->show(); ! else ! scale->hide(); ! box->activate(); ! } ! ! //-----------------------------------... [truncated message content] |