mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #736 - cleanup selection tool state on SELECTION_DISMISSED event
This commit is contained in:
parent
5671eb4782
commit
5e6280301d
|
@ -123,8 +123,7 @@
|
||||||
var tool = pskl.app.drawingController.currentToolBehavior;
|
var tool = pskl.app.drawingController.currentToolBehavior;
|
||||||
var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
|
var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
|
||||||
if (isSelectionTool) {
|
if (isSelectionTool) {
|
||||||
var overlay = pskl.app.drawingController.overlayFrame;
|
tool.commitSelection();
|
||||||
tool.commitSelection(overlay);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
|
ns.AbstractDragSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
|
||||||
if (this.hasSelection) {
|
if (this.hasSelection) {
|
||||||
this.hasSelection = false;
|
this.hasSelection = false;
|
||||||
this.commitSelection(overlay);
|
this.commitSelection();
|
||||||
} else {
|
} else {
|
||||||
this.hasSelection = true;
|
this.hasSelection = true;
|
||||||
this.onDragSelectStart_(col, row);
|
this.onDragSelectStart_(col, row);
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
{key : 'ctrl+v', description : 'Paste the copied area'},
|
{key : 'ctrl+v', description : 'Paste the copied area'},
|
||||||
{key : 'shift', description : 'Hold to move the content'}
|
{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);
|
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_) {
|
if (this.isMovingContent_) {
|
||||||
$.publish(Events.SELECTION_PASTE);
|
$.publish(Events.SELECTION_PASTE);
|
||||||
this.isMovingContent_ = false;
|
this.isMovingContent_ = false;
|
||||||
|
@ -121,6 +124,13 @@
|
||||||
|
|
||||||
// Clean previous selection:
|
// Clean previous selection:
|
||||||
$.publish(Events.SELECTION_DISMISSED);
|
$.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();
|
overlay.clear();
|
||||||
this.hasSelection = false;
|
this.hasSelection = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
|
ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
|
||||||
if (this.hasSelection) {
|
if (this.hasSelection) {
|
||||||
this.hasSelection = false;
|
this.hasSelection = false;
|
||||||
this.commitSelection(overlay);
|
this.commitSelection();
|
||||||
} else {
|
} else {
|
||||||
this.hasSelection = true;
|
this.hasSelection = true;
|
||||||
// From the pixel clicked, get shape using an algorithm similar to the paintbucket one:
|
// From the pixel clicked, get shape using an algorithm similar to the paintbucket one:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"layers.duplicate.json",
|
"layers.duplicate.json",
|
||||||
"layers.fun.json",
|
"layers.fun.json",
|
||||||
"layers.merge.json",
|
"layers.merge.json",
|
||||||
"layers.top.bottom",
|
"layers.top.bottom.json",
|
||||||
"lighten.darken.json",
|
"lighten.darken.json",
|
||||||
"move.json",
|
"move.json",
|
||||||
"move-alllayers-allframes.json",
|
"move-alllayers-allframes.json",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user