Simplify workspace construction.

This commit is contained in:
Neil Fraser
2015-03-06 15:27:41 -06:00
parent 0d6a3bf99f
commit bdc4795fb6
7 changed files with 44 additions and 38 deletions

View File

@@ -102,7 +102,7 @@ Blockly.WorkspaceSvg.prototype.scrollbar = null;
Blockly.WorkspaceSvg.prototype.createDom = function() {
/*
<g>
[Trashcan may go here]
[Trashcan and/or flyout may go here]
<g></g> // Block canvas
<g></g> // Bubble canvas
[Scrollbars may go here]
@@ -151,6 +151,16 @@ Blockly.WorkspaceSvg.prototype.addTrashcan = function() {
}
};
/**
* Add a flyout.
*/
Blockly.WorkspaceSvg.prototype.addFlyout = function() {
this.flyout_ = new Blockly.Flyout();
this.flyout_.autoClose = false;
var svgFlyout = this.flyout_.createDom();
this.svgGroup_.insertBefore(svgFlyout, this.svgBlockCanvas_);
};
/**
* Get the SVG element that forms the drawing surface.
* @return {!Element} SVG element.
@@ -167,6 +177,17 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
return this.svgBubbleCanvas_;
};
/**
* Translate this workspace to new coordinates.
* @param {number} x Horizontal translation.
* @param {number} y Vertical translation.
*/
Blockly.WorkspaceSvg.prototype.translate = function(x, y) {
var translation = 'translate(' + x + ',' + y + ')';
this.svgBlockCanvas_.setAttribute('transform', translation);
this.svgBubbleCanvas_.setAttribute('transform', translation);
};
/**
* Add a block to the list of top blocks.
* @param {!Blockly.Block} block Block to remove.