mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #338 : Store resize prefs to userpref
This commit is contained in:
parent
392204e5c5
commit
30c3cdbcc5
@ -17,14 +17,26 @@
|
|||||||
this.widthInput = this.container.querySelector('[name="resize-width"]');
|
this.widthInput = this.container.querySelector('[name="resize-width"]');
|
||||||
this.heightInput = this.container.querySelector('[name="resize-height"]');
|
this.heightInput = this.container.querySelector('[name="resize-height"]');
|
||||||
this.resizeForm = this.container.querySelector('form');
|
this.resizeForm = this.container.querySelector('form');
|
||||||
this.resizeContentCheckbox = this.container.querySelector('.resize-content-checkbox');
|
|
||||||
this.maintainRatioCheckbox = this.container.querySelector('.resize-ratio-checkbox');
|
var settings = pskl.UserSettings.get('RESIZE_SETTINGS');
|
||||||
|
|
||||||
var initWidth = this.piskelController.getWidth();
|
var initWidth = this.piskelController.getWidth();
|
||||||
var initHeight = this.piskelController.getHeight();
|
var initHeight = this.piskelController.getHeight();
|
||||||
this.sizeInputWidget = new pskl.widgets.SizeInput(this.widthInput, this.heightInput, initWidth, initHeight);
|
this.sizeInputWidget = new pskl.widgets.SizeInput(this.widthInput, this.heightInput, initWidth, initHeight);
|
||||||
|
|
||||||
this.anchorWidget.setOrigin(ns.AnchorWidget.ORIGIN.TOPLEFT);
|
var origin = ns.AnchorWidget.ORIGIN[settings.origin] || ns.AnchorWidget.ORIGIN.TOPLEFT;
|
||||||
|
this.anchorWidget.setOrigin(origin);
|
||||||
|
|
||||||
|
this.resizeContentCheckbox = this.container.querySelector('.resize-content-checkbox');
|
||||||
|
if (settings.content) {
|
||||||
|
this.resizeContentCheckbox.checked = true;
|
||||||
|
this.anchorWidget.disable();
|
||||||
|
}
|
||||||
|
this.maintainRatioCheckbox = this.container.querySelector('.resize-ratio-checkbox');
|
||||||
|
if (settings.ratio) {
|
||||||
|
this.maintainRatioCheckbox.checked = true;
|
||||||
|
this.sizeInputWidget.enableSync();
|
||||||
|
}
|
||||||
|
|
||||||
this.addEventListener(this.resizeForm, 'submit', this.onResizeFormSubmit_);
|
this.addEventListener(this.resizeForm, 'submit', this.onResizeFormSubmit_);
|
||||||
this.addEventListener(this.resizeContentCheckbox, 'change', this.onResizeContentChange_);
|
this.addEventListener(this.resizeContentCheckbox, 'change', this.onResizeContentChange_);
|
||||||
@ -34,6 +46,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ns.ResizeController.prototype.destroy = function () {
|
ns.ResizeController.prototype.destroy = function () {
|
||||||
|
this.updateUserPreferences_();
|
||||||
|
|
||||||
this.anchorWidget.destroy();
|
this.anchorWidget.destroy();
|
||||||
this.sizeInputWidget.destroy();
|
this.sizeInputWidget.destroy();
|
||||||
this.superclass.destroy.call(this);
|
this.superclass.destroy.call(this);
|
||||||
@ -77,6 +91,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.ResizeController.prototype.updateUserPreferences_ = function () {
|
||||||
|
pskl.UserSettings.set('RESIZE_SETTINGS', {
|
||||||
|
origin : this.anchorWidget.getOrigin(),
|
||||||
|
content : !!this.resizeContentCheckbox.checked,
|
||||||
|
ratio : !!this.maintainRatioCheckbox.checked
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/***********************/
|
/***********************/
|
||||||
/* RESIZE LOGIC */
|
/* RESIZE LOGIC */
|
||||||
/***********************/
|
/***********************/
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
LAYER_PREVIEW : 'LAYER_PREVIEW',
|
LAYER_PREVIEW : 'LAYER_PREVIEW',
|
||||||
LAYER_OPACITY : 'LAYER_OPACITY',
|
LAYER_OPACITY : 'LAYER_OPACITY',
|
||||||
EXPORT_SCALING: 'EXPORT_SCALING',
|
EXPORT_SCALING: 'EXPORT_SCALING',
|
||||||
|
RESIZE_SETTINGS: 'RESIZE_SETTINGS',
|
||||||
|
|
||||||
KEY_TO_DEFAULT_VALUE_MAP_ : {
|
KEY_TO_DEFAULT_VALUE_MAP_ : {
|
||||||
'GRID_WIDTH' : 0,
|
'GRID_WIDTH' : 0,
|
||||||
@ -28,7 +29,12 @@
|
|||||||
'ONION_SKIN' : false,
|
'ONION_SKIN' : false,
|
||||||
'LAYER_OPACITY' : 0.2,
|
'LAYER_OPACITY' : 0.2,
|
||||||
'LAYER_PREVIEW' : true,
|
'LAYER_PREVIEW' : true,
|
||||||
'EXPORT_SCALING' : 1
|
'EXPORT_SCALING' : 1,
|
||||||
|
'RESIZE_SETTINGS': {
|
||||||
|
content : false,
|
||||||
|
ratio : true,
|
||||||
|
origin : 'TOPLEFT'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
this.heightInput = heightInput;
|
this.heightInput = heightInput;
|
||||||
this.initWidth = initWidth;
|
this.initWidth = initWidth;
|
||||||
this.initHeight = initHeight;
|
this.initHeight = initHeight;
|
||||||
|
|
||||||
this.syncEnabled = true;
|
this.syncEnabled = true;
|
||||||
this.lastInput = this.widthInput;
|
this.lastInput = this.widthInput;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="resize-section">
|
<div class="resize-section">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" class="resize-ratio-checkbox checkbox-fix" value="true" checked="true"/>
|
<input type="checkbox" class="resize-ratio-checkbox checkbox-fix" value="true"/>
|
||||||
<span>Maintain aspect ratio</span>
|
<span>Maintain aspect ratio</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user