Skip to content

Commit e9d8e00

Browse files
authored
Making all blocks use the MSG colour values. (RaspberryPiFoundation#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.
1 parent d3a9d96 commit e9d8e00

12 files changed

Lines changed: 134 additions & 79 deletions

File tree

blocks/colour.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ goog.require('Blockly');
3737

3838

3939
/**
40-
* Common HSV hue for all blocks in this category.
41-
* This should be the same as Blockly.Msg.COLOUR_HUE.
42-
* @readonly
40+
* Unused constant for the common HSV hue for all blocks in this category.
41+
* @deprecated Use Blockly.Msg.COLOUR_HUE. (2018 April 5)
4342
*/
4443
Blockly.Constants.Colour.HUE = 20;
45-
/** @deprecated Use Blockly.Constants.Colour.HUE */
46-
Blockly.Blocks.colour.HUE = Blockly.Constants.Colour.HUE;
4744

4845
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4946
// Block for colour picker.

blocks/lists.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ goog.provide('Blockly.Constants.Lists');
3535
goog.require('Blockly.Blocks');
3636
goog.require('Blockly');
3737

38-
3938
/**
40-
* Common HSV hue for all blocks in this category.
41-
* This should be the same as Blockly.Msg.LISTS_HUE.
42-
* @readonly
39+
* Unused constant for the common HSV hue for all blocks in this category.
40+
* @deprecated Use Blockly.Msg.LISTS_HUE. (2018 April 5)
4341
*/
4442
Blockly.Constants.Lists.HUE = 260;
45-
/** @deprecated Use Blockly.Constants.Lists.HUE */
46-
Blockly.Blocks.lists.HUE = Blockly.Constants.Lists.HUE;
47-
4843

4944
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
5045
// Block for creating an empty list
@@ -138,7 +133,7 @@ Blockly.Blocks['lists_create_with'] = {
138133
*/
139134
init: function() {
140135
this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
141-
this.setColour(Blockly.Blocks.lists.HUE);
136+
this.setColour(Blockly.Msg.LISTS_HUE);
142137
this.itemCount_ = 3;
143138
this.updateShape_();
144139
this.setOutput(true, 'Array');
@@ -261,7 +256,7 @@ Blockly.Blocks['lists_create_with_container'] = {
261256
* @this Blockly.Block
262257
*/
263258
init: function() {
264-
this.setColour(Blockly.Blocks.lists.HUE);
259+
this.setColour(Blockly.Msg.LISTS_HUE);
265260
this.appendDummyInput()
266261
.appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);
267262
this.appendStatementInput('STACK');
@@ -276,7 +271,7 @@ Blockly.Blocks['lists_create_with_item'] = {
276271
* @this Blockly.Block
277272
*/
278273
init: function() {
279-
this.setColour(Blockly.Blocks.lists.HUE);
274+
this.setColour(Blockly.Msg.LISTS_HUE);
280275
this.appendDummyInput()
281276
.appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);
282277
this.setPreviousStatement(true);
@@ -298,7 +293,7 @@ Blockly.Blocks['lists_indexOf'] = {
298293
[Blockly.Msg.LISTS_INDEX_OF_LAST, 'LAST']
299294
];
300295
this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);
301-
this.setColour(Blockly.Blocks.lists.HUE);
296+
this.setColour(Blockly.Msg.LISTS_HUE);
302297
this.setOutput(true, 'Number');
303298
this.appendValueInput('VALUE')
304299
.setCheck('Array')
@@ -336,7 +331,7 @@ Blockly.Blocks['lists_getIndex'] = {
336331
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']
337332
];
338333
this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);
339-
this.setColour(Blockly.Blocks.lists.HUE);
334+
this.setColour(Blockly.Msg.LISTS_HUE);
340335
var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
341336
var isStatement = (value == 'REMOVE');
342337
this.sourceBlock_.updateStatement_(isStatement);
@@ -520,7 +515,7 @@ Blockly.Blocks['lists_setIndex'] = {
520515
[Blockly.Msg.LISTS_GET_INDEX_RANDOM, 'RANDOM']
521516
];
522517
this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);
523-
this.setColour(Blockly.Blocks.lists.HUE);
518+
this.setColour(Blockly.Msg.LISTS_HUE);
524519
this.appendValueInput('LIST')
525520
.setCheck('Array')
526521
.appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
@@ -659,7 +654,7 @@ Blockly.Blocks['lists_getSublist'] = {
659654
[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST, 'LAST']
660655
];
661656
this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);
662-
this.setColour(Blockly.Blocks.lists.HUE);
657+
this.setColour(Blockly.Msg.LISTS_HUE);
663658
this.appendValueInput('LIST')
664659
.setCheck('Array')
665660
.appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);
@@ -784,7 +779,7 @@ Blockly.Blocks['lists_sort'] = {
784779
}
785780
],
786781
"output": "Array",
787-
"colour": Blockly.Blocks.lists.HUE,
782+
"colour": Blockly.Msg.LISTS_HUE,
788783
"tooltip": Blockly.Msg.LISTS_SORT_TOOLTIP,
789784
"helpUrl": Blockly.Msg.LISTS_SORT_HELPURL
790785
});
@@ -808,7 +803,7 @@ Blockly.Blocks['lists_split'] = {
808803
thisBlock.updateType_(newMode);
809804
});
810805
this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);
811-
this.setColour(Blockly.Blocks.lists.HUE);
806+
this.setColour(Blockly.Msg.LISTS_HUE);
812807
this.appendValueInput('INPUT')
813808
.setCheck('String')
814809
.appendField(dropdown, 'MODE');

