From 5f72aade771ea63eaee468b09e2017dbbc5e6bef Mon Sep 17 00:00:00 2001
From: James Rowe <jroweboy@gmail.com>
Date: Sat, 5 Nov 2016 01:47:05 -0600
Subject: Rework frame layouts to use a max rectangle instead of hardcoded
 calculations

---
 src/common/math_util.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'src/common/math_util.h')

diff --git a/src/common/math_util.h b/src/common/math_util.h
index 41d89666c0..570ec8e56e 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -38,6 +38,18 @@ struct Rectangle {
     T GetHeight() const {
         return std::abs(static_cast<typename std::make_signed<T>::type>(bottom - top));
     }
+    Rectangle<T> TranslateX(const T x) const {
+        return Rectangle{left + x, top, right + x, bottom};
+    }
+    Rectangle<T> TranslateY(const T y) const {
+        return Rectangle{left, top + y, right, bottom + y};
+    }
+    Rectangle<T> Scale(const float s) const {
+        ASSERT(s > 0);
+        return Rectangle {
+            left, top, static_cast<T>((right + left) * s), static_cast<T>((top + bottom) * s)
+        };
+    }
 };
 
 } // namespace MathUtil
-- 
cgit v1.2.3-70-g09d2