1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1704× 1704× 1704× 1704× 1704× 1× 5556× 5556× 5556× 1× 5556× 5556× 5556× 5556× 1× 5556× 5556× 5336× 9779× 9779× 9779× 20× 9759× 9779× 9779× 9779× 20× 9779× 5336× 4443× 4303× 5556× 5556× 5556× 5556× 5556× 1× 5556× 5336× 5336× 5336× 5336× 5336× 9779× 9779× 9779× 9779× 6677× 3102× 9779× 20× 9779× 9779× 9779× 9779× 6677× 3102× 5556× 1× 966× 966× 1× 3337× 3337× 1× 3102× 3102× 13× 3089× 3089× 3089× 661× 3102× 1× 6677× 6677× 3328× 3349× 15× 15× 3334× 3334× 10× 6677× 1× 7042× 6822× 12409× 12409× 7013× 1215× 5396× 142× 1× 9779× 9779× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "./container", "../../utility/base-util"], function (require, exports, container_1, base_util_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var StackPanel = (function (_super) { __extends(StackPanel, _super); function StackPanel() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.orientation = 'Vertical'; _this.measureChildren = undefined; _this.considerPadding = true; return _this; } StackPanel.prototype.measure = function (availableSize) { var updateSize = this.orientation === 'Horizontal' ? this.updateHorizontalStack : this.updateVerticalStack; this.desiredSize = this.measureStackPanel(availableSize, updateSize); return this.desiredSize; }; StackPanel.prototype.arrange = function (desiredSize) { var updateSize = this.orientation === 'Horizontal' ? this.arrangeHorizontalStack : this.arrangeVerticalStack; this.actualSize = this.arrangeStackPanel(desiredSize, updateSize); this.updateBounds(); return this.actualSize; }; StackPanel.prototype.measureStackPanel = function (availableSize, updateSize) { var desired = undefined; if (this.children !== undefined && this.children.length > 0) { for (var _i = 0, _a = this.children; _i < _a.length; _i++) { var child = _a[_i]; child.parentTransform = this.rotateAngle + this.parentTransform; if (this.measureChildren) { child.measure(child.desiredSize); } else { child.measure(availableSize); } var childSize = child.desiredSize.clone(); this.applyChildMargin(child, childSize); if (child.rotateAngle !== 0) { childSize = base_util_1.rotateSize(childSize, child.rotateAngle); } if (desired === undefined) { desired = childSize; } else { if (!child.preventContainer) { updateSize(childSize, desired); } } } } desired = _super.prototype.validateDesiredSize.call(this, desired, availableSize); this.stretchChildren(desired); Eif (this.considerPadding) { this.applyPadding(desired); } return desired; }; StackPanel.prototype.arrangeStackPanel = function (desiredSize, updatePosition) { if (this.children !== undefined && this.children.length > 0) { var x = void 0; var y = void 0; x = this.offsetX - desiredSize.width * this.pivot.x + this.padding.left; y = this.offsetY - desiredSize.height * this.pivot.y + this.padding.top; for (var _i = 0, _a = this.children; _i < _a.length; _i++) { var child = _a[_i]; var childSize = child.desiredSize.clone(); var rotatedSize = childSize; if (this.orientation === 'Vertical') { y += child.margin.top; } else { x += child.margin.left; } if (child.rotateAngle !== 0) { rotatedSize = base_util_1.rotateSize(childSize, child.rotateAngle); } var center = updatePosition(x, y, child, this, desiredSize, rotatedSize); _super.prototype.findChildOffsetFromCenter.call(this, child, center); child.arrange(childSize, true); if (this.orientation === 'Vertical') { y += rotatedSize.height + child.margin.bottom; } else { x += rotatedSize.width + child.margin.right; } } } return desiredSize; }; StackPanel.prototype.updateHorizontalStack = function (child, parent) { parent.height = Math.max(child.height, parent.height); parent.width += child.width; }; StackPanel.prototype.updateVerticalStack = function (child, parent) { parent.width = Math.max(child.width, parent.width); parent.height += child.height; }; StackPanel.prototype.arrangeHorizontalStack = function (x, y, child, parent, parenBounds, childBounds) { var centerY = 0; if (child.verticalAlignment === 'Top') { centerY = y + child.margin.top + childBounds.height / 2; } else Iif (child.verticalAlignment === 'Bottom') { var parentBottom = parent.offsetY + parenBounds.height * (1 - parent.pivot.y); centerY = parentBottom - parent.padding.bottom - child.margin.bottom - childBounds.height / 2; } else { centerY = parent.offsetY - parenBounds.height * parent.pivot.y + parenBounds.height / 2; if (child.margin.top) { centerY = y + child.margin.top + childBounds.height / 2; } } return { x: x + childBounds.width / 2, y: centerY }; }; StackPanel.prototype.arrangeVerticalStack = function (x, y, child, parent, parentSize, childSize) { var centerX = 0; if (child.horizontalAlignment === 'Left') { centerX = x + child.margin.left + childSize.width / 2; } else if (child.horizontalAlignment === 'Right') { var parentRight = parent.offsetX + parentSize.width * (1 - parent.pivot.x); centerX = parentRight - parent.padding.right - child.margin.right - childSize.width / 2; } else { centerX = parent.offsetX - parentSize.width * parent.pivot.x + parentSize.width / 2; if (child.margin.left) { centerX = x + child.margin.left + childSize.width / 2; } } return { x: centerX, y: y + childSize.height / 2 }; }; StackPanel.prototype.stretchChildren = function (size) { if (this.children !== undefined && this.children.length > 0) { for (var _i = 0, _a = this.children; _i < _a.length; _i++) { var child = _a[_i]; if (this.orientation === 'Vertical') { if (child.horizontalAlignment === 'Stretch') { child.desiredSize.width = size.width - (child.margin.left + child.margin.right); } } else { if (child.verticalAlignment === 'Stretch') { child.desiredSize.height = size.height - (child.margin.top + child.margin.bottom); } } } } }; StackPanel.prototype.applyChildMargin = function (child, size) { size.height += child.margin.top + child.margin.bottom; size.width += child.margin.left + child.margin.right; }; return StackPanel; }(container_1.Container)); exports.StackPanel = StackPanel; }); |