Skip to content

Commit

Permalink
Addres feedback, fix endrow after external value.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnesky committed Aug 11, 2023
1 parent 9bbdd39 commit 78f999f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ export class Block implements IASTNodeLocation, IDeletable {
json['message' + i],
json['args' + i] || [],
// Backwards compatibility: lastDummyAlign aliases implicitAlign.
json['lastDummyAlign' + i] || json['implicitAlign' + i],
json['implicitAlign' + i] || json['lastDummyAlign' + i],
warningPrefix,
);
i++;
Expand Down
13 changes: 9 additions & 4 deletions core/renderers/common/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ export class RenderInfo {
activeRow.elements.push(new ExternalValueInput(this.constants_, input));
activeRow.hasExternalInput = true;
} else if (input instanceof DummyInput || input instanceof EndRowInput) {
// Dummy inputs have no visual representation, but the information is
// still important.
// Dummy and end-row inputs have no visual representation, but the
// information is still important.
activeRow.minHeight = Math.max(
activeRow.minHeight,
input.getSourceBlock() && input.getSourceBlock()!.isShadow()
Expand Down Expand Up @@ -368,8 +368,13 @@ export class RenderInfo {
) {
return true;
}
// Value and dummy inputs get new row if inputs are not inlined.
if (input instanceof ValueInput || input instanceof DummyInput) {
// Value inputs, dummy inputs, and any input following an external value
// input get a new row if inputs are not inlined.
if (
input instanceof ValueInput ||
input instanceof DummyInput ||
lastInput instanceof ValueInput
) {
return !this.isInline;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions core/renderers/geras/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export class RenderInfo extends BaseRenderInfo {
activeRow.elements.push(new ExternalValueInput(this.constants_, input));
activeRow.hasExternalInput = true;
} else if (input instanceof DummyInput || input instanceof EndRowInput) {
// Dummy inputs have no visual representation, but the information is
// still important.
// Dummy and end-row inputs have no visual representation, but the
// information is still important.
activeRow.minHeight = Math.max(
activeRow.minHeight,
this.constants_.DUMMY_INPUT_MIN_HEIGHT,
Expand Down Expand Up @@ -383,8 +383,8 @@ export class RenderInfo extends BaseRenderInfo {
} else if (row.hasStatement) {
nextRightEdge = row.width;
} else {
// To avoid jagged right edges along consecutive non-statement rows,
// use the maximum width.
// To keep right edges of consecutive non-statement rows aligned, use
// the maximum width.
nextRightEdge = Math.max(nextRightEdge, row.width);
}
prevInput = row;
Expand Down
8 changes: 6 additions & 2 deletions core/renderers/zelos/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ export class RenderInfo extends BaseRenderInfo {
) {
return true;
}
// Value and dummy inputs get new row if inputs are not inlined.
if (input instanceof ValueInput || input instanceof DummyInput) {
// Value, dummy, and end-row inputs get new row if inputs are not inlined.
if (
input instanceof ValueInput ||
input instanceof DummyInput ||
input instanceof EndRowInput
) {
return !this.isInline || this.isMultiRow;
}
return false;
Expand Down
13 changes: 7 additions & 6 deletions demos/blockfactory/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ Blockly.Blocks['input_dummy'] = {
"previousStatement": "Input",
"nextStatement": "Input",
"colour": 210,
"tooltip": "For adding fields on a separate row with no " +
"connections. Alignment options (left, right, centre) " +
"apply only to multi-line fields.",
"tooltip": "For adding fields without any block connections." +
"Alignment options (left, right, centre) only affect " +
"multi-row blocks.",
"helpUrl": "https://www.youtube.com/watch?v=s2_xaEvcVI0#t=293"
});
}
Expand All @@ -238,9 +238,10 @@ Blockly.Blocks['input_end_row'] = {
"previousStatement": "Input",
"nextStatement": "Input",
"colour": 210,
"tooltip": "For adding fields at the end of a row with no " +
"connections. Alignment options (left, right, centre) " +
"apply only to multi-line fields.",
"tooltip": "For adding fields without any block connections that will " +
"be rendered on a separate row from any following inputs. " +
"Alignment options (left, right, centre) only affect " +
"multi-row blocks.",
"helpUrl": "https://developers.google.com/blockly/guides/create-custom-blocks/define-blocks#block_inputs"
});
}
Expand Down
2 changes: 1 addition & 1 deletion demos/blockfactory/factory_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ FactoryUtils.formatJson_ = function(blockType, rootBlock) {
if (fields && FactoryUtils.getFieldsJson_(fields).join('').trim() !== '') {
var align = lastInput.getFieldValue('ALIGN');
if (align !== 'LEFT') {
JS.lastDummyAlign0 = align;
JS.implicitAlign0 = align;
}
args.pop();
message.pop();
Expand Down

0 comments on commit 78f999f

Please sign in to comment.