当前位置: 首页>>代码示例>>C++>>正文


C++ BLayoutItem::InvalidateLayout方法代码示例

本文整理汇总了C++中BLayoutItem::InvalidateLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem::InvalidateLayout方法的具体用法?C++ BLayoutItem::InvalidateLayout怎么用?C++ BLayoutItem::InvalidateLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BLayoutItem的用法示例。


在下文中一共展示了BLayoutItem::InvalidateLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: splitterFrame


//.........这里部分代码省略.........
        int32 availableSpace = range.sumValue - (int32)fSpacing;
        if (previousCollapsed) {
            previousSize = 0;
            nextSize = availableSpace;
        } else {
            previousSize = availableSpace;
            nextSize = 0;
        }
    }

    int32 newValue = previousSize + (previousCollapsed ? 0 : (int32)fSpacing);
    if (newValue == fDraggingCurrentValue) {
        // nothing changed
        return false;
    }

    // something changed: we need to recompute the layout
    int32 baseOffset = -fDraggingCurrentValue;
    // offset to the current splitter position
    int32 splitterOffset = baseOffset + newValue;
    int32 nextOffset = splitterOffset + (int32)fSplitterSize + (int32)fSpacing;

    BRect splitterFrame(splitterInfo->layoutFrame);
    if (fOrientation == B_HORIZONTAL) {
        // horizontal layout
        // previous item
        float left = splitterFrame.left + baseOffset;
        previousInfo->layoutFrame.Set(
            left,
            splitterFrame.top,
            left + previousSize - 1,
            splitterFrame.bottom);

        // next item
        left = splitterFrame.left + nextOffset;
        nextInfo->layoutFrame.Set(
            left,
            splitterFrame.top,
            left + nextSize - 1,
            splitterFrame.bottom);

        // splitter
        splitterInfo->layoutFrame.left += splitterOffset;
        splitterInfo->layoutFrame.right += splitterOffset;
    } else {
        // vertical layout
        // previous item
        float top = splitterFrame.top + baseOffset;
        previousInfo->layoutFrame.Set(
            splitterFrame.left,
            top,
            splitterFrame.right,
            top + previousSize - 1);

        // next item
        top = splitterFrame.top + nextOffset;
        nextInfo->layoutFrame.Set(
            splitterFrame.left,
            top,
            splitterFrame.right,
            top + nextSize - 1);

        // splitter
        splitterInfo->layoutFrame.top += splitterOffset;
        splitterInfo->layoutFrame.bottom += splitterOffset;
    }

    previousInfo->isVisible = !previousCollapsed;
    nextInfo->isVisible = !nextCollapsed;

    bool heightForWidth = (fOrientation == B_HORIZONTAL && HasHeightForWidth());

    // If the item visibility is to be changed, we need to update the splitter
    // values now, since the visibility change will cause an invalidation.
    if (previousVisible != previousInfo->isVisible
            || nextVisible != nextInfo->isVisible || heightForWidth) {
        _UpdateSplitterWeights();
    }

    // If we have height for width items, we need to invalidate the previous
    // and the next item. Actually we would only need to invalidate height for
    // width items, but since non height for width items might be aligned with
    // height for width items, we need to trigger a layout that creates a
    // context that spans all aligned items.
    // We invalidate already here, so that changing the items' size won't cause
    // an immediate relayout.
    if (heightForWidth) {
        previousItem->InvalidateLayout();
        nextItem->InvalidateLayout();
    }

    // do the layout
    _LayoutItem(previousItem, previousInfo);
    _LayoutItem(_SplitterItemAt(index), splitterInfo);
    _LayoutItem(nextItem, nextInfo);

    fDraggingCurrentValue = newValue;

    return true;
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:101,代码来源:SplitLayout.cpp


注:本文中的BLayoutItem::InvalidateLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。