Issue #258 : Add pensize support to DrawingTest + add pensize test suite

This commit is contained in:
jdescottes
2015-11-28 00:24:52 +01:00
parent f0ed4927e8
commit 92d5a4a2fe
13 changed files with 182 additions and 1 deletions

View File

@@ -28,6 +28,9 @@
$.publish(Events.SELECT_PRIMARY_COLOR, [this.initialState.primaryColor]);
$.publish(Events.SELECT_SECONDARY_COLOR, [this.initialState.secondaryColor]);
$.publish(Events.SELECT_TOOL, [this.initialState.selectedTool]);
if (this.initialState.penSize) {
pskl.app.penSizeService.setPenSize(this.initialState.penSize);
}
};
ns.DrawingTestPlayer.prototype.createPiskel_ = function (width, height) {
@@ -94,6 +97,8 @@
this.playColorEvent_(recordEvent);
} else if (recordEvent.type === 'tool-event') {
this.playToolEvent_(recordEvent);
} else if (recordEvent.type === 'pensize-event') {
this.playPenSizeEvent_(recordEvent);
} else if (recordEvent.type === 'transformtool-event') {
this.playTransformToolEvent_(recordEvent);
} else if (recordEvent.type === 'instrumented-event') {
@@ -144,6 +149,10 @@
$.publish(Events.SELECT_TOOL, [recordEvent.toolId]);
};
ns.DrawingTestPlayer.prototype.playPenSizeEvent_ = function (recordEvent) {
pskl.app.penSizeService.setPenSize(recordEvent.penSize);
};
ns.DrawingTestPlayer.prototype.playTransformToolEvent_ = function (recordEvent) {
pskl.app.transformationsController.applyTool(recordEvent.toolId, recordEvent.event);
};

View File

@@ -11,6 +11,7 @@
$.subscribe(Events.MOUSE_EVENT, this.onMouseEvent_.bind(this));
$.subscribe(Events.KEYBOARD_EVENT, this.onKeyboardEvent_.bind(this));
$.subscribe(Events.TOOL_SELECTED, this.onToolEvent_.bind(this));
$.subscribe(Events.PEN_SIZE_CHANGED, this.onPenSizeChanged_.bind(this));
$.subscribe(Events.TRANSFORMATION_EVENT, this.onTransformationEvent_.bind(this));
$.subscribe(Events.PRIMARY_COLOR_SELECTED, this.onColorEvent_.bind(this, true));
$.subscribe(Events.SECONDARY_COLOR_SELECTED, this.onColorEvent_.bind(this, false));
@@ -48,7 +49,8 @@
},
primaryColor : pskl.app.selectedColorsService.getPrimaryColor(),
secondaryColor : pskl.app.selectedColorsService.getSecondaryColor(),
selectedTool : pskl.app.toolController.currentSelectedTool.toolId
selectedTool : pskl.app.toolController.currentSelectedTool.toolId,
penSize : pskl.app.penSizeService.getPenSize()
};
};
@@ -111,6 +113,15 @@
}
};
ns.DrawingTestRecorder.prototype.onPenSizeChanged_ = function (evt) {
if (this.isRecording) {
var recordEvent = {};
recordEvent.type = 'pensize-event';
recordEvent.penSize = pskl.app.penSizeService.getPenSize();
this.events.push(recordEvent);
}
};
ns.DrawingTestRecorder.prototype.onTransformationEvent_ = function (evt, toolId, domEvent) {
if (this.isRecording) {
var recordEvent = {};