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


C# CSSNode.getChildAt方法代码示例

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


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

示例1: markLayoutAppliedForTree

 private void markLayoutAppliedForTree(CSSNode root)
 {
     root.MarkLayoutSeen();
     for (int i = 0; i < root.getChildCount(); i++)
     {
         markLayoutAppliedForTree(root.getChildAt(i));
     }
 }
开发者ID:tryroach,项目名称:css-layout,代码行数:8,代码来源:LayoutCachingTest.cs

示例2: assertTreeHasNewLayout

        private void assertTreeHasNewLayout(bool expectedHasNewLayout, CSSNode root)
        {
            Assert.AreEqual(expectedHasNewLayout, root.HasNewLayout);

            for (int i = 0; i < root.getChildCount(); i++)
            {
                assertTreeHasNewLayout(expectedHasNewLayout, root.getChildAt(i));
            }
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:9,代码来源:LayoutCachingTest.cs

示例3: areLayoutsEqual

 private static bool areLayoutsEqual(CSSNode a, CSSNode b) {
     bool doNodesHaveSameLayout =
         areFloatsEqual(a.layout.position[POSITION_LEFT], b.layout.position[POSITION_LEFT]) &&
         areFloatsEqual(a.layout.position[POSITION_TOP], b.layout.position[POSITION_TOP]) &&
         areFloatsEqual(a.layout.dimensions[DIMENSION_WIDTH], b.layout.dimensions[DIMENSION_WIDTH]) &&
         areFloatsEqual(a.layout.dimensions[DIMENSION_HEIGHT], b.layout.dimensions[DIMENSION_HEIGHT]);
     if (!doNodesHaveSameLayout) {
         return false;
     }
     for (int i = 0; i < a.getChildCount(); i++) {
         if (!areLayoutsEqual(a.getChildAt(i), b.getChildAt(i))) {
             return false;
         }
     }
     return true;
 }
开发者ID:vjeux,项目名称:css-layout,代码行数:16,代码来源:LayoutEngineTest.cs

示例4: testAddChildGetParent

        public void testAddChildGetParent()
        {
            CSSNode parent = new CSSNode();
            CSSNode child = new CSSNode();

            Assert.IsNull(child.getParent());
            Assert.AreEqual(0, parent.getChildCount());

            parent.addChildAt(child, 0);

            Assert.AreEqual(1, parent.getChildCount());
            Assert.AreEqual(child, parent.getChildAt(0));
            Assert.AreEqual(parent, child.getParent());

            parent.removeChildAt(0);

            Assert.IsNull(child.getParent());
            Assert.AreEqual(0, parent.getChildCount());
        }
开发者ID:tryroach,项目名称:css-layout,代码行数:19,代码来源:CSSNodeTest.cs

示例5: layoutNodeImpl

        static void layoutNodeImpl(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, float parentMaxHeight, CSSDirection? parentDirection)
        {
            var childCount_ = node.getChildCount();
            for (int i_ = 0; i_ < childCount_; i_++)
            {
                node.getChildAt(i_).layout.resetResult();
            }


            /** START_GENERATED **/
    
      CSSDirection direction = resolveDirection(node, parentDirection);
      int mainAxis = resolveAxis(getFlexDirection(node), direction);
      int crossAxis = getCrossFlexDirection(mainAxis, direction);
      int resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);
    
      // Handle width and height style attributes
      setDimensionFromStyle(node, mainAxis);
      setDimensionFromStyle(node, crossAxis);
    
      // Set the resolved resolution in the node's layout
      node.layout.direction = direction;
    
      // The position is set by the parent, but we need to complete it with a
      // delta composed of the margin and left/top/right/bottom
      node.layout.position[leading[mainAxis]] += node.style.margin.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) +
        getRelativePosition(node, mainAxis);
      node.layout.position[trailing[mainAxis]] += node.style.margin.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) +
        getRelativePosition(node, mainAxis);
      node.layout.position[leading[crossAxis]] += node.style.margin.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) +
        getRelativePosition(node, crossAxis);
      node.layout.position[trailing[crossAxis]] += node.style.margin.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) +
        getRelativePosition(node, crossAxis);
    
      // Inline immutable values from the target node to avoid excessive method
      // invocations during the layout calculation.
      int childCount = node.getChildCount();
      float paddingAndBorderAxisResolvedRow = ((node.style.padding.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.border.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis])) + (node.style.padding.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]) + node.style.border.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])));
      float paddingAndBorderAxisColumn = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
    
      if (isMeasureDefined(node)) {
        boolean isResolvedRowDimDefined = !float.IsNaN(node.layout.dimensions[dim[resolvedRowAxis]]);
    
        float width = CSSConstants.Undefined;
        if ((!float.IsNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
          width = node.style.dimensions[DIMENSION_WIDTH];
        } else if (isResolvedRowDimDefined) {
          width = node.layout.dimensions[dim[resolvedRowAxis]];
        } else {
          width = parentMaxWidth -
            (node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
        }
        width -= paddingAndBorderAxisResolvedRow;
    
        float height = CSSConstants.Undefined;
        if ((!float.IsNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
          height = node.style.dimensions[DIMENSION_HEIGHT];
        } else if (!float.IsNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]])) {
          height = node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]];
        } else {
          height = parentMaxHeight -
            (node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
        }
        height -= ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
    
        // We only need to give a dimension for the text if we haven't got any
        // for it computed yet. It can either be from the style attribute or because
        // the element is flexible.
        boolean isRowUndefined = !(!float.IsNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0) && !isResolvedRowDimDefined;
        boolean isColumnUndefined = !(!float.IsNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0) &&
          float.IsNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]);
    
        // Let's not measure the text if we already know both dimensions
        if (isRowUndefined || isColumnUndefined) {
          MeasureOutput measureDim = node.measure(
            
            layoutContext.measureOutput,
            width,
            height
          );
          if (isRowUndefined) {
            node.layout.dimensions[DIMENSION_WIDTH] = measureDim.width +
              paddingAndBorderAxisResolvedRow;
          }
          if (isColumnUndefined) {
            node.layout.dimensions[DIMENSION_HEIGHT] = measureDim.height +
              paddingAndBorderAxisColumn;
          }
        }
        if (childCount == 0) {
          return;
        }
      }
    
      boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.Wrap);
    
      CSSJustify justifyContent = node.style.justifyContent;
    
      float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]));
      float leadingPaddingAndBorderCross = (node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]));
