Make checkbox field width a constant. (#3499)

This commit is contained in:
Sam El-Husseini
2019-12-10 08:32:26 -08:00
committed by GitHub
parent 63f7af115c
commit 8cbec2eaee
3 changed files with 22 additions and 10 deletions

View File

@@ -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);

View File

@@ -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}

View File

@@ -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.