Commit b36a88f4 authored by Neil Fraser's avatar Neil Fraser

Fix bad rendering of collapsed function calls.

parent d05177e1
...@@ -273,7 +273,7 @@ Blockly.Blocks['procedures_defnoreturn'] = { ...@@ -273,7 +273,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
if (change) { if (change) {
this.updateParams_(); this.updateParams_();
// Update the mutator's variables if the mutator is open. // Update the mutator's variables if the mutator is open.
if (this.mutator.isVisible_()) { if (this.mutator.isVisible()) {
var blocks = this.mutator.workspace_.getAllBlocks(); var blocks = this.mutator.workspace_.getAllBlocks();
for (var i = 0, block; block = blocks[i]; i++) { for (var i = 0, block; block = blocks[i]; i++) {
if (block.type == 'procedures_mutatorarg' && if (block.type == 'procedures_mutatorarg' &&
...@@ -428,10 +428,9 @@ Blockly.Blocks['procedures_callnoreturn'] = { ...@@ -428,10 +428,9 @@ Blockly.Blocks['procedures_callnoreturn'] = {
init: function() { init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL); this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE); this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput() this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL) .appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL)
.appendField('', 'NAME') .appendField('', 'NAME');
.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
this.setPreviousStatement(true); this.setPreviousStatement(true);
this.setNextStatement(true); this.setNextStatement(true);
// Tooltip is set in domToMutation. // Tooltip is set in domToMutation.
...@@ -488,6 +487,12 @@ Blockly.Blocks['procedures_callnoreturn'] = { ...@@ -488,6 +487,12 @@ Blockly.Blocks['procedures_callnoreturn'] = {
this.quarkArguments_ = null; this.quarkArguments_ = null;
return; return;
} }
if (goog.array.equals(this.arguments_, paramNames)) {
// No change.
this.quarkArguments_ = paramIds;
return;
}
this.setCollapsed(false);
if (paramIds.length != paramNames.length) { if (paramIds.length != paramNames.length) {
throw 'Error: paramNames and paramIds must be the same length.'; throw 'Error: paramNames and paramIds must be the same length.';
} }
...@@ -536,14 +541,21 @@ Blockly.Blocks['procedures_callnoreturn'] = { ...@@ -536,14 +541,21 @@ Blockly.Blocks['procedures_callnoreturn'] = {
} }
} }
} }
if (savedRendered) {
input.init(); input.init();
} }
}
// Add 'with:' if there are parameters. // Add 'with:' if there are parameters.
var withField = this.getField_('WITH'); var input = this.getInput('TOPROW');
if (withField) { if (input) {
withField.setVisible(!!this.arguments_.length); if (this.arguments_.length) {
if (!this.getField_('WITH')) {
input.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
input.init();
}
} else {
if (this.getField_('WITH')) {
input.removeField('WITH');
}
}
} }
// Restore rendering and show the changes. // Restore rendering and show the changes.
this.rendered = savedRendered; this.rendered = savedRendered;
...@@ -578,7 +590,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { ...@@ -578,7 +590,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
(this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP : (this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP :
Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace('%1', name)); Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace('%1', name));
var def = Blockly.Procedures.getDefinition(name, this.workspace); var def = Blockly.Procedures.getDefinition(name, this.workspace);
if (def && def.mutator.isVisible()) { if (def && def.mutator && def.mutator.isVisible()) {
// Initialize caller with the mutator's IDs. // Initialize caller with the mutator's IDs.
this.setProcedureParameters(def.arguments_, def.paramIds_); this.setProcedureParameters(def.arguments_, def.paramIds_);
} else { } else {
...@@ -634,10 +646,9 @@ Blockly.Blocks['procedures_callreturn'] = { ...@@ -634,10 +646,9 @@ Blockly.Blocks['procedures_callreturn'] = {
init: function() { init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL); this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE); this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput() this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL) .appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL)
.appendField('', 'NAME') .appendField('', 'NAME');
.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
this.setOutput(true); this.setOutput(true);
// Tooltip is set in domToMutation. // Tooltip is set in domToMutation.
this.arguments_ = []; this.arguments_ = [];
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment