[Scummvm-git-logs] scummvm master -> 1dce33dd9f909b09a73902b3939b61a81a149b7a

bgK bastien.bouclet at gmail.com
Thu Oct 17 19:33:54 CEST 2019


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:
1dce33dd9f GUI: Fix launcher layout for small widths


Commit: 1dce33dd9f909b09a73902b3939b61a81a149b7a
    https://github.com/scummvm/scummvm/commit/1dce33dd9f909b09a73902b3939b61a81a149b7a
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2019-10-17T19:33:50+02:00

Commit Message:
GUI: Fix launcher layout for small widths

* Testing if a widget can be centered was ignoring the padding.
* Only resize a layout based on its content if it was not explicitely
   sized by its parent. Fixes the logo causing incorrect layout
   computations when the window width is lower than the image width.

Changed paths:
    gui/ThemeLayout.cpp


diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp
index 71e4b2c..4e3499b 100644
--- a/gui/ThemeLayout.cpp
+++ b/gui/ThemeLayout.cpp
@@ -202,18 +202,11 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
 
 		_children[i]->offsetY(curY);
 
-		// Center child if it this has been requested *and* the space permits it.
-		if (_centered && _children[i]->getWidth() < _w && _w != -1) {
-			_children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
-		} else
-			_children[i]->offsetX(curX);
-
 		// Advance the vertical offset by the height of the newest item, plus
 		// the item spacing value.
 		curY += _children[i]->getHeight() + _spacing;
 
-		// Update width and height of this stack layout
-		_w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
+		// Update the height of this stack layout
 		_h += _children[i]->getHeight() + _spacing;
 	}
 
@@ -238,6 +231,21 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
 				_children[j]->offsetY(newh);
 		}
 	}
+
+	// Set stack width from its children if it was not set by its parent
+	if (_w == -1) {
+		for (uint i = 0; i < _children.size(); ++i) {
+			_w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
+		}
+	}
+
+	for (uint i = 0; i < _children.size(); ++i) {
+		// Center child if it this has been requested *and* the space permits it.
+		if (_centered && _children[i]->getWidth() < (_w - _padding.left - _padding.right) && _w != -1) {
+			_children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
+		} else
+			_children[i]->offsetX(curX);
+	}
 }
 
 void ThemeLayoutStacked::reflowLayoutHorizontal() {
@@ -265,19 +273,12 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
 
 		_children[i]->offsetX(curX);
 
-		// Center child if it this has been requested *and* the space permits it.
-		if (_centered && _children[i]->getHeight() < _h && _h != -1)
-			_children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
-		else
-			_children[i]->offsetY(curY);
-
 		// Advance the horizontal offset by the width of the newest item, plus
 		// the item spacing value.
 		curX += (_children[i]->getWidth() + _spacing);
 
-		// Update width and height of this stack layout
+		// Update the width of this stack layout
 		_w += _children[i]->getWidth() + _spacing;
-		_h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
 	}
 
 	// If there are any children at all, then we added the spacing value once
@@ -301,6 +302,21 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
 				_children[j]->offsetX(neww);
 		}
 	}
+
+	// Set stack height from its children if it was not set by its parent
+	if (_h == -1) {
+		for (uint i = 0; i < _children.size(); ++i) {
+			_h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
+		}
+	}
+
+	for (uint i = 0; i < _children.size(); ++i) {
+		// Center child if it this has been requested *and* the space permits it.
+		if (_centered && _children[i]->getHeight() < (_h - _padding.top - _padding.bottom) && _h != -1)
+			_children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
+		else
+			_children[i]->offsetY(curY);
+	}
 }
 
 } // End of namespace GUI





More information about the Scummvm-git-logs mailing list