qt-material-widgets/components/slider.h

52 lines
1015 B
C
Raw Normal View History

2016-03-22 14:16:49 +00:00
#ifndef SLIDER_H
#define SLIDER_H
#include <QWidget>
2016-03-23 05:35:41 +00:00
#include <QPoint>
class Slider;
2016-03-22 14:16:49 +00:00
2016-03-22 15:05:02 +00:00
class Handle : public QWidget
{
Q_OBJECT
public:
2016-03-23 05:35:41 +00:00
explicit Handle(Slider *slider);
2016-03-22 15:05:02 +00:00
~Handle();
2016-03-23 05:35:41 +00:00
inline QSize sizeHint() const { return QSize(16, 16); }
2016-03-22 15:05:02 +00:00
protected:
void paintEvent(QPaintEvent *event);
2016-03-23 05:35:41 +00:00
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
Slider *const _slider;
QPoint _eventPos;
QPoint _offset;
2016-03-22 15:05:02 +00:00
};
2016-03-22 14:16:49 +00:00
class Slider : public QWidget
{
Q_OBJECT
public:
explicit Slider(QWidget *parent = 0);
~Slider();
2016-03-22 15:05:02 +00:00
2016-03-23 05:35:41 +00:00
inline void setOrientation(Qt::Orientation orientation) { _orientation = orientation; }
inline Qt::Orientation orientation() const { return _orientation; }
2016-03-22 15:05:02 +00:00
protected:
void paintEvent(QPaintEvent *event);
2016-03-23 05:35:41 +00:00
void mousePressEvent(QMouseEvent *event);
2016-03-22 15:05:02 +00:00
private:
2016-03-23 05:35:41 +00:00
Handle *const _handle;
Qt::Orientation _orientation;
2016-03-22 14:16:49 +00:00
};
#endif // SLIDER_H