mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #220 from juliandescottes/enhancement-layers-options
Enhancement layers options
This commit is contained in:
commit
f7f9587520
@ -36,7 +36,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
'travis' : {
|
||||
suite : './test/casperjs/TravisTestSuite.js',
|
||||
delay : 5000
|
||||
delay : 10000
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7,4 +7,8 @@
|
||||
|
||||
.action-icon.edit-icon {
|
||||
background-image: url('../img/tools/pen.png');
|
||||
}
|
||||
|
||||
.action-icon.merge-icon {
|
||||
background-image: url('../img/merge-icon.png');
|
||||
}
|
@ -46,22 +46,34 @@
|
||||
cursor : pointer;
|
||||
}
|
||||
|
||||
.layer-item .edit-icon {
|
||||
.layer-item .edit-icon, .layer-item .merge-icon {
|
||||
float: right;
|
||||
width: 30px;
|
||||
background-size: 12px;
|
||||
opacity: 0;
|
||||
transition : opacity 0.2s;
|
||||
}
|
||||
|
||||
.layer-item:hover .edit-icon {
|
||||
.layer-item:hover .edit-icon, .layer-item:hover .merge-icon {
|
||||
opacity : 0.6;
|
||||
}
|
||||
|
||||
.layer-item:hover .edit-icon:hover {
|
||||
.layer-item:hover .edit-icon:hover, .layer-item:hover .merge-icon:hover {
|
||||
opacity : 1;
|
||||
}
|
||||
|
||||
.layer-item .edit-icon {
|
||||
width: 25px;
|
||||
background-size: 12px;
|
||||
}
|
||||
|
||||
.layer-item .merge-icon {
|
||||
width: 18px;
|
||||
background-size: 16px;
|
||||
}
|
||||
|
||||
.layer-item:last-child .merge-icon {
|
||||
display : none;
|
||||
}
|
||||
|
||||
.layer-item:hover {
|
||||
background : #222;
|
||||
}
|
||||
|
BIN
src/img/merge-icon.png
Normal file
BIN
src/img/merge-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 438 B |
@ -67,6 +67,9 @@
|
||||
} else if (el.classList.contains('edit-icon')) {
|
||||
index = el.parentNode.dataset.layerIndex;
|
||||
this.renameLayerAt_(index);
|
||||
} else if (el.classList.contains('merge-icon')) {
|
||||
index = el.parentNode.dataset.layerIndex;
|
||||
this.mergeDownLayerAt_(index);
|
||||
}
|
||||
};
|
||||
|
||||
@ -79,6 +82,11 @@
|
||||
}
|
||||
};
|
||||
|
||||
ns.LayersListController.prototype.mergeDownLayerAt_ = function (index) {
|
||||
this.piskelController.mergeDownLayerAt(index);
|
||||
this.renderLayerList_();
|
||||
};
|
||||
|
||||
ns.LayersListController.prototype.onButtonClick_ = function (button) {
|
||||
var action = button.getAttribute('data-action');
|
||||
if (action == 'up') {
|
||||
|
@ -205,6 +205,18 @@
|
||||
}
|
||||
};
|
||||
|
||||
ns.PiskelController.prototype.mergeDownLayerAt = function (index) {
|
||||
var layer = this.getLayerByIndex(index);
|
||||
var downLayer = this.getLayerByIndex(index-1);
|
||||
if (layer && downLayer) {
|
||||
var mergedLayer = pskl.utils.LayerUtils.mergeLayers(layer, downLayer);
|
||||
this.removeLayerAt(index);
|
||||
this.piskel.addLayerAt(mergedLayer, index);
|
||||
this.removeLayerAt(index-1);
|
||||
this.selectLayer(mergedLayer);
|
||||
}
|
||||
};
|
||||
|
||||
ns.PiskelController.prototype.generateLayerName_ = function () {
|
||||
var name = "Layer " + this.layerIdCounter;
|
||||
while (this.hasLayerForName_(name)) {
|
||||
|
@ -99,6 +99,12 @@
|
||||
$.publish(Events.PISKEL_RESET);
|
||||
};
|
||||
|
||||
ns.PublicPiskelController.prototype.mergeDownLayerAt = function (index) {
|
||||
this.raiseSaveStateEvent_(this.piskelController.mergeDownLayerAt, [index]);
|
||||
this.piskelController.mergeDownLayerAt(index);
|
||||
$.publish(Events.PISKEL_RESET);
|
||||
};
|
||||
|
||||
ns.PublicPiskelController.prototype.moveLayerUp = function () {
|
||||
this.raiseSaveStateEvent_(this.piskelController.moveLayerUp, []);
|
||||
this.piskelController.moveLayerUp();
|
||||
|
@ -101,6 +101,10 @@
|
||||
var screenCoordinates = pskl.app.drawingController.getScreenCoordinates(recordEvent.coords.x, recordEvent.coords.y);
|
||||
event.clientX = screenCoordinates.x;
|
||||
event.clientY = screenCoordinates.y;
|
||||
if (pskl.utils.UserAgent.isMac && event.ctrlKey) {
|
||||
event.metaKey = true;
|
||||
}
|
||||
|
||||
if (event.type == 'mousedown') {
|
||||
pskl.app.drawingController.onMousedown_(event);
|
||||
} else if (event.type == 'mouseup') {
|
||||
|
@ -73,6 +73,10 @@
|
||||
this.layers.push(layer);
|
||||
};
|
||||
|
||||
ns.Piskel.prototype.addLayerAt = function (layer, index) {
|
||||
this.layers.splice(index, 0, layer);
|
||||
};
|
||||
|
||||
ns.Piskel.prototype.moveLayerUp = function (layer) {
|
||||
var index = this.layers.indexOf(layer);
|
||||
if (index > -1 && index < this.layers.length-1) {
|
||||
|
@ -25,6 +25,18 @@
|
||||
frames.push(frame);
|
||||
}
|
||||
return frames;
|
||||
},
|
||||
|
||||
mergeLayers : function (layerA, layerB) {
|
||||
var framesA = layerA.getFrames();
|
||||
var framesB = layerB.getFrames();
|
||||
var mergedFrames = [];
|
||||
framesA.forEach(function (frame, index) {
|
||||
var otherFrame = framesB[index];
|
||||
mergedFrames.push(pskl.utils.FrameUtils.merge([otherFrame, frame]));
|
||||
});
|
||||
var mergedLayer = pskl.model.Layer.fromFrames(layerA.getName(), mergedFrames);
|
||||
return mergedLayer;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
</div>
|
||||
<script type="text/template" id="layer-item-template">
|
||||
<li class="layer-item {{isselected:current-layer-item}}" data-layer-index="{{layerindex}}">{{layername}}
|
||||
<span class="action-icon edit-icon" title="edit name"> </span>
|
||||
<span class="action-icon edit-icon" title="Edit layer name" rel="tooltip" data-placement="top"> </span>
|
||||
<span class="action-icon merge-icon" title="Merge with layer below" rel="tooltip" data-placement="top"> </span>
|
||||
</li>
|
||||
</script>
|
||||
<ul class="layers-list"></ul>
|
||||
|
@ -4,6 +4,7 @@
|
||||
"color.picker.json",
|
||||
"frames.fun.json",
|
||||
"layers.fun.json",
|
||||
"layers.merge.json",
|
||||
"lighten.darken.json",
|
||||
"move.json",
|
||||
"pen.secondary.color.json",
|
||||
|
@ -3,6 +3,7 @@
|
||||
"color.picker.json",
|
||||
"frames.fun.json",
|
||||
"layers.fun.json",
|
||||
"layers.merge.json",
|
||||
"move.json",
|
||||
"pen.secondary.color.json",
|
||||
"squares.circles.json",
|
||||
|
1
test/drawing/tests/layers.merge.json
Normal file
1
test/drawing/tests/layers.merge.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user