[Scummvm-git-logs] scummvm master -> 2db0c24ce6296c08c92a6c5f5ccdc22547cf8625

sev- noreply at scummvm.org
Thu Nov 2 21:53:40 UTC 2023


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

Summary:
7ff167190b GUI: Switched URL clicking in the Richtext widget to mouse up
2db0c24ce6 GUI: Implement finger scrolling in RichTextWidget


Commit: 7ff167190b2ce71ff7f4ea22445d7c68497b7174
    https://github.com/scummvm/scummvm/commit/7ff167190b2ce71ff7f4ea22445d7c68497b7174
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-11-02T22:21:55+01:00

Commit Message:
GUI: Switched URL clicking in the Richtext widget to mouse up

Changed paths:
    gui/widgets/richtext.cpp
    gui/widgets/richtext.h


diff --git a/gui/widgets/richtext.cpp b/gui/widgets/richtext.cpp
index c5c910c0c5f..5789458374d 100644
--- a/gui/widgets/richtext.cpp
+++ b/gui/widgets/richtext.cpp
@@ -85,7 +85,7 @@ void RichTextWidget::handleMouseWheel(int x, int y, int direction) {
 	_verticalScroll->handleMouseWheel(x, y, direction);
 }
 
-void RichTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
+void RichTextWidget::handleMouseUp(int x, int y, int button, int clickCount) {
 	Common::String link = _txtWnd->getMouseLink(x + _x + _scrolledX, y + _y + _scrolledY).encode();
 
 	if (link.hasPrefixIgnoreCase("http"))
diff --git a/gui/widgets/richtext.h b/gui/widgets/richtext.h
index e89b637801c..5b62a50bb14 100644
--- a/gui/widgets/richtext.h
+++ b/gui/widgets/richtext.h
@@ -61,7 +61,7 @@ public:
 
 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
 	void handleMouseWheel(int x, int y, int direction) override;
-	void handleMouseDown(int x, int y, int button, int clickCount) override;
+	void handleMouseUp(int x, int y, int button, int clickCount) override;
 	void handleTooltipUpdate(int x, int y) override;
 
 	void markAsDirty() override;


Commit: 2db0c24ce6296c08c92a6c5f5ccdc22547cf8625
    https://github.com/scummvm/scummvm/commit/2db0c24ce6296c08c92a6c5f5ccdc22547cf8625
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-11-02T22:52:55+01:00

Commit Message:
GUI: Implement finger scrolling in RichTextWidget

Changed paths:
    gui/widgets/richtext.cpp
    gui/widgets/richtext.h


diff --git a/gui/widgets/richtext.cpp b/gui/widgets/richtext.cpp
index 5789458374d..a3fd36985f9 100644
--- a/gui/widgets/richtext.cpp
+++ b/gui/widgets/richtext.cpp
@@ -85,13 +85,45 @@ void RichTextWidget::handleMouseWheel(int x, int y, int direction) {
 	_verticalScroll->handleMouseWheel(x, y, direction);
 }
 
+void RichTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
+	_mouseDownY = _mouseDownStartY = y;
+}
+
 void RichTextWidget::handleMouseUp(int x, int y, int button, int clickCount) {
+	// Allow some tiny finger slipping
+	if (ABS(_mouseDownY - _mouseDownStartY) > 5) {
+		_mouseDownY = _mouseDownStartY = 0;
+
+		return;
+	}
+
+	_mouseDownY = _mouseDownStartY = 0;
+
 	Common::String link = _txtWnd->getMouseLink(x + _x + _scrolledX, y + _y + _scrolledY).encode();
 
 	if (link.hasPrefixIgnoreCase("http"))
 		g_system->openUrl(link);
 }
 
+void RichTextWidget::handleMouseMoved(int x, int y, int button) {
+	if (_mouseDownStartY == 0 || _mouseDownY == y)
+		return;
+
+	int h = _txtWnd->getTextHeight();
+	int prevScrolledY = _scrolledY;
+
+	_scrolledY = CLIP(_scrolledY - (y - _mouseDownY), 0, h);
+
+	_mouseDownY = y;
+
+	if (_scrolledY == prevScrolledY)
+		return;
+
+	recalc();
+	_verticalScroll->recalc();
+	markAsDirty();
+}
+
 void RichTextWidget::handleTooltipUpdate(int x, int y) {
 	_tooltip = _txtWnd->getMouseLink(x + _x + _scrolledX, y + _y + _scrolledY);
 }
@@ -117,7 +149,7 @@ void RichTextWidget::recalc() {
 	int h = _txtWnd->getTextHeight();
 
 	if (h <= _limitH) _scrolledY = 0;
-	if (_scrolledY > h - _limitH) _scrolledY = 0;
+	if (_scrolledY > h - _limitH) _scrolledY = MAX(0, h - _limitH);
 
 	_verticalScroll->_numEntries = h;
 	_verticalScroll->_currentPos = _scrolledY;
diff --git a/gui/widgets/richtext.h b/gui/widgets/richtext.h
index 5b62a50bb14..6df09ffb8f4 100644
--- a/gui/widgets/richtext.h
+++ b/gui/widgets/richtext.h
@@ -43,6 +43,8 @@ protected:
 
 	ScrollBarWidget *_verticalScroll;
 	int16 _scrolledX, _scrolledY;
+	int _mouseDownY = 0;
+	int _mouseDownStartY = 0;
 	int _scrollbarWidth;
 	uint16 _limitH;
 	int _textWidth;
@@ -61,7 +63,9 @@ public:
 
 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
 	void handleMouseWheel(int x, int y, int direction) override;
+	void handleMouseDown(int x, int y, int button, int clickCount) override;
 	void handleMouseUp(int x, int y, int button, int clickCount) override;
+	void handleMouseMoved(int x, int y, int button) override;
 	void handleTooltipUpdate(int x, int y) override;
 
 	void markAsDirty() override;




More information about the Scummvm-git-logs mailing list