Better windows box saving + expand-shrink back to previous
This commit is contained in:
@@ -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);
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user