windows pos & size in prefs
This commit is contained in:
@@ -29,6 +29,12 @@ 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',
|
||||
{
|
||||
@@ -37,10 +43,10 @@ class DashboardsController extends EICController {
|
||||
expanded: false,
|
||||
withSettings: true,
|
||||
windowStyle:{
|
||||
width: '800px',
|
||||
height: '600px',
|
||||
left: '50px',
|
||||
top: '100px',
|
||||
width: `${width}px`,
|
||||
height: `${height}px`,
|
||||
left: `${left}px`,
|
||||
top: `${top}px`,
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -51,6 +57,11 @@ class DashboardsController extends EICController {
|
||||
ttb: ttb,
|
||||
}
|
||||
)
|
||||
|
||||
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',
|
||||
{
|
||||
@@ -59,10 +70,10 @@ class DashboardsController extends EICController {
|
||||
expanded: false,
|
||||
withSettings: true,
|
||||
windowStyle:{
|
||||
width: '600px',
|
||||
height: '450px',
|
||||
right:'10px',
|
||||
top:'100px',
|
||||
width: `${width}px`,
|
||||
height: `${height}px`,
|
||||
left: `${left}px`,
|
||||
top: `${top}px`,
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ class EICDomContent extends View {
|
||||
let mouseX, mouseY, offsetX = 0, offsetY = 0;
|
||||
|
||||
// mouse button down over the element
|
||||
element.querySelector('header h1').addEventListener('mousedown', onMouseDown);
|
||||
element.querySelector('header h1').addEventListener('mousedown', onMouseDown.bind(this));
|
||||
|
||||
/**
|
||||
* Listens to `mousedown` event.
|
||||
@@ -113,9 +113,9 @@ class EICDomContent extends View {
|
||||
offsetY = element.getBoundingClientRect().y;
|
||||
|
||||
document.addEventListener('mousemove', onMouseMove);
|
||||
element.addEventListener('mouseup', onMouseUp.bind(this));
|
||||
}
|
||||
|
||||
element.addEventListener('mouseup', onMouseUp);
|
||||
|
||||
/**
|
||||
* Listens to `mouseup` event.
|
||||
@@ -126,6 +126,14 @@ class EICDomContent extends View {
|
||||
offsetX = parseInt(element.style.left) || 0;
|
||||
offsetY = parseInt(element.style.top) || 0;
|
||||
document.removeEventListener('mousemove', onMouseMove);
|
||||
element.removeEventListener('mouseup', onMouseUp);
|
||||
if(this.windowPrefsId){
|
||||
const box = element.getBoundingClientRect()
|
||||
app.User.setPreference(`windows.${this.windowPrefsId}`, {
|
||||
x: box.x,
|
||||
y: box.y,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +157,7 @@ class EICDomContent extends View {
|
||||
resizable(element, onResize) {
|
||||
let mouseX, mouseY, offset = 0, offsetY = 0, grab = '';
|
||||
|
||||
element.querySelectorAll(':scope > .handle').forEach(handle => handle.addEventListener('mousedown', onMouseDown))
|
||||
element.querySelectorAll(':scope > .handle').forEach(handle => handle.addEventListener('mousedown', onMouseDown.bind(this)))
|
||||
|
||||
element.querySelector('section').addEventListener('mousedown', onBlockMouseDown);
|
||||
|
||||
@@ -175,16 +183,26 @@ class EICDomContent extends View {
|
||||
offset = element.getBoundingClientRect();
|
||||
|
||||
document.addEventListener('mousemove', onMouseMove);
|
||||
element.addEventListener('mouseup', onMouseUp.bind(this));
|
||||
}
|
||||
|
||||
element.addEventListener('mouseup', onMouseUp);
|
||||
|
||||
/**
|
||||
* mouseup event listener
|
||||
*
|
||||
* @param {Object} event - The event.
|
||||
*/
|
||||
function onMouseUp(event) { document.removeEventListener('mousemove', onMouseMove); }
|
||||
function onMouseUp(event) {
|
||||
document.removeEventListener('mousemove', onMouseMove);
|
||||
element.removeEventListener('mouseup', onMouseUp);
|
||||
if(this.windowPrefsId){
|
||||
const box = element.getBoundingClientRect()
|
||||
app.User.setPreference(`windows.${this.windowPrefsId}`, {
|
||||
w: box.width,
|
||||
h: box.height,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens to `mousemove` event.
|
||||
@@ -237,6 +255,7 @@ class EICDomContent extends View {
|
||||
let device = limits.find(item => item.min < bounds.width);
|
||||
this.el.setAttribute('device', device ? device.name: limits[0].name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('EICDomContent', EICDomContent);
|
||||
+14
-14
@@ -190,7 +190,6 @@ class myUser extends app.LoadedClasses.User {
|
||||
}
|
||||
|
||||
loadPreferences() {
|
||||
console.log('Loading prefs...')
|
||||
this.model.getPreferences().then(settings => {
|
||||
console.log("Prefs received from bus:", settings)
|
||||
this.preferences = settings.value || {}
|
||||
@@ -198,7 +197,6 @@ class myUser extends app.LoadedClasses.User {
|
||||
}
|
||||
|
||||
savePreferences() {
|
||||
console.log('Saving prefs...')
|
||||
this.model.setPreferences({
|
||||
key: `${this.identity.uuid}:userPrefs`,
|
||||
value: this.preferences
|
||||
@@ -207,8 +205,6 @@ class myUser extends app.LoadedClasses.User {
|
||||
|
||||
getPreference(path) {
|
||||
let value = null;
|
||||
|
||||
if(app.MessageBus) {
|
||||
let segments = path.split('.');
|
||||
let pointer = this.preferences;
|
||||
if(pointer) {
|
||||
@@ -224,30 +220,34 @@ class myUser extends app.LoadedClasses.User {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
setPreference(path, value) {
|
||||
if(app.MessageBus) {
|
||||
let segments = path.split('.');
|
||||
let pointer = this.preferences;
|
||||
const segments = path.split('.')
|
||||
let pointer = this.preferences
|
||||
|
||||
for (let i = 0; i < segments.length - 1; i++) {
|
||||
let segment = segments[i];
|
||||
if(!pointer[segment]) {
|
||||
pointer[segment] = {};
|
||||
const segment = segments[i]
|
||||
if (!pointer[segment] || typeof pointer[segment] !== 'object') {
|
||||
pointer[segment] = {}
|
||||
}
|
||||
pointer = pointer[segment];
|
||||
pointer = pointer[segment]
|
||||
}
|
||||
|
||||
pointer[segments[segments.length - 1]] = value;
|
||||
const lastKey = segments.at(-1)
|
||||
const existing = pointer[lastKey]
|
||||
if ((typeof(value) == 'object') && (value !== null) && (typeof(existing) == 'object') && (existing !== null)) { // merge instead of overwrite
|
||||
Object.assign(existing, value)
|
||||
} else {
|
||||
pointer[lastKey] = value
|
||||
}
|
||||
|
||||
this.savePreferences();
|
||||
this.savePreferences()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('User', myUser, true); // for Sparc to use
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<header eicapptoolbar>
|
||||
<button eicbutton icon="icon-menu" xxxlarge rounded class="app-menu" role="button" aria-label="Button" aria-enabled="true"></button>
|
||||
<button eicbutton icon="icon-menu" large rounded class="app-menu" role="button" aria-label="Button" aria-enabled="true"></button>
|
||||
<img src="/app/assets/images/logop42.png" class="logo"/>
|
||||
</header>
|
||||
<menu eicmenu class="app-menu">
|
||||
|
||||
@@ -16,6 +16,7 @@ class SpaceView extends EICDomContent {
|
||||
DOMContentBlured(options) { this.wasBlured = true }
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
this.windowPrefsId = `live.spaceview.${options.mode}`
|
||||
for(let model in options.models) this[model] = options.models[model]
|
||||
this.ttb = options.ttb
|
||||
const components = ui.eicfy(this.el)
|
||||
|
||||
Reference in New Issue
Block a user