From 5f72aade771ea63eaee468b09e2017dbbc5e6bef Mon Sep 17 00:00:00 2001 From: James Rowe 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 41d89666c..570ec8e56 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::type>(bottom - top)); } + Rectangle TranslateX(const T x) const { + return Rectangle{left + x, top, right + x, bottom}; + } + Rectangle TranslateY(const T y) const { + return Rectangle{left, top + y, right, bottom + y}; + } + Rectangle Scale(const float s) const { + ASSERT(s > 0); + return Rectangle { + left, top, static_cast((right + left) * s), static_cast((top + bottom) * s) + }; + } }; } // namespace MathUtil -- cgit v1.2.3 From d9305b0a074a255eb484911db70a126a6fe347b1 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Sat, 5 Nov 2016 02:58:11 -0600 Subject: Add default hotkey to swap primary screens. Also minor style changes --- src/common/math_util.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/common/math_util.h') diff --git a/src/common/math_util.h b/src/common/math_util.h index 570ec8e56..9e630d93d 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -45,10 +45,8 @@ struct Rectangle { return Rectangle{left, top + y, right, bottom + y}; } Rectangle Scale(const float s) const { - ASSERT(s > 0); - return Rectangle { - left, top, static_cast((right + left) * s), static_cast((top + bottom) * s) - }; + return Rectangle{left, top, static_cast((right + left) * s), + static_cast((top + bottom) * s)}; } }; -- cgit v1.2.3 From 793339b73a9bc87d6fa22742be4631565c2201db Mon Sep 17 00:00:00 2001 From: James Rowe Date: Thu, 10 Nov 2016 00:36:07 -0700 Subject: Round the rectangle size to prevent float to int casting issues And other minor style changes --- src/common/math_util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/common/math_util.h') diff --git a/src/common/math_util.h b/src/common/math_util.h index 9e630d93d..cdeaeb733 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -45,8 +45,8 @@ struct Rectangle { return Rectangle{left, top + y, right, bottom + y}; } Rectangle Scale(const float s) const { - return Rectangle{left, top, static_cast((right + left) * s), - static_cast((top + bottom) * s)}; + return Rectangle{left, top, static_cast(left + GetWidth() * s), + static_cast(top + GetHeight() * s)}; } }; -- cgit v1.2.3