rename layoutconfig
This commit is contained in:
parent
919ec7aeb7
commit
4bc81a9ca9
@ -17,9 +17,9 @@ import { Gravity } from "./gravity";
|
|||||||
import { Modeling } from "./types";
|
import { Modeling } from "./types";
|
||||||
|
|
||||||
export enum LayoutSpec {
|
export enum LayoutSpec {
|
||||||
EXACTLY = 0,
|
JUST = 0,
|
||||||
WRAP_CONTENT = 1,
|
FIT = 1,
|
||||||
AT_MOST = 2,
|
MOST = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LayoutConfig {
|
export interface LayoutConfig {
|
||||||
@ -49,35 +49,35 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling {
|
|||||||
//Only affective in VLayout or HLayout
|
//Only affective in VLayout or HLayout
|
||||||
weight?: number
|
weight?: number
|
||||||
|
|
||||||
wrap() {
|
fit() {
|
||||||
this.widthSpec = LayoutSpec.WRAP_CONTENT
|
this.widthSpec = LayoutSpec.FIT
|
||||||
this.heightSpec = LayoutSpec.WRAP_CONTENT
|
this.heightSpec = LayoutSpec.FIT
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
atmost() {
|
most() {
|
||||||
this.widthSpec = LayoutSpec.AT_MOST
|
this.widthSpec = LayoutSpec.MOST
|
||||||
this.heightSpec = LayoutSpec.AT_MOST
|
this.heightSpec = LayoutSpec.MOST
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
exactly() {
|
just() {
|
||||||
this.widthSpec = LayoutSpec.EXACTLY
|
this.widthSpec = LayoutSpec.JUST
|
||||||
this.heightSpec = LayoutSpec.EXACTLY
|
this.heightSpec = LayoutSpec.JUST
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
w(w: LayoutSpec) {
|
configWidth(w: LayoutSpec) {
|
||||||
this.widthSpec = w
|
this.widthSpec = w
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
h(h: LayoutSpec) {
|
configHeight(h: LayoutSpec) {
|
||||||
this.heightSpec = h
|
this.heightSpec = h
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
m(m: {
|
configMargin(m: {
|
||||||
left?: number,
|
left?: number,
|
||||||
right?: number,
|
right?: number,
|
||||||
top?: number,
|
top?: number,
|
||||||
@ -87,12 +87,12 @@ export class LayoutConfigImpl implements LayoutConfig, Modeling {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
a(a: Gravity) {
|
configAligmnet(a: Gravity) {
|
||||||
this.alignment = a
|
this.alignment = a
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
wg(w: number) {
|
configWeight(w: number) {
|
||||||
this.weight = w
|
this.weight = w
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ export function flowlayout(config: IFlowLayout) {
|
|||||||
|
|
||||||
export function flowItem(item: View) {
|
export function flowItem(item: View) {
|
||||||
return (new FlowLayoutItem).also((it) => {
|
return (new FlowLayoutItem).also((it) => {
|
||||||
it.layoutConfig = layoutConfig().wrap()
|
it.layoutConfig = layoutConfig().fit()
|
||||||
it.addChild(item)
|
it.addChild(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ export class Image extends View implements IImage {
|
|||||||
|
|
||||||
export function image(config: IImage) {
|
export function image(config: IImage) {
|
||||||
const ret = new Image
|
const ret = new Image
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let key in config) {
|
for (let key in config) {
|
||||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ export class HLayout extends LinearLayout implements IHLayout {
|
|||||||
|
|
||||||
export function stack(views: View[]) {
|
export function stack(views: View[]) {
|
||||||
const ret = new Stack
|
const ret = new Stack
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let v of views) {
|
for (let v of views) {
|
||||||
ret.addChild(v)
|
ret.addChild(v)
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ export function stack(views: View[]) {
|
|||||||
|
|
||||||
export function hlayout(views: View[]) {
|
export function hlayout(views: View[]) {
|
||||||
const ret = new HLayout
|
const ret = new HLayout
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let v of views) {
|
for (let v of views) {
|
||||||
ret.addChild(v)
|
ret.addChild(v)
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ export function hlayout(views: View[]) {
|
|||||||
|
|
||||||
export function vlayout(views: View[]) {
|
export function vlayout(views: View[]) {
|
||||||
const ret = new VLayout
|
const ret = new VLayout
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let v of views) {
|
for (let v of views) {
|
||||||
ret.addChild(v)
|
ret.addChild(v)
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ export function list(config: IList) {
|
|||||||
|
|
||||||
export function listItem(item: View) {
|
export function listItem(item: View) {
|
||||||
return (new ListItem).also((it) => {
|
return (new ListItem).also((it) => {
|
||||||
it.layoutConfig = layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT)
|
it.layoutConfig = layoutConfig().most().configHeight(LayoutSpec.FIT)
|
||||||
it.addChild(item)
|
it.addChild(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ export class Refreshable extends Superview implements IRefreshable {
|
|||||||
|
|
||||||
export function refreshable(config: IRefreshable) {
|
export function refreshable(config: IRefreshable) {
|
||||||
const ret = new Refreshable
|
const ret = new Refreshable
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let key in config) {
|
for (let key in config) {
|
||||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import { layoutConfig } from '../util/layoutconfig'
|
|||||||
|
|
||||||
export function scroller(content: View) {
|
export function scroller(content: View) {
|
||||||
return (new Scroller).also(v => {
|
return (new Scroller).also(v => {
|
||||||
v.layoutConfig = layoutConfig().wrap()
|
v.layoutConfig = layoutConfig().fit()
|
||||||
v.content = content
|
v.content = content
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ export class Slider extends Superview implements ISlider {
|
|||||||
|
|
||||||
export function slideItem(item: View) {
|
export function slideItem(item: View) {
|
||||||
return (new SlideItem).also((it) => {
|
return (new SlideItem).also((it) => {
|
||||||
it.layoutConfig = layoutConfig().wrap()
|
it.layoutConfig = layoutConfig().fit()
|
||||||
it.addChild(item)
|
it.addChild(item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ export class Text extends View implements IText {
|
|||||||
|
|
||||||
export function text(config: IText) {
|
export function text(config: IText) {
|
||||||
const ret = new Text
|
const ret = new Text
|
||||||
ret.layoutConfig = layoutConfig().wrap()
|
ret.layoutConfig = layoutConfig().fit()
|
||||||
for (let key in config) {
|
for (let key in config) {
|
||||||
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
Reflect.set(ret, key, Reflect.get(config, key, config), ret)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user