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


TypeScript View.resolveSizeAndState方法代码示例

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


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

示例1: onMeasure

    public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
        AbsoluteLayout.adjustChildrenLayoutParams(this, widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        let measureWidth = 0;
        let measureHeight = 0;
        
        let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
        let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
        
        let height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
        let heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
        
        let childMeasureSpec = utils.layout.makeMeasureSpec(0, utils.layout.UNSPECIFIED);
        let density = utils.layout.getDisplayDensity();

        this.eachLayoutChild((child, last) => {
            let childSize = View.measureChild(this, child, childMeasureSpec, childMeasureSpec);
            measureWidth = Math.max(measureWidth, AbsoluteLayout.getLeft(child) * density + childSize.measuredWidth);
            measureHeight = Math.max(measureHeight, AbsoluteLayout.getTop(child) * density + childSize.measuredHeight);
        });

        measureWidth += (this.paddingLeft + this.paddingRight) * density;
        measureHeight += (this.paddingTop + this.paddingBottom) * density;

        measureWidth = Math.max(measureWidth, this.minWidth * density);
        measureHeight = Math.max(measureHeight, this.minHeight * density);

        let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
        let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);

        this.setMeasuredDimension(widthAndState, heightAndState);
    }
开发者ID:329379172,项目名称:NativeScript,代码行数:33,代码来源:absolute-layout.ios.ts

示例2: onMeasure

 onMeasure(widthMeasureSpec, heightMeasureSpec) {
   let utils = require("utils/utils"),
     width = utils.layout.getMeasureSpecSize(widthMeasureSpec),
     widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec),
     height = utils.layout.getMeasureSpecSize(heightMeasureSpec),
     heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec),
     nativeWidth = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.width : 0) : 0,
     nativeHeight = this.nativeView ? (this.nativeView.image ? this.nativeView.image.size.height : 0) : 0,
     measureWidth = Math.max(nativeWidth, this.minWidth as number),
     measureHeight = Math.max(nativeHeight, this.minHeight as number),
     finiteWidth = widthMode !== utils.layout.UNSPECIFIED,
     finiteHeight = heightMode !== utils.layout.UNSPECIFIED;
   if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
     let scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.stretch),
       resultW = Math.floor(nativeWidth * scale.width),
       resultH = Math.floor(nativeHeight * scale.height);
     measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
     measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
     let trace = require("trace");
     trace.write("Image stretch: " + this.stretch +
       ", nativeWidth: " + nativeWidth +
       ", nativeHeight: " + nativeHeight, trace.categories.Layout);
   }
   let view = require("ui/core/view");
   let widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
   let heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
   this.setMeasuredDimension(widthAndState, heightAndState);
 }
开发者ID:VideoSpike,项目名称:nativescript-web-image-cache,代码行数:28,代码来源:web-image-cache.ios.ts

示例3: onMeasure

    public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
        DockLayout.adjustChildrenLayoutParams(this, widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        var measureWidth = 0;
        var measureHeight = 0;

        var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
        var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);

        var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
        var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);

        var density = utils.layout.getDisplayDensity();

        var remainingWidth = widthMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : width - ((this.paddingLeft + this.paddingRight) * density);
        var remainingHeight = heightMode === utils.layout.UNSPECIFIED ? Number.MAX_VALUE : height - ((this.paddingTop + this.paddingBottom) * density);

        var tempHeight: number = 0;
        var tempWidth: number = 0;
        var childWidthMeasureSpec: number;
        var childHeightMeasureSpec: number;

        this.eachLayoutChild((child, last) => {
            if (this.stretchLastChild && last) {
                childWidthMeasureSpec = utils.layout.makeMeasureSpec(remainingWidth, widthMode);
                childHeightMeasureSpec = utils.layout.makeMeasureSpec(remainingHeight, heightMode);
            }
            else {
                // Measure children with AT_MOST even if our mode is EXACT
                childWidthMeasureSpec = utils.layout.makeMeasureSpec(remainingWidth, widthMode === utils.layout.EXACTLY ? utils.layout.AT_MOST : widthMode);
                childHeightMeasureSpec = utils.layout.makeMeasureSpec(remainingHeight, heightMode === utils.layout.EXACTLY ? utils.layout.AT_MOST : heightMode);
            }

            let childSize = View.measureChild(this, child, childWidthMeasureSpec, childHeightMeasureSpec);
            let dock = DockLayout.getDock(child);

            switch (dock) {
                case Dock.top:
                case Dock.bottom:
                    remainingHeight = Math.max(0, remainingHeight - childSize.measuredHeight);
                    tempHeight += childSize.measuredHeight;
                    measureWidth = Math.max(measureWidth, tempWidth + childSize.measuredWidth);
                    measureHeight = Math.max(measureHeight, tempHeight);
                    break;

                case Dock.left:
                case Dock.right:
                default:
                    remainingWidth = Math.max(0, remainingWidth - childSize.measuredWidth);
                    tempWidth += childSize.measuredWidth;
                    measureWidth = Math.max(measureWidth, tempWidth);
                    measureHeight = Math.max(measureHeight, tempHeight + childSize.measuredHeight);
                    break;
            }
        });

        measureWidth += (this.paddingLeft + this.paddingRight) * density;
        measureHeight += (this.paddingTop + this.paddingBottom) * density;

        measureWidth = Math.max(measureWidth, this.minWidth * density);
        measureHeight = Math.max(measureHeight, this.minHeight * density);

        var widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
        var heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);

        this.setMeasuredDimension(widthAndState, heightAndState);
    }
开发者ID:329379172,项目名称:NativeScript,代码行数:68,代码来源:dock-layout.ios.ts


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