blocks/logic.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ goog.provide('Blockly.Constants.Logic');
3535
goog.require('Blockly.Blocks');
3636
goog.require('Blockly');
3737

38-
3938
/**
40-
* Common HSV hue for all blocks in this category.
41-
* Should be the same as Blockly.Msg.LOGIC_HUE.
42-
* @readonly
39+
* Unused constant for the common HSV hue for all blocks in this category.
40+
* @deprecated Use Blockly.Msg.LOGIC_HUE. (2018 April 5)
4341
*/
4442
Blockly.Constants.Logic.HUE = 210;
45-
/** @deprecated Use Blockly.Constants.Logic.HUE */
46-
Blockly.Blocks.logic.HUE = Blockly.Constants.Logic.HUE;
4743

4844
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4945
// Block for boolean data type: true and false.

blocks/loops.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ goog.require('Blockly');
3737

3838

3939
/**
40-
* Common HSV hue for all blocks in this category.
41-
* Should be the same as Blockly.Msg.LOOPS_HUE
42-
* @readonly
40+
* Unused constant for the common HSV hue for all blocks in this category.
41+
* @deprecated Use Blockly.Msg.LOOPS_HUE. (2018 April 5)
4342
*/
4443
Blockly.Constants.Loops.HUE = 120;
45-
/** @deprecated Use Blockly.Constants.Loops.HUE */
46-
Blockly.Blocks.loops.HUE = Blockly.Constants.Loops.HUE;
4744

4845
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4946
// Block for repeat n times (external number).

blocks/math.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ goog.require('Blockly');
3737

3838

3939
/**
40-
* Common HSV hue for all blocks in this category.
41-
* Should be the same as Blockly.Msg.MATH_HUE
42-
* @readonly
40+
* Unused constant for the common HSV hue for all blocks in this category.
41+
* @deprecated Use Blockly.Msg.MATH_HUE. (2018 April 5)
4342
*/
4443
Blockly.Constants.Math.HUE = 230;
45-
/** @deprecated Use Blockly.Constants.Math.HUE */
46-
Blockly.Blocks.math.HUE = Blockly.Constants.Math.HUE;
4744

4845
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4946
// Block for numeric value.

blocks/procedures.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ goog.require('Blockly.Blocks');
3030
goog.require('Blockly');
3131

3232

