From b3f6c38c27154d27aefa3a4f631b42c69b439a18 Mon Sep 17 00:00:00 2001 From: STEINNI Date: Wed, 8 Oct 2025 17:31:07 +0000 Subject: [PATCH] Better windows box saving + expand-shrink back to previous --- app/controllers/live/DashboardsController.js | 47 +++++++++++--------- app/libs/EIC/EICDomContent.js | 19 +++++--- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/app/controllers/live/DashboardsController.js b/app/controllers/live/DashboardsController.js index 56cc4c4..93747f8 100644 --- a/app/controllers/live/DashboardsController.js +++ b/app/controllers/live/DashboardsController.js @@ -7,6 +7,8 @@ class DashboardsController extends EICController { this.eventsMapping = app.Assets.Store.json.eventsMapping } + + /** * * @returns @@ -30,11 +32,6 @@ class DashboardsController extends EICController { //TODO: eventsMapping: address child by suffix in assignations - - let left = app.User.preferences?.windows?.live?.spaceview?.['3D']?.x ? app.User.preferences.windows.live.spaceview['3D'].x :100 - let top = app.User.preferences?.windows?.live?.spaceview?.['3D']?.y ? app.User.preferences.windows.live.spaceview['3D'].y :50 - let width = app.User.preferences?.windows?.live?.spaceview?.['3D']?.w ? app.User.preferences.windows.live.spaceview['3D'].w :600 - let height = app.User.preferences?.windows?.live?.spaceview?.['3D']?.h ? app.User.preferences.windows.live.spaceview['3D'].h :450 this.loadWindow( 'visualisers/SpaceView', { @@ -42,12 +39,7 @@ class DashboardsController extends EICController { static: true, expanded: false, withSettings: true, - windowStyle:{ - width: `${width}px`, - height: `${height}px`, - left: `${left}px`, - top: `${top}px`, - } + windowStyle: this._boxFromPrefs('live.spaceview.3D', { x: 50, y:100, w:600, h:400 }), }, { models: models, @@ -58,10 +50,7 @@ class DashboardsController extends EICController { } ) - left = app.User.preferences?.windows?.live?.spaceview?.['2D']?.x ? app.User.preferences.windows.live.spaceview['2D'].x :500 - top = app.User.preferences?.windows?.live?.spaceview?.['2D']?.y ? app.User.preferences.windows.live.spaceview['2D'].y :100 - width = app.User.preferences?.windows?.live?.spaceview?.['2D']?.w ? app.User.preferences.windows.live.spaceview['2D'].w :600 - height = app.User.preferences?.windows?.live?.spaceview?.['2D']?.h ? app.User.preferences.windows.live.spaceview['2D'].h :450 + this.loadWindow( 'visualisers/SpaceView', { @@ -69,12 +58,7 @@ class DashboardsController extends EICController { static: true, expanded: false, withSettings: true, - windowStyle:{ - width: `${width}px`, - height: `${height}px`, - left: `${left}px`, - top: `${top}px`, - } + windowStyle: this._boxFromPrefs('live.spaceview.2D', { x: 500, y:100, w:600, h:400 }), }, { models: models, @@ -85,6 +69,27 @@ class DashboardsController extends EICController { } ) } + + _boxFromPrefs(viewName, defaults){ + function getPref(path) { + return path.split('.').reduce( + (acc, key) => acc?.[key], + app.User.preferences.windows + ) + } + const box = getPref(viewName) +console.log('====>',box, viewName) + let left = box.x ? box.x : defaults.x + let top = box.y ? box.y : defaults.y + let width = box.w ? box.w : defaults.w + let height = box.x ? box.h : defaults.h + return({ + width: `${width}px`, + height: `${height}px`, + left: `${left}px`, + top: `${top}px`, + }) + } } app.registerClass('DashboardsController', DashboardsController); \ No newline at end of file diff --git a/app/libs/EIC/EICDomContent.js b/app/libs/EIC/EICDomContent.js index 74aad4c..4a0d626 100755 --- a/app/libs/EIC/EICDomContent.js +++ b/app/libs/EIC/EICDomContent.js @@ -14,13 +14,22 @@ class EICDomContent extends View { get expanded() { return this.el.hasAttribute('expanded'); } + _saveWindowBox(){ + const box = this.el.getBoundingClientRect() + this.savedWindowBox = { + width: `${box.width}px`, + height: `${box.height}px`, + left: `${box.x}px`, + top: `${box.y}px`, + } + } -//TODO: memorize size & position /** * */ expand() { + this._saveWindowBox() this.el.setAttribute('expanded',''); this.el.dispatchEvent(new CustomEvent('expanded')); this.el.style.left = 'auto'; @@ -31,17 +40,15 @@ class EICDomContent extends View { this.DOMContentResized() } -//TODO: restore to previous memorize size & position - - /** * */ shrink() { this.el.removeAttribute('expanded'); this.el.dispatchEvent(new CustomEvent('shrinked')); - this.el.style.left = this.el.getBoundingClientRect().x; - this.el.style.top = this.el.getBoundingClientRect().y; + Object.assign(this.el.style, this.savedWindowBox) + // this.el.style.left = this.el.getBoundingClientRect().x; + // this.el.style.top = this.el.getBoundingClientRect().y; this.DOMContentResized(); }