Commit 42134529 authored by haiyoucuv's avatar haiyoucuv

1

parent 7d860051
......@@ -3,7 +3,11 @@
<component name="ChangeListManager">
<list default="true" id="af35c04f-08f6-48ed-85db-2f94c60e87fd" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debug/engine.js" beforeDir="false" afterPath="$PROJECT_DIR$/debug/engine.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debug/engine.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/debug/engine.js.map" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/2d/display/Container.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/2d/display/Container.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/decorators/AlignManager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/decorators/AlignManager.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/decorators/auto-adjust.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/decorators/auto-adjust.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -172,7 +176,7 @@
<workItem from="1589888428282" duration="5840000" />
<workItem from="1589990226868" duration="35000" />
<workItem from="1590026135813" duration="6205000" />
<workItem from="1590111768143" duration="6062000" />
<workItem from="1590111768143" duration="10300000" />
</task>
<task id="LOCAL-00001" summary="11">
<created>1590043861171</created>
......
......@@ -1956,8 +1956,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
AlignManager.prototype.autoSize = function (that) {
var len = that.children.length;
if (len > 0) {
if (that.autoWidth
&& !toBoolean(that.percentWidth)) {
if (that.autoSizeMode === AUTO_SIZE_MODE.ALL
|| that.autoSizeMode === AUTO_SIZE_MODE.WIDTH
&& !toBoolean(that.percentWidth)) {
var maxR = 0;
for (var i = 0; i < len; i++) {
if (toBoolean(that.children[i].right))
......@@ -1968,8 +1969,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
that.width = maxR;
}
if (that.autoHeight
&& !toBoolean(that.percentHeight)) {
if (that.autoSizeMode === AUTO_SIZE_MODE.ALL
|| that.autoSizeMode === AUTO_SIZE_MODE.HEIGHT
&& !toBoolean(that.percentHeight)) {
var maxB = 0;
for (var i = 0; i < len; i++) {
if (toBoolean(that.children[i].bottom))
......@@ -2000,7 +2002,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
var temp = new AdjustProxy(null);
var _loop_1 = function (key) {
if (key == 'alignMode')
if (key == 'alignMode'
|| key == 'autoSizeMode')
return "continue";
Object.defineProperty(ctor.prototype, key, {
get: function () {
......@@ -2020,6 +2023,20 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
for (var key in temp.data) {
_loop_1(key);
}
Object.defineProperty(ctor.prototype, 'autoSizeMode', {
get: function () {
return this.adjustProxy.data['autoSizeMode'];
},
set: function (v) {
var adjustProxy = this.adjustProxy;
if (adjustProxy.data['autoSizeMode'] !== v) {
adjustProxy.data['autoSizeMode'] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ctor.prototype, 'alignMode', {
get: function () {
return this.adjustProxy.data['alignMode'];
......@@ -2042,6 +2059,13 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
ALIGN_MODE["ONCE"] = "once";
ALIGN_MODE["ALWAYS"] = "always";
})(ALIGN_MODE || (ALIGN_MODE = {}));
var AUTO_SIZE_MODE;
(function (AUTO_SIZE_MODE) {
AUTO_SIZE_MODE["NONE"] = "none";
AUTO_SIZE_MODE["WIDTH"] = "width";
AUTO_SIZE_MODE["HEIGHT"] = "height";
AUTO_SIZE_MODE["ALL"] = "all";
})(AUTO_SIZE_MODE || (AUTO_SIZE_MODE = {}));
var AdjustProxy = (function () {
function AdjustProxy(host) {
this.data = {
......@@ -2057,8 +2081,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
percentBottom: NaN,
horizonCenter: NaN,
verticalCenter: NaN,
autoWidth: false,
autoHeight: false,
autoSizeMode: AUTO_SIZE_MODE.NONE,
alignEnabled: true,
alignMode: ALIGN_MODE.ALWAYS,
};
......
This diff is collapsed.
......@@ -779,36 +779,6 @@ export default class Container extends DisplayObject {
protected __width = 0; // 忽略 相对宽度 的 宽度,在父级计算自动宽度的时候用到
protected __height = 0; // 忽略 相对高度 的 高度,在父级计算自动高度的时候用到
/// TODO 移到了auto-dujust里
// protected _autoWidth = false; // 自动宽度?
// protected _autoHeight = false; // 自动高度?
// public get autoWidth() {
// return this._autoWidth;
// }
//
// public get autoHeight() {
// return this._autoHeight;
// }
// public set autoWidth(autoWidth) {
// if(autoWidth === this._autoWidth) return;
// this._autoWidth = autoWidth;
// this.adjustProxy.makeDirty();
// }
//
// public set autoHeight(autoHeight) {
// if(autoHeight === this._autoHeight) return;
// this._autoHeight = autoHeight;
// this.adjustProxy.makeDirty();
// }
// public judgeAutoSize() {
// this.autoWidth = !(toBoolean(this.right) || toBoolean(this.percentWidth) || toBoolean(this._width));
// this.autoHeight = !(toBoolean(this.bottom) || toBoolean(this.percentHeight) || toBoolean(this._height));
// }
get x(): number {
return this.position.x;
}
......
import { ALIGN_MODE } from "./auto-adjust";
import { ALIGN_MODE, AUTO_SIZE_MODE } from "./auto-adjust";
import { toBoolean } from "../utils/utils";
import { Container } from "../../2d/display/index";
......@@ -150,7 +150,9 @@ class AlignManager {
if (len > 0) {
// 检测本身的是否是可以自动宽
if (that.autoWidth
// if (that.autoWidth
if (that.autoSizeMode === AUTO_SIZE_MODE.ALL
|| that.autoSizeMode === AUTO_SIZE_MODE.WIDTH
// && !toBoolean(that.right) /// TODO 我把它注释了 注释这行可以让容器设置了 right 后反向撑开,保持 right 边距不变
&& !toBoolean(that.percentWidth)) {
......@@ -180,7 +182,8 @@ class AlignManager {
}
// 检测本身的是否是可以自动高
if (that.autoHeight
if (that.autoSizeMode === AUTO_SIZE_MODE.ALL
|| that.autoSizeMode === AUTO_SIZE_MODE.HEIGHT
// && !toBoolean(that.bottom) /// TODO 我把它注释了 注释这行可以让容器设置了 bottom 后反向撑开,保持 bottom 边距不变
&& !toBoolean(that.percentHeight)) {
......
......@@ -19,7 +19,8 @@ export function applyAutoAdjust(ctor: Function) {
};
let temp = new AdjustProxy(null);
for (let key in temp.data) {
if (key == 'alignMode') continue;
if (key == 'alignMode'
|| key == 'autoSizeMode') continue;
Object.defineProperty(ctor.prototype, key, {
get: function() {
......@@ -37,6 +38,22 @@ export function applyAutoAdjust(ctor: Function) {
});
}
Object.defineProperty(ctor.prototype, 'autoSizeMode', {
get: function() {
return this.adjustProxy.data['autoSizeMode'];
},
set: function(v) {
const adjustProxy: AdjustProxy = this.adjustProxy;
if (adjustProxy.data['autoSizeMode'] !== v) {
adjustProxy.data['autoSizeMode'] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ctor.prototype, 'alignMode', {
get: function() {
return this.adjustProxy.data['alignMode'];
......@@ -61,6 +78,13 @@ export enum ALIGN_MODE {
ALWAYS = 'always',
}
export enum AUTO_SIZE_MODE {
NONE = 'none',
WIDTH = 'width',
HEIGHT = 'height',
ALL = 'all',
}
/**
* 自适应数据
*/
......@@ -82,8 +106,9 @@ class AdjustProxy {
horizonCenter: NaN,
verticalCenter: NaN,
autoWidth: false,
autoHeight: false,
autoSizeMode: AUTO_SIZE_MODE.NONE,
// autoWidth: false,
// autoHeight: false,
alignEnabled: true,
alignMode: ALIGN_MODE.ALWAYS,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment