2020-01-03 14:44:51 +08:00
|
|
|
export var LayoutSpec;
|
|
|
|
(function (LayoutSpec) {
|
|
|
|
/**
|
|
|
|
* Depends on what's been set on width or height.
|
|
|
|
*/
|
|
|
|
LayoutSpec[LayoutSpec["JUST"] = 0] = "JUST";
|
|
|
|
/**
|
|
|
|
* Depends on it's content.
|
|
|
|
*/
|
|
|
|
LayoutSpec[LayoutSpec["FIT"] = 1] = "FIT";
|
|
|
|
/**
|
|
|
|
* Extend as much as parent let it take.
|
|
|
|
*/
|
|
|
|
LayoutSpec[LayoutSpec["MOST"] = 2] = "MOST";
|
|
|
|
})(LayoutSpec || (LayoutSpec = {}));
|
|
|
|
export class LayoutConfigImpl {
|
|
|
|
fit() {
|
|
|
|
this.widthSpec = LayoutSpec.FIT;
|
|
|
|
this.heightSpec = LayoutSpec.FIT;
|
|
|
|
return this;
|
|
|
|
}
|
2021-05-14 19:32:19 +08:00
|
|
|
fitWidth() {
|
|
|
|
this.widthSpec = LayoutSpec.FIT;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
fitHeight() {
|
|
|
|
this.heightSpec = LayoutSpec.FIT;
|
|
|
|
return this;
|
|
|
|
}
|
2020-01-03 14:44:51 +08:00
|
|
|
most() {
|
|
|
|
this.widthSpec = LayoutSpec.MOST;
|
|
|
|
this.heightSpec = LayoutSpec.MOST;
|
|
|
|
return this;
|
|
|
|
}
|
2021-05-14 19:32:19 +08:00
|
|
|
mostWidth() {
|
|
|
|
this.widthSpec = LayoutSpec.MOST;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
mostHeight() {
|
|
|
|
this.widthSpec = LayoutSpec.MOST;
|
|
|
|
return this;
|
|
|
|
}
|
2020-01-03 14:44:51 +08:00
|
|
|
just() {
|
|
|
|
this.widthSpec = LayoutSpec.JUST;
|
|
|
|
this.heightSpec = LayoutSpec.JUST;
|
|
|
|
return this;
|
|
|
|
}
|
2021-05-14 19:32:19 +08:00
|
|
|
justWidth() {
|
|
|
|
this.widthSpec = LayoutSpec.JUST;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
justHeight() {
|
|
|
|
this.heightSpec = LayoutSpec.JUST;
|
|
|
|
return this;
|
|
|
|
}
|
2020-01-03 14:44:51 +08:00
|
|
|
configWidth(w) {
|
|
|
|
this.widthSpec = w;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configHeight(h) {
|
|
|
|
this.heightSpec = h;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configMargin(m) {
|
|
|
|
this.margin = m;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configAlignment(a) {
|
|
|
|
this.alignment = a;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configWeight(w) {
|
|
|
|
this.weight = w;
|
|
|
|
return this;
|
|
|
|
}
|
2020-04-11 12:20:43 +08:00
|
|
|
configMaxWidth(v) {
|
|
|
|
this.maxWidth = v;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configMaxHeight(v) {
|
|
|
|
this.maxHeight = v;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configMinWidth(v) {
|
|
|
|
this.minWidth = v;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
configMinHeight(v) {
|
|
|
|
this.minHeight = v;
|
|
|
|
return this;
|
|
|
|
}
|
2020-01-03 14:44:51 +08:00
|
|
|
toModel() {
|
|
|
|
return {
|
|
|
|
widthSpec: this.widthSpec,
|
|
|
|
heightSpec: this.heightSpec,
|
|
|
|
margin: this.margin,
|
|
|
|
alignment: this.alignment ? this.alignment.toModel() : undefined,
|
|
|
|
weight: this.weight,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export function layoutConfig() {
|
|
|
|
return new LayoutConfigImpl;
|
|
|
|
}
|