mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
032f290767
This change enforces strict include grouping using IncludeCategories In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes: In ChatterSet.hpp, I changed lrucache to a <>include In Irc2.hpp, I change common/SignalVector.hpp to a "project-include" In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first. clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
106 lines
2.9 KiB
C++
106 lines
2.9 KiB
C++
#pragma once
|
|
|
|
#include "messages/LimitedQueue.hpp"
|
|
#include "widgets/BaseWidget.hpp"
|
|
#include "widgets/helper/ScrollbarHighlight.hpp"
|
|
|
|
#include <pajlada/signals/signal.hpp>
|
|
#include <QMutex>
|
|
#include <QPropertyAnimation>
|
|
#include <QWidget>
|
|
|
|
namespace chatterino {
|
|
|
|
class ChannelView;
|
|
|
|
class Scrollbar : public BaseWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
Scrollbar(ChannelView *parent = nullptr);
|
|
|
|
void addHighlight(ScrollbarHighlight highlight);
|
|
void addHighlightsAtStart(
|
|
const std::vector<ScrollbarHighlight> &highlights_);
|
|
void replaceHighlight(size_t index, ScrollbarHighlight replacement);
|
|
|
|
void pauseHighlights();
|
|
void unpauseHighlights();
|
|
void clearHighlights();
|
|
|
|
void scrollToBottom(bool animate = false);
|
|
void scrollToTop(bool animate = false);
|
|
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;
|
|
|
|
const QPropertyAnimation &getCurrentValueAnimation() const;
|
|
|
|
// offset the desired value without breaking smooth scolling
|
|
void offset(qreal value);
|
|
pajlada::Signals::NoArgSignal &getCurrentValueChanged();
|
|
pajlada::Signals::NoArgSignal &getDesiredValueChanged();
|
|
void setCurrentValue(qreal value);
|
|
|
|
void printCurrentState(const QString &prefix = QString()) const;
|
|
|
|
Q_PROPERTY(qreal desiredValue_ READ getDesiredValue WRITE setDesiredValue)
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *) override;
|
|
void resizeEvent(QResizeEvent *) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
void leaveEvent(QEvent *) override;
|
|
|
|
private:
|
|
Q_PROPERTY(qreal currentValue_ READ getCurrentValue WRITE setCurrentValue)
|
|
|
|
LimitedQueueSnapshot<ScrollbarHighlight> &getHighlightSnapshot();
|
|
void updateScroll();
|
|
|
|
QMutex mutex_;
|
|
|
|
QPropertyAnimation currentValueAnimation_;
|
|
|
|
LimitedQueue<ScrollbarHighlight> highlights_;
|
|
bool highlightsPaused_{false};
|
|
LimitedQueueSnapshot<ScrollbarHighlight> highlightSnapshot_;
|
|
|
|
bool atBottom_{false};
|
|
|
|
int mouseOverIndex_ = -1;
|
|
int mouseDownIndex_ = -1;
|
|
QPoint lastMousePosition_;
|
|
|
|
int buttonHeight_ = 0;
|
|
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;
|
|
|
|
pajlada::Signals::NoArgSignal currentValueChanged_;
|
|
pajlada::Signals::NoArgSignal desiredValueChanged_;
|
|
};
|
|
|
|
} // namespace chatterino
|