-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsuperslider.h
More file actions
92 lines (70 loc) · 2.19 KB
/
superslider.h
File metadata and controls
92 lines (70 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef SUPERSLIDER_H
#define SUPERSLIDER_H
#pragma once
#include <QLabel>
#include <QSlider>
/*
* Super sick nasty awesome double handled slider!
*
* @author Steve
*/
class SuperSliderHandle;
class SuperSlider : public QSlider {
Q_OBJECT
public:
/** Constructor */
SuperSlider(QWidget *parent = 0);
/** Store the alternate handle for this slider*/
SuperSliderHandle *alt_handle;
/** Overridden mouse release event */
void mouseReleaseEvent(QMouseEvent *event);
/** Returns the slider value for the alternate handle */
int alt_value();
/** Convenience function for setting the value of the alternate handle */
void alt_setValue(int value);
/** Resets the alternate handle to the right side of the slider */
void Reset();
/** Used to update the position of the alternate handle through the use of an
* event filter */
void alt_update();
signals:
/** Constructor */
void alt_valueChanged(int);
};
class SliderEventFilter : public QObject {
public:
/** Constructor */
SliderEventFilter(SuperSlider *_grandParent) { grandParent = _grandParent; };
protected:
/*
* overloaded functions for object that inherit from this class
*/
bool eventFilter(QObject *obj, QEvent *event);
private:
/** Store the SuperSlider that this event filter is used within. */
SuperSlider *grandParent;
};
class SuperSliderHandle : public QLabel {
Q_OBJECT
public:
/** Constructor */
SuperSliderHandle(SuperSlider *parent = 0);
/** An overloaded mousePressevent so that we can start grabbing the cursor and
* using it's position for the value */
void mousePressEvent(QMouseEvent *event);
/** Returns the value of this handle with respect to the slider */
int value();
/** Maps mouse coordinates to slider values */
int mapValue();
/** Store the parent as a slider so that you don't have to keep casting it */
SuperSlider *parent;
/** Store a bool to determine if the alternate handle has been activated */
bool handleActivated;
private:
/** Store the filter for installation on the qguiapp */
SliderEventFilter *filter;
public slots:
/** Sets the value of the handle with respect to the slider */
void setValue(double value);
};
#endif // SUPERSLIDER_H