mirror-chatterino2/src/widgets/scrollbar.hpp

90 lines
2.1 KiB
C++
Raw Normal View History

2017-06-06 17:18:23 +02:00
#pragma once
2017-01-03 21:19:33 +01:00
#include "widgets/basewidget.hpp"
2017-06-11 09:31:45 +02:00
#include "widgets/scrollbarhighlight.hpp"
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
2017-04-14 17:52:22 +02:00
namespace chatterino {
class ColorScheme;
2017-04-14 17:52:22 +02:00
namespace widgets {
2017-01-18 21:30:23 +01:00
class ChatWidgetView;
class ScrollBar : public BaseWidget
2017-01-03 21:19:33 +01:00
{
Q_OBJECT
public:
ScrollBar(ChatWidgetView *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)
2017-06-06 17:18:23 +02:00
void scrollToBottom();
bool isAtBottom() const;
2017-04-12 17:46:44 +02:00
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-06-06 17:18:23 +02:00
void printCurrentState(const QString &prefix = QString()) const;
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 *);
int _mouseOverIndex = -1;
int _mouseDownIndex = -1;
2017-04-12 17:46:44 +02:00
QPoint _lastMousePosition;
2017-01-03 21:19:33 +01:00
int _buttonHeight = 16;
int _trackHeight = 100;
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
qreal _maximum = 0;
qreal _minimum = 0;
qreal _largeChange = 0;
qreal _smallChange = 5;
qreal _desiredValue = 0;
qreal _currentValue = 0;
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-06-06 17:18:23 +02:00
} // namespace widgets
} // namespace chatterino