31 Commits

Author SHA1 Message Date
eef85c57b7 release: version 0.8.2 2016-08-16 01:11:07 +02:00
d4e9b1e896 Merge pull request #516 from juliandescottes/feature-drag-selection
Feature drag selection
2016-08-16 01:10:18 +02:00
8e3ac50f81 Issue #290: cleanup unused code in SelectionManager 2016-08-16 01:04:55 +02:00
f4cbabe2ce Issue #290: selection tools: clear hasSelection flag when calling commitSelection 2016-08-16 00:40:01 +02:00
69393127fa Issue #290: rename dismissSelection to commitSelection 2016-08-16 00:40:01 +02:00
fc7fc6d9b0 Issue #290: Fix typo in comment 2016-08-16 00:40:01 +02:00
01aa4629cc Issue #290: Commit selection on ENTER 2016-08-16 00:40:01 +02:00
22797e5dc5 Issue #290: add missing parameter to dismissSelection in BaseSelect 2016-08-16 00:40:01 +02:00
0d5dc21a41 Issue #290: change boolean flag name to isMovingContent in BaseSelect 2016-08-16 00:40:01 +02:00
0d1210e71f Issue #290: fix wand cursor hotspot 2016-08-16 00:40:01 +02:00
34f2a9df0b Issue #163: show highlighter pixel for selection tools when no selection 2016-08-16 00:40:01 +02:00
a383e59280 Issue #290: allow to drag selection when using SHIFT while selection 2016-08-16 00:40:01 +02:00
230f1b23fc Merge pull request #518 from epicabsol/icontweaks
Cursor tweaks
2016-08-06 18:45:40 +02:00
77ccd60e77 Renamed lighten cursor
lighting.png -> lighten.png
2016-08-06 09:23:05 -07:00
5014937392 Merge pull request #517 from epicabsol/master
Correct desktop window icon
2016-08-06 13:08:26 +02:00
17e6cf9b38 Dither & stroke cursors
Added dither and stroke cursors. The line on the stroke cursor is quite
hard to see, but I think that's pretty unaviodable. I would suggest
moving to a larger cursor size.
2016-08-05 22:32:24 -07:00
d795c297f5 Lighting cursor, more tweaks
Added an icon for the lighting tool, although it's somewhat difficult to
see what it is without looking closely. I'd love to hear other ideas for
a cursor. (See juliandescottes/piskel#351)
I also reworked the hit point of the existing cursors by a few pixels.
2016-08-05 21:34:46 -07:00
f4bf053564 Reworked circle drawing cursor
Reworked circle drawing cursor to match the style of the rectangle
cursor.
2016-08-05 20:33:18 -07:00
d10c284436 Correct desktop window icon filename
I found the logo at dest/prod/logo.png, while there was no
dest/logo.png. Fixes juliandescottes/piskel#515
2016-08-05 19:06:49 -07:00
fdd4fb5b4e only update zoom for a valid modifier, fix zoom centering bug when using keyboard shortcuts 2016-07-30 00:01:32 +02:00
3e7999cfc5 Merge pull request #385 from smiegrin/master
Introduces zooming towards/away from mouse
2016-07-28 09:39:18 +02:00
f4c860ddfa Consolidates zooming into single function. 2016-07-26 09:28:18 -06:00
2dee5fcad1 Merge pull request #512 from juliandescottes/fix-move-viewport
Fix viewport shaking on touchmove event on mobile/tablet
2016-07-26 12:20:06 +02:00
4895017ebb Fix viewport shaking on touchmove event on mobile/tablet 2016-07-26 12:13:49 +02:00
81b1bca7f5 Merge branch 'master' of https://github.com/juliandescottes/piskel 2016-07-25 14:40:58 -06:00
0b1ec655ae retina: update lasso & shape select icons 2016-07-25 09:32:50 +02:00
144cf4b7de release: set version to 0.9.0-SNAPSHOT 2016-07-24 19:42:46 +02:00
be79eb2f6f Merge branch 'master' of https://github.com/juliandescottes/piskel 2016-05-04 16:31:53 -06:00
3b6c5aa7a4 Sync upstream Jan 31 2016 2016-01-31 16:41:34 -07:00
e8f6bcee63 Merge remote-tracking branch 'upstream/master' 2016-01-18 07:39:31 -07:00
412067ad90 Introduces zooming towards/away from mouse 2016-01-17 16:30:21 -07:00
22 changed files with 155 additions and 66 deletions

View File

@ -20,9 +20,9 @@
xml:space="preserve" xml:space="preserve"
inkscape:version="0.48.4 r9939" inkscape:version="0.48.4 r9939"
sodipodi:docname="tool-lasso-select.svg" sodipodi:docname="tool-lasso-select.svg"
inkscape:export-filename="C:\Development\git\piskel\misc\icons\source\tool-lasso-select@2x.png" inkscape:export-filename="C:\Development\git\piskel\misc\icons\source\tool-lasso-select.png"
inkscape:export-xdpi="90" inkscape:export-xdpi="45"
inkscape:export-ydpi="90"><metadata inkscape:export-ydpi="45"><metadata
id="metadata9"><rdf:RDF><cc:Work id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
@ -39,22 +39,17 @@
inkscape:window-height="1148" inkscape:window-height="1148"
id="namedview5" id="namedview5"
showgrid="false" showgrid="false"
inkscape:zoom="11.313709" inkscape:zoom="5.6568543"
inkscape:cx="28.848556" inkscape:cx="53.41565"
inkscape:cy="56.05112" inkscape:cy="19.716081"
inkscape:window-x="-8" inkscape:window-x="-8"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" /> inkscape:current-layer="Layer_1" />
<path <path
style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:5.99999987, 5.99999987;stroke-dashoffset:9.59999979" style="fill:none;stroke:#ffffff;stroke-width:3.99999976000000010;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:7.99999982000000020, 3.99999991000000010;stroke-dashoffset:1.59999997000000000"
d="m 27.137305,45.116922 c 4.348192,3.354775 13.757306,5.64287 20.485225,5.05984 6.727919,-0.583031 15.989555,-2.799751 19.954403,-8.454605 3.964848,-5.654854 2.6921,-13.891707 -3.122398,-15.860913 -6.608117,-2.237981 -9.882928,4.099594 -19.471426,4.899951 -7.474124,0.623869 -14.014171,-4.834533 -18.728321,-1.630028 -7.360138,5.003149 -3.465675,12.63098 0.882517,15.985755 z" d="M 63.459007,62.898551 C 51.21203,69.659898 34.408658,68.826355 23.032272,56.955855 11.655886,45.085355 16.081011,27.22439 25.257464,25.049087 c 9.176453,-2.175302 10.165996,14.382407 20.36105,14.647508 10.195054,0.265101 11.555041,-13.986139 23.446941,-11.490831 11.8919,2.495308 6.640529,27.93144 -5.606448,34.692787 z"
id="path4945" id="path4945"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="zszsssz" /><path sodipodi:nodetypes="zzzzzz" /></svg>
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="M 26.563739,67.114661 C 33.855127,59.408496 44.134234,57.708412 44.506573,51.469924"
id="path4947"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" /></svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -25,7 +25,7 @@
inkscape:export-ydpi="90"><metadata inkscape:export-ydpi="90"><metadata
id="metadata9"><rdf:RDF><cc:Work id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview id="defs7" /><sodipodi:namedview
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#666666" bordercolor="#666666"
@ -40,7 +40,7 @@
id="namedview5" id="namedview5"
showgrid="false" showgrid="false"
inkscape:zoom="8.9380977" inkscape:zoom="8.9380977"
inkscape:cx="27.470446" inkscape:cx="8.8982615"
inkscape:cy="50.702772" inkscape:cy="50.702772"
inkscape:window-x="-8" inkscape:window-x="-8"
inkscape:window-y="-8" inkscape:window-y="-8"
@ -49,7 +49,7 @@
<path <path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans" style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="M 54.920882,32.150851 23.207014,63.864718 c 0,0 -1.426625,3.647594 -0.07284,5.00138 1.353787,1.353786 5.00138,-0.07284 5.00138,-0.07284 L 59.849422,37.07939 c 0,0 1.426626,-3.647593 0.07284,-5.001379 -1.353786,-1.353786 -5.00138,0.07284 -5.00138,0.07284 z m -2.537109,5.074219 c 0,0 1.701964,-0.835146 2.46427,-0.07284 0.762306,0.762306 -0.07284,2.464269 -0.07284,2.464269 l -26.639649,26.63965 c 0,0 -1.701963,0.835146 -2.464269,0.07284 -0.762306,-0.762305 0.07284,-2.464269 0.07284,-2.464269 z" d="M 54.920882,32.150851 23.207015,63.864718 c 0,0 -1.426626,3.647594 -0.07284,5.001381 1.353787,1.353785 5.001381,-0.07284 5.001381,-0.07284 L 59.849423,37.07939 c 0,0 1.426625,-3.647592 0.07284,-5.001379 -1.353786,-1.353785 -5.00138,0.07284 -5.00138,0.07284 z m -4.969979,8.298204 c 0,0 1.306407,-1.230703 2.068713,-0.468398 0.762306,0.762307 -0.468398,2.068712 -0.468398,2.068712 L 27.739997,65.860591 c 0,0 -1.306406,1.230704 -2.068712,0.468398 -0.762306,-0.762305 0.468398,-2.068712 0.468398,-2.068712 z"
id="rect4410" id="rect4410"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cczcczcczcczcc" /><path sodipodi:nodetypes="cczcczcczcczcc" /><path

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,6 +1,6 @@
{ {
"name": "piskel", "name": "piskel",
"version": "0.8.1", "version": "0.8.2",
"description": "Pixel art editor", "description": "Pixel art editor",
"author": "Julian Descottes <julian.descottes@gmail.com>", "author": "Julian Descottes <julian.descottes@gmail.com>",
"contributors": [ "contributors": [
@ -55,7 +55,7 @@
}, },
"window": { "window": {
"title": "Piskel", "title": "Piskel",
"icon": "dest/logo.png", "icon": "dest/prod/logo.png",
"toolbar": false, "toolbar": false,
"width": 1000, "width": 1000,
"height": 500 "height": 500

View File

@ -31,33 +31,39 @@
.tool-paint-bucket .drawing-canvas-container:hover, .tool-paint-bucket .drawing-canvas-container:hover,
.tool-colorswap .drawing-canvas-container:hover { .tool-colorswap .drawing-canvas-container:hover {
cursor: url(../img/cursors/paint-bucket.png) 12 12, pointer; cursor: url(../img/cursors/paint-bucket.png) 14 14, pointer;
} }
.tool-vertical-mirror-pen .drawing-canvas-container:hover { .tool-vertical-mirror-pen .drawing-canvas-container:hover {
cursor: url(../img/cursors/vertical-mirror-pen.png) 5 15, pointer; cursor: url(../img/cursors/vertical-mirror-pen.png) 5 15, pointer;
} }
.tool-pen .drawing-canvas-container:hover, .tool-pen .drawing-canvas-container:hover {
.tool-lighten .drawing-canvas-container:hover, cursor: url(../img/cursors/pen.png) 1 14, pointer;
}
.tool-dithering .drawing-canvas-container:hover { .tool-dithering .drawing-canvas-container:hover {
cursor: url(../img/cursors/pen.png) 0 15, pointer; cursor: url(../img/cursors/dither.png) 1 14, pointer;
}
.tool-lighten .drawing-canvas-container:hover {
cursor: url(../img/cursors/lighten.png) 1 15, pointer;
} }
.tool-eraser .drawing-canvas-container:hover { .tool-eraser .drawing-canvas-container:hover {
cursor: url(../img/cursors/eraser.png) 0 15, pointer; cursor: url(../img/cursors/eraser.png) 3 14, pointer;
} }
.tool-stroke .drawing-canvas-container:hover { .tool-stroke .drawing-canvas-container:hover {
cursor: url(../img/cursors/pen.png) 0 15, pointer; cursor: url(../img/cursors/stroke.png) 1 14, pointer;
} }
.tool-rectangle .drawing-canvas-container:hover { .tool-rectangle .drawing-canvas-container:hover {
cursor: url(../img/cursors/rectangle.png) 0 15, pointer; cursor: url(../img/cursors/rectangle.png) 5 15, pointer;
} }
.tool-circle .drawing-canvas-container:hover { .tool-circle .drawing-canvas-container:hover {
cursor: url(../img/cursors/circle.png) 2 15, pointer; cursor: url(../img/cursors/circle.png) 5 15, pointer;
} }
.tool-move .drawing-canvas-container:hover { .tool-move .drawing-canvas-container:hover {
@ -70,11 +76,11 @@
} }
.tool-shape-select .drawing-canvas-container:hover { .tool-shape-select .drawing-canvas-container:hover {
cursor: url(../img/cursors/wand.png) 15 15, pointer; cursor: url(../img/cursors/wand.png) 10 5, pointer;
} }
.tool-colorpicker .drawing-canvas-container:hover { .tool-colorpicker .drawing-canvas-container:hover {
cursor: url(../img/cursors/dropper.png) 0 15, pointer; cursor: url(../img/cursors/dropper.png) 2 15, pointer;
} }
.swap-colors-button { .swap-colors-button {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 766 B

BIN
src/img/cursors/dither.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

BIN
src/img/cursors/lighten.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -63,6 +63,9 @@ var Events = {
SELECTION_CREATED: 'SELECTION_CREATED', SELECTION_CREATED: 'SELECTION_CREATED',
SELECTION_MOVE_REQUEST: 'SELECTION_MOVE_REQUEST', SELECTION_MOVE_REQUEST: 'SELECTION_MOVE_REQUEST',
SELECTION_DISMISSED: 'SELECTION_DISMISSED', SELECTION_DISMISSED: 'SELECTION_DISMISSED',
SELECTION_COPY: 'SELECTION_COPY',
SELECTION_CUT: 'SELECTION_CUT',
SELECTION_PASTE: 'SELECTION_PASTE',
SHOW_NOTIFICATION: 'SHOW_NOTIFICATION', SHOW_NOTIFICATION: 'SHOW_NOTIFICATION',
HIDE_NOTIFICATION: 'HIDE_NOTIFICATION', HIDE_NOTIFICATION: 'HIDE_NOTIFICATION',

View File

@ -64,8 +64,8 @@
var shortcuts = pskl.service.keyboard.Shortcuts; var shortcuts = pskl.service.keyboard.Shortcuts;
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.RESET_ZOOM, this.resetZoom_.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.MISC.RESET_ZOOM, this.resetZoom_.bind(this));
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.INCREASE_ZOOM, this.increaseZoom_.bind(this, 1)); pskl.app.shortcutService.registerShortcut(shortcuts.MISC.INCREASE_ZOOM, this.updateZoom_.bind(this, 1));
pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DECREASE_ZOOM, this.decreaseZoom_.bind(this, 1)); pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DECREASE_ZOOM, this.updateZoom_.bind(this, -1));
window.setTimeout(function () { window.setTimeout(function () {
this.afterWindowResize_(); this.afterWindowResize_();
@ -86,9 +86,10 @@
window.addEventListener('mouseup', this.onMouseup_.bind(this)); window.addEventListener('mouseup', this.onMouseup_.bind(this));
window.addEventListener('mousemove', this.onMousemove_.bind(this)); window.addEventListener('mousemove', this.onMousemove_.bind(this));
window.addEventListener('keyup', this.onKeyup_.bind(this)); window.addEventListener('keyup', this.onKeyup_.bind(this));
window.addEventListener('touchstart', this.onMousedown_.bind(this)); window.addEventListener('touchstart', this.onTouchstart_.bind(this));
window.addEventListener('touchmove' , this.onMousemove_.bind(this)); window.addEventListener('touchmove' , this.onTouchmove_.bind(this));
window.addEventListener('touchend', this.onMouseup_.bind(this)); window.addEventListener('touchend', this.onTouchend_.bind(this));
// Deactivate right click: // Deactivate right click:
body.contextmenu(this.onCanvasContextMenu_); body.contextmenu(this.onCanvasContextMenu_);
@ -136,6 +137,19 @@
$.publish(Events.ZOOM_CHANGED); $.publish(Events.ZOOM_CHANGED);
}; };
ns.DrawingController.prototype.onTouchstart_ = function (event) {
this.onMousedown_(event);
};
ns.DrawingController.prototype.onTouchmove_ = function (event) {
this.onMousemove_(event);
event.preventDefault();
};
ns.DrawingController.prototype.onTouchend_ = function (event) {
this.onMouseup_(event);
};
/** /**
* @private * @private
*/ */
@ -231,7 +245,7 @@
} else if (pskl.utils.UserAgent.isFirefox) { } else if (pskl.utils.UserAgent.isFirefox) {
delta = -40 * evt.deltaY; delta = -40 * evt.deltaY;
} }
var modifier = Math.abs(delta / 120); var modifier = (delta / 120);
if (pskl.utils.UserAgent.isMac ? evt.metaKey : evt.ctrlKey) { if (pskl.utils.UserAgent.isMac ? evt.metaKey : evt.ctrlKey) {
modifier = modifier * 5; modifier = modifier * 5;
@ -239,21 +253,41 @@
evt.preventDefault(); evt.preventDefault();
} }
if (delta > 0) { var coords = this.getSpriteCoordinates(evt.clientX, evt.clientY);
this.increaseZoom_(modifier); this.updateZoom_(modifier, coords);
} else if (delta < 0) { };
this.decreaseZoom_(modifier);
/**
* Update the current zoom level by a given multiplier.
*
* @param {Number} zoomMultiplier: factor by which the zoom should be modified. Negative
* values will decrease the zoom, positive values will increase it.
* @param {Object} centerCoords, optional:
* - {Number} x: x coordinate of the desired center the zoomed canvas
* - {Number} y: y coordinate of the desired center the zoomed canvas
*/
ns.DrawingController.prototype.updateZoom_ = function (zoomMultiplier, centerCoords) {
if (zoomMultiplier === 0) {
return;
} }
};
ns.DrawingController.prototype.increaseZoom_ = function (zoomMultiplier) { var off = this.getOffset();
var step = (zoomMultiplier || 1) * this.getZoomStep_(); var oldWidth = this.getContainerWidth_() / this.renderer.getZoom();
var oldHeight = this.getContainerHeight_() / this.renderer.getZoom();
var step = zoomMultiplier * this.getZoomStep_();
this.setZoom_(this.renderer.getZoom() + step); this.setZoom_(this.renderer.getZoom() + step);
};
ns.DrawingController.prototype.decreaseZoom_ = function (zoomMultiplier) { if (centerCoords) {
var step = (zoomMultiplier || 1) * this.getZoomStep_(); var xRatio = (centerCoords.x - off.x) / oldWidth;
this.setZoom_(this.renderer.getZoom() - step); var yRatio = (centerCoords.y - off.y) / oldHeight;
var newWidth = this.getContainerWidth_() / this.renderer.getZoom();
var newHeight = this.getContainerHeight_() / this.renderer.getZoom();
this.setOffset(
off.x - ((newWidth - oldWidth) * xRatio),
off.y - ((newHeight - oldHeight) * yRatio)
);
}
}; };
/** /**

View File

@ -17,12 +17,16 @@
$.subscribe(Events.SELECTION_CREATED, $.proxy(this.onSelectionCreated_, this)); $.subscribe(Events.SELECTION_CREATED, $.proxy(this.onSelectionCreated_, this));
$.subscribe(Events.SELECTION_DISMISSED, $.proxy(this.onSelectionDismissed_, this)); $.subscribe(Events.SELECTION_DISMISSED, $.proxy(this.onSelectionDismissed_, this));
$.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this)); $.subscribe(Events.SELECTION_MOVE_REQUEST, $.proxy(this.onSelectionMoved_, this));
$.subscribe(Events.SELECTION_COPY, this.copy.bind(this));
$.subscribe(Events.SELECTION_CUT, this.cut.bind(this));
$.subscribe(Events.SELECTION_PASTE, this.paste.bind(this));
var shortcuts = pskl.service.keyboard.Shortcuts; var shortcuts = pskl.service.keyboard.Shortcuts;
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.PASTE, this.paste.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.PASTE, this.paste.bind(this));
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.CUT, this.cut.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.CUT, this.cut.bind(this));
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COPY, this.copy.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COPY, this.copy.bind(this));
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.DELETE, this.onDeleteShortcut_.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.DELETE, this.onDeleteShortcut_.bind(this));
pskl.app.shortcutService.registerShortcut(shortcuts.SELECTION.COMMIT, this.commit.bind(this));
$.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this)); $.subscribe(Events.TOOL_SELECTED, $.proxy(this.onToolSelected_, this));
}; };
@ -107,6 +111,19 @@
}); });
}; };
/**
* If the currently selected tool is a selection tool, call commitSelection handler on
* the current tool instance.
*/
ns.SelectionManager.prototype.commit = function() {
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);
}
};
ns.SelectionManager.prototype.replay = function (frame, replayData) { ns.SelectionManager.prototype.replay = function (frame, replayData) {
if (replayData.type === SELECTION_REPLAY.PASTE) { if (replayData.type === SELECTION_REPLAY.PASTE) {
this.pastePixels_(frame, replayData.pixels); this.pastePixels_(frame, replayData.pixels);

View File

@ -1,7 +1,7 @@
(function () { (function () {
var specialKeys = { var specialKeys = {
191 : '?',
8 : 'back', 8 : 'back',
13 : 'enter',
27 : 'esc', 27 : 'esc',
37 : 'left', 37 : 'left',
38 : 'up', 38 : 'up',
@ -20,6 +20,7 @@
61 : '+', 61 : '+',
188 : '<', 188 : '<',
190 : '>', 190 : '>',
191 : '?',
219 : '[', 219 : '[',
221 : ']' 221 : ']'
}; };

View File

@ -53,7 +53,18 @@
* @return {Boolean} true if the shortcut can be updated * @return {Boolean} true if the shortcut can be updated
*/ */
ns.Shortcut.prototype.isEditable = function () { ns.Shortcut.prototype.isEditable = function () {
return this.getKeys().length < 2; if (this.getKeys().length === 0) {
// No key defined: can be edited.
return true;
}
if (this.getKeys().length === 1) {
// Only one key defined, can be edited if it is not using a forbidden key.
return ns.Shortcuts.FORBIDDEN_KEYS.indexOf(this.getKeys()[0]) === -1;
}
// More than one key, can't be edited.
return false;
}; };
ns.Shortcut.prototype.isCustom = function () { ns.Shortcut.prototype.isCustom = function () {

View File

@ -11,7 +11,7 @@
* Or really custom shortcuts such as the 1-9 for color palette shorctus * Or really custom shortcuts such as the 1-9 for color palette shorctus
*/ */
FORBIDDEN_KEYS : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '?', 'shift+?', FORBIDDEN_KEYS : ['1', '2', '3', '4', '5', '6', '7', '8', '9', '?', 'shift+?',
'del', 'back', 'ctrl+Y', 'ctrl+shift+Z'], 'DEL', 'BACK', 'ENTER', 'ctrl+Y', 'ctrl+shift+Z'],
/** /**
* Syntax : createShortcut(id, description, default key(s)) * Syntax : createShortcut(id, description, default key(s))
@ -38,7 +38,8 @@
CUT : createShortcut('selection-cut', 'Cut selection', 'ctrl+X'), CUT : createShortcut('selection-cut', 'Cut selection', 'ctrl+X'),
COPY : createShortcut('selection-copy', 'Copy selection', 'ctrl+C'), COPY : createShortcut('selection-copy', 'Copy selection', 'ctrl+C'),
PASTE : createShortcut('selection-paste', 'Paste selection', 'ctrl+V'), PASTE : createShortcut('selection-paste', 'Paste selection', 'ctrl+V'),
DELETE : createShortcut('selection-delete', 'Delete selection', ['del', 'back']) DELETE : createShortcut('selection-delete', 'Delete selection', ['DEL', 'BACK']),
COMMIT : createShortcut('selection-commit', 'Commit selection', ['ENTER'])
}, },
MISC : { MISC : {

View File

@ -8,8 +8,6 @@
ns.AbstractDragSelect = function () { ns.AbstractDragSelect = function () {
ns.BaseSelect.call(this); ns.BaseSelect.call(this);
this.hasSelection = false;
}; };
pskl.utils.inherit(ns.AbstractDragSelect, ns.BaseSelect); pskl.utils.inherit(ns.AbstractDragSelect, ns.BaseSelect);
@ -18,8 +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;
overlay.clear(); this.commitSelection(overlay);
$.publish(Events.SELECTION_DISMISSED);
} else { } else {
this.hasSelection = true; this.hasSelection = true;
this.onDragSelectStart_(col, row); this.onDragSelectStart_(col, row);

View File

@ -18,11 +18,13 @@
this.lastMoveRow = null; this.lastMoveRow = null;
this.selection = null; this.selection = null;
this.hasSelection = false;
this.tooltipDescriptors = [ this.tooltipDescriptors = [
{description : 'Drag the selection to move it. You may switch to other layers and frames.'}, {description : 'Drag the selection to move it. You may switch to other layers and frames.'},
{key : 'ctrl+c', description : 'Copy the selected area'}, {key : 'ctrl+c', description : 'Copy the selected area'},
{key : 'ctrl+v', description : 'Paste the copied area'} {key : 'ctrl+v', description : 'Paste the copied area'},
{key : 'shift', description : 'Hold to move the content'}
]; ];
}; };
@ -48,6 +50,11 @@
this.onSelectStart_(col, row, frame, overlay); this.onSelectStart_(col, row, frame, overlay);
} else { } else {
this.mode = 'moveSelection'; this.mode = 'moveSelection';
if (event.shiftKey && !this.isMovingContent_) {
this.isMovingContent_ = true;
$.publish(Events.SELECTION_CUT);
this.drawSelectionOnOverlay_(overlay);
}
this.onSelectionMoveStart_(col, row, frame, overlay); this.onSelectionMoveStart_(col, row, frame, overlay);
} }
}; };
@ -91,6 +98,10 @@
this.bodyRoot.removeClass(this.secondaryToolId); this.bodyRoot.removeClass(this.secondaryToolId);
} }
} }
if (!this.hasSelection) {
pskl.tools.drawing.BaseTool.prototype.moveUnactiveToolAt.apply(this, arguments);
}
}; };
ns.BaseSelect.prototype.isInSelection = function (col, row) { ns.BaseSelect.prototype.isInSelection = function (col, row) {
@ -99,8 +110,19 @@
}); });
}; };
ns.BaseSelect.prototype.hideHighlightedPixel = function() { /**
// there is no highlighted pixel for selection tools, do nothing * Protected method, should be called when the selection is dismissed.
*/
ns.BaseSelect.prototype.commitSelection = function (overlay) {
if (this.isMovingContent_) {
$.publish(Events.SELECTION_PASTE);
this.isMovingContent_ = false;
}
// Clean previous selection:
$.publish(Events.SELECTION_DISMISSED);
overlay.clear();
this.hasSelection = false;
}; };
/** /**

View File

@ -22,16 +22,18 @@
* @override * @override
*/ */
ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) { ns.ShapeSelect.prototype.onSelectStart_ = function (col, row, frame, overlay) {
// Clean previous selection: if (this.hasSelection) {
$.publish(Events.SELECTION_DISMISSED); this.hasSelection = false;
overlay.clear(); this.commitSelection(overlay);
} else {
this.hasSelection = true;
// From the pixel clicked, get shape using an algorithm similar to the paintbucket one:
var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row);
this.selection = new pskl.selection.ShapeSelection(pixels);
// From the pixel cliked, get shape using an algorithm similar to the paintbucket one: $.publish(Events.SELECTION_CREATED, [this.selection]);
var pixels = pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(frame, col, row); this.drawSelectionOnOverlay_(overlay);
this.selection = new pskl.selection.ShapeSelection(pixels); }
$.publish(Events.SELECTION_CREATED, [this.selection]);
this.drawSelectionOnOverlay_(overlay);
}; };
})(); })();