From 2d4087c90aa8f269b9e82ccb45073e0afd63bff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Thu, 17 Mar 2011 01:08:01 +0000 Subject: [PATCH] Cleanup. Addition of constructor BRect(float side), allowing e.g. BRect(B_LARGE_ICON). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40984 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Rect.h | 60 ++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/headers/os/interface/Rect.h b/headers/os/interface/Rect.h index 86712ff98c..f55f24f6f6 100644 --- a/headers/os/interface/Rect.h +++ b/headers/os/interface/Rect.h @@ -25,6 +25,7 @@ public: float bottom); BRect(BPoint leftTop, BPoint rightBottom); BRect(BPoint leftTop, BSize size); + BRect(float side); BRect& operator=(const BRect& other); void Set(float left, float top, float right, @@ -90,14 +91,14 @@ public: inline BPoint BRect::LeftTop() const { - return *(const BPoint *)&left; + return *(const BPoint*)&left; } inline BPoint BRect::RightBottom() const { - return *(const BPoint *)&right; + return *(const BPoint*)&right; } @@ -117,48 +118,66 @@ BRect::RightTop() const inline BRect::BRect() + : + left(0), + top(0), + right(-1), + bottom(-1) { - top = left = 0; - bottom = right = -1; } inline BRect::BRect(float l, float t, float r, float b) + : + left(l), + top(t), + right(r), + bottom(b) { - left = l; - top = t; - right = r; - bottom = b; } inline BRect::BRect(const BRect& r) + : + left(r.left), + top(r.top), + right(r.right), + bottom(r.bottom) { - left = r.left; - top = r.top; - right = r.right; - bottom = r.bottom; } inline BRect::BRect(BPoint leftTop, BPoint rightBottom) + : + left(leftTop.x), + top(leftTop.y), + right(rightBottom.x), + bottom(rightBottom.y) { - left = leftTop.x; - top = leftTop.y; - right = rightBottom.x; - bottom = rightBottom.y; } inline BRect::BRect(BPoint leftTop, BSize size) - : left(leftTop.x), - top(leftTop.y), - right(leftTop.x + size.width), - bottom(leftTop.y + size.height) + : + left(leftTop.x), + top(leftTop.y), + right(leftTop.x + size.width), + bottom(leftTop.y + size.height) +{ +} + + +inline +BRect::BRect(float side) + : + left(0), + top(0), + right(side - 1), + bottom(side - 1) { } @@ -218,6 +237,7 @@ BRect::Height() const return bottom - top; } + inline BSize BRect::Size() const {