Implement shade().

This commit is contained in:
Michael Jumper
2014-01-15 16:03:09 -08:00
parent ad5ab18605
commit 773f64762a

View File

@@ -954,13 +954,8 @@ Guacamole.Client = function(tunnel) {
// Only valid for visible layers (not buffers) // Only valid for visible layers (not buffers)
if (layer_index >= 0) { if (layer_index >= 0) {
var layer_container = getLayerContainer(layer_index);
// Get container element layer_container.shade(a);
var layer_container = getLayerContainer(layer_index).getElement();
// Set layer opacity
layer_container.style.opacity = a/255.0;
} }
}, },
@@ -1315,18 +1310,22 @@ Guacamole.Client = function(tunnel) {
// Draw all immediate children // Draw all immediate children
for (index in layers) { for (index in layers) {
var layer = layers[index]; layer = layers[index];
var context = canvas.getContext("2d");
context.globalAlpha = layer.alpha / 255.0;
context.drawImage(layer.getLayer().getCanvas(), context.drawImage(layer.getLayer().getCanvas(),
layer.x + x, layer.y + y); layer.x + x, layer.y + y);
} }
// Draw all children of children // Draw all children of children
for (layer in layers) { for (layer in layers) {
var layer = layers[index]; layer = layers[index];
draw_all(layer.children, layer.x + x, layer.y + y); draw_all(layer.children, layer.x + x, layer.y + y);
} }
// Restore alpha
context.globalAlpha = 1;
} }
// Draw all immediate children // Draw all immediate children
@@ -1368,6 +1367,12 @@ Guacamole.Client.LayerContainer = function(index, width, height) {
*/ */
this.index = index; this.index = index;
/**
* The opacity of the layer container, where 255 is fully opaque and 0 is
* fully transparent.
*/
this.alpha = 0xFF;
/** /**
* X coordinate of the upper-left corner of this layer container within * X coordinate of the upper-left corner of this layer container within
* its parent, in pixels. * its parent, in pixels.
@@ -1518,8 +1523,6 @@ Guacamole.Client.LayerContainer = function(index, width, height) {
*/ */
this.move = function(parent, x, y, z) { this.move = function(parent, x, y, z) {
var layer_container_element = layer_container.getElement();
// Set parent if necessary // Set parent if necessary
if (layer_container.parent !== parent) { if (layer_container.parent !== parent) {
@@ -1531,17 +1534,28 @@ Guacamole.Client.LayerContainer = function(index, width, height) {
// Reparent element // Reparent element
var parent_element = parent.getElement(); var parent_element = parent.getElement();
parent_element.appendChild(layer_container_element); parent_element.appendChild(div);
} }
// Set location // Set location
layer_container.translate(x, y); layer_container.translate(x, y);
layer_container.z = z; layer_container.z = z;
layer_container_element.style.zIndex = z; div.style.zIndex = z;
}; };
/**
* Sets the opacity of this layer to the given value, where 255 is fully
* opaque and 0 is fully transparent.
*
* @param {Number} a The opacity to set.
*/
this.shade = function(a) {
layer_container.alpha = a;
div.style.opacity = a/255.0;
};
/** /**
* Applies the given affine transform (defined with six values from the * Applies the given affine transform (defined with six values from the
* transform's matrix). * transform's matrix).