mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Merge pull request #2886 from rachel-fenichel/measurables_inputs
Move input measurables to their own file
This commit is contained in:
@@ -62,7 +62,7 @@ goog.addDependency("../../../" + dir + "/core/dropdowndiv.js", ['Blockly.DropDow
|
||||
goog.addDependency("../../../" + dir + "/core/events.js", ['Blockly.Events'], ['Blockly.utils']);
|
||||
goog.addDependency("../../../" + dir + "/core/events_abstract.js", ['Blockly.Events.Abstract'], ['Blockly.Events']);
|
||||
goog.addDependency("../../../" + dir + "/core/extensions.js", ['Blockly.Extensions'], ['Blockly.Mutator', 'Blockly.utils']);
|
||||
goog.addDependency("../../../" + dir + "/core/field.js", ['Blockly.Field'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Gesture', 'Blockly.utils.dom', 'Blockly.utils.Size', 'Blockly.utils.userAgent', 'Blockly.utils.style']);
|
||||
goog.addDependency("../../../" + dir + "/core/field.js", ['Blockly.Field'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Gesture', 'Blockly.utils', 'Blockly.utils.dom', 'Blockly.utils.Size', 'Blockly.utils.userAgent', 'Blockly.utils.style']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_angle.js", ['Blockly.FieldAngle'], ['Blockly.DropDownDiv', 'Blockly.fieldRegistry', 'Blockly.FieldTextInput', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.userAgent']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_checkbox.js", ['Blockly.FieldCheckbox'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.utils.dom', 'Blockly.utils.Size']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_colour.js", ['Blockly.FieldColour'], ['Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.IdGenerator', 'Blockly.utils.colour', 'Blockly.utils.Size']);
|
||||
@@ -72,7 +72,7 @@ goog.addDependency("../../../" + dir + "/core/field_image.js", ['Blockly.FieldIm
|
||||
goog.addDependency("../../../" + dir + "/core/field_label.js", ['Blockly.FieldLabel'], ['Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.dom', 'Blockly.utils.Size']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_label_serializable.js", ['Blockly.FieldLabelSerializable'], ['Blockly.FieldLabel', 'Blockly.fieldRegistry', 'Blockly.utils']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_number.js", ['Blockly.FieldNumber'], ['Blockly.fieldRegistry', 'Blockly.FieldTextInput']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_registry.js", ['Blockly.fieldRegistry'], ['Blockly.utils']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_registry.js", ['Blockly.fieldRegistry'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/field_textinput.js", ['Blockly.FieldTextInput'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.Msg', 'Blockly.utils', 'Blockly.utils.aria', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.Size', 'Blockly.utils.userAgent']);
|
||||
goog.addDependency("../../../" + dir + "/core/field_variable.js", ['Blockly.FieldVariable'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.FieldDropdown', 'Blockly.fieldRegistry', 'Blockly.Msg', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.Xml']);
|
||||
goog.addDependency("../../../" + dir + "/core/flyout_base.js", ['Blockly.Flyout'], ['Blockly.Block', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.VarCreate', 'Blockly.FlyoutButton', 'Blockly.Gesture', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.WorkspaceSvg', 'Blockly.Xml']);
|
||||
@@ -102,15 +102,16 @@ goog.addDependency("../../../" + dir + "/core/rendered_connection.js", ['Blockly
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw.js", ['Blockly.blockRendering.Drawer'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Debug', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Highlighter', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw_debug.js", ['Blockly.blockRendering.Debug'], ['Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Highlighter', 'Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js", ['Blockly.blockRendering.Highlighter'], ['Blockly.blockRendering.highlightConstants', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_info.js", ['Blockly.blockRendering.RenderInfo'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_info.js", ['Blockly.blockRendering.RenderInfo'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering.js", ['Blockly.blockRendering'], ['Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.RenderInfo']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering_constants.js", ['Blockly.blockRendering.constants'], ['Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/highlight_constants.js", ['Blockly.blockRendering.highlightConstants'], ['Blockly.blockRendering.constants', 'Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/measurables.js", ['Blockly.blockRendering.Input', 'Blockly.blockRendering.InRowSpacer'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/measurables.js", ['Blockly.blockRendering.InRowSpacer'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/shape_map.js", ['Blockly.blockRendering.connectionShapes'], ['Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/base.js", ['Blockly.blockRendering.Measurable'], ['Blockly.blockRendering.constants']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/connections.js", ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.constants', 'Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/rows.js", ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Input', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/inputs.js", ['Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.ExternalValueInput'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.constants']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/rows.js", ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.RenderedConnection']);
|
||||
goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../../" + dir + "/core/theme.js", ['Blockly.Theme'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/theme/classic.js", ['Blockly.Themes.Classic'], ['Blockly.Theme']);
|
||||
@@ -1905,9 +1906,11 @@ goog.require('Blockly.blockRendering.BottomRow');
|
||||
goog.require('Blockly.blockRendering.Connection');
|
||||
goog.require('Blockly.blockRendering.Debug');
|
||||
goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.blockRendering.ExternalValueInput');
|
||||
goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.InRowSpacer');
|
||||
goog.require('Blockly.blockRendering.Input');
|
||||
goog.require('Blockly.blockRendering.InlineInput');
|
||||
goog.require('Blockly.blockRendering.InputConnection');
|
||||
goog.require('Blockly.blockRendering.InputRow');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.NextConnection');
|
||||
@@ -1916,6 +1919,7 @@ goog.require('Blockly.blockRendering.PreviousConnection');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.SpacerRow');
|
||||
goog.require('Blockly.blockRendering.StatementInput');
|
||||
goog.require('Blockly.blockRendering.TopRow');
|
||||
goog.require('Blockly.blockRendering.connectionShapes');
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
|
||||
@@ -34,6 +34,10 @@ goog.require('Blockly.blockRendering.Row');
|
||||
goog.require('Blockly.blockRendering.SpacerRow');
|
||||
goog.require('Blockly.blockRendering.TopRow');
|
||||
|
||||
goog.require('Blockly.blockRendering.InlineInput');
|
||||
goog.require('Blockly.blockRendering.ExternalValueInput');
|
||||
goog.require('Blockly.blockRendering.StatementInput');
|
||||
|
||||
goog.require('Blockly.blockRendering.PreviousConnection');
|
||||
goog.require('Blockly.blockRendering.NextConnection');
|
||||
goog.require('Blockly.blockRendering.OutputConnection');
|
||||
|
||||
@@ -1,44 +1,9 @@
|
||||
|
||||
goog.provide('Blockly.blockRendering.Input');
|
||||
goog.provide('Blockly.blockRendering.InRowSpacer');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
|
||||
|
||||
/**
|
||||
* The base class to represent an input that takes up space on a block
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The input to measure and store information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Measurable}
|
||||
*/
|
||||
Blockly.blockRendering.Input = function(input) {
|
||||
Blockly.blockRendering.Input.superClass_.constructor.call(this);
|
||||
|
||||
this.isInput = true;
|
||||
this.input = input;
|
||||
this.align = input.align;
|
||||
this.connectedBlock = input.connection && input.connection.targetBlock() ?
|
||||
input.connection.targetBlock() : null;
|
||||
|
||||
if (this.connectedBlock) {
|
||||
var bBox = this.connectedBlock.getHeightWidth();
|
||||
this.connectedBlockWidth = bBox.width;
|
||||
this.connectedBlockHeight = bBox.height;
|
||||
} else {
|
||||
this.connectedBlockWidth = 0;
|
||||
this.connectedBlockHeight = 0;
|
||||
}
|
||||
|
||||
this.connection = input.connection;
|
||||
this.connectionOffsetX = 0;
|
||||
this.connectionOffsetY = 0;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.Input, Blockly.blockRendering.Measurable);
|
||||
|
||||
|
||||
/**
|
||||
* An object containing information about the space an icon takes up during
|
||||
* rendering
|
||||
@@ -98,93 +63,6 @@ Blockly.blockRendering.Field = function(field, parentInput) {
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.Field, Blockly.blockRendering.Measurable);
|
||||
|
||||
/**
|
||||
* An object containing information about the space an inline input takes up
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The inline input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Input}
|
||||
*/
|
||||
Blockly.blockRendering.InlineInput = function(input) {
|
||||
Blockly.blockRendering.InlineInput.superClass_.constructor.call(this, input);
|
||||
this.type = 'inline input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT;
|
||||
this.width = this.connectionShape.width +
|
||||
Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_PADDING;
|
||||
} else {
|
||||
// We allow the dark path to show on the parent block so that the child
|
||||
// block looks embossed. This takes up an extra pixel in both x and y.
|
||||
this.width = this.connectedBlockWidth +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
this.height = this.connectedBlockHeight + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
}
|
||||
|
||||
this.connectionOffsetY = Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
this.connectionHeight = this.connectionShape.height;
|
||||
this.connectionWidth = this.connectionShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.InlineInput, Blockly.blockRendering.Input);
|
||||
|
||||
/**
|
||||
* An object containing information about the space a statement input takes up
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The statement input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Input}
|
||||
*/
|
||||
Blockly.blockRendering.StatementInput = function(input) {
|
||||
Blockly.blockRendering.StatementInput.superClass_.constructor.call(this, input);
|
||||
this.type = 'statement input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT;
|
||||
} else {
|
||||
this.height =
|
||||
this.connectedBlockHeight + Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER;
|
||||
if (this.connectedBlock.nextConnection) {
|
||||
this.height -= this.notchShape.height;
|
||||
}
|
||||
}
|
||||
this.width = this.notchOffset + this.notchShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.StatementInput,
|
||||
Blockly.blockRendering.Input);
|
||||
|
||||
/**
|
||||
* An object containing information about the space an external value input
|
||||
* takes up during rendering
|
||||
* @param {!Blockly.Input} input The external value input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Input}
|
||||
*/
|
||||
Blockly.blockRendering.ExternalValueInput = function(input) {
|
||||
Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this, input);
|
||||
this.type = 'external value input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = this.connectionShape.height;
|
||||
} else {
|
||||
this.height =
|
||||
this.connectedBlockHeight - 2 * Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
}
|
||||
this.width = this.connectionShape.width +
|
||||
Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_PADDING;
|
||||
|
||||
this.connectionOffsetY = Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
this.connectionHeight = this.connectionShape.height;
|
||||
this.connectionWidth = this.connectionShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.ExternalValueInput,
|
||||
Blockly.blockRendering.Input);
|
||||
|
||||
/**
|
||||
* An object containing information about the space a hat takes up during
|
||||
* rendering.
|
||||
|
||||
162
core/renderers/measurables/inputs.js
Normal file
162
core/renderers/measurables/inputs.js
Normal file
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Objects representing inputs with connections on a rendered
|
||||
* block.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
goog.provide('Blockly.blockRendering.InputConnection');
|
||||
goog.provide('Blockly.blockRendering.InlineInput');
|
||||
goog.provide('Blockly.blockRendering.StatementInput');
|
||||
goog.provide('Blockly.blockRendering.ExternalValueInput');
|
||||
|
||||
goog.require('Blockly.blockRendering.Connection');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
|
||||
|
||||
/**
|
||||
* The base class to represent an input that takes up space on a block
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The input to measure and store information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Connection}
|
||||
*/
|
||||
Blockly.blockRendering.InputConnection = function(input) {
|
||||
Blockly.blockRendering.InputConnection.superClass_.constructor.call(this,
|
||||
input.connection);
|
||||
|
||||
this.isInput = true;
|
||||
this.input = input;
|
||||
this.align = input.align;
|
||||
this.connectedBlock = input.connection && input.connection.targetBlock() ?
|
||||
input.connection.targetBlock() : null;
|
||||
|
||||
if (this.connectedBlock) {
|
||||
var bBox = this.connectedBlock.getHeightWidth();
|
||||
this.connectedBlockWidth = bBox.width;
|
||||
this.connectedBlockHeight = bBox.height;
|
||||
} else {
|
||||
this.connectedBlockWidth = 0;
|
||||
this.connectedBlockHeight = 0;
|
||||
}
|
||||
|
||||
// TODO: change references to connectionModel, since that's on Connection.
|
||||
this.connection = input.connection;
|
||||
this.connectionOffsetX = 0;
|
||||
this.connectionOffsetY = 0;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.InputConnection,
|
||||
Blockly.blockRendering.Connection);
|
||||
|
||||
/**
|
||||
* An object containing information about the space an inline input takes up
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The inline input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.InputConnection}
|
||||
*/
|
||||
Blockly.blockRendering.InlineInput = function(input) {
|
||||
Blockly.blockRendering.InlineInput.superClass_.constructor.call(this,
|
||||
input);
|
||||
this.type = 'inline input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT;
|
||||
this.width = this.connectionShape.width +
|
||||
Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_PADDING;
|
||||
} else {
|
||||
// We allow the dark path to show on the parent block so that the child
|
||||
// block looks embossed. This takes up an extra pixel in both x and y.
|
||||
this.width = this.connectedBlockWidth +
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
this.height = this.connectedBlockHeight + Blockly.blockRendering.constants.DARK_PATH_OFFSET;
|
||||
}
|
||||
|
||||
this.connectionOffsetY = Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
this.connectionHeight = this.connectionShape.height;
|
||||
this.connectionWidth = this.connectionShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.InlineInput,
|
||||
Blockly.blockRendering.InputConnection);
|
||||
|
||||
/**
|
||||
* An object containing information about the space a statement input takes up
|
||||
* during rendering
|
||||
* @param {!Blockly.Input} input The statement input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.InputConnection}
|
||||
*/
|
||||
Blockly.blockRendering.StatementInput = function(input) {
|
||||
Blockly.blockRendering.StatementInput.superClass_.constructor.call(this,
|
||||
input);
|
||||
this.type = 'statement input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT;
|
||||
} else {
|
||||
this.height =
|
||||
this.connectedBlockHeight + Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER;
|
||||
if (this.connectedBlock.nextConnection) {
|
||||
this.height -= this.notchShape.height;
|
||||
}
|
||||
}
|
||||
this.width = Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT +
|
||||
this.notchShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.StatementInput,
|
||||
Blockly.blockRendering.InputConnection);
|
||||
|
||||
/**
|
||||
* An object containing information about the space an external value input
|
||||
* takes up during rendering
|
||||
* @param {!Blockly.Input} input The external value input to measure and store
|
||||
* information for.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.InputConnection}
|
||||
*/
|
||||
Blockly.blockRendering.ExternalValueInput = function(input) {
|
||||
Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this,
|
||||
input);
|
||||
this.type = 'external value input';
|
||||
|
||||
if (!this.connectedBlock) {
|
||||
this.height = this.connectionShape.height;
|
||||
} else {
|
||||
this.height =
|
||||
this.connectedBlockHeight - 2 * Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
}
|
||||
this.width = this.connectionShape.width +
|
||||
Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_PADDING;
|
||||
|
||||
this.connectionOffsetY = Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;
|
||||
this.connectionHeight = this.connectionShape.height;
|
||||
this.connectionWidth = this.connectionShape.width;
|
||||
};
|
||||
goog.inherits(Blockly.blockRendering.ExternalValueInput,
|
||||
Blockly.blockRendering.InputConnection);
|
||||
@@ -31,7 +31,7 @@ goog.provide('Blockly.blockRendering.SpacerRow');
|
||||
goog.provide('Blockly.blockRendering.TopRow');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.blockRendering.Input');
|
||||
goog.require('Blockly.blockRendering.InputConnection');
|
||||
goog.require('Blockly.blockRendering.InRowSpacer');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.NextConnection');
|
||||
@@ -174,7 +174,8 @@ Blockly.blockRendering.Row.prototype.measure = function() {
|
||||
/**
|
||||
* Get the last input on this row, if it has one.
|
||||
* TODO: Consider moving this to InputRow, if possible.
|
||||
* @return {Blockly.blockRendering.Input} The last input on the row, or null.
|
||||
* @return {Blockly.blockRendering.InputConnection} The last input on the row,
|
||||
* or null.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Row.prototype.getLastInput = function() {
|
||||
@@ -183,9 +184,9 @@ Blockly.blockRendering.Row.prototype.getLastInput = function() {
|
||||
continue;
|
||||
}
|
||||
if (elem.isInput) {
|
||||
return /** @type {Blockly.blockRendering.Input} */ (elem);
|
||||
return /** @type {Blockly.blockRendering.InputConnection} */ (elem);
|
||||
} else if (elem.isField()) {
|
||||
return /** @type {Blockly.blockRendering.Input} */ (elem.parentInput);
|
||||
return /** @type {Blockly.blockRendering.InputConnection} */ (elem.parentInput);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user