From 8cbec2eaeeb976bd233e93ee384e9657c5539355 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 10 Dec 2019 08:32:26 -0800 Subject: [PATCH] Make checkbox field width a constant. (#3499) --- core/field_checkbox.js | 11 +---------- core/renderers/common/constants.js | 6 ++++++ core/renderers/zelos/constants.js | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/core/field_checkbox.js b/core/field_checkbox.js index 0d9c362f1..ea417927f 100644 --- a/core/field_checkbox.js +++ b/core/field_checkbox.js @@ -60,9 +60,6 @@ Blockly.FieldCheckbox = function(opt_value, opt_validator, opt_config) { } Blockly.FieldCheckbox.superClass_.constructor.call( this, opt_value, opt_validator, opt_config); - - this.size_.width = Blockly.FieldCheckbox.WIDTH; - }; Blockly.utils.object.inherits(Blockly.FieldCheckbox, Blockly.Field); @@ -77,13 +74,6 @@ Blockly.FieldCheckbox.fromJson = function(options) { return new Blockly.FieldCheckbox(options['checked'], undefined, options); }; -/** - * The width of a checkbox field. - * @type {number} - * @const - */ -Blockly.FieldCheckbox.WIDTH = 15; - /** * Default character for the checkmark. * @type {string} @@ -129,6 +119,7 @@ Blockly.FieldCheckbox.prototype.configure_ = function(config) { * @package */ Blockly.FieldCheckbox.prototype.initView = function() { + this.size_.width = this.constants_.FIELD_CHECKBOX_DEFAULT_WIDTH; Blockly.FieldCheckbox.superClass_.initView.call(this); this.textElement_.setAttribute('x', this.constants_.FIELD_CHECKBOX_X_OFFSET); diff --git a/core/renderers/common/constants.js b/core/renderers/common/constants.js index 4f3c2dcee..68e4294ca 100644 --- a/core/renderers/common/constants.js +++ b/core/renderers/common/constants.js @@ -360,6 +360,12 @@ Blockly.blockRendering.ConstantProvider = function() { */ this.FIELD_CHECKBOX_Y_OFFSET = 14; + /** + * A checkbox field's default width. + * @type {number} + */ + this.FIELD_CHECKBOX_DEFAULT_WIDTH = 15; + /** * The ID of the emboss filter, or the empty string if no filter is set. * @type {string} diff --git a/core/renderers/zelos/constants.js b/core/renderers/zelos/constants.js index fa33df775..67f6b18be 100644 --- a/core/renderers/zelos/constants.js +++ b/core/renderers/zelos/constants.js @@ -318,6 +318,21 @@ Blockly.zelos.ConstantProvider = function() { */ this.FIELD_COLOUR_DEFAULT_HEIGHT = 4 * this.GRID_UNIT; + /** + * @override + */ + this.FIELD_CHECKBOX_X_OFFSET = this.FIELD_BORDER_RECT_X_PADDING - 3; + + /** + * @override + */ + this.FIELD_CHECKBOX_Y_OFFSET = 22; + + /** + * @override + */ + this.FIELD_CHECKBOX_DEFAULT_WIDTH = 6 * this.GRID_UNIT; + /** * The ID of the highlight glow filter, or the empty string if no filter is * set.