From 0cc8c71bba30edfa1923bc528f541adc5d74f55b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 14 Apr 2015 23:28:45 +0200 Subject: [PATCH] BLayoutItem: Add RemoveSelf() convenience method. It works analoguous to BView::RemoveSelf(), i.e. it removes itself from the parent (layout in this case) and returns whether or not it had and was successfully removed from said parent. --- headers/os/interface/LayoutItem.h | 1 + src/kits/interface/LayoutItem.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/headers/os/interface/LayoutItem.h b/headers/os/interface/LayoutItem.h index 851fdd031c..82dd03fee5 100644 --- a/headers/os/interface/LayoutItem.h +++ b/headers/os/interface/LayoutItem.h @@ -23,6 +23,7 @@ public: virtual ~BLayoutItem(); BLayout* Layout() const; + bool RemoveSelf(); virtual BSize MinSize() = 0; virtual BSize MaxSize() = 0; diff --git a/src/kits/interface/LayoutItem.cpp b/src/kits/interface/LayoutItem.cpp index 5ef6cab9c5..4cfc01e2c3 100644 --- a/src/kits/interface/LayoutItem.cpp +++ b/src/kits/interface/LayoutItem.cpp @@ -47,6 +47,13 @@ BLayoutItem::Layout() const } +bool +BLayoutItem::RemoveSelf() +{ + return Layout() != NULL && Layout()->RemoveItem(this); +} + + void BLayoutItem::SetExplicitSize(BSize size) {