void BTwoDimensionalLayout::VerticalCompoundLayouter::DoLayout(float size, LocalLayouter* localLayouter, BLayoutContext* context) { Layouter* layouter; if (_HasHeightForWidth()) { float minHeight, maxHeight, preferredHeight; InternalGetHeightForWidth(localLayouter, context, true, &minHeight, &maxHeight, &preferredHeight); size = max_c(size, minHeight); layouter = fHeightForWidthLayouter; } else layouter = fLayouter; layouter->Layout(fLayoutInfo, size); }
void BSplitLayout::DoLayout() { _ValidateMinMax(); // layout the elements BSize size = _SubtractInsets(LayoutArea().Size()); fHorizontalLayouter->Layout(fHorizontalLayoutInfo, size.width); Layouter* verticalLayouter; if (HasHeightForWidth()) { float minHeight, maxHeight, preferredHeight; _InternalGetHeightForWidth(size.width, true, &minHeight, &maxHeight, &preferredHeight); size.height = max_c(size.height, minHeight); verticalLayouter = fHeightForWidthVerticalLayouter; } else verticalLayouter = fVerticalLayouter; verticalLayouter->Layout(fVerticalLayoutInfo, size.height); float xOffset = fLeftInset; float yOffset = fTopInset; float splitterWidth = 0; // pixel counts, no distances float splitterHeight = 0; // float xSpacing = 0; float ySpacing = 0; if (fOrientation == B_HORIZONTAL) { splitterWidth = fSplitterSize; splitterHeight = size.height + 1; xSpacing = fSpacing; } else { splitterWidth = size.width + 1; splitterHeight = fSplitterSize; ySpacing = fSpacing; } int itemCount = CountItems(); for (int i = 0; i < itemCount; i++) { // layout the splitter if (i > 0) { SplitterItem* splitterItem = _SplitterItemAt(i - 1); _LayoutItem(splitterItem, BRect(xOffset, yOffset, xOffset + splitterWidth - 1, yOffset + splitterHeight - 1), true); if (fOrientation == B_HORIZONTAL) xOffset += splitterWidth + xSpacing; else yOffset += splitterHeight + ySpacing; } // layout the item BLayoutItem* item = ItemAt(i); int32 visibleIndex = fVisibleItems.IndexOf(item); if (visibleIndex < 0) { _LayoutItem(item, BRect(), false); continue; } // get the dimensions of the item float width = fHorizontalLayoutInfo->ElementSize(visibleIndex); float height = fVerticalLayoutInfo->ElementSize(visibleIndex); // place the component _LayoutItem(item, BRect(xOffset, yOffset, xOffset + width, yOffset + height), true); if (fOrientation == B_HORIZONTAL) xOffset += width + xSpacing + 1; else yOffset += height + ySpacing + 1; } fLayoutValid = true; }