Added keyboard shortcuts

This commit is contained in:
jdescottes 2014-07-04 19:17:02 +02:00
parent 939042a645
commit 24186d5aec
5 changed files with 26 additions and 7 deletions

View file

@ -19,6 +19,8 @@
this.updateZoom_();
$.subscribe(Events.FRAME_SIZE_CHANGED, this.onFrameSizeChange_.bind(this));
$.subscribe(Events.USER_SETTINGS_CHANGED, $.proxy(this.onUserSettingsChange_, this));
pskl.app.shortcutService.addShortcut('alt+O', this.toggleOnionSkin_.bind(this));
};
ns.AnimatedPreviewController.prototype.onUserSettingsChange_ = function () {
@ -122,4 +124,9 @@
containerEl.style.marginLeft = ((PREVIEW_SIZE - width) / 2) + "px";
containerEl.style.marginRight = ((PREVIEW_SIZE - width) / 2) + "px";
};
ns.AnimatedPreviewController.prototype.toggleOnionSkin_ = function () {
var currentValue = pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN);
pskl.UserSettings.set(pskl.UserSettings.ONION_SKIN, !currentValue);
};
})();

View file

@ -113,7 +113,7 @@
ns.DrawingController.prototype.onUserSettingsChange_ = function (evt, settingsName, settingsValue) {
if(settingsName == pskl.UserSettings.SHOW_GRID) {
console.warn('DrawingController:onUserSettingsChange_ not implemented !');
} else if (settingsName == pskl.UserSettings.OVERLAY) {
} else if (settingsName == pskl.UserSettings.ONION_SKIN || settingsName == pskl.UserSettings.LAYER_PREVIEW) {
this.onionSkinRenderer.clear();
this.onionSkinRenderer.flush();
this.layersRenderer.clear();
@ -319,10 +319,11 @@
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(currentFrame);
}
var overlaySetting = pskl.UserSettings.get(pskl.UserSettings.OVERLAY);
if (overlaySetting === Constants.OVERLAY_ONION_SKIN) {
if (pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN)) {
this.onionSkinRenderer.render();
} else if (overlaySetting === Constants.OVERLAY_LAYER_PREVIEW) {
}
if (pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW)) {
this.layersRenderer.render();
}

View file

@ -14,6 +14,8 @@
$.subscribe(Events.PISKEL_RESET, this.renderLayerList_.bind(this));
pskl.app.shortcutService.addShortcut('alt+L', this.toggleLayerPreview_.bind(this));
this.renderLayerList_();
};
@ -69,4 +71,9 @@
this.piskelController.removeCurrentLayer();
}
};
ns.LayersListController.prototype.toggleLayerPreview_ = function () {
var currentValue = pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW);
pskl.UserSettings.set(pskl.UserSettings.LAYER_PREVIEW, !currentValue);
};
})();

View file

@ -103,7 +103,9 @@
this.toDescriptor_('N', 'Create new frame'),
this.toDescriptor_('shift + N', 'Duplicate selected frame'),
this.toDescriptor_('shift + ?', 'Open/Close this popup'),
this.toDescriptor_('alt + P', 'Open the Palette Manager')
this.toDescriptor_('alt + P', 'Open the Palette Manager'),
this.toDescriptor_('alt + O', 'Toggle Onion Skin'),
this.toDescriptor_('alt + L', 'Toggle Layer Preview')
];
this.initMarkupAbstract_(descriptors, '.cheatsheet-misc-shortcuts');

View file

@ -6,14 +6,16 @@
CANVAS_BACKGROUND : 'CANVAS_BACKGROUND',
SELECTED_PALETTE : 'SELECTED_PALETTE',
TILED_PREVIEW : 'TILED_PREVIEW',
OVERLAY : 'OVERLAY',
ONION_SKIN : 'ONION_SKIN',
LAYER_PREVIEW : 'LAYER_PREVIEW',
KEY_TO_DEFAULT_VALUE_MAP_ : {
'GRID_WIDTH' : 0,
'CANVAS_BACKGROUND' : 'lowcont-dark-canvas-background',
'SELECTED_PALETTE' : Constants.CURRENT_COLORS_PALETTE_ID,
'TILED_PREVIEW' : false,
'OVERLAY' : Constants.OVERLAY_ONION_SKIN
'ONION_SKIN' : false,
'LAYER_PREVIEW' : true
},
/**