mirror of
https://github.com/google/blockly.git
synced 2026-01-14 04:17:10 +01:00
Fix path_object inheritance (#3403)
* Fix path_object inheritance, add zelos path_object
This commit is contained in:
@@ -35,7 +35,6 @@ goog.addDependency("../../core/comment.js", ['Blockly.Comment'], ['Blockly.Bubbl
|
||||
goog.addDependency("../../core/components/component.js", ['Blockly.Component', 'Blockly.Component.Error'], ['Blockly.utils.dom', 'Blockly.utils.IdGenerator', 'Blockly.utils.style']);
|
||||
goog.addDependency("../../core/components/menu/menu.js", ['Blockly.Menu'], ['Blockly.Component', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/components/menu/menuitem.js", ['Blockly.MenuItem'], ['Blockly.Component', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/components/slider/slider.js", ['Blockly.Slider'], ['Blockly.Component', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/components/tree/basenode.js", ['Blockly.tree.BaseNode'], ['Blockly.Component', 'Blockly.utils.aria', 'Blockly.utils.object', 'Blockly.utils.KeyCodes', 'Blockly.utils.style']);
|
||||
goog.addDependency("../../core/components/tree/treecontrol.js", ['Blockly.tree.TreeControl'], ['Blockly.tree.TreeNode', 'Blockly.tree.BaseNode', 'Blockly.utils.aria', 'Blockly.utils.object', 'Blockly.utils.style']);
|
||||
goog.addDependency("../../core/components/tree/treenode.js", ['Blockly.tree.TreeNode'], ['Blockly.tree.BaseNode', 'Blockly.utils.object', 'Blockly.utils.KeyCodes']);
|
||||
@@ -103,7 +102,7 @@ goog.addDependency("../../core/renderers/geras/highlight_constants.js", ['Blockl
|
||||
goog.addDependency("../../core/renderers/geras/highlighter.js", ['Blockly.geras.Highlighter'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../core/renderers/geras/info.js", ['Blockly.geras', 'Blockly.geras.RenderInfo'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.Types', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.geras.InlineInput', 'Blockly.geras.StatementInput', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/geras/measurables/inputs.js", ['Blockly.geras.InlineInput', 'Blockly.geras.StatementInput'], ['Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/geras/path_object.js", ['Blockly.geras.PathObject'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.IPathObject', 'Blockly.geras.ConstantProvider', 'Blockly.Theme', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/geras/path_object.js", ['Blockly.geras.PathObject'], ['Blockly.blockRendering.PathObject', 'Blockly.geras.ConstantProvider', 'Blockly.Theme', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/geras/renderer.js", ['Blockly.geras.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.geras.ConstantProvider', 'Blockly.geras.Drawer', 'Blockly.geras.HighlightConstantProvider', 'Blockly.geras.PathObject', 'Blockly.geras.RenderInfo', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/measurables/base.js", ['Blockly.blockRendering.Measurable'], ['Blockly.blockRendering.Types']);
|
||||
goog.addDependency("../../core/renderers/measurables/connections.js", ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object']);
|
||||
@@ -121,8 +120,9 @@ goog.addDependency("../../core/renderers/zelos/constants.js", ['Blockly.zelos.Co
|
||||
goog.addDependency("../../core/renderers/zelos/drawer.js", ['Blockly.zelos.Drawer'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.Types', 'Blockly.utils.object', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency("../../core/renderers/zelos/info.js", ['Blockly.zelos', 'Blockly.zelos.RenderInfo'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SquareCorner', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.utils.object', 'Blockly.zelos.AfterStatementSpacerRow', 'Blockly.zelos.BeforeStatementSpacerRow', 'Blockly.zelos.BottomRow', 'Blockly.zelos.TopRow']);
|
||||
goog.addDependency("../../core/renderers/zelos/measurables/rows.js", ['Blockly.zelos.BottomRow', 'Blockly.zelos.TopRow', 'Blockly.zelos.AfterStatementSpacerRow', 'Blockly.zelos.BeforeStatementSpacerRow'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.SpacerRow', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/zelos/renderer.js", ['Blockly.zelos.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider', 'Blockly.zelos.Drawer', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency("../../core/requires.js", ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.HorizontalFlyout', 'Blockly.VerticalFlyout', 'Blockly.FlyoutButton', 'Blockly.Generator', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.ZoomControls', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldLabelSerializable', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldMultilineInput', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.geras.Renderer', 'Blockly.Themes.Classic', 'Blockly.Themes.Dark', 'Blockly.Themes.Deuteranopia', 'Blockly.Themes.HighContrast', 'Blockly.Themes.Tritanopia']);
|
||||
goog.addDependency("../../core/renderers/zelos/path_object.js", ['Blockly.zelos.PathObject'], ['Blockly.blockRendering.PathObject', 'Blockly.zelos.ConstantProvider', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/renderers/zelos/renderer.js", ['Blockly.zelos.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider', 'Blockly.zelos.Drawer', 'Blockly.zelos.PathObject', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency("../../core/requires.js", ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.HorizontalFlyout', 'Blockly.VerticalFlyout', 'Blockly.FlyoutButton', 'Blockly.Generator', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.ZoomControls', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldLabelSerializable', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldMultilineInput', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.geras.Renderer', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer', 'Blockly.Themes.Classic', 'Blockly.Themes.Dark', 'Blockly.Themes.Deuteranopia', 'Blockly.Themes.HighContrast', 'Blockly.Themes.Tritanopia']);
|
||||
goog.addDependency("../../core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../core/theme.js", ['Blockly.Theme'], ['Blockly.utils', 'Blockly.utils.colour']);
|
||||
goog.addDependency("../../core/theme/classic.js", ['Blockly.Themes.Classic'], ['Blockly.Theme']);
|
||||
@@ -163,7 +163,7 @@ goog.addDependency("../../core/variables.js", ['Blockly.Variables'], ['Blockly.B
|
||||
goog.addDependency("../../core/variables_dynamic.js", ['Blockly.VariablesDynamic'], ['Blockly.Variables', 'Blockly.Blocks', 'Blockly.Msg', 'Blockly.utils.xml', 'Blockly.VariableModel']);
|
||||
goog.addDependency("../../core/warning.js", ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.Ui', 'Blockly.Icon', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/widgetdiv.js", ['Blockly.WidgetDiv'], ['Blockly.utils.style']);
|
||||
goog.addDependency("../../core/workspace.js", ['Blockly.Workspace'], ['Blockly.Cursor', 'Blockly.MarkerCursor', 'Blockly.Events', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.utils', 'Blockly.utils.math', 'Blockly.VariableMap']);
|
||||
goog.addDependency("../../core/workspace.js", ['Blockly.Workspace'], ['Blockly.Cursor', 'Blockly.MarkerCursor', 'Blockly.Events', 'Blockly.utils', 'Blockly.utils.math', 'Blockly.VariableMap']);
|
||||
goog.addDependency("../../core/workspace_audio.js", ['Blockly.WorkspaceAudio'], ['Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.userAgent']);
|
||||
goog.addDependency("../../core/workspace_comment.js", ['Blockly.WorkspaceComment'], ['Blockly.Events', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.xml']);
|
||||
goog.addDependency("../../core/workspace_comment_render_svg.js", ['Blockly.WorkspaceCommentSvg.render'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
@@ -171,7 +171,7 @@ goog.addDependency("../../core/workspace_comment_svg.js", ['Blockly.WorkspaceCom
|
||||
goog.addDependency("../../core/workspace_drag_surface_svg.js", ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../core/workspace_dragger.js", ['Blockly.WorkspaceDragger'], ['Blockly.utils.Coordinate']);
|
||||
goog.addDependency("../../core/workspace_events.js", ['Blockly.Events.FinishedLoading'], ['Blockly.Events', 'Blockly.Events.Ui', 'Blockly.utils.object']);
|
||||
goog.addDependency("../../core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.blockRendering', 'Blockly.ConnectionDB', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.TouchGesture', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.Rect', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml']);
|
||||
goog.addDependency("../../core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.blockRendering', 'Blockly.ConnectionDB', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.TouchGesture', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.Rect', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml']);
|
||||
goog.addDependency("../../core/ws_comment_events.js", ['Blockly.Events.CommentBase', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.Coordinate', 'Blockly.utils.object', 'Blockly.utils.xml']);
|
||||
goog.addDependency("../../core/xml.js", ['Blockly.Xml'], ['Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.VarCreate', 'Blockly.utils', 'Blockly.utils.dom', 'Blockly.utils.global', 'Blockly.utils.xml']);
|
||||
goog.addDependency("../../core/zoom_controls.js", ['Blockly.ZoomControls'], ['Blockly.Css', 'Blockly.Scrollbar', 'Blockly.Touch', 'Blockly.utils.dom']);
|
||||
|
||||
@@ -72,7 +72,7 @@ Blockly.blockRendering.Drawer.prototype.draw = function() {
|
||||
this.drawOutline_();
|
||||
this.drawInternals_();
|
||||
|
||||
this.block_.pathObject.setPaths(this.outlinePath_ + '\n' + this.inlinePath_);
|
||||
this.block_.pathObject.setPath(this.outlinePath_ + '\n' + this.inlinePath_);
|
||||
if (this.info_.RTL) {
|
||||
this.block_.pathObject.flipRTL();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,13 @@ goog.requireType('Blockly.Theme');
|
||||
*/
|
||||
Blockly.blockRendering.IPathObject = function(_root, _constants) {};
|
||||
|
||||
/**
|
||||
* Set the path generated by the renderer onto the respective SVG element.
|
||||
* @param {string} pathString The path.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.IPathObject.prototype.setPath;
|
||||
|
||||
/**
|
||||
* Apply the stored colours to the block's path, taking into account whether
|
||||
* the paths belong to a shadow block.
|
||||
|
||||
@@ -46,6 +46,7 @@ Blockly.blockRendering.PathObject = function(root, constants) {
|
||||
* @type {!Blockly.blockRendering.ConstantProvider}
|
||||
*/
|
||||
this.constants_ = constants;
|
||||
|
||||
this.svgRoot = root;
|
||||
|
||||
/**
|
||||
@@ -81,7 +82,7 @@ Blockly.blockRendering.PathObject = function(root, constants) {
|
||||
* @param {string} pathString The path.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.PathObject.prototype.setPaths = function(pathString) {
|
||||
Blockly.blockRendering.PathObject.prototype.setPath = function(pathString) {
|
||||
this.svgPath.setAttribute('d', pathString);
|
||||
this.svgPathLight.style.display = 'none';
|
||||
};
|
||||
|
||||
@@ -57,10 +57,12 @@ Blockly.geras.Drawer.prototype.draw = function() {
|
||||
this.drawOutline_();
|
||||
this.drawInternals_();
|
||||
|
||||
this.block_.pathObject.setPaths(this.outlinePath_ + '\n' + this.inlinePath_,
|
||||
this.highlighter_.getPath());
|
||||
var pathObject =
|
||||
/** @type {!Blockly.geras.PathObject} */ (this.block_.pathObject);
|
||||
pathObject.setPath(this.outlinePath_ + '\n' + this.inlinePath_);
|
||||
pathObject.setHighlightPath(this.highlighter_.getPath());
|
||||
if (this.info_.RTL) {
|
||||
this.block_.pathObject.flipRTL();
|
||||
pathObject.flipRTL();
|
||||
}
|
||||
if (Blockly.blockRendering.useDebugger) {
|
||||
this.block_.renderingDebugger.drawDebug(this.block_, this.info_);
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
|
||||
goog.provide('Blockly.geras.PathObject');
|
||||
|
||||
goog.require('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.IPathObject');
|
||||
goog.require('Blockly.blockRendering.PathObject');
|
||||
goog.require('Blockly.geras.ConstantProvider');
|
||||
goog.require('Blockly.Theme');
|
||||
goog.require('Blockly.utils.dom');
|
||||
@@ -36,10 +35,9 @@ goog.require('Blockly.utils.object');
|
||||
* An object that handles creating and setting each of the SVG elements
|
||||
* used by the renderer.
|
||||
* @param {!SVGElement} root The root SVG element.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The renderer's
|
||||
* constants.
|
||||
* @param {!Blockly.geras.ConstantProvider} constants The renderer's constants.
|
||||
* @constructor
|
||||
* @implements {Blockly.blockRendering.IPathObject}
|
||||
* @extends {Blockly.blockRendering.PathObject}
|
||||
* @package
|
||||
*/
|
||||
Blockly.geras.PathObject = function(root, constants) {
|
||||
@@ -47,7 +45,7 @@ Blockly.geras.PathObject = function(root, constants) {
|
||||
* The renderer's constant provider.
|
||||
* @type {!Blockly.geras.ConstantProvider}
|
||||
*/
|
||||
this.constants_ = /** @type {!Blockly.geras.ConstantProvider} */ (constants);
|
||||
this.constants_ = constants;
|
||||
|
||||
this.svgRoot = root;
|
||||
|
||||
@@ -93,22 +91,28 @@ Blockly.geras.PathObject = function(root, constants) {
|
||||
*/
|
||||
this.style = Blockly.Theme.createBlockStyle('#000000');
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.geras.PathObject,
|
||||
Blockly.blockRendering.PathObject);
|
||||
|
||||
/**
|
||||
* Set each of the paths generated by the renderer onto the respective SVG element.
|
||||
* @param {string} mainPath The main path.
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.setPath = function(mainPath) {
|
||||
this.svgPath.setAttribute('d', mainPath);
|
||||
this.svgPathDark.setAttribute('d', mainPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the highlight path generated by the renderer onto the SVG element.
|
||||
* @param {string} highlightPath The highlight path.
|
||||
* @package
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.setPaths = function(mainPath, highlightPath) {
|
||||
this.svgPath.setAttribute('d', mainPath);
|
||||
this.svgPathDark.setAttribute('d', mainPath);
|
||||
Blockly.geras.PathObject.prototype.setHighlightPath = function(highlightPath) {
|
||||
this.svgPathLight.setAttribute('d', highlightPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Flip the SVG paths in RTL.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.flipRTL = function() {
|
||||
// Mirror the block's path.
|
||||
@@ -118,10 +122,7 @@ Blockly.geras.PathObject.prototype.flipRTL = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply the stored colours to the block's path, taking into account whether
|
||||
* the paths belong to a shadow block.
|
||||
* @param {boolean} isShadow True if the block is a shadow block.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.applyColour = function(isShadow) {
|
||||
if (isShadow) {
|
||||
@@ -140,9 +141,7 @@ Blockly.geras.PathObject.prototype.applyColour = function(isShadow) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the style.
|
||||
* @param {!Blockly.Theme.BlockStyle} blockStyle The block style to use.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.setStyle = function(blockStyle) {
|
||||
this.style = blockStyle;
|
||||
@@ -152,9 +151,7 @@ Blockly.geras.PathObject.prototype.setStyle = function(blockStyle) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether the block shows a highlight or not. Block highlighting is
|
||||
* often used to visually mark blocks currently being executed.
|
||||
* @param {boolean} highlighted True if highlighted.
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.setHighlighted = function(highlighted) {
|
||||
if (highlighted) {
|
||||
@@ -168,9 +165,7 @@ Blockly.geras.PathObject.prototype.setHighlighted = function(highlighted) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether the block shows a disable pattern or not.
|
||||
* @param {boolean} disabled True if disabled.
|
||||
* @param {boolean} isShadow True if the block is a shadow block.
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.PathObject.prototype.setDisabled = function(disabled, isShadow) {
|
||||
if (disabled) {
|
||||
|
||||
@@ -113,7 +113,7 @@ Blockly.geras.Renderer.prototype.makePathObject = function(root) {
|
||||
* provider.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.makeHighlightConstants_ = function() {
|
||||
Blockly.geras.Renderer.prototype.makeHighlightConstants_ = function() {
|
||||
return new Blockly.geras.HighlightConstantProvider(
|
||||
/** @type {!Blockly.blockRendering.ConstantProvider} */
|
||||
(this.getConstants()));
|
||||
|
||||
@@ -63,7 +63,8 @@ Blockly.blockRendering.InputConnection = function(constants, input) {
|
||||
|
||||
// TODO (#3186): change references to connectionModel, since that's on
|
||||
// Connection.
|
||||
this.connection = input.connection;
|
||||
this.connection =
|
||||
/** @type {!Blockly.RenderedConnection} */ (input.connection);
|
||||
this.connectionOffsetX = 0;
|
||||
this.connectionOffsetY = 0;
|
||||
};
|
||||
|
||||
51
core/renderers/zelos/path_object.js
Normal file
51
core/renderers/zelos/path_object.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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 An object that owns a block's rendering SVG elements.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.zelos.PathObject');
|
||||
|
||||
goog.require('Blockly.blockRendering.PathObject');
|
||||
goog.require('Blockly.zelos.ConstantProvider');
|
||||
goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
* An object that handles creating and setting each of the SVG elements
|
||||
* used by the renderer.
|
||||
* @param {!SVGElement} root The root SVG element.
|
||||
* @param {!Blockly.zelos.ConstantProvider} constants The renderer's constants.
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.PathObject}
|
||||
* @package
|
||||
*/
|
||||
Blockly.zelos.PathObject = function(root, constants) {
|
||||
Blockly.zelos.PathObject.superClass_.constructor.call(this, root, constants);
|
||||
|
||||
/**
|
||||
* The renderer's constant provider.
|
||||
* @type {!Blockly.zelos.ConstantProvider}
|
||||
*/
|
||||
this.constants_ = constants;
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.zelos.PathObject,
|
||||
Blockly.blockRendering.PathObject);
|
||||
@@ -28,6 +28,7 @@ goog.require('Blockly.blockRendering.Renderer');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.zelos.ConstantProvider');
|
||||
goog.require('Blockly.zelos.Drawer');
|
||||
goog.require('Blockly.zelos.PathObject');
|
||||
goog.require('Blockly.zelos.RenderInfo');
|
||||
|
||||
|
||||
@@ -78,4 +79,16 @@ Blockly.zelos.Renderer.prototype.makeDrawer_ = function(block, info) {
|
||||
/** @type {!Blockly.zelos.RenderInfo} */ (info));
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of a renderer path object.
|
||||
* @param {!SVGElement} root The root SVG element.
|
||||
* @return {!Blockly.zelos.PathObject} The renderer path object.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Blockly.zelos.Renderer.prototype.makePathObject = function(root) {
|
||||
return new Blockly.zelos.PathObject(root,
|
||||
/** @type {!Blockly.zelos.ConstantProvider} */ (this.getConstants()));
|
||||
};
|
||||
|
||||
Blockly.blockRendering.register('zelos', Blockly.zelos.Renderer);
|
||||
|
||||
@@ -79,8 +79,8 @@ goog.require('Blockly.FieldVariable');
|
||||
// At least one renderer is mandatory. Geras is the default one.
|
||||
// Others may be chosen using Blockly.inject's "renderer" configuration.
|
||||
goog.require('Blockly.geras.Renderer');
|
||||
// goog.require('Blockly.thrasos.Renderer');
|
||||
// goog.require('Blockly.zelos.Renderer');
|
||||
goog.require('Blockly.thrasos.Renderer');
|
||||
goog.require('Blockly.zelos.Renderer');
|
||||
// The debug renderer, which shows simplified versions of the blocks for
|
||||
// developer use.
|
||||
// goog.require('Blockly.blockRendering.Debug');
|
||||
|
||||
Reference in New Issue
Block a user