[Scummvm-git-logs] scummvm master -> 648d7e971838085683043f43f98865ff31515dca

bluegr noreply at scummvm.org
Wed Jan 4 09:26:30 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
648d7e9718 GUI: Add mousewheel scrolling to credits.


Commit: 648d7e971838085683043f43f98865ff31515dca
    https://github.com/scummvm/scummvm/commit/648d7e971838085683043f43f98865ff31515dca
Author: elasota (ejlasota at gmail.com)
Date: 2023-01-04T11:26:25+02:00

Commit Message:
GUI: Add mousewheel scrolling to credits.

Changed paths:
    gui/about.cpp
    gui/about.h


diff --git a/gui/about.cpp b/gui/about.cpp
index 7810e661a21..0af3e31c4a3 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -86,7 +86,7 @@ static const char *gpl_text[] = {
 
 AboutDialog::AboutDialog()
 	: Dialog(10, 20, 300, 174),
-	_scrollPos(0), _scrollTime(0), _willClose(false) {
+	  _scrollPos(0), _scrollTime(0), _willClose(false), _autoScroll(true) {
 
 	reflowLayout();
 
@@ -257,7 +257,7 @@ void AboutDialog::drawDialog(DrawLayer layerToDraw) {
 void AboutDialog::handleTickle() {
 	const uint32 t = g_system->getMillis();
 	int scrollOffset = ((int)t - (int)_scrollTime) / kScrollMillisPerPixel;
-	if (scrollOffset > 0) {
+	if (_autoScroll && scrollOffset > 0) {
 		int modifiers = g_system->getEventManager()->getModifierState();
 
 		// Scroll faster when shift is pressed
@@ -284,6 +284,24 @@ void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) {
 	close();
 }
 
+void AboutDialog::handleMouseWheel(int x, int y, int direction) {
+	const int stepping = 5 * _lineHeight * direction;
+
+	if (stepping == 0)
+		return;
+
+	_autoScroll = false;
+
+	int newScrollPos = _scrollPos + stepping;
+
+	if (_scrollPos < 0) {
+		_scrollPos = 0;
+	} else if ((uint32)newScrollPos < _lines.size() * _lineHeight) {
+		_scrollPos = newScrollPos;
+	}
+	drawDialog(kDrawLayerForeground);
+}
+
 void AboutDialog::handleKeyDown(Common::KeyState state) {
 	EEHandler eeHandler;
 
diff --git a/gui/about.h b/gui/about.h
index e73d6393fb3..b51266f0865 100644
--- a/gui/about.h
+++ b/gui/about.h
@@ -39,6 +39,7 @@ protected:
 	Common::U32StringArray _lines;
 	uint32         _lineHeight;
 	bool           _willClose;
+	bool _autoScroll;
 
 	int _xOff, _yOff;
 
@@ -54,6 +55,7 @@ public:
 	void drawDialog(DrawLayer layerToDraw) override;
 	void handleTickle() override;
 	void handleMouseUp(int x, int y, int button, int clickCount) override;
+	void handleMouseWheel(int x, int y, int direction) override;
 	void handleKeyDown(Common::KeyState state) override;
 	void handleKeyUp(Common::KeyState state) override;
 




More information about the Scummvm-git-logs mailing list