Better windows box saving + expand-shrink back to previous

This commit is contained in:
STEINNI
2025-10-08 17:31:07 +00:00
parent 93de6045e3
commit b3f6c38c27
2 changed files with 39 additions and 27 deletions
+26 -21
View File
@@ -7,6 +7,8 @@ class DashboardsController extends EICController {
this.eventsMapping = app.Assets.Store.json.eventsMapping this.eventsMapping = app.Assets.Store.json.eventsMapping
} }
/** /**
* *
* @returns * @returns
@@ -30,11 +32,6 @@ class DashboardsController extends EICController {
//TODO: eventsMapping: address child by suffix in assignations //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( this.loadWindow(
'visualisers/SpaceView', 'visualisers/SpaceView',
{ {
@@ -42,12 +39,7 @@ class DashboardsController extends EICController {
static: true, static: true,
expanded: false, expanded: false,
withSettings: true, withSettings: true,
windowStyle:{ windowStyle: this._boxFromPrefs('live.spaceview.3D', { x: 50, y:100, w:600, h:400 }),
width: `${width}px`,
height: `${height}px`,
left: `${left}px`,
top: `${top}px`,
}
}, },
{ {
models: models, 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( this.loadWindow(
'visualisers/SpaceView', 'visualisers/SpaceView',
{ {
@@ -69,12 +58,7 @@ class DashboardsController extends EICController {
static: true, static: true,
expanded: false, expanded: false,
withSettings: true, withSettings: true,
windowStyle:{ windowStyle: this._boxFromPrefs('live.spaceview.2D', { x: 500, y:100, w:600, h:400 }),
width: `${width}px`,
height: `${height}px`,
left: `${left}px`,
top: `${top}px`,
}
}, },
{ {
models: models, 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); app.registerClass('DashboardsController', DashboardsController);
+13 -6
View File
@@ -14,13 +14,22 @@ class EICDomContent extends View {
get expanded() { return this.el.hasAttribute('expanded'); } 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() { expand() {
this._saveWindowBox()
this.el.setAttribute('expanded',''); this.el.setAttribute('expanded','');
this.el.dispatchEvent(new CustomEvent('expanded')); this.el.dispatchEvent(new CustomEvent('expanded'));
this.el.style.left = 'auto'; this.el.style.left = 'auto';
@@ -31,17 +40,15 @@ class EICDomContent extends View {
this.DOMContentResized() this.DOMContentResized()
} }
//TODO: restore to previous memorize size & position
/** /**
* *
*/ */
shrink() { shrink() {
this.el.removeAttribute('expanded'); this.el.removeAttribute('expanded');
this.el.dispatchEvent(new CustomEvent('shrinked')); this.el.dispatchEvent(new CustomEvent('shrinked'));
this.el.style.left = this.el.getBoundingClientRect().x; Object.assign(this.el.style, this.savedWindowBox)
this.el.style.top = this.el.getBoundingClientRect().y; // this.el.style.left = this.el.getBoundingClientRect().x;
// this.el.style.top = this.el.getBoundingClientRect().y;
this.DOMContentResized(); this.DOMContentResized();
} }