mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* chore: use casts to narrow types in renderers * chore: add @struct and type information on common measurables * refactor: update some renderer measurables to es6 classes * refactor: convert many measurables to es6 classes * chore: format * chore: rebuild
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Methods for graphically rendering a block as SVG.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Methods for graphically rendering a block as SVG.
|
|
* @class
|
|
*/
|
|
goog.module('Blockly.blockRendering.Measurable');
|
|
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
const {Types} = goog.require('Blockly.blockRendering.Types');
|
|
|
|
|
|
/**
|
|
* The base class to represent a part of a block that takes up space during
|
|
* rendering. The constructor for each non-spacer Measurable records the size
|
|
* of the block element (e.g. field, statement input).
|
|
* @param {!ConstantProvider} constants The rendering
|
|
* constants provider.
|
|
* @package
|
|
* @constructor
|
|
* @alias Blockly.blockRendering.Measurable
|
|
*/
|
|
const Measurable = function(constants) {
|
|
/** @type {number} */
|
|
this.width = 0;
|
|
|
|
/** @type {number} */
|
|
this.height = 0;
|
|
|
|
/** @type {number} */
|
|
this.type = Types.NONE;
|
|
|
|
/** @type {number} */
|
|
this.xPos = 0;
|
|
|
|
/** @type {number} */
|
|
this.centerline = 0;
|
|
|
|
/**
|
|
* The renderer's constant provider.
|
|
* @type {!ConstantProvider}
|
|
* @protected
|
|
*/
|
|
this.constants_ = constants;
|
|
|
|
/** @type {number} */
|
|
this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
|
|
};
|
|
|
|
exports.Measurable = Measurable;
|