mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Migrate core/renderers/zelos/renderer.js named requires
This commit is contained in:
@@ -13,22 +13,26 @@
|
||||
goog.module('Blockly.zelos.Renderer');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.require('Blockly.blockRendering');
|
||||
goog.require('Blockly.blockRendering.Renderer');
|
||||
goog.require('Blockly.connectionTypes');
|
||||
goog.require('Blockly.InsertionMarkerManager');
|
||||
goog.require('Blockly.utils.object');
|
||||
goog.require('Blockly.zelos.ConstantProvider');
|
||||
goog.require('Blockly.zelos.Drawer');
|
||||
goog.require('Blockly.zelos.MarkerSvg');
|
||||
goog.require('Blockly.zelos.PathObject');
|
||||
goog.require('Blockly.zelos.RenderInfo');
|
||||
|
||||
goog.requireType('Blockly.BlockSvg');
|
||||
goog.requireType('Blockly.Marker');
|
||||
goog.requireType('Blockly.blockRendering.RenderInfo');
|
||||
goog.requireType('Blockly.Theme');
|
||||
goog.requireType('Blockly.WorkspaceSvg');
|
||||
const BaseRenderer = goog.require('Blockly.blockRendering.Renderer');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const BaseRenderInfo = goog.requireType('Blockly.blockRendering.RenderInfo');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const BlockSvg = goog.requireType('Blockly.BlockSvg');
|
||||
const ConstantProvider = goog.require('Blockly.zelos.ConstantProvider');
|
||||
const Drawer = goog.require('Blockly.zelos.Drawer');
|
||||
const InsertionMarkerManager = goog.require('Blockly.InsertionMarkerManager');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const Marker = goog.requireType('Blockly.Marker');
|
||||
const MarkerSvg = goog.require('Blockly.zelos.MarkerSvg');
|
||||
const PathObject = goog.require('Blockly.zelos.PathObject');
|
||||
const RenderInfo = goog.require('Blockly.zelos.RenderInfo');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const Theme = goog.requireType('Blockly.Theme');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
|
||||
const blockRendering = goog.require('Blockly.blockRendering');
|
||||
const connectionTypes = goog.require('Blockly.connectionTypes');
|
||||
const object = goog.require('Blockly.utils.object');
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,83 +40,83 @@ goog.requireType('Blockly.WorkspaceSvg');
|
||||
* @param {string} name The renderer name.
|
||||
* @package
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Renderer}
|
||||
* @extends {BaseRenderer}
|
||||
*/
|
||||
const Renderer = function(name) {
|
||||
Renderer.superClass_.constructor.call(this, name);
|
||||
};
|
||||
Blockly.utils.object.inherits(Renderer,
|
||||
Blockly.blockRendering.Renderer);
|
||||
object.inherits(Renderer,
|
||||
BaseRenderer);
|
||||
|
||||
/**
|
||||
* Create a new instance of the renderer's constant provider.
|
||||
* @return {!Blockly.zelos.ConstantProvider} The constant provider.
|
||||
* @return {!ConstantProvider} The constant provider.
|
||||
* @protected
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.makeConstants_ = function() {
|
||||
return new Blockly.zelos.ConstantProvider();
|
||||
return new ConstantProvider();
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of the renderer's render info object.
|
||||
* @param {!Blockly.BlockSvg} block The block to measure.
|
||||
* @return {!Blockly.zelos.RenderInfo} The render info object.
|
||||
* @param {!BlockSvg} block The block to measure.
|
||||
* @return {!RenderInfo} The render info object.
|
||||
* @protected
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.makeRenderInfo_ = function(block) {
|
||||
return new Blockly.zelos.RenderInfo(this, block);
|
||||
return new RenderInfo(this, block);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of the renderer's drawer.
|
||||
* @param {!Blockly.BlockSvg} block The block to render.
|
||||
* @param {!Blockly.blockRendering.RenderInfo} info An object containing all
|
||||
* @param {!BlockSvg} block The block to render.
|
||||
* @param {!BaseRenderInfo} info An object containing all
|
||||
* information needed to render this block.
|
||||
* @return {!Blockly.zelos.Drawer} The drawer.
|
||||
* @return {!Drawer} The drawer.
|
||||
* @protected
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.makeDrawer_ = function(block, info) {
|
||||
return new Blockly.zelos.Drawer(block,
|
||||
/** @type {!Blockly.zelos.RenderInfo} */ (info));
|
||||
return new Drawer(block,
|
||||
/** @type {!RenderInfo} */ (info));
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of the renderer's cursor drawer.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The workspace the cursor belongs to.
|
||||
* @param {!Blockly.Marker} marker The marker.
|
||||
* @return {!Blockly.zelos.MarkerSvg} The object in charge of drawing
|
||||
* @param {!WorkspaceSvg} workspace The workspace the cursor belongs to.
|
||||
* @param {!Marker} marker The marker.
|
||||
* @return {!MarkerSvg} The object in charge of drawing
|
||||
* the marker.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.makeMarkerDrawer = function(
|
||||
workspace, marker) {
|
||||
return new Blockly.zelos.MarkerSvg(workspace, this.getConstants(), marker);
|
||||
return new MarkerSvg(workspace, this.getConstants(), marker);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of a renderer path object.
|
||||
* @param {!SVGElement} root The root SVG element.
|
||||
* @param {!Blockly.Theme.BlockStyle} style The style object to use for
|
||||
* @param {!Theme.BlockStyle} style The style object to use for
|
||||
* colouring.
|
||||
* @return {!Blockly.zelos.PathObject} The renderer path object.
|
||||
* @return {!PathObject} The renderer path object.
|
||||
* @package
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.makePathObject = function(root, style) {
|
||||
return new Blockly.zelos.PathObject(root, style,
|
||||
/** @type {!Blockly.zelos.ConstantProvider} */ (this.getConstants()));
|
||||
return new PathObject(root, style,
|
||||
/** @type {!ConstantProvider} */ (this.getConstants()));
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Renderer.prototype.shouldHighlightConnection = function(conn) {
|
||||
return conn.type != Blockly.connectionTypes.INPUT_VALUE &&
|
||||
conn.type !== Blockly.connectionTypes.OUTPUT_VALUE;
|
||||
return conn.type != connectionTypes.INPUT_VALUE &&
|
||||
conn.type !== connectionTypes.OUTPUT_VALUE;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -120,22 +124,22 @@ Renderer.prototype.shouldHighlightConnection = function(conn) {
|
||||
*/
|
||||
Renderer.prototype.getConnectionPreviewMethod = function(
|
||||
closest, local, topBlock) {
|
||||
if (local.type == Blockly.connectionTypes.OUTPUT_VALUE) {
|
||||
if (local.type == connectionTypes.OUTPUT_VALUE) {
|
||||
if (!closest.isConnected()) {
|
||||
return Blockly.InsertionMarkerManager.PREVIEW_TYPE.INPUT_OUTLINE;
|
||||
return InsertionMarkerManager.PREVIEW_TYPE.INPUT_OUTLINE;
|
||||
}
|
||||
// TODO: Returning this is a total hack, because we don't want to show
|
||||
// a replacement fade, we want to show an outline affect.
|
||||
// Sadly zelos does not support showing an outline around filled
|
||||
// inputs, so we have to pretend like the connected block is getting
|
||||
// replaced.
|
||||
return Blockly.InsertionMarkerManager.PREVIEW_TYPE.REPLACEMENT_FADE;
|
||||
return InsertionMarkerManager.PREVIEW_TYPE.REPLACEMENT_FADE;
|
||||
}
|
||||
|
||||
return Renderer.superClass_.getConnectionPreviewMethod(
|
||||
closest, local, topBlock);
|
||||
};
|
||||
|
||||
Blockly.blockRendering.register('zelos', Renderer);
|
||||
blockRendering.register('zelos', Renderer);
|
||||
|
||||
exports = Renderer;
|
||||
|
||||
Reference in New Issue
Block a user