mirror of
https://github.com/google/blockly.git
synced 2026-01-17 22:07:10 +01:00
Migrate core/renderers/common/constants.js to goog.module
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.blockRendering.ConstantProvider');
|
||||
goog.module('Blockly.blockRendering.ConstantProvider');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
goog.require('Blockly.connectionTypes');
|
||||
goog.require('Blockly.utils');
|
||||
@@ -30,7 +31,7 @@ goog.requireType('Blockly.Theme');
|
||||
* @constructor
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider = function() {
|
||||
const ConstantProvider = function() {
|
||||
|
||||
/**
|
||||
* The size of an empty spacer.
|
||||
@@ -543,7 +544,7 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
* Initialize shape objects based on the constants set in the constructor.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.init = function() {
|
||||
ConstantProvider.prototype.init = function() {
|
||||
|
||||
/**
|
||||
* An object containing sizing and path information about collapsed block
|
||||
@@ -588,7 +589,7 @@ Blockly.blockRendering.ConstantProvider.prototype.init = function() {
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setTheme = function(
|
||||
ConstantProvider.prototype.setTheme = function(
|
||||
theme) {
|
||||
|
||||
/**
|
||||
@@ -611,7 +612,7 @@ Blockly.blockRendering.ConstantProvider.prototype.setTheme = function(
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setDynamicProperties_ =
|
||||
ConstantProvider.prototype.setDynamicProperties_ =
|
||||
function(theme) {
|
||||
/* eslint-disable indent */
|
||||
this.setFontConstants_(theme);
|
||||
@@ -626,7 +627,7 @@ Blockly.blockRendering.ConstantProvider.prototype.setDynamicProperties_ =
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setFontConstants_ = function(
|
||||
ConstantProvider.prototype.setFontConstants_ = function(
|
||||
theme) {
|
||||
this.FIELD_TEXT_FONTFAMILY =
|
||||
theme.fontStyle && theme.fontStyle['family'] != undefined ?
|
||||
@@ -652,7 +653,7 @@ Blockly.blockRendering.ConstantProvider.prototype.setFontConstants_ = function(
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setComponentConstants_ =
|
||||
ConstantProvider.prototype.setComponentConstants_ =
|
||||
function(theme) {
|
||||
/* eslint-disable indent */
|
||||
this.CURSOR_COLOUR = theme.getComponentStyle('cursorColour') ||
|
||||
@@ -675,7 +676,7 @@ Blockly.blockRendering.ConstantProvider.prototype.setComponentConstants_ =
|
||||
* containing the style and an autogenerated name for that style.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getBlockStyleForColour =
|
||||
ConstantProvider.prototype.getBlockStyleForColour =
|
||||
function(colour) {
|
||||
/* eslint-disable indent */
|
||||
var name = 'auto_' + colour;
|
||||
@@ -691,7 +692,7 @@ Blockly.blockRendering.ConstantProvider.prototype.getBlockStyleForColour =
|
||||
* @return {!Blockly.Theme.BlockStyle} The named block style, or a default style
|
||||
* if no style with the given name was found.
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getBlockStyle = function(
|
||||
ConstantProvider.prototype.getBlockStyle = function(
|
||||
blockStyleName) {
|
||||
return this.blockStyles[blockStyleName || ''] ||
|
||||
(blockStyleName && blockStyleName.indexOf('auto_') == 0 ?
|
||||
@@ -706,7 +707,7 @@ Blockly.blockRendering.ConstantProvider.prototype.getBlockStyle = function(
|
||||
* given colour.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.createBlockStyle_ = function(
|
||||
ConstantProvider.prototype.createBlockStyle_ = function(
|
||||
colour) {
|
||||
return this.validatedBlockStyle_({
|
||||
'colourPrimary': colour
|
||||
@@ -727,7 +728,7 @@ Blockly.blockRendering.ConstantProvider.prototype.createBlockStyle_ = function(
|
||||
* required properties populated.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.validatedBlockStyle_ =
|
||||
ConstantProvider.prototype.validatedBlockStyle_ =
|
||||
function(blockStyle) {
|
||||
/* eslint-disable indent */
|
||||
// Make a new object with all of the same properties.
|
||||
@@ -756,7 +757,7 @@ Blockly.blockRendering.ConstantProvider.prototype.validatedBlockStyle_ =
|
||||
* @return {string} The generated secondary colour.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.generateSecondaryColour_ =
|
||||
ConstantProvider.prototype.generateSecondaryColour_ =
|
||||
function(colour) {
|
||||
/* eslint-disable indent */
|
||||
return Blockly.utils.colour.blend('#fff', colour, 0.6) || colour;
|
||||
@@ -768,7 +769,7 @@ Blockly.blockRendering.ConstantProvider.prototype.generateSecondaryColour_ =
|
||||
* @return {string} The generated tertiary colour.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.generateTertiaryColour_ =
|
||||
ConstantProvider.prototype.generateTertiaryColour_ =
|
||||
function(colour) {
|
||||
/* eslint-disable indent */
|
||||
return Blockly.utils.colour.blend('#fff', colour, 0.3) || colour;
|
||||
@@ -780,7 +781,7 @@ Blockly.blockRendering.ConstantProvider.prototype.generateTertiaryColour_ =
|
||||
* Delete all DOM elements that this provider created.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.dispose = function() {
|
||||
ConstantProvider.prototype.dispose = function() {
|
||||
if (this.embossFilter_) {
|
||||
Blockly.utils.dom.removeNode(this.embossFilter_);
|
||||
}
|
||||
@@ -798,7 +799,7 @@ Blockly.blockRendering.ConstantProvider.prototype.dispose = function() {
|
||||
* collapsed block indicators.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
ConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
var height = this.JAGGED_TEETH_HEIGHT;
|
||||
var width = this.JAGGED_TEETH_WIDTH;
|
||||
|
||||
@@ -821,7 +822,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
* start hats.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makeStartHat = function() {
|
||||
ConstantProvider.prototype.makeStartHat = function() {
|
||||
var height = this.START_HAT_HEIGHT;
|
||||
var width = this.START_HAT_WIDTH;
|
||||
|
||||
@@ -844,7 +845,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makeStartHat = function() {
|
||||
* puzzle tabs.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makePuzzleTab = function() {
|
||||
ConstantProvider.prototype.makePuzzleTab = function() {
|
||||
var width = this.TAB_WIDTH;
|
||||
var height = this.TAB_HEIGHT;
|
||||
|
||||
@@ -898,7 +899,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makePuzzleTab = function() {
|
||||
* notches.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makeNotch = function() {
|
||||
ConstantProvider.prototype.makeNotch = function() {
|
||||
var width = this.NOTCH_WIDTH;
|
||||
var height = this.NOTCH_HEIGHT;
|
||||
var innerWidth = 3;
|
||||
@@ -928,7 +929,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makeNotch = function() {
|
||||
* inside corners.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makeInsideCorners = function() {
|
||||
ConstantProvider.prototype.makeInsideCorners = function() {
|
||||
var radius = this.CORNER_RADIUS;
|
||||
|
||||
var innerTopLeftCorner = Blockly.utils.svgPaths.arc('a', '0 0,0', radius,
|
||||
@@ -950,7 +951,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makeInsideCorners = function()
|
||||
* outside corners.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.makeOutsideCorners = function() {
|
||||
ConstantProvider.prototype.makeOutsideCorners = function() {
|
||||
var radius = this.CORNER_RADIUS;
|
||||
/**
|
||||
* SVG path for drawing the rounded top-left corner.
|
||||
@@ -1000,7 +1001,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makeOutsideCorners = function(
|
||||
* @return {!Object} The shape object for the connection.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.shapeFor = function(
|
||||
ConstantProvider.prototype.shapeFor = function(
|
||||
connection) {
|
||||
switch (connection.type) {
|
||||
case Blockly.connectionTypes.INPUT_VALUE:
|
||||
@@ -1022,7 +1023,7 @@ Blockly.blockRendering.ConstantProvider.prototype.shapeFor = function(
|
||||
* @suppress {strictModuleDepCheck} Debug renderer only included in playground.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg,
|
||||
ConstantProvider.prototype.createDom = function(svg,
|
||||
tagName, selector) {
|
||||
this.injectCSS_(tagName, selector);
|
||||
|
||||
@@ -1121,7 +1122,7 @@ Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg,
|
||||
* render debugging.
|
||||
* @private
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.createDebugFilter =
|
||||
ConstantProvider.prototype.createDebugFilter =
|
||||
function() {
|
||||
// Only create the debug filter once.
|
||||
if (!this.debugFilter_) {
|
||||
@@ -1166,7 +1167,7 @@ Blockly.blockRendering.ConstantProvider.prototype.createDebugFilter =
|
||||
* @param {string} selector The CSS selector to use.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.injectCSS_ = function(
|
||||
ConstantProvider.prototype.injectCSS_ = function(
|
||||
tagName, selector) {
|
||||
var cssArray = this.getCSS_(selector);
|
||||
var cssNodeId = 'blockly-renderer-style-' + tagName;
|
||||
@@ -1194,7 +1195,7 @@ Blockly.blockRendering.ConstantProvider.prototype.injectCSS_ = function(
|
||||
* @return {!Array<string>} Array of CSS strings.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(selector) {
|
||||
ConstantProvider.prototype.getCSS_ = function(selector) {
|
||||
return [
|
||||
/* eslint-disable indent */
|
||||
// Text.
|
||||
@@ -1269,3 +1270,5 @@ Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(selector) {
|
||||
/* eslint-enable indent */
|
||||
];
|
||||
};
|
||||
|
||||
exports = ConstantProvider;
|
||||
|
||||
@@ -120,7 +120,7 @@ goog.addDependency('../../core/procedures.js', ['Blockly.Procedures'], ['Blockly
|
||||
goog.addDependency('../../core/registry.js', ['Blockly.registry'], []);
|
||||
goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.connectionTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object']);
|
||||
goog.addDependency('../../core/renderers/common/block_rendering.js', ['Blockly.blockRendering'], ['Blockly.registry']);
|
||||
goog.addDependency('../../core/renderers/common/constants.js', ['Blockly.blockRendering.ConstantProvider'], ['Blockly.connectionTypes', 'Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.svgPaths', 'Blockly.utils.userAgent'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/renderers/common/constants.js', ['Blockly.blockRendering.ConstantProvider'], ['Blockly.connectionTypes', 'Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.svgPaths', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/renderers/common/debugger.js', ['Blockly.blockRendering.Debug'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.Types', 'Blockly.connectionTypes', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/renderers/common/drawer.js', ['Blockly.blockRendering.Drawer'], ['Blockly.blockRendering.Row', 'Blockly.blockRendering.Types', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/renderers/common/i_path_object.js', ['Blockly.blockRendering.IPathObject'], []);
|
||||
|
||||
Reference in New Issue
Block a user