Simplified SAVE STATE events, added wrap method to easily build decorators

This commit is contained in:
juliandescottes
2014-04-20 13:15:30 +02:00
parent 8335c07519
commit c2a3ccc8d0
11 changed files with 119 additions and 201 deletions

View File

@@ -50,12 +50,12 @@
}
};
ns.BaseTool.prototype.raiseSaveStateEvent = function (args) {
var toolInfo = {
toolId : this.toolId,
args : args
};
$.publish(Events.PISKEL_SAVE_STATE, toolInfo);
ns.BaseTool.prototype.raiseSaveStateEvent = function (replayData) {
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'REPLAY',
scope : this,
replay : replayData
});
};

View File

@@ -53,13 +53,9 @@
ns.Move.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
this.moveToolAt(col, row, color, frame, overlay);
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'TOOL',
tool : this,
replay : {
colDiff : col - this.startCol,
rowDiff : row - this.startRow
}
this.raiseSaveStateEvent({
colDiff : col - this.startCol,
rowDiff : row - this.startRow
});
};

View File

@@ -19,14 +19,10 @@
ns.PaintBucket.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
pskl.PixelUtils.paintSimilarConnectedPixelsFromFrame(frame, col, row, color);
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'TOOL',
tool : this,
replay : {
col : col,
row : row,
color : color
}
this.raiseSaveStateEvent({
col : col,
row : row,
color : color
});
};

View File

@@ -51,17 +51,12 @@
this.draw_(coords.col, coords.row, color, frame);
$.publish(Events.DRAG_END, [col, row]);
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'TOOL',
tool : this,
replay : {
col : col,
row : row,
startCol : this.startCol,
startRow : this.startRow,
color : color
}
this.raiseSaveStateEvent({
col : col,
row : row,
startCol : this.startCol,
startRow : this.startRow,
color : color
});
};

View File

@@ -55,13 +55,9 @@
ns.SimplePen.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'TOOL',
tool : this,
replay : {
pixels : this.pixels.slice(0),
color : color
}
this.raiseSaveStateEvent({
pixels : this.pixels.slice(0),
color : color
});
this.pixels = [];
};

View File

@@ -73,13 +73,9 @@
// For now, we are done with the stroke tool and don't need an overlay anymore:
overlay.clear();
$.publish(Events.PISKEL_SAVE_STATE, {
type : 'TOOL',
tool : this,
replay : {
pixels : strokePoints,
color : color
}
this.raiseSaveStateEvent({
pixels : strokePoints,
color : color
});
};