Permalink
Browse files

Merge pull request #1560 from khanning/menu-field-matrix

Add new menu type field matrix
  • Loading branch information...
ericrosenbaum committed Jul 9, 2018
2 parents 78ea5ef + f12f9a6 commit 42abd6ecb505cf9b832b9be2315e6a099bddda90
View
@@ -0,0 +1,54 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2012 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Matrix blocks for Blockly.
* @author khanning@gmail.com (Kreg Hanning)
*/
'use strict';
goog.provide('Blockly.Blocks.matrix');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
goog.require('Blockly.constants');
Blockly.Blocks['matrix'] = {
/**
* Block for matrix value.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_matrix",
"name": "MATRIX"
}
],
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"output": "Number",
"extensions": ["colours_pen"]
});
}
};
@@ -541,5 +541,12 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
'</value>' +
'</block>' +
'<block type="extension_music_reporter" id="extension_music_reporter"></block>' +
'<block type="extension_microbit_display" id="extension_microbit_display">' +
'<value name="MATRIX">' +
'<shadow type="matrix">' +
'<field name="MATRIX">0101010101100010101000100</field>' +
'</shadow>' +
'</value>' +
'</block>' +
'</category>' +
'</xml>';
@@ -232,3 +232,31 @@ Blockly.Blocks['extension_music_reporter'] = {
});
}
};
Blockly.Blocks['extension_microbit_display'] = {
/**
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "%1 %2 display %3",
"args0": [
{
"type": "field_image",
"src": Blockly.mainWorkspace.options.pathToMedia + "extensions/microbit-block-icon.svg",
"width": 40,
"height": 40
},
{
"type": "field_vertical_separator"
},
{
"type": "input_value",
"name": "MATRIX"
},
],
"category": Blockly.Categories.pen,
"extensions": ["colours_pen", "shape_statement", "scratch_extension"]
});
}
};
View
@@ -48,6 +48,7 @@ goog.require('Blockly.FieldTextInputRemovable');
goog.require('Blockly.FieldTextDropdown');
goog.require('Blockly.FieldNumber');
goog.require('Blockly.FieldNumberDropdown');
goog.require('Blockly.FieldMatrix');
goog.require('Blockly.FieldVariable');
goog.require('Blockly.FieldVerticalSeparator');
goog.require('Blockly.Generator');
View
@@ -995,6 +995,12 @@ Blockly.Css.CONTENT = [
'margin-left: 10px;',
'}',
'.scratchMatrixButtonDiv {',
'width: 50%;',
'text-align: center;',
'float: left;',
'}',
/* Copied from: goog/css/menu.css */
/*
* Copyright 2009 The Closure Library Authors. All Rights Reserved.
Oops, something went wrong.

0 comments on commit 42abd6e

Please sign in to comment.