mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #258 : KB shortcuts to increase/decrease pensize
This commit is contained in:
parent
fce9bb5727
commit
3525b318a6
@ -45,6 +45,8 @@
|
||||
RESET_ZOOM : createShortcut('reset-zoom', 'Reset zoom level', '0'),
|
||||
INCREASE_ZOOM : createShortcut('increase-zoom', 'Increase zoom level', '+'),
|
||||
DECREASE_ZOOM : createShortcut('decrease-zoom', 'Decrease zoom level', '-'),
|
||||
INCREASE_PENSIZE : createShortcut('increase-pensize', 'Increase pen size', ']'),
|
||||
DECREASE_PENSIZE : createShortcut('decrease-pensize', 'Decrease pen size', '['),
|
||||
UNDO : createShortcut('undo', 'Undo', 'ctrl+Z'),
|
||||
REDO : createShortcut('redo', 'Redo', ['ctrl+Y', 'ctrl+shift+Z']),
|
||||
PREVIOUS_FRAME : createShortcut('previous-frame', 'Select previous frame', 'up'),
|
||||
|
@ -1,20 +1,43 @@
|
||||
(function () {
|
||||
var ns = $.namespace('pskl.service.pensize');
|
||||
|
||||
var MIN_PENSIZE = 1;
|
||||
var MAX_PENSIZE = 4;
|
||||
|
||||
ns.PenSizeService = function () {};
|
||||
|
||||
ns.PenSizeService.prototype.init = function () {
|
||||
this.size = pskl.UserSettings.get('PEN_SIZE');
|
||||
|
||||
var shortcuts = pskl.service.keyboard.Shortcuts;
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.INCREASE_PENSIZE, this.increasePenSize_.bind(this));
|
||||
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DECREASE_PENSIZE, this.decreasePenSize_.bind(this));
|
||||
};
|
||||
|
||||
ns.PenSizeService.prototype.increasePenSize_ = function () {
|
||||
this.setPenSize(this.size + 1);
|
||||
};
|
||||
|
||||
ns.PenSizeService.prototype.decreasePenSize_ = function () {
|
||||
this.setPenSize(this.size - 1);
|
||||
};
|
||||
|
||||
ns.PenSizeService.prototype.setPenSize = function (size) {
|
||||
if (size != this.size) {
|
||||
if (this.isPenSizeValid_(size) && size != this.size) {
|
||||
this.size = size;
|
||||
pskl.UserSettings.set('PEN_SIZE', size);
|
||||
$.publish(Events.PEN_SIZE_CHANGED);
|
||||
}
|
||||
};
|
||||
|
||||
ns.PenSizeService.prototype.isPenSizeValid_ = function (size) {
|
||||
if (isNaN(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return size >= MIN_PENSIZE && size <= MAX_PENSIZE;
|
||||
};
|
||||
|
||||
ns.PenSizeService.prototype.getPenSize = function () {
|
||||
return this.size;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user