33-
/**
34-
* Common HSV hue for all blocks in this category.
35-
*/
36-
Blockly.Blocks.procedures.HUE = 290;
37-
3833
Blockly.Blocks['procedures_defnoreturn'] = {
3934
/**
4035
* Block for defining a procedure with no return value.
@@ -55,7 +50,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
5550
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT) {
5651
this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);
5752
}
58-
this.setColour(Blockly.Blocks.procedures.HUE);
53+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
5954
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
6055
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
6156
this.arguments_ = [];
@@ -415,7 +410,7 @@ Blockly.Blocks['procedures_defreturn'] = {
415410
Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT) {
416411
this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);
417412
}
418-
this.setColour(Blockly.Blocks.procedures.HUE);
413+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
419414
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);
420415
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
421416
this.arguments_ = [];
@@ -461,7 +456,7 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
461456
this.appendDummyInput('STATEMENT_INPUT')
462457
.appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
463458
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
464-
this.setColour(Blockly.Blocks.procedures.HUE);
459+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
465460
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
466461
this.contextMenu = false;
467462
}
@@ -488,7 +483,7 @@ Blockly.Blocks['procedures_mutatorarg'] = {
488483
.appendField(field, 'NAME');
489484
this.setPreviousStatement(true);
490485
this.setNextStatement(true);
491-
this.setColour(Blockly.Blocks.procedures.HUE);
486+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
492487
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
493488
this.contextMenu = false;
494489

@@ -561,7 +556,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
561556
.appendField(this.id, 'NAME');
562557
this.setPreviousStatement(true);
563558
this.setNextStatement(true);
564-
this.setColour(Blockly.Blocks.procedures.HUE);
559+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
565560
// Tooltip is set in renameProcedure.
566561
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
567562
this.arguments_ = [];
@@ -879,7 +874,7 @@ Blockly.Blocks['procedures_callreturn'] = {
879874
this.appendDummyInput('TOPROW')
880875
.appendField('', 'NAME');
881876
this.setOutput(true);
882-
this.setColour(Blockly.Blocks.procedures.HUE);
877+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
883878
// Tooltip is set in domToMutation.
884879
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
885880
this.arguments_ = [];
@@ -914,7 +909,7 @@ Blockly.Blocks['procedures_ifreturn'] = {
914909
this.setInputsInline(true);
915910
this.setPreviousStatement(true);
916911
this.setNextStatement(true);
917-
this.setColour(Blockly.Blocks.procedures.HUE);
912+
this.setColour(Blockly.Msg.PROCEDURES_HUE);
918913
this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
919914
this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);
920915
this.hasReturnValue_ = true;

blocks/text.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ goog.require('Blockly');
3232

3333

3434
/**
35-
* Common HSV hue for all blocks in this category.
36-
* Should be the same as Blockly.Msg.TEXTS_HUE
37-
* @readonly
35+
* Unused constant for the common HSV hue for all blocks in this category.
36+
* @deprecated Use Blockly.Msg.TEXTS_HUE. (2018 April 5)
3837
*/
3938
Blockly.Constants.Text.HUE = 160;
40-
/** @deprecated Use Blockly.Constants.Text.HUE */
41-
Blockly.Blocks.texts.HUE = Blockly.Constants.Text.HUE;
4239

4340
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4441
// Block for text value
@@ -224,7 +221,7 @@ Blockly.Blocks['text_getSubstring'] = {
224221
[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST, 'LAST']
225222
];
226223
this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);
227-
this.setColour(Blockly.Blocks.texts.HUE);
224+
this.setColour(Blockly.Msg.TEXTS_HUE);
228225
this.appendValueInput('STRING')
229226
.setCheck('String')
230227
.appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);
@@ -332,7 +329,7 @@ Blockly.Blocks['text_changeCase'] = {
332329
[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE, 'TITLECASE']
333330
];
334331
this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);
335-
this.setColour(Blockly.Blocks.texts.HUE);
332+
this.setColour(Blockly.Msg.TEXTS_HUE);
336333
this.appendValueInput('TEXT')
337334
.setCheck('String')
338335
.appendField(new Blockly.FieldDropdown(OPERATORS), 'CASE');
@@ -353,7 +350,7 @@ Blockly.Blocks['text_trim'] = {
353350
[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT, 'RIGHT']
354351
];
355352
this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);
356-
this.setColour(Blockly.Blocks.texts.HUE);
353+
this.setColour(Blockly.Msg.TEXTS_HUE);
357354
this.appendValueInput('TEXT')
358355
.setCheck('String')
359356
.appendField(new Blockly.FieldDropdown(OPERATORS), 'MODE');
@@ -378,7 +375,7 @@ Blockly.Blocks['text_print'] = {
378375
],
379376
"previousStatement": null,
380377
"nextStatement": null,
381-
"colour": Blockly.Blocks.texts.HUE,
378+
"colour": Blockly.Msg.TEXTS_HUE,
382379
"tooltip": Blockly.Msg.TEXT_PRINT_TOOLTIP,
383380
"helpUrl": Blockly.Msg.TEXT_PRINT_HELPURL
384381
});
@@ -396,7 +393,7 @@ Blockly.Blocks['text_prompt_ext'] = {
396393
[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER, 'NUMBER']
397394
];
398395
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
399-
this.setColour(Blockly.Blocks.texts.HUE);
396+
this.setColour(Blockly.Msg.TEXTS_HUE);
400397
// Assign 'this' to a variable for use in the closures below.
401398
var thisBlock = this;
402399
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
@@ -456,7 +453,7 @@ Blockly.Blocks['text_prompt'] = {
456453
// Assign 'this' to a variable for use in the closures below.
457454
var thisBlock = this;
458455
this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);
459-
this.setColour(Blockly.Blocks.texts.HUE);
456+
this.setColour(Blockly.Msg.TEXTS_HUE);
460457
var dropdown = new Blockly.FieldDropdown(TYPES, function(newOp) {
461458
thisBlock.updateType_(newOp);
462459
});
@@ -499,7 +496,7 @@ Blockly.Blocks['text_count'] = {
499496
],
500497
"output": "Number",
501498
"inputsInline": true,
502-
"colour": Blockly.Blocks.texts.HUE,
499+
"colour": Blockly.Msg.TEXTS_HUE,
503500
"tooltip": Blockly.Msg.TEXT_COUNT_TOOLTIP,
504501
"helpUrl": Blockly.Msg.TEXT_COUNT_HELPURL
505502
});
@@ -533,7 +530,7 @@ Blockly.Blocks['text_replace'] = {
533530
],
534531
"output": "String",
535532
"inputsInline": true,
536-
"colour": Blockly.Blocks.texts.HUE,
533+
"colour": Blockly.Msg.TEXTS_HUE,
537534
"tooltip": Blockly.Msg.TEXT_REPLACE_TOOLTIP,
538535
"helpUrl": Blockly.Msg.TEXT_REPLACE_HELPURL
539536
});
@@ -557,7 +554,7 @@ Blockly.Blocks['text_reverse'] = {
557554
],
558555
"output": "String",
559556
"inputsInline": true,
560-
"colour": Blockly.Blocks.texts.HUE,
557+
"colour": Blockly.Msg.TEXTS_HUE,
561558
"tooltip": Blockly.Msg.TEXT_REVERSE_TOOLTIP,
562559
"helpUrl": Blockly.Msg.TEXT_REVERSE_HELPURL
563560
});

