#pragma once #include "widgets/basewidget.hpp" #include "widgets/helper/scrollbarhighlight.hpp" #include #include #include #include #include namespace chatterino { class ColorScheme; namespace widgets { class ChannelView; class ScrollBar : public BaseWidget { Q_OBJECT public: ScrollBar(ChannelView *parent = 0); ~ScrollBar(); void removeHighlightsWhere(std::function func); void addHighlight(ScrollBarHighlight *highlight); Q_PROPERTY(qreal desiredValue READ getDesiredValue WRITE setDesiredValue) void scrollToBottom(); bool isAtBottom() const; 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; // offset the desired value without breaking smooth scolling void offset(qreal value); boost::signals2::signal &getCurrentValueChanged(); void setCurrentValue(qreal value); void printCurrentState(const QString &prefix = QString()) const; private: Q_PROPERTY(qreal currentValue READ getCurrentValue WRITE setCurrentValue) QMutex mutex; QPropertyAnimation currentValueAnimation; ScrollBarHighlight *highlights; void paintEvent(QPaintEvent *); void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void leaveEvent(QEvent *); bool atBottom = false; int mouseOverIndex = -1; int mouseDownIndex = -1; QPoint lastMousePosition; int buttonHeight = 16; int trackHeight = 100; QRect thumbRect; qreal maximum = 0; qreal minimum = 0; qreal largeChange = 0; qreal smallChange = 5; qreal desiredValue = 0; qreal currentValue = 0; qreal smoothScrollingOffset = 0; boost::signals2::signal currentValueChanged; pajlada::Settings::Setting &smoothScrollingSetting; void updateScroll(); }; } // namespace widgets } // namespace chatterino