BBox: propagate alignment from child for the...
...FULL_{VERTICAL,HORIZONTAL} case.
This commit is contained in:
@@ -70,6 +70,7 @@ class BBox : public BView {
|
|||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
virtual BSize MaxSize();
|
virtual BSize MaxSize();
|
||||||
virtual BSize PreferredSize();
|
virtual BSize PreferredSize();
|
||||||
|
virtual BAlignment LayoutAlignment();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void LayoutInvalidated(bool descendants = false);
|
virtual void LayoutInvalidated(bool descendants = false);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct BBox::LayoutData {
|
|||||||
BSize min;
|
BSize min;
|
||||||
BSize max;
|
BSize max;
|
||||||
BSize preferred;
|
BSize preferred;
|
||||||
|
BAlignment alignment;
|
||||||
bool valid; // validity the other fields
|
bool valid; // validity the other fields
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -540,6 +541,17 @@ BBox::PreferredSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BBox::LayoutAlignment()
|
||||||
|
{
|
||||||
|
_ValidateLayoutData();
|
||||||
|
|
||||||
|
BAlignment alignment = (GetLayout() ? GetLayout()->Alignment()
|
||||||
|
: fLayoutData->alignment);
|
||||||
|
return BLayoutUtils::ComposeAlignment(ExplicitAlignment(), alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BBox::LayoutInvalidated(bool descendants)
|
BBox::LayoutInvalidated(bool descendants)
|
||||||
{
|
{
|
||||||
@@ -849,6 +861,8 @@ BBox::_ValidateLayoutData()
|
|||||||
else
|
else
|
||||||
minWidth = addWidth - 1;
|
minWidth = addWidth - 1;
|
||||||
|
|
||||||
|
BAlignment alignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER);
|
||||||
|
|
||||||
// finally consider the child constraints, if we shall support layout
|
// finally consider the child constraints, if we shall support layout
|
||||||
BView* child = _Child();
|
BView* child = _Child();
|
||||||
if (child && (Flags() & B_SUPPORTS_LAYOUT)) {
|
if (child && (Flags() & B_SUPPORTS_LAYOUT)) {
|
||||||
@@ -870,10 +884,19 @@ BBox::_ValidateLayoutData()
|
|||||||
fLayoutData->min = min;
|
fLayoutData->min = min;
|
||||||
fLayoutData->max = max;
|
fLayoutData->max = max;
|
||||||
fLayoutData->preferred = preferred;
|
fLayoutData->preferred = preferred;
|
||||||
|
|
||||||
|
BAlignment childAlignment = child->LayoutAlignment();
|
||||||
|
if (childAlignment.horizontal == B_ALIGN_USE_FULL_WIDTH)
|
||||||
|
alignment.horizontal = B_ALIGN_USE_FULL_WIDTH;
|
||||||
|
if (childAlignment.vertical == B_ALIGN_USE_FULL_HEIGHT)
|
||||||
|
alignment.vertical = B_ALIGN_USE_FULL_HEIGHT;
|
||||||
|
|
||||||
|
fLayoutData->alignment = alignment;
|
||||||
} else {
|
} else {
|
||||||
fLayoutData->min.Set(minWidth, addHeight - 1);
|
fLayoutData->min.Set(minWidth, addHeight - 1);
|
||||||
fLayoutData->max.Set(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
|
fLayoutData->max.Set(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
|
||||||
fLayoutData->preferred = fLayoutData->min;
|
fLayoutData->preferred = fLayoutData->min;
|
||||||
|
fLayoutData->alignment = alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
fLayoutData->valid = true;
|
fLayoutData->valid = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user