Scroll Using Click-and-Drag with Middle Mouse Button (#1559)

* ChannelView: Rename mouse event related members

This is more in line with the naming of the other members as well as
future members.

* ChannelView: Add ability to scroll with middle mouse button

* Add scrolling resources

* Use custom icons for scroll cursor

* Slightly refactor scrolling logic

* Respect screen scaling when calculating scroll offset

* Nicer scrolling UX

This change allows scrolling to be feel smoother when close to the
starting point.

* Add scrolling with keeping middle mouse pressed

This mimics the behavior of browsers as well.

* Refactor ChannelView::enableScrolling

* Disable drag-scrolling on left or right click
This commit is contained in:
Leon Richardt
2020-04-18 11:09:22 +02:00
committed by GitHub
parent 2076715e23
commit b4a2ced180
11 changed files with 448 additions and 13 deletions
+18 -2
View File
@@ -148,6 +148,9 @@ private:
void updatePauses();
void unpaused();
void enableScrolling(const QPointF &scrollStart);
void disableScrolling();
QTimer *layoutCooldown_;
bool layoutQueued_;
@@ -183,15 +186,26 @@ private:
bool onlyUpdateEmotes_ = false;
// Mouse event variables
bool isMouseDown_ = false;
bool isLeftMouseDown_ = false;
bool isRightMouseDown_ = false;
bool isDoubleClick_ = false;
DoubleClickSelection doubleClickSelection_;
QPointF lastPressPosition_;
QPointF lastLeftPressPosition_;
QPointF lastRightPressPosition_;
QPointF lastDClickPosition_;
QTimer *clickTimer_;
bool isScrolling_ = false;
QPointF lastMiddlePressPosition_;
QPointF currentMousePosition_;
QTimer scrollTimer_;
struct {
QCursor neutral;
QCursor up;
QCursor down;
} cursors_;
Selection selection_;
bool selecting_ = false;
@@ -211,6 +225,8 @@ private slots:
queueLayout();
update();
}
void scrollUpdateRequested();
};
} // namespace chatterino