Issue 24 : Layers

!! NOT STABLE !!
Initial implementation. No UI update yet.
Check js/model/Piskel.js and js/model/Layer.js for an overview of the new
API.

Piskels can be saved on the existing service.

Previous piskels cannot be loaded. This should be fixed soon.
This commit is contained in:
jdescottes
2013-09-22 21:02:43 +02:00
parent 4f6863eb8a
commit 6528c7724b
24 changed files with 572 additions and 230 deletions

View File

@@ -1,9 +1,9 @@
(function () {
var ns = $.namespace("pskl.selection");
ns.SelectionManager = function (framesheet) {
ns.SelectionManager = function (piskelController) {
this.framesheet = framesheet;
this.piskelController = piskelController;
this.currentSelection = null;
};
@@ -52,10 +52,10 @@
ns.SelectionManager.prototype.onCut_ = function(evt) {
if(this.currentSelection) {
// Put cut target into the selection:
this.currentSelection.fillSelectionFromFrame(this.framesheet.getCurrentFrame());
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
var pixels = this.currentSelection.pixels;
var currentFrame = this.framesheet.getCurrentFrame();
var currentFrame = this.piskelController.getCurrentFrame();
for(var i=0, l=pixels.length; i<l; i++) {
try {
currentFrame.setPixel(pixels[i].col, pixels[i].row, Constants.TRANSPARENT_COLOR);
@@ -73,7 +73,7 @@
ns.SelectionManager.prototype.onPaste_ = function(evt) {
if(this.currentSelection && this.currentSelection.hasPastedContent) {
var pixels = this.currentSelection.pixels;
var currentFrame = this.framesheet.getCurrentFrame();
var currentFrame = this.piskelController.getCurrentFrame();
for(var i=0, l=pixels.length; i<l; i++) {
try {
currentFrame.setPixel(
@@ -91,8 +91,8 @@
* @private
*/
ns.SelectionManager.prototype.onCopy_ = function(evt) {
if(this.currentSelection && this.framesheet.getCurrentFrame()) {
this.currentSelection.fillSelectionFromFrame(this.framesheet.getCurrentFrame());
if(this.currentSelection && this.piskelController.getCurrentFrame()) {
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
}
else {
throw "Bad state for CUT callback in SelectionManager";