mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Move highlighting code into geras.
This commit is contained in:
@@ -92,14 +92,15 @@ goog.addDependency("../../../" + dir + "/core/names.js", ['Blockly.Names'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/options.js", ['Blockly.Options'], ['Blockly.Themes.Classic', 'Blockly.utils.userAgent', 'Blockly.Xml']);
|
||||
goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedures'], ['Blockly.Blocks', 'Blockly.constants', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.Names', 'Blockly.utils.xml', 'Blockly.Workspace', 'Blockly.Xml']);
|
||||
goog.addDependency("../../../" + dir + "/core/rendered_connection.js", ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.Events', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw.js", ['Blockly.blockRendering.Drawer'], ['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.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.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_draw.js", ['Blockly.blockRendering.Drawer'], ['Blockly.blockRendering.Debug', '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_draw_debug.js", ['Blockly.blockRendering.Debug'], ['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.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', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.HighlightConstantProvider', 'Blockly.geras.RenderInfo', 'Blockly.thrasos.RenderInfo', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering.js", ['Blockly.blockRendering'], ['Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.ConstantProvider', 'Blockly.geras.HighlightConstantProvider', 'Blockly.geras.RenderInfo', 'Blockly.thrasos.RenderInfo', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering_constants.js", ['Blockly.blockRendering.ConstantProvider'], ['Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/highlight_constants.js", ['Blockly.blockRendering.HighlightConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/measurables.js", ['Blockly.blockRendering.InRowSpacer'], ['Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/geras/drawer.js", ['Blockly.geras.Drawer'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Drawer', 'Blockly.geras.Highlighter', 'Blockly.geras.RenderInfo']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/geras/highlight_constants.js", ['Blockly.geras.HighlightConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/geras/highlighter.js", ['Blockly.geras.Highlighter'], ['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/geras/info.js", ['Blockly.geras', 'Blockly.geras.RenderInfo'], ['Blockly.blockRendering.RenderInfo', '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/measurables/base.js", ['Blockly.blockRendering.Measurable'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/measurables/connections.js", ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection'], ['Blockly.blockRendering.Measurable', 'Blockly.RenderedConnection']);
|
||||
@@ -267,8 +268,6 @@ goog.require('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.Debug');
|
||||
goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.blockRendering.ExternalValueInput');
|
||||
goog.require('Blockly.blockRendering.HighlightConstantProvider');
|
||||
goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.InRowSpacer');
|
||||
goog.require('Blockly.blockRendering.InlineInput');
|
||||
goog.require('Blockly.blockRendering.InputConnection');
|
||||
@@ -285,6 +284,9 @@ goog.require('Blockly.blockRendering.TopRow');
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.fieldRegistry');
|
||||
goog.require('Blockly.geras');
|
||||
goog.require('Blockly.geras.Drawer');
|
||||
goog.require('Blockly.geras.HighlightConstantProvider');
|
||||
goog.require('Blockly.geras.Highlighter');
|
||||
goog.require('Blockly.geras.RenderInfo');
|
||||
goog.require('Blockly.inject');
|
||||
goog.require('Blockly.navigation');
|
||||
|
||||
@@ -28,7 +28,6 @@ goog.provide('Blockly.blockRendering.Drawer');
|
||||
|
||||
goog.require('Blockly.blockRendering.Debug');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.BottomRow');
|
||||
goog.require('Blockly.blockRendering.InputRow');
|
||||
@@ -52,9 +51,6 @@ Blockly.blockRendering.Drawer = function(block, info) {
|
||||
this.outlinePath_ = '';
|
||||
this.inlinePath_ = '';
|
||||
this.pathObject_ = new Blockly.BlockSvg.PathObject();
|
||||
this.highlighter_ =
|
||||
new Blockly.blockRendering.Highlighter(this.info_, this.pathObject_);
|
||||
|
||||
this.constants_ = Blockly.blockRendering.getConstants();
|
||||
};
|
||||
|
||||
@@ -139,10 +135,6 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() {
|
||||
var topRow = this.info_.topRow;
|
||||
var elements = topRow.elements;
|
||||
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawTopCorner(topRow);
|
||||
this.highlighter_.drawRightSideRow(topRow);
|
||||
}
|
||||
this.positionPreviousConnection_();
|
||||
this.outlinePath_ +=
|
||||
Blockly.utils.svgPaths.moveBy(topRow.xPos, this.info_.startY);
|
||||
@@ -168,9 +160,6 @@ Blockly.blockRendering.Drawer.prototype.drawTop_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_ = function(row) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawJaggedEdge_(row);
|
||||
}
|
||||
var remainder =
|
||||
row.height - this.constants_.JAGGED_TEETH.height;
|
||||
this.outlinePath_ += this.constants_.JAGGED_TEETH.path +
|
||||
@@ -186,9 +175,6 @@ Blockly.blockRendering.Drawer.prototype.drawJaggedEdge_ = function(row) {
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawValueInput_ = function(row) {
|
||||
var input = row.getLastInput();
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawValueInput(row);
|
||||
}
|
||||
this.positionExternalValueConnection_(row);
|
||||
|
||||
this.outlinePath_ +=
|
||||
@@ -205,9 +191,6 @@ Blockly.blockRendering.Drawer.prototype.drawValueInput_ = function(row) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawStatementInput(row);
|
||||
}
|
||||
var input = row.getLastInput();
|
||||
// Where to start drawing the notch, which is on the right side in LTR.
|
||||
var x = input.xPos + input.width;
|
||||
@@ -237,9 +220,6 @@ Blockly.blockRendering.Drawer.prototype.drawStatementInput_ = function(row) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawRightSideRow_ = function(row) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawRightSideRow(row);
|
||||
}
|
||||
this.outlinePath_ +=
|
||||
Blockly.utils.svgPaths.lineOnAxis('H', row.xPos + row.width) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('V', row.yPos + row.height);
|
||||
@@ -254,9 +234,6 @@ Blockly.blockRendering.Drawer.prototype.drawRightSideRow_ = function(row) {
|
||||
Blockly.blockRendering.Drawer.prototype.drawBottom_ = function() {
|
||||
var bottomRow = this.info_.bottomRow;
|
||||
var elems = bottomRow.elements;
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawBottomRow(bottomRow);
|
||||
}
|
||||
this.positionNextConnection_();
|
||||
|
||||
this.outlinePath_ +=
|
||||
@@ -281,10 +258,6 @@ Blockly.blockRendering.Drawer.prototype.drawBottom_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawLeft_ = function() {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawLeft();
|
||||
}
|
||||
|
||||
var outputConnection = this.info_.outputConnection;
|
||||
this.positionOutputConnection_();
|
||||
|
||||
@@ -364,9 +337,6 @@ Blockly.blockRendering.Drawer.prototype.layoutField_ = function(fieldInfo) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.Drawer.prototype.drawInlineInput_ = function(input) {
|
||||
if (this.highlighter_) {
|
||||
this.highlighter_.drawInlineInput(input);
|
||||
}
|
||||
var width = input.width;
|
||||
var height = input.height;
|
||||
var yPos = input.centerline - height / 2;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
goog.provide('Blockly.blockRendering.Debug');
|
||||
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.BottomRow');
|
||||
goog.require('Blockly.blockRendering.InputRow');
|
||||
|
||||
@@ -34,12 +34,15 @@ goog.require('Blockly.blockRendering.Debug');
|
||||
goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.HighlightConstantProvider');
|
||||
goog.require('Blockly.geras.HighlightConstantProvider');
|
||||
|
||||
goog.require('Blockly.geras.RenderInfo');
|
||||
goog.require('Blockly.thrasos.RenderInfo');
|
||||
goog.require('Blockly.zelos.RenderInfo');
|
||||
|
||||
// TODO (#2702): Pick an API for choosing a renderer.
|
||||
Blockly.blockRendering.rendererName = 'geras';
|
||||
|
||||
/**
|
||||
* Initialize anything needed for rendering (constants, etc).
|
||||
* @package
|
||||
@@ -47,8 +50,10 @@ goog.require('Blockly.zelos.RenderInfo');
|
||||
Blockly.blockRendering.init = function() {
|
||||
Blockly.blockRendering.constants =
|
||||
new Blockly.blockRendering.ConstantProvider();
|
||||
// No one else has a highlight provider. It's possible this should only be
|
||||
// created if we're rendering with geras.
|
||||
Blockly.blockRendering.highlightConstants =
|
||||
new Blockly.blockRendering.HighlightConstantProvider();
|
||||
new Blockly.geras.HighlightConstantProvider();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -61,8 +66,16 @@ Blockly.blockRendering.render = function(block) {
|
||||
if (!block.renderingDebugger) {
|
||||
block.renderingDebugger = new Blockly.blockRendering.Debug();
|
||||
}
|
||||
var info = new Blockly.geras.RenderInfo(block);
|
||||
new Blockly.blockRendering.Drawer(block, info).draw_();
|
||||
if (Blockly.blockRendering.rendererName == 'geras') {
|
||||
var info = new Blockly.geras.RenderInfo(block);
|
||||
new Blockly.geras.Drawer(block, info).draw_();
|
||||
} else if (Blockly.blockRendering.rendererName == 'thrasos') {
|
||||
var info = new Blockly.thrasos.RenderInfo(block);
|
||||
new Blockly.blockRendering.Drawer(block, info).draw_();
|
||||
} else if (Blockly.blockRendering.rendererName == 'zelos') {
|
||||
var info = new Blockly.zelos.RenderInfo(block);
|
||||
new Blockly.blockRendering.Drawer(block, info).draw_();
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.getConstants = function() {
|
||||
|
||||
139
core/renderers/geras/drawer.js
Normal file
139
core/renderers/geras/drawer.js
Normal file
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* @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 Renderer that preserves the look and feel of Blockly pre-2019.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.geras.Drawer');
|
||||
|
||||
goog.require('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.geras.Highlighter');
|
||||
goog.require('Blockly.geras.RenderInfo');
|
||||
|
||||
|
||||
/**
|
||||
* An object that draws a block based on the given rendering information.
|
||||
* @param {!Blockly.BlockSvg} block The block to render.
|
||||
* @param {!Blockly.geras.RenderInfo} info An object containing all
|
||||
* information needed to render this block.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Drawer}
|
||||
*/
|
||||
Blockly.geras.Drawer = function(block, info) {
|
||||
Blockly.geras.Drawer.superClass_.constructor.call(this, block, info);
|
||||
// Unlike Thrasos, Geras has highlights and drop shadows.
|
||||
this.highlighter_ =
|
||||
new Blockly.geras.Highlighter(this.info_, this.pathObject_);
|
||||
};
|
||||
goog.inherits(Blockly.geras.Drawer, Blockly.blockRendering.Drawer);
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.recordSizeOnBlock_ = function() {
|
||||
// This is used when the block is reporting its size to anyone else.
|
||||
// The dark path adds to the size of the block in both X and Y.
|
||||
this.block_.height = this.info_.height +
|
||||
this.constants_.DARK_PATH_OFFSET;
|
||||
this.block_.width = this.info_.widthWithChildren +
|
||||
this.constants_.DARK_PATH_OFFSET;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawTop_ = function() {
|
||||
this.highlighter_.drawTopCorner(this.info_.topRow);
|
||||
this.highlighter_.drawRightSideRow(this.info_.topRow);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawTop_.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawJaggedEdge_ = function(row) {
|
||||
this.highlighter_.drawJaggedEdge_(row);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawJaggedEdge_.call(this, row);
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawValueInput_ = function(row) {
|
||||
this.highlighter_.drawValueInput(row);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawValueInput_.call(this, row);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawStatementInput_ = function(row) {
|
||||
this.highlighter_.drawStatementInput(row);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawStatementInput_.call(this, row);
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawRightSideRow_ = function(row) {
|
||||
this.highlighter_.drawRightSideRow(row);
|
||||
Blockly.geras.Drawer.superClass_.drawRightSideRow_.call(this, row);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawBottom_ = function() {
|
||||
this.highlighter_.drawBottomRow(this.info_.bottomRow);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawBottom_.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add steps for the left side of the block, which may include an output
|
||||
* connection
|
||||
* @private
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawLeft_ = function() {
|
||||
this.highlighter_.drawLeft();
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawLeft_.call(this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.Drawer.prototype.drawInlineInput_ = function(input) {
|
||||
this.highlighter_.drawInlineInput(input);
|
||||
|
||||
Blockly.geras.Drawer.superClass_.drawInlineInput_.call(this, input);
|
||||
};
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.HighlightConstantProvider');
|
||||
goog.provide('Blockly.geras.HighlightConstantProvider');
|
||||
|
||||
goog.require('Blockly.blockRendering.ConstantProvider');
|
||||
goog.require('Blockly.utils.svgPaths');
|
||||
@@ -37,7 +37,7 @@ goog.require('Blockly.utils.svgPaths');
|
||||
* @constructor
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider = function() {
|
||||
Blockly.geras.HighlightConstantProvider = function() {
|
||||
/**
|
||||
* An object that provides the constants used for base block rendering.
|
||||
* @type {!Blockly.blockRendering.ConstantProvider}
|
||||
@@ -104,7 +104,7 @@ Blockly.blockRendering.HighlightConstantProvider = function() {
|
||||
* inside corner highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makeInsideCorner = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makeInsideCorner = function() {
|
||||
var radius = this.constantProvider.CORNER_RADIUS;
|
||||
var offset = this.OFFSET;
|
||||
|
||||
@@ -149,7 +149,7 @@ Blockly.blockRendering.HighlightConstantProvider.prototype.makeInsideCorner = fu
|
||||
* outside corner highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makeOutsideCorner = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makeOutsideCorner = function() {
|
||||
var radius = this.constantProvider.CORNER_RADIUS;
|
||||
var offset = this.OFFSET;
|
||||
|
||||
@@ -199,7 +199,7 @@ Blockly.blockRendering.HighlightConstantProvider.prototype.makeOutsideCorner = f
|
||||
* puzzle tab highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makePuzzleTab = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makePuzzleTab = function() {
|
||||
var width = this.constantProvider.TAB_WIDTH;
|
||||
var height = this.constantProvider.TAB_HEIGHT;
|
||||
|
||||
@@ -253,7 +253,7 @@ Blockly.blockRendering.HighlightConstantProvider.prototype.makePuzzleTab = funct
|
||||
* notch highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makeNotch = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makeNotch = function() {
|
||||
// This is only for the previous connection.
|
||||
var pathLeft =
|
||||
Blockly.utils.svgPaths.lineOnAxis(
|
||||
@@ -269,7 +269,7 @@ Blockly.blockRendering.HighlightConstantProvider.prototype.makeNotch = function(
|
||||
* collapsed block edge highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
var pathLeft =
|
||||
Blockly.utils.svgPaths.lineTo(5.1, 2.6) +
|
||||
Blockly.utils.svgPaths.moveBy(-10.2, 6.8) +
|
||||
@@ -284,7 +284,7 @@ Blockly.blockRendering.HighlightConstantProvider.prototype.makeJaggedTeeth = fun
|
||||
* start highlights.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.HighlightConstantProvider.prototype.makeStartHat = function() {
|
||||
Blockly.geras.HighlightConstantProvider.prototype.makeStartHat = function() {
|
||||
var hatHeight = this.constantProvider.START_HAT.height;
|
||||
var pathRtl =
|
||||
Blockly.utils.svgPaths.moveBy(25, -8.7) +
|
||||
@@ -19,12 +19,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Methods for graphically rendering a block as SVG.
|
||||
* @fileoverview Methods for adding highlights on block, for rendering in
|
||||
* compatibility mode.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.Highlighter');
|
||||
goog.provide('Blockly.geras.Highlighter');
|
||||
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
@@ -46,14 +47,14 @@ goog.require('Blockly.blockRendering.TopRow');
|
||||
* or closed paths. The highlights for tabs and notches are loosely based on
|
||||
* tab and notch shapes, but are not exactly the same.
|
||||
*
|
||||
* @param {!Blockly.blockRendering.RenderInfo} info An object containing all
|
||||
* @param {!Blockly.geras.RenderInfo} info An object containing all
|
||||
* information needed to render this block.
|
||||
* @param {!Blockly.BlockSvg.PathObject} pathObject An object that stores all of
|
||||
* the block's paths before they are propagated to the page.
|
||||
* @package
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.blockRendering.Highlighter = function(info, pathObject) {
|
||||
Blockly.geras.Highlighter = function(info, pathObject) {
|
||||
this.info_ = info;
|
||||
this.pathObject_ = pathObject;
|
||||
this.steps_ = this.pathObject_.highlightSteps;
|
||||
@@ -79,7 +80,7 @@ Blockly.blockRendering.Highlighter = function(info, pathObject) {
|
||||
this.highlightConstants_.JAGGED_TEETH;
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
this.steps_.push(
|
||||
Blockly.utils.svgPaths.moveBy(row.xPos, this.info_.startY));
|
||||
for (var i = 0, elem; (elem = row.elements[i]); i++) {
|
||||
@@ -104,7 +105,7 @@ Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
this.steps_.push('H', right);
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawJaggedEdge_ = function(row) {
|
||||
if (this.info_.RTL) {
|
||||
this.steps_.push('H', row.width - this.highlightOffset_);
|
||||
this.steps_.push(this.jaggedTeethPaths_.pathLeft);
|
||||
@@ -114,7 +115,7 @@ Blockly.blockRendering.Highlighter.prototype.drawJaggedEdge_ = function(row) {
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawValueInput = function(row) {
|
||||
var input = row.getLastInput();
|
||||
var steps = '';
|
||||
if (this.RTL_) {
|
||||
@@ -134,7 +135,7 @@ Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) {
|
||||
this.steps_.push(steps);
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawStatementInput = function(row) {
|
||||
var input = row.getLastInput();
|
||||
var steps = '';
|
||||
if (this.RTL_) {
|
||||
@@ -152,7 +153,7 @@ Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row)
|
||||
this.steps_.push(steps);
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawRightSideRow = function(row) {
|
||||
var rightEdge = row.xPos + row.width - this.highlightOffset_;
|
||||
if (row.followsStatement) {
|
||||
this.steps_.push('H', rightEdge);
|
||||
@@ -165,7 +166,7 @@ Blockly.blockRendering.Highlighter.prototype.drawRightSideRow = function(row) {
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomRow = function(row) {
|
||||
Blockly.geras.Highlighter.prototype.drawBottomRow = function(row) {
|
||||
var height = row.yPos + row.height - row.overhangY;
|
||||
|
||||
// Highlight the vertical edge of the bottom row on the input side.
|
||||
@@ -186,7 +187,7 @@ Blockly.blockRendering.Highlighter.prototype.drawBottomRow = function(row) {
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawLeft = function() {
|
||||
Blockly.geras.Highlighter.prototype.drawLeft = function() {
|
||||
var outputConnection = this.info_.outputConnection;
|
||||
if (outputConnection) {
|
||||
var tabBottom =
|
||||
@@ -213,7 +214,7 @@ Blockly.blockRendering.Highlighter.prototype.drawLeft = function() {
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawInlineInput = function(input) {
|
||||
Blockly.geras.Highlighter.prototype.drawInlineInput = function(input) {
|
||||
var offset = this.highlightOffset_;
|
||||
|
||||
// Relative to the block's left.
|
||||
Reference in New Issue
Block a user