From 00873f781865e715519570b3a002aa5ac06efc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 19 Mar 2010 00:28:38 +0000 Subject: [PATCH] Added BShape::CurrentPoint(), returning the current end point of the path. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35908 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Shape.h | 1 + src/kits/interface/Shape.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/headers/os/interface/Shape.h b/headers/os/interface/Shape.h index 7b6181be9c..b287ed5e3e 100644 --- a/headers/os/interface/Shape.h +++ b/headers/os/interface/Shape.h @@ -63,6 +63,7 @@ public: void Clear(); BRect Bounds() const; + BPoint CurrentPosition() const; status_t AddShape(const BShape* other); diff --git a/src/kits/interface/Shape.cpp b/src/kits/interface/Shape.cpp index 7dbbca64fa..3666d4face 100644 --- a/src/kits/interface/Shape.cpp +++ b/src/kits/interface/Shape.cpp @@ -301,13 +301,13 @@ BShape::Bounds() const if (data->ptCount == 0) return bounds; + // TODO: This implementation doesn't take into account curves at all. bounds.left = data->ptList[0].x; bounds.top = data->ptList[0].y; bounds.right = data->ptList[0].x; bounds.bottom = data->ptList[0].y; - for (int32 i = 1; i < data->ptCount; i++) - { + for (int32 i = 1; i < data->ptCount; i++) { if (bounds.left > data->ptList[i].x) bounds.left = data->ptList[i].x; if (bounds.top > data->ptList[i].y) @@ -322,6 +322,18 @@ BShape::Bounds() const } +BPoint +BShape::CurrentPosition() const +{ + shape_data* data = (shape_data*)fPrivateData; + + if (data->ptCount == 0) + return B_ORIGIN; + + return data->ptList[data->ptCount - 1]; +} + + status_t BShape::AddShape(const BShape* otherShape) {