[Libreoffice-commits] core.git: include/tools
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 26 11:05:50 UTC 2021
include/tools/gen.hxx | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
New commits:
commit 5c81670bd66a222f8c8de45b52a62adb8f333b38
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Apr 26 08:03:35 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Apr 26 13:05:14 2021 +0200
Simplify center calculation
Change-Id: Iabe16cee8fe0b32d262be7066a036a305878cf39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114595
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 0f1e942c2eb5..34ac425b7fc1 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -497,8 +497,7 @@ public:
if (IsEmpty())
return Point(nLeft, nTop);
else
- return Point(std::min(nLeft, nRight) + std::abs((nRight - nLeft) / 2),
- std::min(nTop, nBottom));
+ return Point((nLeft + nRight) / 2, std::min(nTop, nBottom));
}
inline Point BottomLeft() const;
inline Point BottomRight() const;
@@ -677,8 +676,7 @@ inline Point tools::Rectangle::BottomCenter() const
if ( IsEmpty() )
return Point( nLeft, nTop );
else
- return Point( std::min( nLeft, nRight ) + std::abs( (nRight - nLeft)/2 ),
- std::max( nTop, nBottom) );
+ return Point((nLeft + nRight) / 2, std::max(nTop, nBottom));
}
inline Point tools::Rectangle::LeftCenter() const
@@ -686,7 +684,7 @@ inline Point tools::Rectangle::LeftCenter() const
if ( IsEmpty() )
return Point( nLeft, nTop );
else
- return Point( std::min( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
+ return Point(std::min(nLeft, nRight), (nTop + nBottom) / 2);
}
inline Point tools::Rectangle::RightCenter() const
@@ -694,7 +692,7 @@ inline Point tools::Rectangle::RightCenter() const
if ( IsEmpty() )
return Point( nLeft, nTop );
else
- return Point( std::max( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
+ return Point(std::max(nLeft, nRight), (nTop + nBottom) / 2);
}
inline Point tools::Rectangle::Center() const
@@ -702,7 +700,7 @@ inline Point tools::Rectangle::Center() const
if ( IsEmpty() )
return Point( nLeft, nTop );
else
- return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 );
+ return Point((nLeft + nRight) / 2, (nTop + nBottom) / 2);
}
inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long nVertMove )
More information about the Libreoffice-commits
mailing list