summaryrefslogtreecommitdiff
path: root/include/tools/gen.hxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-08-14 22:08:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-08-17 11:24:46 +0200
commit28708b5b7ad12bc30f02142c990e5ad4128af912 (patch)
treeb3a25f28020dd2693dcbc0e8e66ea2656f1fc351 /include/tools/gen.hxx
parent8e5cb2bcae998b8606de12c7bc4cde1f98346190 (diff)
Simplify and inline tools::Rectangle::Justify
Change-Id: I535fb70fa532d98542ac30e0b2053bdaa6b94383 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120494 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include/tools/gen.hxx')
-rw-r--r--include/tools/gen.hxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 2d23b693fa50..5cc23bf83654 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -472,7 +472,7 @@ public:
constexpr Rectangle( tools::Long nLeft, tools::Long nTop );
constexpr Rectangle( const Point& rLT, const Size& rSize );
- static Rectangle Justify( const Point& rLT, const Point& rRB );
+ inline constexpr static Rectangle Justify(const Point& rLT, const Point& rRB);
constexpr tools::Long Left() const { return nLeft; }
constexpr tools::Long Right() const { return IsWidthEmpty() ? nLeft : nRight; }
@@ -626,6 +626,13 @@ constexpr inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSiz
, nBottom(rSize.Height() ? nTop + (rSize.Height() + (rSize.Height() > 0 ? -1 : 1)) : RECT_EMPTY)
{}
+constexpr inline tools::Rectangle tools::Rectangle::Justify(const Point& rLT, const Point& rRB)
+{
+ const std::pair<tools::Long, tools::Long> aLeftRight = std::minmax(rLT.X(), rRB.X());
+ const std::pair<tools::Long, tools::Long> aTopBottom = std::minmax(rLT.Y(), rRB.Y());
+ return { aLeftRight.first, aTopBottom.first, aLeftRight.second, aTopBottom.second };
+}
+
inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long nVertMove )
{
nLeft += nHorzMove;