Add a isMutator member similar to isFlyout to workspace_svg so it knows whether
it is mutator or not. Allow blocks to access that property so that they can recalculate
coordinates appropriately.
This commit is contained in:
Katelyn Mann 2016-08-11 16:09:22 -07:00
parent f6f39c48f5
commit 33e9d75457
4 changed files with 17 additions and 0 deletions

View file

@ -127,6 +127,9 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
this.workspace = workspace;
/** @type {boolean} */
this.isInFlyout = workspace.isFlyout;
/** @type {boolean} */
this.isInMutator = workspace.isMutator;
/** @type {boolean} */
this.RTL = workspace.RTL;

View file

@ -533,6 +533,12 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
if (this.isInFlyout) {
return;
}
if (this.isInMutator) {
// Mutator's coordinate system could be out of date because the bubble was
// dragged, the block was moved, the parent workspace zoomed, etc.
this.workspace.resize();
}
this.workspace.updateScreenCalculationsIfScrolled();
this.workspace.markFocused();
Blockly.terminateDrag_();

View file

@ -129,6 +129,7 @@ Blockly.Mutator.prototype.createEditor_ = function() {
setMetrics: null
};
this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions);
this.workspace_.isMutator = true;
this.svgDialog_.appendChild(
this.workspace_.createDom('blocklyMutatorBackground'));
return this.svgDialog_;

View file

@ -82,6 +82,13 @@ Blockly.WorkspaceSvg.prototype.rendered = true;
*/
Blockly.WorkspaceSvg.prototype.isFlyout = false;
/**
* Is this workspace the surface for a mutator?
* @type {boolean}
* @package
*/
Blockly.WorkspaceSvg.prototype.isMutator = false;
/**
* Is this workspace currently being dragged around?
* DRAG_NONE - No drag operation.