blockly 7.20211209.4 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.d.ts +18963 -18432
- package/blockly.min.js +5 -4
- package/blockly_compressed.js +4 -3
- package/blockly_compressed.js.map +1 -1
- package/blocks/blocks.js +47 -0
- package/blocks/colour.js +13 -3
- package/blocks/lists.js +22 -13
- package/blocks/logic.js +13 -3
- package/blocks/loops.js +24 -11
- package/blocks/math.js +12 -3
- package/blocks/procedures.js +45 -32
- package/blocks/text.js +22 -13
- package/blocks/variables.js +14 -3
- package/blocks/variables_dynamic.js +13 -3
- package/blocks_compressed.js +1 -1
- package/blocks_compressed.js.map +1 -1
- package/core/block.js +1869 -1814
- package/core/block_drag_surface.js +201 -200
- package/core/block_dragger.js +377 -373
- package/core/block_svg.js +1593 -1479
- package/core/blockly.js +8 -22
- package/core/blocks.js +9 -2
- package/core/browser_events.js +22 -5
- package/core/bubble.js +841 -797
- package/core/bubble_dragger.js +213 -206
- package/core/bump_objects.js +2 -2
- package/core/clipboard.js +9 -9
- package/core/comment.js +353 -332
- package/core/common.js +46 -17
- package/core/component_manager.js +181 -174
- package/core/config.js +87 -0
- package/core/connection.js +595 -584
- package/core/connection_checker.js +242 -244
- package/core/connection_db.js +235 -230
- package/core/contextmenu.js +9 -6
- package/core/contextmenu_items.js +1 -2
- package/core/contextmenu_registry.js +93 -89
- package/core/css.js +474 -474
- package/core/delete_area.js +45 -42
- package/core/drag_target.js +57 -56
- package/core/dropdowndiv.js +153 -163
- package/core/events/events.js +2 -2
- package/core/events/events_abstract.js +89 -77
- package/core/events/events_block_base.js +37 -36
- package/core/events/events_block_change.js +130 -124
- package/core/events/events_block_create.js +73 -71
- package/core/events/events_block_delete.js +84 -82
- package/core/events/events_block_drag.js +50 -49
- package/core/events/events_block_move.js +147 -140
- package/core/events/events_bubble_open.js +51 -50
- package/core/events/events_click.js +48 -44
- package/core/events/events_comment_base.js +72 -69
- package/core/events/events_comment_change.js +63 -61
- package/core/events/events_comment_create.js +44 -42
- package/core/events/events_comment_delete.js +42 -40
- package/core/events/events_comment_move.js +106 -104
- package/core/events/events_marker_move.js +65 -64
- package/core/events/events_selected.js +46 -45
- package/core/events/events_theme_change.js +36 -35
- package/core/events/events_toolbox_item_select.js +46 -45
- package/core/events/events_trashcan_open.js +37 -36
- package/core/events/events_ui.js +47 -46
- package/core/events/events_ui_base.js +30 -29
- package/core/events/events_var_base.js +37 -36
- package/core/events/events_var_create.js +50 -48
- package/core/events/events_var_delete.js +50 -48
- package/core/events/events_var_rename.js +51 -49
- package/core/events/events_viewport.js +66 -65
- package/core/events/utils.js +29 -14
- package/core/events/workspace_events.js +49 -55
- package/core/extensions.js +4 -3
- package/core/field.js +1061 -997
- package/core/field_angle.js +462 -442
- package/core/field_checkbox.js +194 -182
- package/core/field_colour.js +519 -505
- package/core/field_dropdown.js +617 -598
- package/core/field_image.js +229 -220
- package/core/field_label.js +102 -91
- package/core/field_label_serializable.js +42 -41
- package/core/field_multilineinput.js +372 -358
- package/core/field_number.js +272 -253
- package/core/field_textinput.js +499 -467
- package/core/field_variable.js +458 -420
- package/core/flyout_base.js +1005 -952
- package/core/flyout_button.js +277 -260
- package/core/flyout_horizontal.js +304 -302
- package/core/flyout_metrics_manager.js +64 -64
- package/core/flyout_vertical.js +306 -300
- package/core/generator.js +459 -446
- package/core/gesture.js +829 -813
- package/core/grid.js +166 -163
- package/core/icon.js +168 -159
- package/core/inject.js +7 -5
- package/core/input.js +257 -248
- package/core/insertion_marker_manager.js +655 -624
- package/core/internal_constants.js +0 -129
- package/core/keyboard_nav/ast_node.js +605 -596
- package/core/keyboard_nav/basic_cursor.js +166 -165
- package/core/keyboard_nav/cursor.js +99 -97
- package/core/keyboard_nav/marker.js +83 -79
- package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
- package/core/marker_manager.js +153 -141
- package/core/menu.js +377 -372
- package/core/menuitem.js +223 -217
- package/core/metrics_manager.js +403 -390
- package/core/mutator.js +468 -437
- package/core/names.js +229 -188
- package/core/options.js +290 -284
- package/core/procedures.js +29 -17
- package/core/registry.js +19 -16
- package/core/rendered_connection.js +482 -463
- package/core/renderers/common/block_rendering.js +9 -3
- package/core/renderers/common/constants.js +1119 -1112
- package/core/renderers/common/debug.js +14 -0
- package/core/renderers/common/debugger.js +338 -316
- package/core/renderers/common/drawer.js +380 -370
- package/core/renderers/common/i_path_object.js +2 -2
- package/core/renderers/common/info.js +626 -618
- package/core/renderers/common/marker_svg.js +579 -541
- package/core/renderers/common/path_object.js +203 -200
- package/core/renderers/common/renderer.js +220 -218
- package/core/renderers/geras/constants.js +36 -36
- package/core/renderers/geras/drawer.js +155 -147
- package/core/renderers/geras/highlight_constants.js +244 -238
- package/core/renderers/geras/highlighter.js +231 -179
- package/core/renderers/geras/info.js +392 -369
- package/core/renderers/geras/measurables/inline_input.js +25 -19
- package/core/renderers/geras/measurables/statement_input.js +23 -17
- package/core/renderers/geras/path_object.js +106 -121
- package/core/renderers/geras/renderer.js +96 -98
- package/core/renderers/measurables/base.js +30 -18
- package/core/renderers/measurables/bottom_row.js +83 -80
- package/core/renderers/measurables/connection.js +22 -15
- package/core/renderers/measurables/external_value_input.js +35 -22
- package/core/renderers/measurables/field.js +35 -20
- package/core/renderers/measurables/hat.js +18 -13
- package/core/renderers/measurables/icon.js +24 -17
- package/core/renderers/measurables/in_row_spacer.js +15 -13
- package/core/renderers/measurables/inline_input.js +43 -33
- package/core/renderers/measurables/input_connection.js +41 -28
- package/core/renderers/measurables/input_row.js +50 -44
- package/core/renderers/measurables/jagged_edge.js +14 -12
- package/core/renderers/measurables/next_connection.js +16 -14
- package/core/renderers/measurables/output_connection.js +26 -20
- package/core/renderers/measurables/previous_connection.js +16 -15
- package/core/renderers/measurables/round_corner.js +20 -18
- package/core/renderers/measurables/row.js +184 -168
- package/core/renderers/measurables/spacer_row.js +38 -23
- package/core/renderers/measurables/square_corner.js +18 -16
- package/core/renderers/measurables/statement_input.js +23 -20
- package/core/renderers/measurables/top_row.js +88 -85
- package/core/renderers/minimalist/constants.js +8 -7
- package/core/renderers/minimalist/drawer.js +11 -10
- package/core/renderers/minimalist/info.js +18 -18
- package/core/renderers/minimalist/renderer.js +40 -39
- package/core/renderers/thrasos/info.js +258 -248
- package/core/renderers/thrasos/renderer.js +20 -20
- package/core/renderers/zelos/constants.js +898 -873
- package/core/renderers/zelos/drawer.js +186 -169
- package/core/renderers/zelos/info.js +502 -479
- package/core/renderers/zelos/marker_svg.js +129 -115
- package/core/renderers/zelos/measurables/bottom_row.js +31 -30
- package/core/renderers/zelos/measurables/inputs.js +22 -21
- package/core/renderers/zelos/measurables/row_elements.js +14 -13
- package/core/renderers/zelos/measurables/top_row.js +34 -33
- package/core/renderers/zelos/path_object.js +181 -180
- package/core/renderers/zelos/renderer.js +91 -92
- package/core/scrollbar.js +759 -713
- package/core/scrollbar_pair.js +250 -245
- package/core/serialization/blocks.js +26 -10
- package/core/serialization/workspaces.js +3 -2
- package/core/shortcut_registry.js +286 -277
- package/core/sprites.js +31 -0
- package/core/theme.js +135 -141
- package/core/theme_manager.js +147 -143
- package/core/toolbox/category.js +602 -576
- package/core/toolbox/collapsible_category.js +226 -227
- package/core/toolbox/separator.js +70 -61
- package/core/toolbox/toolbox.js +934 -927
- package/core/toolbox/toolbox_item.js +115 -99
- package/core/tooltip.js +108 -35
- package/core/touch.js +8 -3
- package/core/touch_gesture.js +254 -251
- package/core/trashcan.js +606 -595
- package/core/utils/coordinate.js +97 -95
- package/core/utils/dom.js +2 -2
- package/core/utils/global.js +2 -0
- package/core/utils/rect.js +41 -37
- package/core/utils/sentinel.js +25 -0
- package/core/utils/size.js +30 -27
- package/core/utils/svg.js +18 -16
- package/core/variable_map.js +325 -341
- package/core/variable_model.js +55 -54
- package/core/variables.js +9 -2
- package/core/variables_dynamic.js +3 -1
- package/core/warning.js +126 -120
- package/core/widgetdiv.js +4 -4
- package/core/workspace.js +685 -664
- package/core/workspace_audio.js +124 -118
- package/core/workspace_comment.js +308 -298
- package/core/workspace_comment_svg.js +1029 -951
- package/core/workspace_drag_surface_svg.js +147 -140
- package/core/workspace_dragger.js +70 -71
- package/core/workspace_svg.js +2322 -2297
- package/core/xml.js +30 -20
- package/core/zoom_controls.js +431 -439
- package/generators/dart/colour.js +56 -64
- package/generators/dart/lists.js +61 -50
- package/generators/dart/math.js +160 -148
- package/generators/dart/text.js +83 -61
- package/generators/javascript/colour.js +37 -34
- package/generators/javascript/lists.js +50 -43
- package/generators/javascript/math.js +123 -139
- package/generators/javascript/text.js +67 -81
- package/generators/lua/colour.js +25 -23
- package/generators/lua/lists.js +97 -69
- package/generators/lua/logic.js +1 -2
- package/generators/lua/math.js +182 -144
- package/generators/lua/text.js +116 -99
- package/generators/php/colour.js +38 -32
- package/generators/php/lists.js +109 -89
- package/generators/php/math.js +90 -81
- package/generators/php/text.js +63 -61
- package/generators/python/colour.js +18 -18
- package/generators/python/lists.js +38 -30
- package/generators/python/loops.js +12 -8
- package/generators/python/math.js +104 -106
- package/generators/python/text.js +34 -30
- package/msg/smn.js +436 -0
- package/package.json +7 -6
- package/blocks/all.js +0 -23
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
goog.module('Blockly.geras.InlineInput');
|
|
19
19
|
|
|
20
|
-
const object = goog.require('Blockly.utils.object');
|
|
21
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
22
|
-
const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
21
|
+
const {ConstantProvider: BaseConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
22
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
23
|
+
const {ConstantProvider: GerasConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
|
|
23
24
|
const {InlineInput: BaseInlineInput} = goog.require('Blockly.blockRendering.InlineInput');
|
|
24
25
|
/* eslint-disable-next-line no-unused-vars */
|
|
25
26
|
const {Input} = goog.requireType('Blockly.Input');
|
|
@@ -27,26 +28,31 @@ const {Input} = goog.requireType('Blockly.Input');
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* An object containing information about the space an inline input takes up
|
|
30
|
-
* during rendering
|
|
31
|
-
* @param {!ConstantProvider} constants The rendering
|
|
32
|
-
* constants provider.
|
|
33
|
-
* @param {!Input} input The inline input to measure and store
|
|
34
|
-
* information for.
|
|
35
|
-
* @package
|
|
36
|
-
* @constructor
|
|
31
|
+
* during rendering.
|
|
37
32
|
* @extends {BaseInlineInput}
|
|
38
33
|
* @alias Blockly.geras.InlineInput
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
class InlineInput extends BaseInlineInput {
|
|
36
|
+
/**
|
|
37
|
+
* @param {!BaseConstantProvider} constants The rendering
|
|
38
|
+
* constants provider.
|
|
39
|
+
* @param {!Input} input The inline input to measure and store
|
|
40
|
+
* information for.
|
|
41
|
+
* @package
|
|
42
|
+
*/
|
|
43
|
+
constructor(constants, input) {
|
|
44
|
+
super(constants, input);
|
|
45
|
+
|
|
46
|
+
/** @type {!GerasConstantProvider} */
|
|
47
|
+
this.constants_;
|
|
48
|
+
|
|
49
|
+
if (this.connectedBlock) {
|
|
50
|
+
// We allow the dark path to show on the parent block so that the child
|
|
51
|
+
// block looks embossed. This takes up an extra pixel in both x and y.
|
|
52
|
+
this.width += this.constants_.DARK_PATH_OFFSET;
|
|
53
|
+
this.height += this.constants_.DARK_PATH_OFFSET;
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
|
-
}
|
|
50
|
-
object.inherits(InlineInput, BaseInlineInput);
|
|
56
|
+
}
|
|
51
57
|
|
|
52
58
|
exports.InlineInput = InlineInput;
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
goog.module('Blockly.geras.StatementInput');
|
|
19
19
|
|
|
20
|
-
const object = goog.require('Blockly.utils.object');
|
|
21
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
22
|
-
const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
21
|
+
const {ConstantProvider: BaseConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
22
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
23
|
+
const {ConstantProvider: GerasConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
|
|
23
24
|
/* eslint-disable-next-line no-unused-vars */
|
|
24
25
|
const {Input} = goog.requireType('Blockly.Input');
|
|
25
26
|
const {StatementInput: BaseStatementInput} = goog.require('Blockly.blockRendering.StatementInput');
|
|
@@ -27,25 +28,30 @@ const {StatementInput: BaseStatementInput} = goog.require('Blockly.blockRenderin
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* An object containing information about the space a statement input takes up
|
|
30
|
-
* during rendering
|
|
31
|
-
* @param {!ConstantProvider} constants The rendering
|
|
32
|
-
* constants provider.
|
|
33
|
-
* @param {!Input} input The statement input to measure and store
|
|
34
|
-
* information for.
|
|
35
|
-
* @package
|
|
36
|
-
* @constructor
|
|
31
|
+
* during rendering.
|
|
37
32
|
* @extends {BaseStatementInput}
|
|
38
33
|
* @alias Blockly.geras.StatementInput
|
|
39
34
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
class StatementInput extends BaseStatementInput {
|
|
36
|
+
/**
|
|
37
|
+
* @param {!BaseConstantProvider} constants The rendering
|
|
38
|
+
* constants provider.
|
|
39
|
+
* @param {!Input} input The statement input to measure and store
|
|
40
|
+
* information for.
|
|
41
|
+
* @package
|
|
42
|
+
*/
|
|
43
|
+
constructor(constants, input) {
|
|
44
|
+
super(constants, input);
|
|
45
|
+
|
|
46
|
+
/** @type {!GerasConstantProvider} */
|
|
47
|
+
this.constants_;
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
if (this.connectedBlock) {
|
|
50
|
+
// We allow the dark path to show on the parent block so that the child
|
|
51
|
+
// block looks embossed. This takes up an extra pixel in both x and y.
|
|
52
|
+
this.height += this.constants_.DARK_PATH_OFFSET;
|
|
53
|
+
}
|
|
47
54
|
}
|
|
48
|
-
}
|
|
49
|
-
object.inherits(StatementInput, BaseStatementInput);
|
|
55
|
+
}
|
|
50
56
|
|
|
51
57
|
exports.StatementInput = StatementInput;
|
|
@@ -18,7 +18,6 @@ goog.module('Blockly.geras.PathObject');
|
|
|
18
18
|
|
|
19
19
|
const colour = goog.require('Blockly.utils.colour');
|
|
20
20
|
const dom = goog.require('Blockly.utils.dom');
|
|
21
|
-
const object = goog.require('Blockly.utils.object');
|
|
22
21
|
/* eslint-disable-next-line no-unused-vars */
|
|
23
22
|
const {ConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
|
|
24
23
|
const {PathObject: BasePathObject} = goog.require('Blockly.blockRendering.PathObject');
|
|
@@ -30,152 +29,138 @@ const {Theme} = goog.requireType('Blockly.Theme');
|
|
|
30
29
|
/**
|
|
31
30
|
* An object that handles creating and setting each of the SVG elements
|
|
32
31
|
* used by the renderer.
|
|
33
|
-
* @param {!SVGElement} root The root SVG element.
|
|
34
|
-
* @param {!Theme.BlockStyle} style The style object to use for
|
|
35
|
-
* colouring.
|
|
36
|
-
* @param {!ConstantProvider} constants The renderer's constants.
|
|
37
|
-
* @constructor
|
|
38
|
-
* @extends {BasePathObject}
|
|
39
|
-
* @package
|
|
40
32
|
* @alias Blockly.geras.PathObject
|
|
41
33
|
*/
|
|
42
|
-
|
|
34
|
+
class PathObject extends BasePathObject {
|
|
43
35
|
/**
|
|
44
|
-
* The
|
|
45
|
-
* @
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.svgRoot = root;
|
|
50
|
-
|
|
51
|
-
// The order of creation for these next three matters, because that
|
|
52
|
-
// effectively sets their z-indices.
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The dark path of the block.
|
|
56
|
-
* @type {SVGElement}
|
|
36
|
+
* @param {!SVGElement} root The root SVG element.
|
|
37
|
+
* @param {!Theme.BlockStyle} style The style object to use for
|
|
38
|
+
* colouring.
|
|
39
|
+
* @param {!ConstantProvider} constants The renderer's constants.
|
|
57
40
|
* @package
|
|
58
41
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
constructor(root, style, constants) {
|
|
43
|
+
super(root, style, constants);
|
|
44
|
+
/**
|
|
45
|
+
* The renderer's constant provider.
|
|
46
|
+
* @type {!ConstantProvider}
|
|
47
|
+
*/
|
|
48
|
+
this.constants = constants;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The dark path of the block.
|
|
52
|
+
* @type {SVGElement}
|
|
53
|
+
* @package
|
|
54
|
+
*/
|
|
55
|
+
this.svgPathDark = dom.createSvgElement(
|
|
56
|
+
Svg.PATH, {'class': 'blocklyPathDark', 'transform': 'translate(1,1)'});
|
|
57
|
+
|
|
58
|
+
// SVG draw order is based on the order of elements (top most = back most)
|
|
59
|
+
// So we need to insert the dark path before the base path to make sure it
|
|
60
|
+
// gets drawn first.
|
|
61
|
+
this.svgRoot.insertBefore(this.svgPathDark, this.svgPath);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The light path of the block.
|
|
65
|
+
* @type {SVGElement}
|
|
66
|
+
* @package
|
|
67
|
+
*/
|
|
68
|
+
this.svgPathLight = dom.createSvgElement(
|
|
69
|
+
Svg.PATH, {'class': 'blocklyPathLight'}, this.svgRoot);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The colour of the dark path on the block in '#RRGGBB' format.
|
|
73
|
+
* @type {string}
|
|
74
|
+
* @package
|
|
75
|
+
*/
|
|
76
|
+
this.colourDark = '#000000';
|
|
77
|
+
}
|
|
62
78
|
|
|
63
79
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @type {!SVGElement}
|
|
66
|
-
* @package
|
|
80
|
+
* @override
|
|
67
81
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
setPath(mainPath) {
|
|
83
|
+
this.svgPath.setAttribute('d', mainPath);
|
|
84
|
+
this.svgPathDark.setAttribute('d', mainPath);
|
|
85
|
+
}
|
|
70
86
|
|
|
71
87
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
88
|
+
* Set the highlight path generated by the renderer onto the SVG element.
|
|
89
|
+
* @param {string} highlightPath The highlight path.
|
|
74
90
|
* @package
|
|
75
91
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
setHighlightPath(highlightPath) {
|
|
93
|
+
this.svgPathLight.setAttribute('d', highlightPath);
|
|
94
|
+
}
|
|
78
95
|
|
|
79
96
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @type {string}
|
|
82
|
-
* @package
|
|
97
|
+
* @override
|
|
83
98
|
*/
|
|
84
|
-
|
|
99
|
+
flipRTL() {
|
|
100
|
+
// Mirror the block's path.
|
|
101
|
+
this.svgPath.setAttribute('transform', 'scale(-1 1)');
|
|
102
|
+
this.svgPathLight.setAttribute('transform', 'scale(-1 1)');
|
|
103
|
+
this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)');
|
|
104
|
+
}
|
|
85
105
|
|
|
86
106
|
/**
|
|
87
|
-
*
|
|
88
|
-
* @type {!Theme.BlockStyle}
|
|
89
|
-
* @package
|
|
107
|
+
* @override
|
|
90
108
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
applyColour(block) {
|
|
110
|
+
this.svgPathLight.style.display = '';
|
|
111
|
+
this.svgPathDark.style.display = '';
|
|
112
|
+
this.svgPathLight.setAttribute('stroke', this.style.colourTertiary);
|
|
113
|
+
this.svgPathDark.setAttribute('fill', this.colourDark);
|
|
94
114
|
|
|
95
|
-
|
|
96
|
-
* @override
|
|
97
|
-
*/
|
|
98
|
-
PathObject.prototype.setPath = function(mainPath) {
|
|
99
|
-
this.svgPath.setAttribute('d', mainPath);
|
|
100
|
-
this.svgPathDark.setAttribute('d', mainPath);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Set the highlight path generated by the renderer onto the SVG element.
|
|
105
|
-
* @param {string} highlightPath The highlight path.
|
|
106
|
-
* @package
|
|
107
|
-
*/
|
|
108
|
-
PathObject.prototype.setHighlightPath = function(highlightPath) {
|
|
109
|
-
this.svgPathLight.setAttribute('d', highlightPath);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @override
|
|
114
|
-
*/
|
|
115
|
-
PathObject.prototype.flipRTL = function() {
|
|
116
|
-
// Mirror the block's path.
|
|
117
|
-
this.svgPath.setAttribute('transform', 'scale(-1 1)');
|
|
118
|
-
this.svgPathLight.setAttribute('transform', 'scale(-1 1)');
|
|
119
|
-
this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)');
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @override
|
|
124
|
-
*/
|
|
125
|
-
PathObject.prototype.applyColour = function(block) {
|
|
126
|
-
this.svgPathLight.style.display = '';
|
|
127
|
-
this.svgPathDark.style.display = '';
|
|
128
|
-
this.svgPathLight.setAttribute('stroke', this.style.colourTertiary);
|
|
129
|
-
this.svgPathDark.setAttribute('fill', this.colourDark);
|
|
115
|
+
super.applyColour(block);
|
|
130
116
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
this.svgPath.setAttribute('stroke', 'none');
|
|
134
|
-
};
|
|
117
|
+
this.svgPath.setAttribute('stroke', 'none');
|
|
118
|
+
}
|
|
135
119
|
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
120
|
+
/**
|
|
121
|
+
* @override
|
|
122
|
+
*/
|
|
123
|
+
setStyle(blockStyle) {
|
|
124
|
+
this.style = blockStyle;
|
|
125
|
+
this.colourDark =
|
|
126
|
+
colour.blend('#000', this.style.colourPrimary, 0.2) || this.colourDark;
|
|
127
|
+
}
|
|
144
128
|
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
129
|
+
/**
|
|
130
|
+
* @override
|
|
131
|
+
*/
|
|
132
|
+
updateHighlighted(highlighted) {
|
|
133
|
+
if (highlighted) {
|
|
134
|
+
this.svgPath.setAttribute(
|
|
135
|
+
'filter', 'url(#' + this.constants.embossFilterId + ')');
|
|
136
|
+
this.svgPathLight.style.display = 'none';
|
|
137
|
+
} else {
|
|
138
|
+
this.svgPath.setAttribute('filter', 'none');
|
|
139
|
+
this.svgPathLight.style.display = 'inline';
|
|
140
|
+
}
|
|
156
141
|
}
|
|
157
|
-
};
|
|
158
142
|
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
143
|
+
/**
|
|
144
|
+
* @override
|
|
145
|
+
*/
|
|
146
|
+
updateShadow_(shadow) {
|
|
147
|
+
if (shadow) {
|
|
148
|
+
this.svgPathLight.style.display = 'none';
|
|
149
|
+
this.svgPathDark.setAttribute('fill', this.style.colourSecondary);
|
|
150
|
+
this.svgPath.setAttribute('stroke', 'none');
|
|
151
|
+
this.svgPath.setAttribute('fill', this.style.colourSecondary);
|
|
152
|
+
}
|
|
168
153
|
}
|
|
169
|
-
};
|
|
170
154
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
155
|
+
/**
|
|
156
|
+
* @override
|
|
157
|
+
*/
|
|
158
|
+
updateDisabled_(disabled) {
|
|
159
|
+
super.updateDisabled_(disabled);
|
|
160
|
+
if (disabled) {
|
|
161
|
+
this.svgPath.setAttribute('stroke', 'none');
|
|
162
|
+
}
|
|
178
163
|
}
|
|
179
|
-
}
|
|
164
|
+
}
|
|
180
165
|
|
|
181
166
|
exports.PathObject = PathObject;
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
goog.module('Blockly.geras.Renderer');
|
|
17
17
|
|
|
18
18
|
const blockRendering = goog.require('Blockly.blockRendering');
|
|
19
|
-
const object = goog.require('Blockly.utils.object');
|
|
20
19
|
/* eslint-disable-next-line no-unused-vars */
|
|
21
20
|
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
|
|
22
21
|
/* eslint-disable-next-line no-unused-vars */
|
|
@@ -35,116 +34,115 @@ const {Theme} = goog.requireType('Blockly.Theme');
|
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* The geras renderer.
|
|
38
|
-
* @param {string} name The renderer name.
|
|
39
|
-
* @package
|
|
40
|
-
* @constructor
|
|
41
37
|
* @extends {BaseRenderer}
|
|
42
38
|
* @alias Blockly.geras.Renderer
|
|
43
39
|
*/
|
|
44
|
-
|
|
45
|
-
Renderer.superClass_.constructor.call(this, name);
|
|
46
|
-
|
|
40
|
+
class Renderer extends BaseRenderer {
|
|
47
41
|
/**
|
|
48
|
-
* The renderer
|
|
49
|
-
* @
|
|
50
|
-
* @private
|
|
42
|
+
* @param {string} name The renderer name.
|
|
43
|
+
* @package
|
|
51
44
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
object.inherits(Renderer, BaseRenderer);
|
|
45
|
+
constructor(name) {
|
|
46
|
+
super(name);
|
|
55
47
|
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Renderer.superClass_.init.call(this, theme, opt_rendererOverrides);
|
|
64
|
-
this.highlightConstants_ = this.makeHighlightConstants_();
|
|
65
|
-
this.highlightConstants_.init();
|
|
66
|
-
};
|
|
48
|
+
/**
|
|
49
|
+
* The renderer's highlight constant provider.
|
|
50
|
+
* @type {HighlightConstantProvider}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
this.highlightConstants_ = null;
|
|
54
|
+
}
|
|
67
55
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the renderer. Geras has a highlight provider in addition to
|
|
58
|
+
* the normal constant provider.
|
|
59
|
+
* @package
|
|
60
|
+
* @override
|
|
61
|
+
*/
|
|
62
|
+
init(theme, opt_rendererOverrides) {
|
|
63
|
+
super.init(theme, opt_rendererOverrides);
|
|
64
|
+
this.highlightConstants_ = this.makeHighlightConstants_();
|
|
65
|
+
this.highlightConstants_.init();
|
|
66
|
+
}
|
|
75
67
|
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @override
|
|
70
|
+
*/
|
|
71
|
+
refreshDom(svg, theme) {
|
|
72
|
+
super.refreshDom(svg, theme);
|
|
73
|
+
this.getHighlightConstants().init();
|
|
74
|
+
}
|
|
82
75
|
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*/
|
|
90
|
-
Renderer.prototype.makeRenderInfo_ = function(block) {
|
|
91
|
-
return new RenderInfo(this, block);
|
|
92
|
-
};
|
|
76
|
+
/**
|
|
77
|
+
* @override
|
|
78
|
+
*/
|
|
79
|
+
makeConstants_() {
|
|
80
|
+
return new ConstantProvider();
|
|
81
|
+
}
|
|
93
82
|
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return new Drawer(
|
|
105
|
-
block,
|
|
106
|
-
/** @type {!RenderInfo} */ (info));
|
|
107
|
-
};
|
|
83
|
+
/**
|
|
84
|
+
* Create a new instance of the renderer's render info object.
|
|
85
|
+
* @param {!BlockSvg} block The block to measure.
|
|
86
|
+
* @return {!RenderInfo} The render info object.
|
|
87
|
+
* @protected
|
|
88
|
+
* @override
|
|
89
|
+
*/
|
|
90
|
+
makeRenderInfo_(block) {
|
|
91
|
+
return new RenderInfo(this, block);
|
|
92
|
+
}
|
|
108
93
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a new instance of the renderer's drawer.
|
|
96
|
+
* @param {!BlockSvg} block The block to render.
|
|
97
|
+
* @param {!BaseRenderInfo} info An object containing all information needed
|
|
98
|
+
* to render this block.
|
|
99
|
+
* @return {!Drawer} The drawer.
|
|
100
|
+
* @protected
|
|
101
|
+
* @override
|
|
102
|
+
*/
|
|
103
|
+
makeDrawer_(block, info) {
|
|
104
|
+
return new Drawer(
|
|
105
|
+
block,
|
|
106
|
+
/** @type {!RenderInfo} */ (info));
|
|
107
|
+
}
|
|
123
108
|
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Create a new instance of a renderer path object.
|
|
111
|
+
* @param {!SVGElement} root The root SVG element.
|
|
112
|
+
* @param {!Theme.BlockStyle} style The style object to use for colouring.
|
|
113
|
+
* @return {!PathObject} The renderer path object.
|
|
114
|
+
* @package
|
|
115
|
+
* @override
|
|
116
|
+
*/
|
|
117
|
+
makePathObject(root, style) {
|
|
118
|
+
return new PathObject(
|
|
119
|
+
root, style,
|
|
120
|
+
/** @type {!ConstantProvider} */ (this.getConstants()));
|
|
121
|
+
}
|
|
135
122
|
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Create a new instance of the renderer's highlight constant provider.
|
|
125
|
+
* @return {!HighlightConstantProvider} The highlight constant provider.
|
|
126
|
+
* @protected
|
|
127
|
+
*/
|
|
128
|
+
makeHighlightConstants_() {
|
|
129
|
+
return new HighlightConstantProvider(
|
|
130
|
+
/** @type {!BaseConstantProvider} */
|
|
131
|
+
(this.getConstants()));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get the renderer's highlight constant provider. We assume that when this
|
|
136
|
+
* is called, the renderer has already been initialized.
|
|
137
|
+
* @return {!HighlightConstantProvider} The highlight constant provider.
|
|
138
|
+
* @package
|
|
139
|
+
*/
|
|
140
|
+
getHighlightConstants() {
|
|
141
|
+
return (
|
|
142
|
+
/** @type {!HighlightConstantProvider} */
|
|
143
|
+
(this.highlightConstants_));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
148
146
|
|
|
149
147
|
blockRendering.register('geras', Renderer);
|
|
150
148
|
|
|
@@ -25,28 +25,40 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
|
|
|
25
25
|
* The base class to represent a part of a block that takes up space during
|
|
26
26
|
* rendering. The constructor for each non-spacer Measurable records the size
|
|
27
27
|
* of the block element (e.g. field, statement input).
|
|
28
|
-
* @param {!ConstantProvider} constants The rendering
|
|
29
|
-
* constants provider.
|
|
30
|
-
* @package
|
|
31
|
-
* @constructor
|
|
32
28
|
* @alias Blockly.blockRendering.Measurable
|
|
33
29
|
*/
|
|
34
|
-
|
|
35
|
-
this.width = 0;
|
|
36
|
-
this.height = 0;
|
|
37
|
-
this.type = Types.NONE;
|
|
38
|
-
|
|
39
|
-
this.xPos = 0;
|
|
40
|
-
this.centerline = 0;
|
|
41
|
-
|
|
30
|
+
class Measurable {
|
|
42
31
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
32
|
+
* @param {!ConstantProvider} constants The rendering
|
|
33
|
+
* constants provider.
|
|
34
|
+
* @package
|
|
46
35
|
*/
|
|
47
|
-
|
|
36
|
+
constructor(constants) {
|
|
37
|
+
/** @type {number} */
|
|
38
|
+
this.width = 0;
|
|
39
|
+
|
|
40
|
+
/** @type {number} */
|
|
41
|
+
this.height = 0;
|
|
42
|
+
|
|
43
|
+
/** @type {number} */
|
|
44
|
+
this.type = Types.NONE;
|
|
45
|
+
|
|
46
|
+
/** @type {number} */
|
|
47
|
+
this.xPos = 0;
|
|
48
|
+
|
|
49
|
+
/** @type {number} */
|
|
50
|
+
this.centerline = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The renderer's constant provider.
|
|
54
|
+
* @type {!ConstantProvider}
|
|
55
|
+
* @protected
|
|
56
|
+
*/
|
|
57
|
+
this.constants_ = constants;
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
/** @type {number} */
|
|
60
|
+
this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
51
63
|
|
|
52
64
|
exports.Measurable = Measurable;
|