Making all blocks use the MSG colour values. (#1749)

* Making all blocks use the MSG colour values.
 * Deprecating Blockly.Constants.Lists.HUE and similar constants.
 * Removing deprecated Blockly.Blocks.lists.HUE constants.
 * Allowing message references in the Block.setColour() parameter.
 * Adding checking of older constants, ensuring they are not overwritten.
This commit is contained in:
Andrew n marshall
2018-04-09 17:37:47 -07:00
committed by GitHub
parent d3a9d96841
commit e9d8e00a55
12 changed files with 134 additions and 79 deletions

View File

@@ -37,13 +37,10 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* This should be the same as Blockly.Msg.COLOUR_HUE.
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.COLOUR_HUE. (2018 April 5)
*/
Blockly.Constants.Colour.HUE = 20;
/** @deprecated Use Blockly.Constants.Colour.HUE */
Blockly.Blocks.colour.HUE = Blockly.Constants.Colour.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for colour picker.

View File

@@ -35,16 +35,11 @@ goog.provide('Blockly.Constants.Lists');
goog.require('Blockly.Blocks');
goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* This should be the same as Blockly.Msg.LISTS_HUE.
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.LISTS_HUE. (2018 April 5)
*/
Blockly.Constants.Lists.HUE = 260;
/** @deprecated Use Blockly.Constants.Lists.HUE */
Blockly.Blocks.lists.HUE = Blockly.Constants.Lists.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for creating an empty list
@@ -138,7 +133,7 @@ Blockly.Blocks['lists_create_with'] = {
*/
init: function() {
this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.itemCount_ = 3;
this.updateShape_();
this.setOutput(true, 'Array');
@@ -261,7 +256,7 @@ Blockly.Blocks['lists_create_with_container'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);
this.appendStatementInput('STACK');
@@ -276,7 +271,7 @@ Blockly.Blocks['lists_create_with_item'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
this.setPreviousStatement(true);
@@ -298,7 +293,7 @@ Blockly.Blocks['lists_indexOf'] = {
[Blockly.Msg.LISTS_INDEX_OF_LAST, 'LAST']
];
this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.setOutput(true, 'Number');
this.appendValueInput('VALUE')
.setCheck('Array')
@@ -336,7 +331,7 @@ Blockly.Blocks['lists_getIndex'] = {
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']
];
this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
var isStatement = (value == 'REMOVE');
this.sourceBlock_.updateStatement_(isStatement);
@@ -520,7 +515,7 @@ Blockly.Blocks['lists_setIndex'] = {
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']
];
this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.appendValueInput('LIST')
.setCheck('Array')
.appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
@@ -659,7 +654,7 @@ Blockly.Blocks['lists_getSublist'] = {
[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST, 'LAST']
];
this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.appendValueInput('LIST')
.setCheck('Array')
.appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);
@@ -784,7 +779,7 @@ Blockly.Blocks['lists_sort'] = {
}
],
"output": "Array",
"colour": Blockly.Blocks.lists.HUE,
"colour": Blockly.Msg.LISTS_HUE,
"tooltip": Blockly.Msg.LISTS_SORT_TOOLTIP,
"helpUrl": Blockly.Msg.LISTS_SORT_HELPURL
});
@@ -808,7 +803,7 @@ Blockly.Blocks['lists_split'] = {
thisBlock.updateType_(newMode);
});
this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);
this.setColour(Blockly.Blocks.lists.HUE);
this.setColour(Blockly.Msg.LISTS_HUE);
this.appendValueInput('INPUT')
.setCheck('String')
.appendField(dropdown, 'MODE');

View File

@@ -35,15 +35,11 @@ goog.provide('Blockly.Constants.Logic');
goog.require('Blockly.Blocks');
goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.LOGIC_HUE.
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.LOGIC_HUE. (2018 April 5)
*/
Blockly.Constants.Logic.HUE = 210;
/** @deprecated Use Blockly.Constants.Logic.HUE */
Blockly.Blocks.logic.HUE = Blockly.Constants.Logic.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for boolean data type: true and false.

View File

@@ -37,13 +37,10 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.LOOPS_HUE
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.LOOPS_HUE. (2018 April 5)
*/
Blockly.Constants.Loops.HUE = 120;
/** @deprecated Use Blockly.Constants.Loops.HUE */
Blockly.Blocks.loops.HUE = Blockly.Constants.Loops.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for repeat n times (external number).

View File

@@ -37,13 +37,10 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.MATH_HUE
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.MATH_HUE. (2018 April 5)
*/
Blockly.Constants.Math.HUE = 230;
/** @deprecated Use Blockly.Constants.Math.HUE */
Blockly.Blocks.math.HUE = Blockly.Constants.Math.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for numeric value.

View File

