[Scummvm-git-logs] scummvm master -> 0e99ed1ad13c790c5c58071ae067d159ad476501

bluegr noreply at scummvm.org
Sat May 27 08:10:22 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:
bf087e4ad3 COMMON: Add Rect constructor that accepts top-left and bottom-right coordinates as points
0e99ed1ad1 COMMON: Add Rect constructor that accepts a top-left coordinate, width, and height


Commit: bf087e4ad323584810999d65c2fc5a7fa19cc2ff
    https://github.com/scummvm/scummvm/commit/bf087e4ad323584810999d65c2fc5a7fa19cc2ff
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-27T11:10:18+03:00

Commit Message:
COMMON: Add Rect constructor that accepts top-left and bottom-right coordinates as points

Changed paths:
    common/rect.h


diff --git a/common/rect.h b/common/rect.h
index 0a74cec6c39..c661ab8ef99 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -150,6 +150,16 @@ struct Rect {
 	 * Create a rectangle with the top-left corner at position (0, 0) and the given width @p w and height @p h.
 	 */
 	constexpr Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
+	/**
+	 * Create a rectangle with the top-left corner at the position @p topLeft
+	 * and the bottom-right corner at the position @p bottomRight.
+	 *
+	 * The @p topLeft x value must be greater or equal @p bottomRight x and
+	 * @p topLeft y must be greater or equal @p bottomRight y.
+	 */
+	Rect(const Point &topLeft, const Point &bottomRight) : top(topLeft.y), left(topLeft.x), bottom(bottomRight.y), right(bottomRight.x) {
+		assert(isValidRect());
+	}
 	/**
 	 * Create a rectangle with the top-left corner at the given position (x1, y1)
 	 * and the bottom-right corner at the position (x2, y2).


Commit: 0e99ed1ad13c790c5c58071ae067d159ad476501
    https://github.com/scummvm/scummvm/commit/0e99ed1ad13c790c5c58071ae067d159ad476501
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-27T11:10:18+03:00

Commit Message:
COMMON: Add Rect constructor that accepts a top-left coordinate, width, and height

Changed paths:
    common/rect.h


diff --git a/common/rect.h b/common/rect.h
index c661ab8ef99..373b02a9b3d 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -160,6 +160,12 @@ struct Rect {
 	Rect(const Point &topLeft, const Point &bottomRight) : top(topLeft.y), left(topLeft.x), bottom(bottomRight.y), right(bottomRight.x) {
 		assert(isValidRect());
 	}
+	/**
+	 * Create a rectangle with the top-left corner at the position @p topLeft
+	 * and the given width @p w and height @p h.
+	 */
+	constexpr Rect(const Point &topLeft, int16 w, int16 h) : top(topLeft.y), left(topLeft.x), bottom(topLeft.y + h), right(topLeft.x + w) {
+	}
 	/**
 	 * Create a rectangle with the top-left corner at the given position (x1, y1)
 	 * and the bottom-right corner at the position (x2, y2).




More information about the Scummvm-git-logs mailing list