2017-01-03 21:19:33 +01:00
|
|
|
#ifndef SCROLLBAR_H
|
|
|
|
#define SCROLLBAR_H
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "widgets/scrollbarhighlight.h"
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <QMutex>
|
2017-01-26 04:26:40 +01:00
|
|
|
#include <QPropertyAnimation>
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <QWidget>
|
2017-01-26 04:26:40 +01:00
|
|
|
#include <boost/signals2.hpp>
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <functional>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
class ScrollBar : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-01-11 18:52:09 +01:00
|
|
|
ScrollBar(QWidget *parent = 0);
|
2017-01-03 21:19:33 +01:00
|
|
|
~ScrollBar();
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
|
|
|
void addHighlight(ScrollBarHighlight *highlight);
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
Q_PROPERTY(qreal _desiredValue READ getDesiredValue WRITE setDesiredValue)
|
|
|
|
|
|
|
|
void setMaximum(qreal value);
|
|
|
|
void setMinimum(qreal value);
|
|
|
|
void setLargeChange(qreal value);
|
|
|
|
void setSmallChange(qreal value);
|
|
|
|
void setDesiredValue(qreal value, bool animated = false);
|
|
|
|
qreal getMaximum() const;
|
|
|
|
qreal getMinimum() const;
|
|
|
|
qreal getLargeChange() const;
|
|
|
|
qreal getSmallChange() const;
|
|
|
|
qreal getDesiredValue() const;
|
|
|
|
qreal getCurrentValue() const;
|
|
|
|
boost::signals2::signal<void()> &getCurrentValueChanged();
|
|
|
|
void setCurrentValue(qreal value);
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
private:
|
2017-04-12 17:46:44 +02:00
|
|
|
Q_PROPERTY(qreal _currentValue READ getCurrentValue WRITE setCurrentValue)
|
2017-02-02 00:25:57 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QMutex _mutex;
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QPropertyAnimation _currentValueAnimation;
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-05-27 16:16:39 +02:00
|
|
|
ScrollBarHighlight *_highlights;
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
void paintEvent(QPaintEvent *);
|
2017-01-26 04:26:40 +01:00
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event);
|
|
|
|
void leaveEvent(QEvent *);
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int _mouseOverIndex;
|
|
|
|
int _mouseDownIndex;
|
|
|
|
QPoint _lastMousePosition;
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int _buttonHeight;
|
|
|
|
int _trackHeight;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QRect _thumbRect;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
qreal _maximum;
|
|
|
|
qreal _minimum;
|
|
|
|
qreal _largeChange;
|
|
|
|
qreal _smallChange;
|
|
|
|
qreal _desiredValue;
|
|
|
|
qreal _currentValue;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
boost::signals2::signal<void()> _currentValueChanged;
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
void updateScroll();
|
2017-01-03 21:19:33 +01:00
|
|
|
};
|
2017-01-18 21:30:23 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#endif // SCROLLBAR_H
|