mirror-chatterino2/src/widgets/scrollbar.hpp
Rasmus Karlsson adf3ff3075 Switch some c-style includes to c++-style includes (i.e. stdint.h to
cstdint)

Make MessageElement to a class to fit better with the derived classes.
Make MessageLayoutElement to a class to fit better with the derived
classes.

Remove virtual from override functions

Replace all instances of boost::signals2 with pajlada::Signals. This
lets us properly use clang code model to check for issues.

Add missing virtual destructor to AbstractIrcServer
Add missing virtual destructor to MessageLayoutElement

Remove unused "connectedConnection" connection in TwitchChannel

Fix typo in TrimChannelName function
Fix typo in MessageParseArgs

Replace some raw pointers with unique pointers where it made more sense.
This allowed us to remove some manually written destructors whose only
purpose was to delete that raw pointer.

Reformat: Add namespace comments
Reformat: Add empty empty lines between main namespace beginning and end
Reformat: Re-order includes
Reformat: Fix some includes that used quotes where they should use angle
brackets
Reformat: Replace some typedef's with using's

Filter out more useless warnings
2018-04-03 03:00:34 +02:00

98 lines
2.5 KiB
C++

#pragma once
#include "messages/limitedqueue.hpp"
#include "singletons/settingsmanager.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/helper/scrollbarhighlight.hpp"
#include <QMutex>
#include <QPropertyAnimation>
#include <QWidget>
#include <pajlada/signals/signal.hpp>
namespace chatterino {
namespace widgets {
class ChannelView;
class Scrollbar : public BaseWidget
{
Q_OBJECT
public:
Scrollbar(ChannelView *parent = 0);
void addHighlight(ScrollbarHighlight highlight);
void addHighlightsAtStart(const std::vector<ScrollbarHighlight> &highlights);
void replaceHighlight(size_t index, ScrollbarHighlight replacement);
void scrollToBottom(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;
// offset the desired value without breaking smooth scolling
void offset(qreal value);
pajlada::Signals::NoArgSignal &getCurrentValueChanged();
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)
QMutex mutex;
QPropertyAnimation currentValueAnimation;
messages::LimitedQueue<ScrollbarHighlight> highlights;
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::Settings::Setting<bool> &smoothScrollingSetting;
void updateScroll();
};
} // namespace widgets
} // namespace chatterino