Add zooming feature.

By carloslfu.
This commit is contained in:
Neil Fraser
2015-08-19 17:21:05 -07:00
parent 0478d308a6
commit 5b7fec7092
26 changed files with 919 additions and 322 deletions

View File

@@ -98,7 +98,7 @@ Blockly.Field.prototype.init = function(block) {
'ry': 4,
'x': -Blockly.BlockSvg.SEP_SPACE_X / 2,
'y': -12,
'height': 16}, this.fieldGroup_);
'height': 16}, this.fieldGroup_, this.sourceBlock_.workspace);
this.textElement_ = Blockly.createSvgElement('text',
{'class': 'blocklyText'}, this.fieldGroup_);
@@ -224,6 +224,18 @@ Blockly.Field.prototype.getSize = function() {
return this.size_;
};
/**
* Returns the height and width of the field,
* accounting for the workspace scaling.
* @return {!Object} Height and width.
*/
Blockly.Field.prototype.getScaledBBox_ = function() {
var bBox = this.borderRect_.getBBox();
bBox.width *= this.sourceBlock_.workspace.scale;
bBox.height *= this.sourceBlock_.workspace.scale;
return bBox;
};
/**
* Get the text from this field.
* @return {string} Current text.