@@ -30,11 +30,6 @@ goog.require('Blockly.Blocks');
goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.procedures.HUE = 290;
Blockly.Blocks['procedures_defnoreturn'] = {
/**
* Block for defining a procedure with no return value.
@@ -55,7 +50,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT) {
this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);
}
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.arguments_ = [];
@@ -415,7 +410,7 @@ Blockly.Blocks['procedures_defreturn'] = {
Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT) {
this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);
}
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.arguments_ = [];
@@ -461,7 +456,7 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
this.appendDummyInput('STATEMENT_INPUT')
.appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
this.contextMenu = false;
}
@@ -488,7 +483,7 @@ Blockly.Blocks['procedures_mutatorarg'] = {
.appendField(field, 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
this.contextMenu = false;
@@ -561,7 +556,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
.appendField(this.id, 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
// Tooltip is set in renameProcedure.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.arguments_ = [];
@@ -879,7 +874,7 @@ Blockly.Blocks['procedures_callreturn'] = {
this.appendDummyInput('TOPROW')
.appendField('', 'NAME');
this.setOutput(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
// Tooltip is set in domToMutation.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.arguments_ = [];
@@ -914,7 +909,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setColour(Blockly.Msg.PROCEDURES_HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);
this.hasReturnValue_ = true;

View File

@@ -32,13 +32,10 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.TEXTS_HUE
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.TEXTS_HUE. (2018 April 5)
*/
Blockly.Constants.Text.HUE = 160;
/** @deprecated Use Blockly.Constants.Text.HUE */
Blockly.Blocks.texts.HUE = Blockly.Constants.Text.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for text value
@@ -224,7 +221,7 @@ Blockly.Blocks['text_getSubstring'] = {
[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST, 'LAST']
];
this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);
this.setColour(Blockly.Blocks.texts.HUE);
this.setColour(Blockly.Msg.TEXTS_HUE);
this.appendValueInput('STRING')
.setCheck('String')
.appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);
@@ -332,7 +329,7 @@ Blockly.Blocks['text_changeCase'] = {
[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, 'TITLECASE']
];
this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);
this.setColour(Blockly.Blocks.texts.HUE);
this.setColour(Blockly.Msg.TEXTS_HUE);
this.appendValueInput('TEXT')
.setCheck('String')
.appendField(new Blockly.FieldDropdown(OPERATORS), 'CASE');
@@ -353,7 +350,7 @@ Blockly.Blocks['text_trim'] = {
[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT, 'RIGHT']
];
this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);
this.setColour(Blockly.Blocks.texts.HUE);
this.setColour(Blockly.Msg.TEXTS_HUE);
this.appendValueInput('TEXT')
.setCheck('String')
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
@@ -378,7 +375,7 @@ Blockly.Blocks['text_print'] = {
],
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Blocks.texts.HUE,
"colour": Blockly.Msg.TEXTS_HUE,
"tooltip": Blockly.Msg.TEXT_PRINT_TOOLTIP,
"helpUrl": Blockly.Msg.TEXT_PRINT_HELPURL
});
@@ -396,7 +393,7 @@ Blockly.Blocks['text_prompt_ext'] = {
[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, 'NUMBER']
];
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
this.setColour(Blockly.Blocks.texts.HUE);
this.setColour(Blockly.Msg.TEXTS_HUE);
// Assign 'this' to a variable for use in the closures below.
var thisBlock = this;
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
@@ -456,7 +453,7 @@ Blockly.Blocks['text_prompt'] = {
// Assign 'this' to a variable for use in the closures below.
var thisBlock = this;
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
this.setColour(Blockly.Blocks.texts.HUE);
this.setColour(Blockly.Msg.TEXTS_HUE);
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
thisBlock.updateType_(newOp);
});
@@ -499,7 +496,7 @@ Blockly.Blocks['text_count'] = {
],
"output": "Number",
"inputsInline": true,
"colour": Blockly.Blocks.texts.HUE,
"colour": Blockly.Msg.TEXTS_HUE,
"tooltip": Blockly.Msg.TEXT_COUNT_TOOLTIP,
"helpUrl": Blockly.Msg.TEXT_COUNT_HELPURL
});
@@ -533,7 +530,7 @@ Blockly.Blocks['text_replace'] = {
],
"output": "String",
"inputsInline": true,
"colour": Blockly.Blocks.texts.HUE,
"colour": Blockly.Msg.TEXTS_HUE,
"tooltip": Blockly.Msg.TEXT_REPLACE_TOOLTIP,
"helpUrl": Blockly.Msg.TEXT_REPLACE_HELPURL
});
@@ -557,7 +554,7 @@ Blockly.Blocks['text_reverse'] = {
],
"output": "String",
"inputsInline": true,
"colour": Blockly.Blocks.texts.HUE,
"colour": Blockly.Msg.TEXTS_HUE,
"tooltip": Blockly.Msg.TEXT_REVERSE_TOOLTIP,
"helpUrl": Blockly.Msg.TEXT_REVERSE_HELPURL
});

View File

@@ -37,13 +37,10 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.VARIABLES_HUE.
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.VARIABLES_HUE. (2018 April 5)
*/
Blockly.Constants.Variables.HUE = 330;
/** @deprecated Use Blockly.Constants.Variables.HUE */
Blockly.Blocks.variables.HUE = Blockly.Constants.Variables.HUE;
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
// Block for variable getter.

View File

@@ -36,9 +36,8 @@ goog.require('Blockly');
/**
* Common HSV hue for all blocks in this category.
* Should be the same as Blockly.Msg.VARIABLES_DYNAMIC_HUE.
* @readonly
* Unused constant for the common HSV hue for all blocks in this category.
* @deprecated Use Blockly.Msg.VARIABLES_DYNAMIC_HUE. (2018 April 5)
*/
Blockly.Constants.VariablesDynamic.HUE = 310;