本文整理汇总了C++中BLayoutItem::IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem::IsVisible方法的具体用法?C++ BLayoutItem::IsVisible怎么用?C++ BLayoutItem::IsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLayoutItem
的用法示例。
在下文中一共展示了BLayoutItem::IsVisible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SubtractInsets
void
BTwoDimensionalLayout::LayoutView()
{
_ValidateMinMax();
// layout the horizontal/vertical elements
BSize size = SubtractInsets(View()->Frame().Size());
#ifdef DEBUG_LAYOUT
printf("BTwoDimensionalLayout::LayoutView(%p): size: (%.1f, %.1f)\n",
View(), size.width, size.height);
#endif
fLocalLayouter->Layout(size);
// layout the items
int itemCount = CountItems();
for (int i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
if (item->IsVisible()) {
Dimensions itemDimensions;
GetItemDimensions(item, &itemDimensions);
BRect frame = fLocalLayouter->ItemFrame(itemDimensions);
frame.left += fLeftInset;
frame.top += fTopInset;
frame.right += fLeftInset;
frame.bottom += fTopInset;
{
#ifdef DEBUG_LAYOUT
printf(" frame for item %2d (view: %p): ", i, item->View());
frame.PrintToStream();
#endif
//BSize min(item->MinSize());
//BSize max(item->MaxSize());
//printf(" min: (%.1f, %.1f), max: (%.1f, %.1f)\n", min.width, min.height,
// max.width, max.height);
//if (item->HasHeightForWidth()) {
//float minHeight, maxHeight, preferredHeight;
//item->GetHeightForWidth(frame.Width(), &minHeight, &maxHeight,
// &preferredHeight);
//printf(" hfw: min: %.1f, max: %.1f, pref: %.1f\n", minHeight, maxHeight,
// preferredHeight);
//}
}
item->AlignInFrame(frame);
}
//else
//printf(" item %2d not visible", i);
}
}
示例2: CountElements
void
BTwoDimensionalLayout::LocalLayouter::AddConstraints(
CompoundLayouter* compoundLayouter, Layouter* layouter)
{
enum orientation orientation = compoundLayouter->Orientation();
int itemCount = fLayout->CountItems();
if (itemCount > 0) {
for (int i = 0; i < itemCount; i++) {
BLayoutItem* item = fLayout->ItemAt(i);
if (item->IsVisible()) {
Dimensions itemDimensions;
fLayout->GetItemDimensions(item, &itemDimensions);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
if (orientation == B_HORIZONTAL) {
layouter->AddConstraints(
itemDimensions.x,
itemDimensions.width,
min.width,
max.width,
preferred.width);
if (item->HasHeightForWidth())
fHeightForWidthItems.AddItem(item);
} else {
layouter->AddConstraints(
itemDimensions.y,
itemDimensions.height,
min.height,
max.height,
preferred.height);
}
}
}
// add column/row constraints
ColumnRowConstraints constraints;
int elementCount = CountElements(compoundLayouter);
for (int element = 0; element < elementCount; element++) {
fLayout->GetColumnRowConstraints(orientation, element,
&constraints);
layouter->SetWeight(element, constraints.weight);
layouter->AddConstraints(element, 1, constraints.min,
constraints.max, constraints.min);
}
}
}
示例3: CountItems
void
BSplitLayout::_ValidateMinMax()
{
if (fHorizontalLayouter != NULL)
return;
fLayoutValid = false;
fVisibleItems.MakeEmpty();
fHeightForWidthItems.MakeEmpty();
_InvalidateCachedHeightForWidth();
// filter the visible items
int32 itemCount = CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
if (item->IsVisible())
fVisibleItems.AddItem(item);
// Add "height for width" items even, if they aren't visible. Otherwise
// we may get our parent into trouble, since we could change from
// "height for width" to "not height for width".
if (item->HasHeightForWidth())
fHeightForWidthItems.AddItem(item);
}
itemCount = fVisibleItems.CountItems();
// create the layouters
Layouter* itemLayouter = new SimpleLayouter(itemCount, 0);
if (fOrientation == B_HORIZONTAL) {
fHorizontalLayouter = itemLayouter;
fVerticalLayouter = new OneElementLayouter();
} else {
fHorizontalLayouter = new OneElementLayouter();
fVerticalLayouter = itemLayouter;
}
// tell the layouters about our constraints
if (itemCount > 0) {
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = (BLayoutItem*)fVisibleItems.ItemAt(i);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
fHorizontalLayouter->AddConstraints(i, 1, min.width, max.width,
preferred.width);
fVerticalLayouter->AddConstraints(i, 1, min.height, max.height,
preferred.height);
float weight = ItemWeight(item);
fHorizontalLayouter->SetWeight(i, weight);
fVerticalLayouter->SetWeight(i, weight);
}
}
fMin.width = fHorizontalLayouter->MinSize();
fMin.height = fVerticalLayouter->MinSize();
fMax.width = fHorizontalLayouter->MaxSize();
fMax.height = fVerticalLayouter->MaxSize();
fPreferred.width = fHorizontalLayouter->PreferredSize();
fPreferred.height = fVerticalLayouter->PreferredSize();
fHorizontalLayoutInfo = fHorizontalLayouter->CreateLayoutInfo();
if (fHeightForWidthItems.IsEmpty())
fVerticalLayoutInfo = fVerticalLayouter->CreateLayoutInfo();
ResetLayoutInvalidation();
}