Devirtualize BLayout::InvalidateLayout(), add a protected hook BLayout::DoLayout(). This will allow for much better control over the propagation of layout invalidations, and therefore cleaner, more optimal code.
This commit is contained in:
@@ -28,13 +28,12 @@ public:
|
|||||||
virtual void GetHeightForWidth(float width, float* min,
|
virtual void GetHeightForWidth(float width, float* min,
|
||||||
float* max, float* preferred);
|
float* max, float* preferred);
|
||||||
|
|
||||||
virtual void InvalidateLayout(bool children = false);
|
|
||||||
|
|
||||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||||
virtual status_t AllUnarchived(const BMessage* from);
|
virtual status_t AllUnarchived(const BMessage* from);
|
||||||
static BArchivable* Instantiate(BMessage* from);
|
static BArchivable* Instantiate(BMessage* from);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void LayoutInvalidated(bool children = false);
|
||||||
virtual void DoLayout();
|
virtual void DoLayout();
|
||||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
// Layouting related methods
|
// Layouting related methods
|
||||||
|
|
||||||
virtual void InvalidateLayout(bool children = false);
|
void InvalidateLayout(bool children = false);
|
||||||
void Relayout(bool immediate = false);
|
void Relayout(bool immediate = false);
|
||||||
void RequireLayout();
|
void RequireLayout();
|
||||||
bool IsValid();
|
bool IsValid();
|
||||||
@@ -73,6 +73,7 @@ protected:
|
|||||||
// BLayout hook methods
|
// BLayout hook methods
|
||||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||||
|
virtual void LayoutInvalidated(bool children);
|
||||||
virtual void DoLayout() = 0;
|
virtual void DoLayout() = 0;
|
||||||
virtual void OwnerChanged(BView* was);
|
virtual void OwnerChanged(BView* was);
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ public:
|
|||||||
|
|
||||||
virtual void SetFrame(BRect frame);
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
virtual void InvalidateLayout(bool children = false);
|
|
||||||
|
|
||||||
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
||||||
virtual status_t AllArchived(BMessage* into) const;
|
virtual status_t AllArchived(BMessage* into) const;
|
||||||
virtual status_t AllUnarchived(const BMessage* from);
|
virtual status_t AllUnarchived(const BMessage* from);
|
||||||
@@ -58,6 +56,7 @@ protected:
|
|||||||
int32 height;
|
int32 height;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual void LayoutInvalidated(bool children = false);
|
||||||
virtual void DoLayout();
|
virtual void DoLayout();
|
||||||
|
|
||||||
BSize AddInsets(BSize size);
|
BSize AddInsets(BSize size);
|
||||||
|
|||||||
@@ -174,10 +174,8 @@ BCardLayout::GetHeightForWidth(float width, float* min, float* max,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCardLayout::InvalidateLayout(bool children)
|
BCardLayout::LayoutInvalidated(bool children)
|
||||||
{
|
{
|
||||||
BLayout::InvalidateLayout(children);
|
|
||||||
|
|
||||||
fMinMaxValid = false;
|
fMinMaxValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ BLayout::InvalidateLayout(bool children)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fState |= B_LAYOUT_NECESSARY;
|
fState |= B_LAYOUT_NECESSARY;
|
||||||
|
LayoutInvalidated(children);
|
||||||
|
|
||||||
if (children) {
|
if (children) {
|
||||||
for (int32 i = CountItems() - 1; i >= 0; i--)
|
for (int32 i = CountItems() - 1; i >= 0; i--)
|
||||||
@@ -522,6 +523,12 @@ BLayout::ItemRemoved(BLayoutItem* item, int32 fromIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BLayout::LayoutInvalidated(bool children)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BLayout::OwnerChanged(BView* was)
|
BLayout::OwnerChanged(BView* was)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -546,9 +546,21 @@ BSplitLayout::GetHeightForWidth(float width, float* min, float* max,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BSplitLayout::InvalidateLayout(bool children)
|
BSplitLayout::LayoutInvalidated(bool children)
|
||||||
{
|
{
|
||||||
_InvalidateLayout(true, children);
|
delete fHorizontalLayouter;
|
||||||
|
delete fVerticalLayouter;
|
||||||
|
delete fHorizontalLayoutInfo;
|
||||||
|
delete fVerticalLayoutInfo;
|
||||||
|
|
||||||
|
fHorizontalLayouter = NULL;
|
||||||
|
fVerticalLayouter = NULL;
|
||||||
|
fHorizontalLayoutInfo = NULL;
|
||||||
|
fVerticalLayoutInfo = NULL;
|
||||||
|
|
||||||
|
_InvalidateCachedHeightForWidth();
|
||||||
|
|
||||||
|
fLayoutValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -820,28 +832,6 @@ BSplitLayout::ItemRemoved(BLayoutItem* item, int32 atIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BSplitLayout::_InvalidateLayout(bool invalidateView, bool children)
|
|
||||||
{
|
|
||||||
if (invalidateView)
|
|
||||||
BAbstractLayout::InvalidateLayout(children);
|
|
||||||
|
|
||||||
delete fHorizontalLayouter;
|
|
||||||
delete fVerticalLayouter;
|
|
||||||
delete fHorizontalLayoutInfo;
|
|
||||||
delete fVerticalLayoutInfo;
|
|
||||||
|
|
||||||
fHorizontalLayouter = NULL;
|
|
||||||
fVerticalLayouter = NULL;
|
|
||||||
fHorizontalLayoutInfo = NULL;
|
|
||||||
fVerticalLayoutInfo = NULL;
|
|
||||||
|
|
||||||
_InvalidateCachedHeightForWidth();
|
|
||||||
|
|
||||||
fLayoutValid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BSplitLayout::_InvalidateCachedHeightForWidth()
|
BSplitLayout::_InvalidateCachedHeightForWidth()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ public:
|
|||||||
virtual void GetHeightForWidth(float width, float* min,
|
virtual void GetHeightForWidth(float width, float* min,
|
||||||
float* max, float* preferred);
|
float* max, float* preferred);
|
||||||
|
|
||||||
virtual void InvalidateLayout(bool children = false);
|
virtual void LayoutInvalidated(bool children);
|
||||||
|
|
||||||
virtual void DoLayout();
|
virtual void DoLayout();
|
||||||
|
|
||||||
// interface for BSplitView
|
// interface for BSplitView
|
||||||
|
|||||||
@@ -407,14 +407,6 @@ BTwoDimensionalLayout::SetFrame(BRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BTwoDimensionalLayout::InvalidateLayout(bool children)
|
|
||||||
{
|
|
||||||
BLayout::InvalidateLayout(children);
|
|
||||||
fLocalLayouter->InvalidateLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BTwoDimensionalLayout::Archive(BMessage* into, bool deep) const
|
BTwoDimensionalLayout::Archive(BMessage* into, bool deep) const
|
||||||
{
|
{
|
||||||
@@ -464,6 +456,13 @@ BTwoDimensionalLayout::AllUnarchived(const BMessage* from)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTwoDimensionalLayout::LayoutInvalidated(bool children)
|
||||||
|
{
|
||||||
|
fLocalLayouter->InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTwoDimensionalLayout::DoLayout()
|
BTwoDimensionalLayout::DoLayout()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user