include/tools/gen.hxx | 68 ++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 32 deletions(-)
New commits: commit 434d471e9b8e54626af332974268ffd8fce4a78e Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Thu Jun 2 22:35:15 2022 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Sat Jun 4 19:30:10 2022 +0200 Rectangle: move inline definition into functions ... and add GetPos() as TopLeft() alias. Change-Id: Ia2c169d40ed121e829802835011648281f48f585 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135424 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 6d4548065495..20da07cb99af 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -495,7 +495,7 @@ public: constexpr Rectangle( tools::Long nLeft, tools::Long nTop ); constexpr Rectangle( const Point& rLT, const Size& rSize ); - inline constexpr static Rectangle Justify(const Point& rLT, const Point& rRB); + constexpr inline 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; } @@ -531,41 +531,13 @@ public: inline void SetPos( const Point& rPoint ); void SetSize( const Size& rSize ); + constexpr Point GetPos() const { return TopLeft(); } constexpr Size GetSize() const { return { GetWidth(), GetHeight() }; } /// Returns the difference between right and left, assuming the range is inclusive. - constexpr tools::Long GetWidth() const - { - tools::Long n = 0; - - if (!IsWidthEmpty()) - { - n = nRight - nLeft; - if (n < 0) - n--; - else - n++; - } - - return n; - } - + constexpr inline tools::Long GetWidth() const; /// Returns the difference between bottom and top, assuming the range is inclusive. - constexpr tools::Long GetHeight() const - { - tools::Long n = 0; - - if (!IsHeightEmpty()) - { - n = nBottom - nTop; - if (n < 0) - n--; - else - n++; - } - - return n; - } + constexpr inline tools::Long GetHeight() const; tools::Rectangle& Union( const tools::Rectangle& rRect ); tools::Rectangle& Intersection( const tools::Rectangle& rRect ); @@ -691,6 +663,38 @@ inline void tools::Rectangle::SetPos( const Point& rPoint ) SetPosY(rPoint.Y()); } +constexpr inline tools::Long tools::Rectangle::GetWidth() const +{ + tools::Long n = 0; + + if (!IsWidthEmpty()) + { + n = nRight - nLeft; + if (n < 0) + n--; + else + n++; + } + + return n; +} + +constexpr inline tools::Long tools::Rectangle::GetHeight() const +{ + tools::Long n = 0; + + if (!IsHeightEmpty()) + { + n = nBottom - nTop; + if (n < 0) + n--; + else + n++; + } + + return n; +} + inline tools::Rectangle tools::Rectangle::GetUnion( const tools::Rectangle& rRect ) const { tools::Rectangle aTmpRect( *this );