diff --git a/src/util/layoutconfig.ts b/src/util/layoutconfig.ts index b074056f..377333db 100644 --- a/src/util/layoutconfig.ts +++ b/src/util/layoutconfig.ts @@ -17,9 +17,9 @@ import { Gravity } from "./gravity"; import { Modeling } from "./types"; export enum LayoutSpec { - EXACTLY = 0, - WRAP_CONTENT = 1, - AT_MOST = 2, + JUST = 0, + FIT = 1, + MOST = 2, } export interface LayoutConfig { @@ -49,35 +49,35 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling { //Only affective in VLayout or HLayout weight?: number - wrap() { - this.widthSpec = LayoutSpec.WRAP_CONTENT - this.heightSpec = LayoutSpec.WRAP_CONTENT + fit() { + this.widthSpec = LayoutSpec.FIT + this.heightSpec = LayoutSpec.FIT return this } - atmost() { - this.widthSpec = LayoutSpec.AT_MOST - this.heightSpec = LayoutSpec.AT_MOST + most() { + this.widthSpec = LayoutSpec.MOST + this.heightSpec = LayoutSpec.MOST return this } - exactly() { - this.widthSpec = LayoutSpec.EXACTLY - this.heightSpec = LayoutSpec.EXACTLY + just() { + this.widthSpec = LayoutSpec.JUST + this.heightSpec = LayoutSpec.JUST return this } - w(w: LayoutSpec) { + configWidth(w: LayoutSpec) { this.widthSpec = w return this } - h(h: LayoutSpec) { + configHeight(h: LayoutSpec) { this.heightSpec = h return this } - m(m: { + configMargin(m: { left?: number, right?: number, top?: number, @@ -87,12 +87,12 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling { return this } - a(a: Gravity) { + configAligmnet(a: Gravity) { this.alignment = a return this } - wg(w: number) { + configWeight(w: number) { this.weight = w return this } diff --git a/src/widget/flowlayout.ts b/src/widget/flowlayout.ts index 61d3191e..16915649 100644 --- a/src/widget/flowlayout.ts +++ b/src/widget/flowlayout.ts @@ -123,7 +123,7 @@ export function flowlayout(config: IFlowLayout) { export function flowItem(item: View) { return (new FlowLayoutItem).also((it) => { - it.layoutConfig = layoutConfig().wrap() + it.layoutConfig = layoutConfig().fit() it.addChild(item) }) } diff --git a/src/widget/image.ts b/src/widget/image.ts index 2d5d693a..c713ea93 100644 --- a/src/widget/image.ts +++ b/src/widget/image.ts @@ -46,7 +46,7 @@ export class Image extends View implements IImage { export function image(config: IImage) { const ret = new Image - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let key in config) { Reflect.set(ret, key, Reflect.get(config, key, config), ret) } diff --git a/src/widget/layouts.ts b/src/widget/layouts.ts index 9162af66..b0c8fa66 100644 --- a/src/widget/layouts.ts +++ b/src/widget/layouts.ts @@ -53,7 +53,7 @@ export class HLayout extends LinearLayout implements IHLayout { export function stack(views: View[]) { const ret = new Stack - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let v of views) { ret.addChild(v) } @@ -62,7 +62,7 @@ export function stack(views: View[]) { export function hlayout(views: View[]) { const ret = new HLayout - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let v of views) { ret.addChild(v) } @@ -71,7 +71,7 @@ export function hlayout(views: View[]) { export function vlayout(views: View[]) { const ret = new VLayout - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let v of views) { ret.addChild(v) } diff --git a/src/widget/list.ts b/src/widget/list.ts index 08a1cdfa..99e3dde6 100644 --- a/src/widget/list.ts +++ b/src/widget/list.ts @@ -111,7 +111,7 @@ export function list(config: IList) { export function listItem(item: View) { return (new ListItem).also((it) => { - it.layoutConfig = layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT) + it.layoutConfig = layoutConfig().most().configHeight(LayoutSpec.FIT) it.addChild(item) }) } diff --git a/src/widget/refreshable.ts b/src/widget/refreshable.ts index 0a21bcc3..7b78e31a 100644 --- a/src/widget/refreshable.ts +++ b/src/widget/refreshable.ts @@ -52,7 +52,7 @@ export class Refreshable extends Superview implements IRefreshable { export function refreshable(config: IRefreshable) { const ret = new Refreshable - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let key in config) { Reflect.set(ret, key, Reflect.get(config, key, config), ret) } diff --git a/src/widget/scroller.ts b/src/widget/scroller.ts index c0155cd0..965a0225 100644 --- a/src/widget/scroller.ts +++ b/src/widget/scroller.ts @@ -18,7 +18,7 @@ import { layoutConfig } from '../util/layoutconfig' export function scroller(content: View) { return (new Scroller).also(v => { - v.layoutConfig = layoutConfig().wrap() + v.layoutConfig = layoutConfig().fit() v.content = content }) } diff --git a/src/widget/slider.ts b/src/widget/slider.ts index ac622c31..733faad2 100644 --- a/src/widget/slider.ts +++ b/src/widget/slider.ts @@ -77,7 +77,7 @@ export class Slider extends Superview implements ISlider { export function slideItem(item: View) { return (new SlideItem).also((it) => { - it.layoutConfig = layoutConfig().wrap() + it.layoutConfig = layoutConfig().fit() it.addChild(item) }) } diff --git a/src/widget/text.ts b/src/widget/text.ts index d3663a72..527a4463 100644 --- a/src/widget/text.ts +++ b/src/widget/text.ts @@ -45,7 +45,7 @@ export class Text extends View implements IText { export function text(config: IText) { const ret = new Text - ret.layoutConfig = layoutConfig().wrap() + ret.layoutConfig = layoutConfig().fit() for (let key in config) { Reflect.set(ret, key, Reflect.get(config, key, config), ret) }