De-virtualize BView::InvalidateLayout() and introduce LayoutInvalidated() hook, like BLayout.

This commit is contained in:
Alex Wilson 2011-10-20 19:18:22 -06:00
parent b38ea98f52
commit eee4243d35
29 changed files with 138 additions and 131 deletions

View File

@ -71,7 +71,8 @@ class BBox : public BView {
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual void InvalidateLayout(bool descendants = false);
protected:
virtual void LayoutInvalidated(bool descendants = false);
virtual void DoLayout();
private:

View File

@ -63,13 +63,15 @@ public:
virtual status_t GetSupportedSuites(BMessage* message);
virtual status_t Perform(perform_code d, void* arg);
virtual void InvalidateLayout(bool descendants = false);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
protected:
virtual void LayoutInvalidated(bool descendants = false);
private:
virtual void _ReservedButton1();
virtual void _ReservedButton2();

View File

@ -52,8 +52,6 @@ public:
float* _height);
virtual void ResizeToPreferred();
virtual void InvalidateLayout(bool descendants = false);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
@ -70,6 +68,9 @@ public:
virtual status_t Perform(perform_code code, void* data);
protected:
virtual void LayoutInvalidated(bool descendants = false);
private:
// FBC padding
virtual void _ReservedCheckBox1();

View File

@ -41,7 +41,6 @@ public:
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual void InvalidateLayout(bool descendants = false);
virtual void ResizeToPreferred();
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float newWidth, float newHeight);
@ -62,6 +61,8 @@ public:
virtual void SetFont(const BFont* font,
uint32 mask = B_FONT_ALL);
protected:
virtual void LayoutInvalidated(bool descendants = false);
private:
// FBC padding and forbidden methods

View File

@ -548,10 +548,10 @@ public:
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred);
void InvalidateLayout(bool descendants = false);
virtual void SetLayout(BLayout* layout);
BLayout* GetLayout() const;
virtual void InvalidateLayout(bool descendants = false);
void EnableLayoutInvalidation();
void DisableLayoutInvalidation();
bool IsLayoutValid() const;
@ -565,6 +565,7 @@ public:
class Private;
protected:
virtual void LayoutInvalidated(bool descendants = false);
virtual void DoLayout();
public:

View File

@ -19,7 +19,7 @@ enum {
PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH = 1004,
PERFORM_CODE_GET_HEIGHT_FOR_WIDTH = 1005,
PERFORM_CODE_SET_LAYOUT = 1006,
PERFORM_CODE_INVALIDATE_LAYOUT = 1007,
PERFORM_CODE_LAYOUT_INVALIDATED = 1007,
PERFORM_CODE_DO_LAYOUT = 1008,
PERFORM_CODE_GET_TOOL_TIP_AT = 1009,

View File

@ -41,7 +41,7 @@ struct perform_data_set_layout {
BLayout* layout;
};
struct perform_data_invalidate_layout {
struct perform_data_layout_invalidated {
bool descendants;
};

View File

@ -487,11 +487,11 @@ BBox::Perform(perform_code code, void* _data)
BBox::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BBox::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BBox::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:
@ -537,10 +537,9 @@ BBox::PreferredSize()
void
BBox::InvalidateLayout(bool descendants)
BBox::LayoutInvalidated(bool descendants)
{
fLayoutData->valid = false;
BView::InvalidateLayout(descendants);
}

View File

@ -650,11 +650,11 @@ BButton::Perform(perform_code code, void* _data)
BButton::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BButton::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BButton::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:
@ -668,16 +668,6 @@ BButton::Perform(perform_code code, void* _data)
}
void
BButton::InvalidateLayout(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(-1, -1);
BControl::InvalidateLayout(descendants);
}
BSize
BButton::MinSize()
{
@ -702,6 +692,14 @@ BButton::PreferredSize()
}
void
BButton::LayoutInvalidated(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(-1, -1);
}
void BButton::_ReservedButton1() {}
void BButton::_ReservedButton2() {}
void BButton::_ReservedButton3() {}

View File

@ -440,16 +440,6 @@ BCheckBox::ResizeToPreferred()
}
void
BCheckBox::InvalidateLayout(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(B_SIZE_UNSET, B_SIZE_UNSET);
BControl::InvalidateLayout(descendants);
}
BSize
BCheckBox::MinSize()
{
@ -558,11 +548,11 @@ BCheckBox::Perform(perform_code code, void* _data)
BCheckBox::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BCheckBox::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BCheckBox::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:
@ -576,6 +566,14 @@ BCheckBox::Perform(perform_code code, void* _data)
}
void
BCheckBox::LayoutInvalidated(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(B_SIZE_UNSET, B_SIZE_UNSET);
}
// #pragma mark - FBC padding

