mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Editable field spacing (#3635)
* Substituting checks for isEditable. * Add isField checks. * Add parentheses for casting. * Update value of isEditable and use for spacing. * Changing to double equals.
This commit is contained in:
@@ -172,7 +172,8 @@ Blockly.geras.RenderInfo.prototype.addElemSpacing_ = function() {
|
||||
Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
if (!prev) {
|
||||
// Between an editable field and the beginning of the row.
|
||||
if (next && Blockly.blockRendering.Types.isField(next) && next.isEditable) {
|
||||
if (next && Blockly.blockRendering.Types.isField(next) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (next)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
}
|
||||
// Inline input at the beginning of the row.
|
||||
@@ -190,7 +191,8 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) && (!next ||
|
||||
Blockly.blockRendering.Types.isStatementInput(next))) {
|
||||
// Between an editable field and the end of the row.
|
||||
if (Blockly.blockRendering.Types.isField(prev) && prev.isEditable) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (prev)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
}
|
||||
// Padding at the end of an icon-only row to make the block shape clearer.
|
||||
@@ -231,7 +233,8 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) &&
|
||||
next && Blockly.blockRendering.Types.isInput(next)) {
|
||||
// Between an editable field and an input.
|
||||
if (prev.isEditable) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (prev)).isEditable) {
|
||||
if (Blockly.blockRendering.Types.isInlineInput(next)) {
|
||||
return this.constants_.SMALL_PADDING;
|
||||
} else if (Blockly.blockRendering.Types.isExternalInput(next)) {
|
||||
@@ -257,9 +260,9 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
|
||||
// Spacing between an inline input and a field.
|
||||
if (Blockly.blockRendering.Types.isInlineInput(prev) &&
|
||||
next && !Blockly.blockRendering.Types.isInput(next)) {
|
||||
next && Blockly.blockRendering.Types.isField(next)) {
|
||||
// Editable field after inline input.
|
||||
if (next.isEditable) {
|
||||
if ((/** @type Blockly.blockRendering.Field */ (next)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
} else {
|
||||
// Noneditable field after inline input.
|
||||
@@ -298,9 +301,10 @@ Blockly.geras.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
}
|
||||
|
||||
// Spacing between two fields of the same editability.
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) &&
|
||||
next && !Blockly.blockRendering.Types.isInput(next) &&
|
||||
(prev.isEditable == next.isEditable)) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
next && Blockly.blockRendering.Types.isField(next) &&
|
||||
((/** @type Blockly.blockRendering.Field */ (prev)).isEditable ==
|
||||
(/** @type Blockly.blockRendering.Field */ (next)).isEditable)) {
|
||||
return this.constants_.LARGE_PADDING;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ Blockly.utils.object.inherits(Blockly.blockRendering.JaggedEdge,
|
||||
Blockly.blockRendering.Field = function(constants, field, parentInput) {
|
||||
Blockly.blockRendering.Field.superClass_.constructor.call(this, constants);
|
||||
this.field = field;
|
||||
this.isEditable = field.isCurrentlyEditable();
|
||||
this.isEditable = field.EDITABLE;
|
||||
this.flipRtl = field.getFlipRtl();
|
||||
this.type |= Blockly.blockRendering.Types.FIELD;
|
||||
|
||||
|
||||
@@ -114,7 +114,8 @@ Blockly.thrasos.RenderInfo.prototype.addElemSpacing_ = function() {
|
||||
Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
if (!prev) {
|
||||
// Between an editable field and the beginning of the row.
|
||||
if (next && Blockly.blockRendering.Types.isField(next) && next.isEditable) {
|
||||
if (next && Blockly.blockRendering.Types.isField(next) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (next)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
}
|
||||
// Inline input at the beginning of the row.
|
||||
@@ -131,7 +132,8 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
// Spacing between a non-input and the end of the row.
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) && !next) {
|
||||
// Between an editable field and the end of the row.
|
||||
if (Blockly.blockRendering.Types.isField(prev) && prev.isEditable) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (prev)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
}
|
||||
// Padding at the end of an icon-only row to make the block shape clearer.
|
||||
@@ -172,7 +174,8 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) &&
|
||||
next && Blockly.blockRendering.Types.isInput(next)) {
|
||||
// Between an editable field and an input.
|
||||
if (prev.isEditable) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
(/** @type Blockly.blockRendering.Field */ (prev)).isEditable) {
|
||||
if (Blockly.blockRendering.Types.isInlineInput(next)) {
|
||||
return this.constants_.SMALL_PADDING;
|
||||
} else if (Blockly.blockRendering.Types.isExternalInput(next)) {
|
||||
@@ -198,9 +201,9 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
|
||||
// Spacing between an inline input and a field.
|
||||
if (Blockly.blockRendering.Types.isInlineInput(prev) &&
|
||||
next && !Blockly.blockRendering.Types.isInput(next)) {
|
||||
next && Blockly.blockRendering.Types.isField(next)) {
|
||||
// Editable field after inline input.
|
||||
if (next.isEditable) {
|
||||
if ((/** @type Blockly.blockRendering.Field */ (next)).isEditable) {
|
||||
return this.constants_.MEDIUM_PADDING;
|
||||
} else {
|
||||
// Noneditable field after inline input.
|
||||
@@ -226,9 +229,10 @@ Blockly.thrasos.RenderInfo.prototype.getInRowSpacing_ = function(prev, next) {
|
||||
}
|
||||
|
||||
// Spacing between two fields of the same editability.
|
||||
if (!Blockly.blockRendering.Types.isInput(prev) &&
|
||||
next && !Blockly.blockRendering.Types.isInput(next) &&
|
||||
(prev.isEditable == next.isEditable)) {
|
||||
if (Blockly.blockRendering.Types.isField(prev) &&
|
||||
next && Blockly.blockRendering.Types.isField(next) &&
|
||||
((/** @type Blockly.blockRendering.Field */ (prev)).isEditable ==
|
||||
(/** @type Blockly.blockRendering.Field */ (next)).isEditable)) {
|
||||
return this.constants_.LARGE_PADDING;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user