import { Widget } from "./Widget";
import {CssStyle} from "../models/CssStyle";

export class Layout extends Widget {
    static emptyLayout(): Layout {
        return new Layout({
            rows: [new LayoutRow({
                columns: [
                    new LayoutColumn({ width: 0 })
                ]
            })]
        });
    }
    rows: LayoutRow[] = [];

    public constructor(init?: Partial<Layout>) {
        super();
        Object.assign(this, init);
    }
}

export class LayoutRow {
    static emptyRow(): LayoutRow {
        return new LayoutRow({ columns: [ LayoutColumn.emptyColumn() ]})
    }
    columns: LayoutColumn[] = [];
    public constructor(init?: Partial<LayoutRow>) {
        Object.assign(this, init);
    }
}

export class LayoutColumn {
    static emptyColumn(): LayoutColumn {
      return new LayoutColumn({ width: 0 });
    }
    width: number = 0;
    widgets: Widget[] = [];
    style?: CssStyle;

    public constructor(init?: Partial<LayoutColumn>) {
        Object.assign(this, init);
    }

}
