mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Issue #414: part4: UI to view/update layer opacity
This commit is contained in:
parent
a75e78e366
commit
186b5a305a
@ -46,6 +46,11 @@
|
||||
background : #222;
|
||||
}
|
||||
|
||||
.layer-item-opacity {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
}
|
||||
|
||||
.current-layer-item,
|
||||
.current-layer-item:hover {
|
||||
background : #333;
|
||||
|
@ -88,7 +88,8 @@
|
||||
var layerItemHtml = pskl.utils.Template.replace(this.layerItemTemplate_, {
|
||||
'layername' : layer.getName(),
|
||||
'layerindex' : index,
|
||||
'isselected:current-layer-item' : isSelected
|
||||
'isselected:current-layer-item' : isSelected,
|
||||
'opacity': layer.getOpacity()
|
||||
});
|
||||
var layerItem = pskl.utils.Template.createFromHTML(layerItemHtml);
|
||||
this.layersListEl.insertBefore(layerItem, this.layersListEl.firstChild);
|
||||
@ -102,6 +103,11 @@
|
||||
} else if (el.classList.contains('layer-item')) {
|
||||
index = el.dataset.layerIndex;
|
||||
this.piskelController.setCurrentLayerIndex(parseInt(index, 10));
|
||||
} else if (el.classList.contains('layer-item-opacity')) {
|
||||
index = pskl.utils.Dom.getData(el, 'layerIndex');
|
||||
var layer = this.piskelController.getLayerAt(parseInt(index, 10));
|
||||
var opacity = window.prompt('Set layer opacity (value between 0 and 1)', layer.getOpacity());
|
||||
this.piskelController.setLayerOpacityAt(index, opacity);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,13 @@
|
||||
<ul class="layers-list"></ul>
|
||||
|
||||
<script type="text/template" id="layer-item-template">
|
||||
<li class="layer-item {{isselected:current-layer-item}}" data-layer-index="{{layerindex}}">{{layername}}</li>
|
||||
<li class="layer-item {{isselected:current-layer-item}}"
|
||||
data-layer-index="{{layerindex}}">
|
||||
{{layername}}
|
||||
<span class="layer-item-opacity"
|
||||
title="Layer opacity" rel="tooltip" data-placement="top">
|
||||
{{opacity}}α
|
||||
</span>
|
||||
</li>
|
||||
</script>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user