summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-05-15 18:56:00 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-05-15 18:56:00 +0000
commit38988a37365c8772da11f3f41d49e5c1fd083084 (patch)
treee3995bb749b9a7359466b7aea6b6077ba6b96bd8 /muse2
parent0021af8ef6f76dd4575bc74da2b20431d58a8f7e (diff)
mouse wheel rework
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog8
-rw-r--r--muse2/muse/arranger/arranger.cpp46
-rw-r--r--muse2/muse/arranger/arranger.h2
-rw-r--r--muse2/muse/midiedit/drumedit.cpp2
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp2
-rw-r--r--muse2/muse/midieditor.cpp27
-rw-r--r--muse2/muse/midieditor.h4
-rw-r--r--muse2/muse/waveedit/waveedit.cpp31
-rw-r--r--muse2/muse/waveedit/waveedit.h3
-rw-r--r--muse2/muse/waveedit/waveview.cpp49
-rw-r--r--muse2/muse/waveedit/waveview.h3
-rw-r--r--muse2/muse/widgets/canvas.cpp44
-rw-r--r--muse2/muse/widgets/canvas.h2
13 files changed, 197 insertions, 26 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 9379bdf8..fce03eb0 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,11 @@
+15.05.2011:
+ - Changed mouse wheel behaviour in graphical editors except the score editor (rj)
+ * wheel scrolls left-right
+ * shift+wheel scrolls up-down
+ * control+wheel zooms horizontally
+ TODO:
+ - score editor
+ - zoom to where the mouse is located
14.05.2011:
- Fixed problem with project save dialog missing a forward slash '/'. (Tim)
~/.config was being polluted with wrong folders. Fixed ProjectCreateImpl::updateDirectoryPath().
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp
index 495c4cb8..d74bed78 100644
--- a/muse2/muse/arranger/arranger.cpp
+++ b/muse2/muse/arranger/arranger.cpp
@@ -384,6 +384,8 @@ Arranger::Arranger(QMainWindow* parent, const char* name)
connect(list, SIGNAL(keyPressExt(QKeyEvent*)), canvas, SLOT(redirKeypress(QKeyEvent*)));
connect(canvas, SIGNAL(selectTrackAbove()), list, SLOT(selectTrackAbove()));
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*)));
@@ -1078,27 +1080,39 @@ void Arranger::keyPressEvent(QKeyEvent* event)
key+= Qt::CTRL;
if (key == shortcuts[SHRT_ZOOM_IN].key) {
- int mag = hscroll->mag();
- int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
- if (zoomlvl < 23)
- zoomlvl++;
-
- int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
-
- hscroll->setMag(newmag);
+ horizontalZoomIn();
return;
}
else if (key == shortcuts[SHRT_ZOOM_OUT].key) {
- int mag = hscroll->mag();
- int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
- if (zoomlvl > 1)
- zoomlvl--;
-
- int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
-
- hscroll->setMag(newmag);
+ horizontalZoomOut();
return;
}
QWidget::keyPressEvent(event);
}
+
+void Arranger::horizontalZoomIn()
+{
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl < 23)
+ zoomlvl++;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
+
+void Arranger::horizontalZoomOut()
+{
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl > 1)
+ zoomlvl--;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h
index 0143afd5..262d7464 100644
--- a/muse2/muse/arranger/arranger.h
+++ b/muse2/muse/arranger/arranger.h
@@ -122,6 +122,8 @@ class Arranger : public QWidget {
void setTempo200();
//void seek();
void verticalScrollSetYpos(unsigned);
+ void horizontalZoomIn();
+ void horizontalZoomOut();
signals:
void redirectWheelEvent(QWheelEvent*);
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index ed3cd0e8..5cd4c130 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -368,6 +368,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini
canvas->setCanvasTools(drumeditTools);
canvas->setFocus();
connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int)));
+ connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn()));
+ connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut()));
time->setOrigin(offset, 0);
QList<int> mops;
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 2778d8b9..f02b10a6 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -423,6 +423,8 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i
canvas->setCanvasTools(pianorollTools);
canvas->setFocus();
connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int)));
+ connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn()));
+ connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut()));
time->setOrigin(offset, 0);
gridS1->setRowStretch(2, 100);
diff --git a/muse2/muse/midieditor.cpp b/muse2/muse/midieditor.cpp
index 9191233d..7e25972c 100644
--- a/muse2/muse/midieditor.cpp
+++ b/muse2/muse/midieditor.cpp
@@ -241,3 +241,30 @@ void MidiEditor::setCurCanvasPart(Part* part)
canvas->setCurrentPart(part);
}
+void MidiEditor::horizontalZoomIn()
+{
+ printf("zoom in \n");
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl < 23)
+ zoomlvl++;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
+
+void MidiEditor::horizontalZoomOut()
+{
+ printf("zoom out \n");
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl > 1)
+ zoomlvl--;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
diff --git a/muse2/muse/midieditor.h b/muse2/muse/midieditor.h
index 1f465c2d..c5668abf 100644
--- a/muse2/muse/midieditor.h
+++ b/muse2/muse/midieditor.h
@@ -55,7 +55,9 @@ class MidiEditor : public TopWin {
public slots:
void songChanged(int type);
void setCurDrumInstrument(int instr);
-
+ void horizontalZoomIn();
+ void horizontalZoomOut();
+
virtual void updateHScrollRange() { };
signals:
void curDrumInstrumentChanged(int);
diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp
index 2350a2c5..ccfb2730 100644
--- a/muse2/muse/waveedit/waveedit.cpp
+++ b/muse2/muse/waveedit/waveedit.cpp
@@ -222,6 +222,9 @@ WaveEdit::WaveEdit(PartList* pl)
ymag->setFixedWidth(16);
connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int)));
connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int)));
+ connect(view, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn()));
+ connect(view, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut()));
+
time->setOrigin(0, 0);
mainGrid->setRowStretch(0, 100);
@@ -246,6 +249,8 @@ WaveEdit::WaveEdit(PartList* pl)
// connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
connect(view, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(view, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned)));
+
connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
@@ -498,3 +503,29 @@ void WaveEdit::moveVerticalSlider(int val)
ymag->setValue(ymag->value() + val);
}
+
+void WaveEdit::horizontalZoomIn()
+{
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl < 23)
+ zoomlvl++;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
+
+void WaveEdit::horizontalZoomOut()
+{
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl > 1)
+ zoomlvl--;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+
+ hscroll->setMag(newmag);
+
+}
diff --git a/muse2/muse/waveedit/waveedit.h b/muse2/muse/waveedit/waveedit.h
index 67230897..b4000794 100644
--- a/muse2/muse/waveedit/waveedit.h
+++ b/muse2/muse/waveedit/waveedit.h
@@ -66,6 +66,9 @@ class WaveEdit : public MidiEditor {
void configChanged();
virtual void updateHScrollRange();
+ void horizontalZoomIn();
+ void horizontalZoomOut();
+
signals:
void deleted(unsigned long);
diff --git a/muse2/muse/waveedit/waveview.cpp b/muse2/muse/waveedit/waveview.cpp
index f83ae1d5..0c387f72 100644
--- a/muse2/muse/waveedit/waveview.cpp
+++ b/muse2/muse/waveedit/waveview.cpp
@@ -25,6 +25,7 @@
#include "waveedit.h"
#include "audio.h"
#include "gconfig.h"
+#include "fastlog.h"
bool modifyWarnedYet = false;
//---------------------------------------------------------
@@ -381,14 +382,52 @@ void WaveView::viewMousePressEvent(QMouseEvent* event)
viewMouseMoveEvent(event);
}
-
+#define WHEEL_STEPSIZE 40
+#define WHEEL_DELTA 120
//---------------------------------------------------------
// wheelEvent
//---------------------------------------------------------
-void WaveView::wheelEvent(QWheelEvent* event)
- {
- emit mouseWheelMoved(event->delta() / 10);
- }
+void WaveView::wheelEvent(QWheelEvent* ev)
+{
+ int keyState = ev->modifiers();
+
+ bool shift = keyState & Qt::ShiftModifier;
+ bool alt = keyState & Qt::AltModifier;
+ bool ctrl = keyState & Qt::ControlModifier;
+
+ if (shift) { // scroll vertically
+ emit mouseWheelMoved(ev->delta() / 10);
+
+ } else if (ctrl) { // zoom horizontally
+ if (ev->delta()>0)
+ emit horizontalZoomIn();
+ else
+ emit horizontalZoomOut();
+
+ } else { // scroll horizontally
+ int delta = ev->delta() / WHEEL_DELTA;
+ int xpixelscale = 5*fast_log10(rmapxDev(1));
+
+
+ if (xpixelscale <= 0)
+ xpixelscale = 1;
+
+ int scrollstep = WHEEL_STEPSIZE * (delta);
+ ///if (ev->state() == Qt::ShiftModifier)
+// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
+ scrollstep = scrollstep / 10;
+
+ int newXpos = xpos + xpixelscale * scrollstep;
+
+ if (newXpos < 0)
+ newXpos = 0;
+
+ //setYPos(newYpos);
+ emit horizontalScroll((unsigned)newXpos);
+
+ }
+
+}
//---------------------------------------------------------
// viewMouseReleaseEvent
diff --git a/muse2/muse/waveedit/waveview.h b/muse2/muse/waveedit/waveview.h
index 3ee0d5f8..c7992952 100644
--- a/muse2/muse/waveedit/waveview.h
+++ b/muse2/muse/waveedit/waveview.h
@@ -88,6 +88,9 @@ class WaveView : public View {
void followEvent(int);
void timeChanged(unsigned);
void mouseWheelMoved(int);
+ void horizontalScroll(unsigned);
+ void horizontalZoomIn();
+ void horizontalZoomOut();
public:
WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale);
diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp
index 14f414b7..07ad1d1f 100644
--- a/muse2/muse/widgets/canvas.cpp
+++ b/muse2/muse/widgets/canvas.cpp
@@ -24,6 +24,7 @@
#include "icons.h"
#include "../marker/marker.h"
#include "part.h"
+#include "fastlog.h"
#define ABS(x) ((x) < 0) ? -(x) : (x)
@@ -338,7 +339,13 @@ void Canvas::draw(QPainter& p, const QRect& rect)
// wheelEvent
//---------------------------------------------------------
void Canvas::wheelEvent(QWheelEvent* ev)
- {
+{
+ int keyState = ev->modifiers();
+
+ bool shift = keyState & Qt::ShiftModifier;
+ bool ctrl = keyState & Qt::ControlModifier;
+
+ if (shift) { // scroll vertically
int delta = ev->delta() / WHEEL_DELTA;
int ypixelscale = rmapyDev(1);
@@ -347,8 +354,8 @@ void Canvas::wheelEvent(QWheelEvent* ev)
int scrollstep = WHEEL_STEPSIZE * (-delta);
///if (ev->state() == Qt::ShiftModifier)
- if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
- scrollstep = scrollstep / 10;
+// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
+ scrollstep = scrollstep / 2;
int newYpos = ypos + ypixelscale * scrollstep;
@@ -358,7 +365,36 @@ void Canvas::wheelEvent(QWheelEvent* ev)
//setYPos(newYpos);
emit verticalScroll((unsigned)newYpos);
- }
+ } else if (ctrl) { // zoom horizontally
+ if (ev->delta()>0)
+ emit horizontalZoomIn();
+ else
+ emit horizontalZoomOut();
+
+ } else { // scroll horizontally
+ int delta = ev->delta() / WHEEL_DELTA;
+ int xpixelscale = 5*fast_log10(rmapxDev(1));
+
+
+ if (xpixelscale <= 0)
+ xpixelscale = 1;
+
+ int scrollstep = WHEEL_STEPSIZE * (delta);
+ ///if (ev->state() == Qt::ShiftModifier)
+// if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
+ scrollstep = scrollstep / 10;
+
+ int newXpos = xpos + xpixelscale * scrollstep;
+
+ if (newXpos < 0)
+ newXpos = 0;
+
+ //setYPos(newYpos);
+ emit horizontalScroll((unsigned)newXpos);
+
+ }
+
+}
void Canvas::redirectedWheelEvent(QWheelEvent* ev)
{
diff --git a/muse2/muse/widgets/canvas.h b/muse2/muse/widgets/canvas.h
index 97392f1e..6e8b9fa8 100644
--- a/muse2/muse/widgets/canvas.h
+++ b/muse2/muse/widgets/canvas.h
@@ -174,6 +174,8 @@ class Canvas : public View {
void verticalScroll(unsigned);
void horizontalScroll(unsigned);
void horizontalScrollNoLimit(unsigned);
+ void horizontalZoomIn();
+ void horizontalZoomOut();
public:
Canvas(QWidget* parent, int sx, int sy, const char* name = 0);
bool isSingleSelection();