//.........这里部分代码省略.........
开发者ID:tryroach,项目名称:css-layout,代码行数:101,代码来源:LayoutEngine.cs

示例6: layoutNodeImpl


//.........这里部分代码省略.........
              // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
              int mainAxis = resolveAxis(getFlexDirection(node), direction);
              int crossAxis = getCrossFlexDirection(mainAxis, direction);
              boolean isMainAxisRow = (mainAxis == CSS_FLEX_DIRECTION_ROW || mainAxis == CSS_FLEX_DIRECTION_ROW_REVERSE);
              CSSJustify justifyContent = node.style.justifyContent;
              boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.Wrap);

              CSSNode firstAbsoluteChild = null;
              CSSNode currentAbsoluteChild = null;

              float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]));
              float trailingPaddingAndBorderMain = (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
              float leadingPaddingAndBorderCross = (node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]));
              float paddingAndBorderAxisMain = ((node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])) + (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])));
              float paddingAndBorderAxisCross = ((node.style.padding.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis]) + node.style.border.getWithFallback(leadingSpacing[crossAxis], leading[crossAxis])) + (node.style.padding.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis]) + node.style.border.getWithFallback(trailingSpacing[crossAxis], trailing[crossAxis])));

              CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode;
              CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode;

              // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
              float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow;
              float availableInnerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn;
              float availableInnerMainDim = isMainAxisRow ? availableInnerWidth : availableInnerHeight;
              float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;

              // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
              CSSNode child;
              int i;
              float childWidth;
              float childHeight;
              CSSMeasureMode childWidthMeasureMode;
              CSSMeasureMode childHeightMeasureMode;
              for (i = 0; i < childCount; i++) {
            child = node.getChildAt(i);

            if (performLayout) {
              // Set the initial position (relative to the parent).
              CSSDirection childDirection = resolveDirection(child, direction);
              setPosition(child, childDirection);
            }

            // Absolute-positioned children don't participate in flex layout. Add them
            // to a list that we can process later.
            if (child.style.positionType == CSSPositionType.Absolute) {

              // Store a private linked list of absolutely positioned children
              // so that we can efficiently traverse them later.
              if (firstAbsoluteChild == null) {
            firstAbsoluteChild = child;
              }
              if (currentAbsoluteChild != null) {
            currentAbsoluteChild.nextChild = child;
              }
              currentAbsoluteChild = child;
              child.nextChild = null;
            } else {

              if (isMainAxisRow && (child.style.dimensions[dim[CSS_FLEX_DIRECTION_ROW]] >= 0.0)) {

            // The width is definite, so use that as the flex basis.
            child.layout.flexBasis = Math.Max(child.style.dimensions[DIMENSION_WIDTH], ((child.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW]) + child.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_ROW], leading[CSS_FLEX_DIRECTION_ROW])) + (child.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]) + child.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_ROW], trailing[CSS_FLEX_DIRECTION_ROW]))));
              } else if (!isMainAxisRow && (child.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {

            // The height is definite, so use that as the flex basis.
            child.layout.flexBasis = Math.Max(child.style.dimensions[DIMENSION_HEIGHT], ((child.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + child.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (child.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + child.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]))));
              } else if (!isFlexBasisAuto(child) && !float.IsNaN(availableInnerMainDim)) {
开发者ID:emilsjolander,项目名称:css-layout,代码行数:67,代码来源:LayoutEngine.cs


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