Add a BObjectList<BLayoutItem> to BView::fLayoutData that keeps track of any BLayoutItems that refer to this view that are part of a layout. BLayoutItem does the registering/deregistering of the items, and BView::Private proxies fLayoutData for us. Currently, this is not used anywhere, but there are many places where it will be used soon.
This commit is contained in:
@@ -66,6 +66,11 @@ public:
|
|||||||
bool WillLayout();
|
bool WillLayout();
|
||||||
bool MinMaxValid();
|
bool MinMaxValid();
|
||||||
|
|
||||||
|
BLayoutItem* LayoutItemAt(int32 index);
|
||||||
|
int32 CountLayoutItems();
|
||||||
|
void RegisterLayoutItem(BLayoutItem* item);
|
||||||
|
void DeregisterLayoutItem(BLayoutItem* item);
|
||||||
|
|
||||||
bool RemoveSelf()
|
bool RemoveSelf()
|
||||||
{
|
{
|
||||||
return fView->_RemoveSelf();
|
return fView->_RemoveSelf();
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ BLayout::RemoveItem(int32 index)
|
|||||||
|
|
||||||
BLayoutItem* item = (BLayoutItem*)fItems.RemoveItem(index);
|
BLayoutItem* item = (BLayoutItem*)fItems.RemoveItem(index);
|
||||||
|
|
||||||
// if the item refers to a BView, we make sure, it is removed from the
|
// if the item refers to a BView, we make sure it is removed from the
|
||||||
// parent view
|
// parent view
|
||||||
BView* view = item->View();
|
BView* view = item->View();
|
||||||
if (view && view->fParent == fTarget)
|
if (view && view->fParent == fTarget)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <Layout.h>
|
#include <Layout.h>
|
||||||
#include <LayoutUtils.h>
|
#include <LayoutUtils.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
#include <ViewPrivate.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -166,7 +167,15 @@ BLayoutItem::SetLayout(BLayout* layout)
|
|||||||
std::swap(fLayout, layout);
|
std::swap(fLayout, layout);
|
||||||
if (layout)
|
if (layout)
|
||||||
DetachedFromLayout(layout);
|
DetachedFromLayout(layout);
|
||||||
|
|
||||||
|
if (BView* view = View()) {
|
||||||
|
if (layout && !fLayout) {
|
||||||
|
BView::Private(view).DeregisterLayoutItem(this);
|
||||||
|
} else if (fLayout && !layout) {
|
||||||
|
BView::Private(view).RegisterLayoutItem(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fLayout)
|
if (fLayout)
|
||||||
AttachedToLayout();
|
AttachedToLayout();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <MessageQueue.h>
|
#include <MessageQueue.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
#include <Picture.h>
|
#include <Picture.h>
|
||||||
#include <Point.h>
|
#include <Point.h>
|
||||||
#include <Polygon.h>
|
#include <Polygon.h>
|
||||||
@@ -335,6 +336,7 @@ struct BView::LayoutData {
|
|||||||
fLayoutInvalidationDisabled(0),
|
fLayoutInvalidationDisabled(0),
|
||||||
fLayout(NULL),
|
fLayout(NULL),
|
||||||
fLayoutContext(NULL),
|
fLayoutContext(NULL),
|
||||||
|
fLayoutItems(5, false),
|
||||||
fLayoutValid(true), // TODO: Rethink these initial values!
|
fLayoutValid(true), // TODO: Rethink these initial values!
|
||||||
fMinMaxValid(true), //
|
fMinMaxValid(true), //
|
||||||
fLayoutInProgress(false),
|
fLayoutInProgress(false),
|
||||||
@@ -375,6 +377,7 @@ struct BView::LayoutData {
|
|||||||
int fLayoutInvalidationDisabled;
|
int fLayoutInvalidationDisabled;
|
||||||
BLayout* fLayout;
|
BLayout* fLayout;
|
||||||
BLayoutContext* fLayoutContext;
|
BLayoutContext* fLayoutContext;
|
||||||
|
BObjectList<BLayoutItem> fLayoutItems;
|
||||||
bool fLayoutValid;
|
bool fLayoutValid;
|
||||||
bool fMinMaxValid;
|
bool fMinMaxValid;
|
||||||
bool fLayoutInProgress;
|
bool fLayoutInProgress;
|
||||||
@@ -5959,6 +5962,34 @@ BView::_PrintTree()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutItem*
|
||||||
|
BView::Private::LayoutItemAt(int32 index)
|
||||||
|
{
|
||||||
|
return fView->fLayoutData->fLayoutItems.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BView::Private::CountLayoutItems()
|
||||||
|
{
|
||||||
|
return fView->fLayoutData->fLayoutItems.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::Private::RegisterLayoutItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
fView->fLayoutData->fLayoutItems.AddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::Private::DeregisterLayoutItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
fView->fLayoutData->fLayoutItems.RemoveItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BView::Private::MinMaxValid()
|
BView::Private::MinMaxValid()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user