Sign in
Register
Home
Projects
Help
Search
:
SV Libraries
»
SV GUI Library
Overview
Members
Activity
Issues
Repository
Code docs
svgui
1.9
Main Page
Classes
Files
File List
File Members
widgets
WheelCounter.h
Go to the documentation of this file.
1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3
/*
4
Sonic Visualiser
5
An audio file viewer and annotation editor.
6
Centre for Digital Music, Queen Mary, University of London.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License as
10
published by the Free Software Foundation; either version 2 of the
11
License, or (at your option) any later version. See the file
12
COPYING included with this distribution for more information.
13
*/
14
15
#ifndef SV_WHEEL_COUNTER_H
16
#define SV_WHEEL_COUNTER_H
17
18
#include <QWheelEvent>
19
24
class
WheelCounter
25
{
26
public
:
27
WheelCounter
() :
m_pendingWheelAngle
(0) { }
28
29
~WheelCounter
() { }
30
31
int
count
(QWheelEvent *e) {
32
33
e->accept();
34
35
int
delta = e->angleDelta().y();
36
if
(delta == 0) {
37
return
0;
38
}
39
40
if
(e->phase() == Qt::ScrollBegin ||
41
std::abs(delta) >= 120 ||
42
(delta > 0 &&
m_pendingWheelAngle
< 0) ||
43
(delta < 0 && m_pendingWheelAngle > 0)) {
44
m_pendingWheelAngle
= delta;
45
}
else
{
46
m_pendingWheelAngle
+= delta;
47
}
48
49
if
(abs(
m_pendingWheelAngle
) >= 600) {
50
// Sometimes on Linux we're seeing absurdly extreme angles
51
// on the first wheel event -- discard those entirely
52
m_pendingWheelAngle
= 0;
53
return
0;
54
}
55
56
int
count
=
m_pendingWheelAngle
/ 120;
57
m_pendingWheelAngle
-= count * 120;
58
return
count
;
59
}
60
61
private
:
62
int
m_pendingWheelAngle
;
63
};
64
65
#endif
WheelCounter::~WheelCounter
~WheelCounter()
Definition:
WheelCounter.h:29
WheelCounter
Manage the little bit of tedious book-keeping associated with translating vertical wheel events into ...
Definition:
WheelCounter.h:24
WheelCounter::count
int count(QWheelEvent *e)
Definition:
WheelCounter.h:31
WheelCounter::WheelCounter
WheelCounter()
Definition:
WheelCounter.h:27
WheelCounter::m_pendingWheelAngle
int m_pendingWheelAngle
Definition:
WheelCounter.h:62
Generated by
1.8.11
Loading...