View File

@ -937,11 +937,11 @@ BColorControl::Perform(perform_code code, void* _data)
BColorControl::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BColorControl::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BColorControl::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -497,11 +497,11 @@ BControl::Perform(perform_code code, void* _data)
BControl::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BControl::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BControl::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -491,11 +491,11 @@ BDragger::Perform(perform_code code, void* _data)
BDragger::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BDragger::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BDragger::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -1309,11 +1309,11 @@ BListView::Perform(perform_code code, void* _data)
BListView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BListView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BListView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -1236,11 +1236,11 @@ BMenu::Perform(perform_code code, void* _data)
BMenu::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BMenu::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BMenu::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -438,11 +438,11 @@ BMenuBar::Perform(perform_code code, void* _data)
BMenuBar::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BMenuBar::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BMenuBar::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -872,11 +872,11 @@ BMenuField::Perform(perform_code code, void* _data)
BMenuField::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BMenuField::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BMenuField::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -555,11 +555,11 @@ BOutlineListView::Perform(perform_code code, void* _data)
BOutlineListView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BOutlineListView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BOutlineListView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -458,11 +458,11 @@ BPictureButton::Perform(perform_code code, void* _data)
BPictureButton::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BPictureButton::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BPictureButton::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -211,11 +211,11 @@ BPopUpMenu::Perform(perform_code code, void* _data)
BPopUpMenu::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BPopUpMenu::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BPopUpMenu::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -541,11 +541,11 @@ BRadioButton::Perform(perform_code code, void* _data)
BRadioButton::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BRadioButton::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BRadioButton::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -1282,11 +1282,11 @@ BScrollBar::Perform(perform_code code, void* _data)
BScrollBar::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BScrollBar::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BScrollBar::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -650,11 +650,11 @@ BScrollView::Perform(perform_code code, void* _data)
BScrollView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BScrollView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BScrollView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -333,11 +333,11 @@ BSlider::Perform(perform_code code, void* _data)
BSlider::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BSlider::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BSlider::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -701,11 +701,11 @@ BStatusBar::Perform(perform_code code, void* _data)
BStatusBar::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BStatusBar::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BStatusBar::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -185,16 +185,6 @@ BStringView::PreferredSize()
}
void
BStringView::InvalidateLayout(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(-1, -1);
BView::InvalidateLayout(descendants);
}
void
BStringView::ResizeToPreferred()
{
@ -359,6 +349,14 @@ BStringView::SetFont(const BFont* font, uint32 mask)
}
void
BStringView::LayoutInvalidated(bool descendants)
{
// invalidate cached preferred size
fPreferredSize.Set(-1, -1);
}
// #pragma mark -
@ -400,11 +398,11 @@ BStringView::Perform(perform_code code, void* _data)
BStringView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BStringView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BStringView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -965,11 +965,11 @@ BTextControl::Perform(perform_code code, void* _data)
BTextControl::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BTextControl::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BTextControl::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -1122,11 +1122,11 @@ BTextView::Perform(perform_code code, void* _data)
BTextView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BTextView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BTextView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:

View File

@ -4481,11 +4481,11 @@ BView::Perform(perform_code code, void* _data)
BView::SetLayout(data->layout);
return B_OK;
}
case PERFORM_CODE_INVALIDATE_LAYOUT:
case PERFORM_CODE_LAYOUT_INVALIDATED:
{
perform_data_invalidate_layout* data
= (perform_data_invalidate_layout*)_data;
BView::InvalidateLayout(data->descendants);
perform_data_layout_invalidated* data
= (perform_data_layout_invalidated*)_data;
BView::LayoutInvalidated(data->descendants);
return B_OK;
}
case PERFORM_CODE_DO_LAYOUT:
@ -4697,6 +4697,7 @@ BView::InvalidateLayout(bool descendants)
fLayoutData->fLayoutValid = false;
fLayoutData->fMinMaxValid = false;
LayoutInvalidated(descendants);
if (descendants) {
for (BView* child = fFirstChild;
@ -4790,6 +4791,13 @@ BView::Relayout()
}
void
BView::LayoutInvalidated(bool descendants)
{
// hook method
}
void
BView::DoLayout()
{
@ -5772,10 +5780,10 @@ _ReservedView8__5BView(BView* view, BLayout* layout)
extern "C" void
_ReservedView9__5BView(BView* view, bool descendants)
{
// InvalidateLayout()
perform_data_invalidate_layout data;
// LayoutInvalidated()
perform_data_layout_invalidated data;
data.descendants = descendants;
view->Perform(PERFORM_CODE_INVALIDATE_LAYOUT, &data);
view->Perform(PERFORM_CODE_LAYOUT_INVALIDATED, &data);
}