Wrap dummy inputs in a measurable so that it can be aligned appropriately. (#3337)

This commit is contained in:
Sam El-Husseini
2019-10-24 21:42:44 -04:00
committed by GitHub
parent d387841db2
commit 7fc733b81f
3 changed files with 25 additions and 4 deletions

View File

@@ -374,8 +374,8 @@ Blockly.blockRendering.RenderInfo.prototype.addInput_ = function(input, activeRo
new Blockly.blockRendering.ExternalValueInput(this.constants_, input));
activeRow.hasExternalInput = true;
} else if (input.type == Blockly.DUMMY_INPUT) {
// Dummy inputs have no visual representation, but the information is still
// important.
activeRow.elements.push(
new Blockly.blockRendering.DummyInput(this.constants_, input));
activeRow.hasDummyInput = true;
}
};

View File

@@ -113,8 +113,8 @@ Blockly.geras.RenderInfo.prototype.addInput_ = function(input, activeRow) {
new Blockly.blockRendering.ExternalValueInput(this.constants_, input));
activeRow.hasExternalInput = true;
} else if (input.type == Blockly.DUMMY_INPUT) {
// Dummy inputs have no visual representation, but the information is still
// important.
activeRow.elements.push(
new Blockly.blockRendering.DummyInput(this.constants_, input));
activeRow.hasDummyInput = true;
}
};

View File

@@ -70,6 +70,27 @@ Blockly.blockRendering.InputConnection = function(constants, input) {
Blockly.utils.object.inherits(Blockly.blockRendering.InputConnection,
Blockly.blockRendering.Connection);
/**
* An object containing information about the space a dummy input takes up
* during rendering
* @param {!Blockly.blockRendering.ConstantProvider} constants The rendering
* constants provider.
* @param {!Blockly.Input} input The inline input to measure and store
* information for.
* @package
* @constructor
* @extends {Blockly.blockRendering.Measurable}
*/
Blockly.blockRendering.DummyInput = function(constants, input) {
Blockly.blockRendering.DummyInput.superClass_.constructor.call(this,
constants);
this.type |= Blockly.blockRendering.Types.INPUT;
this.input = input;
this.align = input.align;
};
Blockly.utils.object.inherits(Blockly.blockRendering.DummyInput,
Blockly.blockRendering.Measurable);
/**
* An object containing information about the space an inline input takes up
* during rendering