From 87764660308468cf3bee4b115211f2a0e882050f Mon Sep 17 00:00:00 2001 From: X512 Date: Sun, 10 Nov 2024 18:34:40 +0900 Subject: [PATCH] BRect: add 2 argument width, height constructor Left top position will be set to zero. It is a common pattern to define `BRect` value with only width and height so it allow to simplify code a bit. Change-Id: Ie14644843324c9e5bcc55e7cfbd557a8884559d3 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8535 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- headers/os/interface/Rect.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/headers/os/interface/Rect.h b/headers/os/interface/Rect.h index ecca25baf5..30783126f6 100644 --- a/headers/os/interface/Rect.h +++ b/headers/os/interface/Rect.h @@ -26,6 +26,7 @@ public: BRect(BPoint leftTop, BPoint rightBottom); BRect(BPoint leftTop, BSize size); BRect(float side); + BRect(float width, float height); BRect& operator=(const BRect& other); void Set(float left, float top, float right, @@ -182,6 +183,17 @@ BRect::BRect(float side) } +inline +BRect::BRect(float width, float height) + : + left(0), + top(0), + right(width), + bottom(height) +{ +} + + inline BRect& BRect::operator=(const BRect& other) {