blocks/variables.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ goog.require('Blockly');
3737

3838

3939
/**
40-
* Common HSV hue for all blocks in this category.
41-
* Should be the same as Blockly.Msg.VARIABLES_HUE.
42-
* @readonly
40+
* Unused constant for the common HSV hue for all blocks in this category.
41+
* @deprecated Use Blockly.Msg.VARIABLES_HUE. (2018 April 5)
4342
*/
4443
Blockly.Constants.Variables.HUE = 330;
45-
/** @deprecated Use Blockly.Constants.Variables.HUE */
46-
Blockly.Blocks.variables.HUE = Blockly.Constants.Variables.HUE;
4744

4845
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
4946
// Block for variable getter.

blocks/variables_dynamic.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ goog.require('Blockly');
3636

3737

3838
/**
39-
* Common HSV hue for all blocks in this category.
40-
* Should be the same as Blockly.Msg.VARIABLES_DYNAMIC_HUE.
41-
* @readonly
39+
* Unused constant for the common HSV hue for all blocks in this category.
40+
* @deprecated Use Blockly.Msg.VARIABLES_DYNAMIC_HUE. (2018 April 5)
4241
*/
4342
Blockly.Constants.VariablesDynamic.HUE = 310;
4443

0 commit comments

Comments
 (0)