[Scummvm-git-logs] scummvm master -> bbf0d1f9da5f8730e54932af6bfcb644d69ad6aa

sev- noreply at scummvm.org
Tue Jun 3 10:55:50 UTC 2025


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

Summary:
bbf0d1f9da GUI: Remove RTL hack


Commit: bbf0d1f9da5f8730e54932af6bfcb644d69ad6aa
    https://github.com/scummvm/scummvm/commit/bbf0d1f9da5f8730e54932af6bfcb644d69ad6aa
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-06-03T12:55:47+02:00

Commit Message:
GUI: Remove RTL hack

The hack was here because the RTL aware code was incomplete.
Fix everything and remove useless code.

Changed paths:
    gui/ThemeLayout.cpp
    gui/Tooltip.cpp
    gui/dialog.cpp
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/widget.cpp
    gui/widgets/editable.cpp
    gui/widgets/popup.cpp


diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp
index 41f0cbb8b4f..f8f1ab88936 100644
--- a/gui/ThemeLayout.cpp
+++ b/gui/ThemeLayout.cpp
@@ -243,19 +243,7 @@ void ThemeLayoutMain::reflowLayout(Widget *widgetChain) {
 			_w = g_gui.getGUIWidth()  * 8 / 10 * g_gui.getScaleFactor();
 			_h = g_gui.getGUIHeight() * 8 / 10 * g_gui.getScaleFactor();
 		}
-	}
 
-	if (g_gui.useRTL()) {
-		if (this->_name == "GameOptions" || this->_name == "GlobalOptions" || this->_name == "Browser") {
-			/** The dialogs named above are the stacked dialogs for which the left+right paddings need to be adjusted for RTL.
-				Whenever a stacked dialog is opened, the below code sets the left and right paddings and enables widgets to be
-				shifted by that amount. If any new stacked and padded dialogs are added in the future,
-				add them here and in Widget::draw() to enable RTL support for that particular dialog
-			*/
-			int oldX = _x;
-			_x = g_gui.getGUIWidth() * g_gui.getScaleFactor() - _w - _x;
-			g_gui.setDialogPaddings(oldX, _x);
-		}
 	}
 
 	if (_x >= 0) _x += _inset * g_gui.getScaleFactor();
diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp
index 23e5b5f7437..79f0f9db91a 100644
--- a/gui/Tooltip.cpp
+++ b/gui/Tooltip.cpp
@@ -58,9 +58,6 @@ void Tooltip::setup(Dialog *parent, Widget *widget, int x, int y) {
 	_x = MIN<int16>(parent->_x + x + _xdelta + _xpadding, g_system->getOverlayWidth() - _w - _xpadding * 2);
 	_y = MIN<int16>(parent->_y + y + _ydelta + _ypadding, g_system->getOverlayHeight() - _h - _ypadding * 2);
 
-	if (g_gui.useRTL())
-		_x = g_system->getOverlayWidth() - _w - _x + g_gui.getOverlayOffset();
-
 	if (ConfMan.hasKey("tts_enabled", "scummvm") &&
 			ConfMan.getBool("tts_enabled", "scummvm")) {
 		Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
@@ -76,7 +73,11 @@ void Tooltip::drawDialog(DrawLayer layerToDraw) {
 
 	Dialog::drawDialog(layerToDraw);
 
-	int16 textX = g_gui.useRTL() ? _x - 1 - _xpadding : _x + 1 + _xpadding;
+	int16 textX = _x + 1 + _xpadding;
+	if (g_gui.useRTL()) {
+		textX = g_system->getOverlayWidth() - _w - textX;
+	}
+
 	int16 textY = _y + 1 + _ypadding;
 
 	Graphics::TextAlign textAlignment = g_gui.useRTL() ? Graphics::kTextAlignRight : Graphics::kTextAlignLeft;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 5f46bcd5952..0010c3dcb7a 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -170,7 +170,11 @@ void Dialog::drawDialog(DrawLayer layerToDraw) {
 
 	g_gui.theme()->disableClipRect();
 	g_gui.theme()->_layerToDraw = layerToDraw;
-	g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
+	int16 x = _x;
+	if (g_gui.useRTL()) {
+		x = g_system->getOverlayWidth() - _x - _w;
+	}
+	g_gui.theme()->drawDialogBackground(Common::Rect(x, _y, x + _w, _y + _h), _backgroundType);
 
 	markWidgetsAsDirty();
 
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index d0a1d3aa458..2dcfb457418 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -69,9 +69,6 @@ GuiManager::GuiManager() : CommandSender(nullptr), _redrawStatus(kRedrawDisabled
 
 	_iconsSetChanged = false;
 
-	_topDialogLeftPadding = 0;
-	_topDialogRightPadding = 0;
-
 	_displayTopDialogOnly = false;
 
 	// Clear the cursor
@@ -477,11 +474,6 @@ void GuiManager::redraw() {
 	if (_dialogStack.empty())
 		return;
 
-	// Reset any custom RTL paddings set by stacked dialogs when we go back to the top
-	if (useRTL() && _dialogStack.size() == 1) {
-		setDialogPaddings(0, 0);
-	}
-
 	if (_displayTopDialogOnly) {
 		redrawInternalTopDialogOnly();
 	} else {
@@ -842,10 +834,11 @@ void GuiManager::processEvent(const Common::Event &event, Dialog *const activeDi
 		return;
 	int button;
 	uint32 time;
-	Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
+	int16 mouseX = event.mouse.x;
 	if (g_gui.useRTL()) {
-		mouse.x = g_system->getOverlayWidth() - event.mouse.x - activeDialog->_x + g_gui.getOverlayOffset();
+		mouseX = g_system->getOverlayWidth() - mouseX;
 	}
+	Common::Point mouse(mouseX - activeDialog->_x, event.mouse.y - activeDialog->_y);
 	switch (event.type) {
 	case Common::EVENT_KEYDOWN:
 		activeDialog->handleKeyDown(event.kbd);
@@ -854,11 +847,7 @@ void GuiManager::processEvent(const Common::Event &event, Dialog *const activeDi
 		activeDialog->handleKeyUp(event.kbd);
 		break;
 	case Common::EVENT_MOUSEMOVE:
-		if (g_gui.useRTL()) {
-			_globalMousePosition.x = g_system->getOverlayWidth() - event.mouse.x + g_gui.getOverlayOffset();
-		} else {
-			_globalMousePosition.x = event.mouse.x;
-		}
+		_globalMousePosition.x = mouseX;
 		_globalMousePosition.y = event.mouse.y;
 		activeDialog->handleMouseMoved(mouse.x, mouse.y, 0);
 
@@ -948,11 +937,6 @@ void GuiManager::setLanguageRTL() {
 	_useRTL = false;
 }
 
-void GuiManager::setDialogPaddings(int l, int r) {
-	_topDialogLeftPadding = l;
-	_topDialogRightPadding = r;
-}
-
 void GuiManager::initTextToSpeech() {
 	Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
 	if (ttsMan == nullptr)
diff --git a/gui/gui-manager.h b/gui/gui-manager.h
index dc890e9c4a3..0718f631c8b 100644
--- a/gui/gui-manager.h
+++ b/gui/gui-manager.h
@@ -122,9 +122,6 @@ public:
 	bool useRTL() const { return _useRTL; }
 	void setLanguageRTL();
 
-	void setDialogPaddings(int l, int r);
-	int getOverlayOffset() { return _topDialogRightPadding - _topDialogLeftPadding; }
-
 	const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
 	int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
 	int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
@@ -184,9 +181,6 @@ protected:
 
 	bool		_useRTL;
 
-	int			_topDialogLeftPadding;
-	int			_topDialogRightPadding;
-
 	bool		_displayTopDialogOnly;
 
 	Common::Mutex _iconsMutex;
diff --git a/gui/widget.cpp b/gui/widget.cpp
index cb3eac811ec..e196e51e70b 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -113,13 +113,6 @@ void Widget::draw() {
 		if (g_gui.useRTL()) {
 			_x = g_system->getOverlayWidth() - _x - _w;
 
-			if (this->_name.contains("GameOptions") || this->_name.contains("GlobalOptions") || this->_name.contains("Browser") || this->_name.empty()) {
-				/** The dialogs named above are the stacked dialogs for which the left+right paddings need to be adjusted for RTL.
-					The _name is empty for some special widgets - like RemapWidgets, NavBars, ScrollBars and they need to be adjusted too.
-				*/
-				_x = _x + g_gui.getOverlayOffset();
-			}
-
 			clip.moveTo(_x, clip.top);
 			g_gui.theme()->swapClipRect(clip);
 		}
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index da8149f78f1..42b5b89a402 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -571,7 +571,7 @@ int EditableWidget::getSelectionCarretOffset() const {
 		return;
 
 	if (g_gui.useRTL())
-		x += g_system->getOverlayWidth() - _w - xOff + g_gui.getOverlayOffset();
+		x += g_system->getOverlayWidth() - _w - xOff;
 	else
 		x += xOff;
 	y += yOff;
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 5b3f1168a7f..4e5d4f629cb 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -131,12 +131,13 @@ void PopUpDialog::reflowLayout() {
 void PopUpDialog::drawDialog(DrawLayer layerToDraw) {
 	Dialog::drawDialog(layerToDraw);
 
+	int16 x = _x;
 	if (g_gui.useRTL()) {
-		_x = g_system->getOverlayWidth() - _x - _w + g_gui.getOverlayOffset();
+		x = g_system->getOverlayWidth() - _x - _w;
 	}
 
 	// Draw the menu border
-	g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundPlain);
+	g_gui.theme()->drawWidgetBackground(Common::Rect(x, _y, x + _w, _y + _h), ThemeEngine::kWidgetBackgroundPlain);
 
 	/*if (_twoColumns)
 		g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/
@@ -405,11 +406,10 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
 	int pad = _leftPadding;
 
 	if (g_gui.useRTL()) {
-		if (_twoColumns) {
-			r1.translate(this->getWidth() - w, 0);		// Shift the line-separator to the "first" col of RTL popup
-		}
-
-		r2.left = g_system->getOverlayWidth() - r2.left - w + g_gui.getOverlayOffset();
+		const int16 screenW = g_system->getOverlayWidth();
+		r1.left = screenW - r1.left - w;
+		r1.right = r1.left + w;
+		r2.left = screenW - r2.left - w;
 		r2.right = r2.left + w;
 
 		alignment = Graphics::kTextAlignRight;




More information about the Scummvm-git-logs mailing list