[Scummvm-git-logs] scummvm master -> 5ed9b34bf2b2cffbe0b041d8e75b97c9ef4770fc

lephilousophe noreply at scummvm.org
Sat Nov 2 19:07:36 UTC 2024


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:
5ed9b34bf2 GUI: Resolve text alignment on reflow


Commit: 5ed9b34bf2b2cffbe0b041d8e75b97c9ef4770fc
    https://github.com/scummvm/scummvm/commit/5ed9b34bf2b2cffbe0b041d8e75b97c9ef4770fc
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-11-02T20:02:17+01:00

Commit Message:
GUI: Resolve text alignment on reflow

Resolving it when constructing the text widget may be too early for
widgets not defined in XML (like Android options widget).
This makes the alignment being invalid some times and valid some other
times.

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


diff --git a/gui/widget.cpp b/gui/widget.cpp
index 279737cdc1b..0fdb8f3d52a 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -305,7 +305,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name,
 	setFlags(WIDGET_ENABLED | WIDGET_CLEARBG);
 	_type = kStaticTextWidget;
 	_label = text;
-	_align = Graphics::convertTextAlignH(g_gui.xmlEval()->getWidgetTextHAlign(name), g_gui.useRTL() && _useRTL);
+	_align = Graphics::kTextAlignInvalid;
 	setFont(font, lang);
 	_fontColor = ThemeEngine::FontColor::kFontColorNormal;
 	_useEllipsis = useEllipsis;
@@ -336,6 +336,14 @@ void StaticTextWidget::setFontColor(const ThemeEngine::FontColor color) {
 	_fontColor = color;
 }
 
+void StaticTextWidget::reflowLayout() {
+	Widget::reflowLayout();
+
+	if (_align == Graphics::kTextAlignInvalid) {
+		setAlign(g_gui.xmlEval()->getWidgetTextHAlign(_name));
+	}
+}
+
 void StaticTextWidget::drawWidget() {
 	g_gui.theme()->drawText(
 			Common::Rect(_x, _y, _x + _w, _y + _h),
diff --git a/gui/widget.h b/gui/widget.h
index f20696ef3da..72223c2f43e 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -224,6 +224,7 @@ public:
 	void setFontColor(ThemeEngine::FontColor color);
 
 protected:
+	void reflowLayout() override;
 	void drawWidget() override;
 	void setFont(ThemeEngine::FontStyle font, Common::Language lang);
 };




More information about the Scummvm-git-logs mailing list