diff --git a/projects/common/unit.ts b/projects/common/unit.ts index 40e6a510afbf26feeed042e5e7b8604b249783a1..136ca6a523f7beeb07a6d30c933f2b8e0bdd4686 100644 --- a/projects/common/unit.ts +++ b/projects/common/unit.ts @@ -16,17 +16,24 @@ export interface UnitPageSection { width: number; height: number; backgroundColor: string; + dynamicPositioning: boolean; + gridColumnSizes: string; } export interface UnitUIElement { [index: string]: string | number | boolean | string[] | undefined; type: string; // TODO maybe use enum or manual enumeration, because possible values are known id: string; - xPosition: number; - yPosition: number; zIndex: number width: number; height: number; + dynamicPositioning: boolean; + xPosition: number; + yPosition: number; + gridColumnStart: number; + gridColumnEnd: number; + gridRowStart: number; + gridRowEnd: number; } export interface TextUIElement extends UnitUIElement { diff --git a/projects/editor/src/app/model/UnitFactory.ts b/projects/editor/src/app/model/UnitFactory.ts index 4d9d6c3f238a5346672aa5b5225e3c904efe301b..ee7351f96db1e9228bc52d0517cf1d3bc1216874 100644 --- a/projects/editor/src/app/model/UnitFactory.ts +++ b/projects/editor/src/app/model/UnitFactory.ts @@ -28,7 +28,9 @@ export function createUnitPageSection(): UnitPageSection { elements: [], width: 1200, height: 200, - backgroundColor: '#FFFAF0' + backgroundColor: '#FFFAF0', + dynamicPositioning: false, + gridColumnSizes: '1fr 1fr 1fr' }; } @@ -36,11 +38,16 @@ export function createUnitUIElement(type: string): UnitUIElement { return { type, id: 'id_placeholder', - xPosition: 0, - yPosition: 0, zIndex: 0, width: 180, - height: 60 + height: 60, + dynamicPositioning: false, + xPosition: 0, + yPosition: 0, + gridColumnStart: 1, + gridColumnEnd: 1, + gridRowStart: 1, + gridRowEnd: 1 }; } diff --git a/projects/editor/src/app/unit.service.ts b/projects/editor/src/app/unit.service.ts index 910292be782bb4b979d65b24b84ad767f00e95a8..9688b3b1249ccc633566ce26d7c7c985bbffb42e 100644 --- a/projects/editor/src/app/unit.service.ts +++ b/projects/editor/src/app/unit.service.ts @@ -153,6 +153,8 @@ export class UnitService { throw new Error(`ElementType ${elementType} not found!`); } newElement.id = this.idService.getNewID(elementType); + newElement.dynamicPositioning = this._unit.value.pages[this._selectedPageIndex.value] + .sections[this._selectedPageSectionIndex.value].dynamicPositioning; this._unit.value.pages[this._selectedPageIndex.value] .sections[this._selectedPageSectionIndex.value].elements.push(newElement!); @@ -241,6 +243,14 @@ export class UnitService { this.elementPropertyUpdated.next(); } + setSectionDynamicPositioning(section: UnitPageSection, value: boolean): void { + section.dynamicPositioning = value; + section.elements.forEach((element: UnitUIElement) => { + element.dynamicPositioning = value; + }); + this.elementPropertyUpdated.next(); + } + saveUnit(): void { const unitJSON = JSON.stringify(this._unit.value); FileService.saveUnitToFile(unitJSON);