Issue #736 - cleanup selection tool state on SELECTION_DISMISSED event

This commit is contained in:
juliandescottes 2017-09-06 00:35:07 +02:00 committed by Julian Descottes
parent 5671eb4782
commit 5e6280301d
5 changed files with 16 additions and 7 deletions

View File

@ -123,8 +123,7 @@
var tool = pskl.app.drawingController.currentToolBehavior;
var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
if (isSelectionTool) {
var overlay = pskl.app.drawingController.overlayFrame;
tool.commitSelection(overlay);
tool.commitSelection();
}
};

View File

@ -16,7 +16,7 @@
ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
if (this.hasSelection) {
this.hasSelection = false;
this.commitSelection(overlay);
this.commitSelection();
} else {
this.hasSelection = true;
this.onDragSelectStart_(col, row);

View File

@ -26,6 +26,8 @@
{key : 'ctrl+v', description : 'Paste the copied area'},
{key : 'shift', description : 'Hold to move the content'}
];
$.subscribe(Events.SELECTION_DISMISSED, this.onSelectionDismissed_.bind(this));
};
pskl.utils.inherit(ns.BaseSelect, pskl.tools.drawing.BaseTool);
@ -111,9 +113,10 @@
};
/**
* Protected method, should be called when the selection is dismissed.
* Protected method, should be called when the selection is committed,
* typically by clicking outside of the selected area.
*/
ns.BaseSelect.prototype.commitSelection = function (overlay) {
ns.BaseSelect.prototype.commitSelection = function () {
if (this.isMovingContent_) {
$.publish(Events.SELECTION_PASTE);
this.isMovingContent_ = false;
@ -121,6 +124,13 @@
// Clean previous selection:
$.publish(Events.SELECTION_DISMISSED);
};
/**
* Protected method, should be called when the selection is dismissed.
*/
ns.BaseSelect.prototype.onSelectionDismissed_ = function () {
var overlay = pskl.app.drawingController.overlayFrame;
overlay.clear();
this.hasSelection = false;
};

View File

@ -24,7 +24,7 @@
ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
if (this.hasSelection) {
this.hasSelection = false;
this.commitSelection(overlay);
this.commitSelection();
} else {
this.hasSelection = true;
// From the pixel clicked, get shape using an algorithm similar to the paintbucket one:

View File

@ -8,7 +8,7 @@
"layers.duplicate.json",
"layers.fun.json",
"layers.merge.json",
"layers.top.bottom",
"layers.top.bottom.json",
"lighten.darken.json",
"move.json",
"move-alllayers-allframes.json",