summaryrefslogtreecommitdiff
path: root/muse2/muse/widgets/canvas.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-16 12:16:44 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-16 12:16:44 +0000
commit2cf9d99932d8f45d5508c45729bea7af4e6ec8fd (patch)
treeea423f965efa83e841e267778f537af8de28a953 /muse2/muse/widgets/canvas.cpp
parent4e1ca61b03bab50d5e71e6da433503ac3b4470c0 (diff)
parent38988a37365c8772da11f3f41d49e5c1fd083084 (diff)
set focus policy to strong in all editors
merged with trunk
Diffstat (limited to 'muse2/muse/widgets/canvas.cpp')
-rw-r--r--muse2/muse/widgets/canvas.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp
index c12ac956..18de985b 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)
{