Skip to content

Commit

Permalink
Merge pull request #1 from LLK/develop
Browse files Browse the repository at this point in the history
Updated from scratch-blocks
  • Loading branch information
howettl authored May 31, 2018
2 parents ed7fae9 + f7be0a9 commit 67381a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/block_render_svg_horizontal.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ Blockly.BlockSvg.prototype.updateColour = function() {
*/
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
if (add) {
this.svgPath_.setAttribute('filter', 'url(#blocklyReplacementGlowFilter)');
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|| 'blocklyReplacementGlowFilter';
this.svgPath_.setAttribute('filter', 'url(#' + replacementGlowFilterId + ')');
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
} else {
Expand Down
8 changes: 6 additions & 2 deletions core/block_render_svg_vertical.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ Blockly.BlockSvg.prototype.updateColour = function() {
*/
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
if (add) {
this.svgPath_.setAttribute('filter', 'url(#blocklyReplacementGlowFilter)');
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|| 'blocklyReplacementGlowFilter';
this.svgPath_.setAttribute('filter', 'url(#' + replacementGlowFilterId + ')');
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
} else {
Expand All @@ -585,8 +587,10 @@ Blockly.BlockSvg.prototype.highlightShapeForInput = function(conn, add) {
return;
}
if (add) {
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|| 'blocklyReplacementGlowFilter';
input.outlinePath.setAttribute('filter',
'url(#blocklyReplacementGlowFilter)');
'url(#' + replacementGlowFilterId + ')');
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyReplaceable');
} else {
Expand Down
3 changes: 2 additions & 1 deletion core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ Blockly.BlockSvg.prototype.setGlowStack = function(isGlowingStack) {
// Update the applied SVG filter if the property has changed
var svg = this.getSvgRoot();
if (this.isGlowingStack_ && !svg.hasAttribute('filter')) {
svg.setAttribute('filter', 'url(#blocklyStackGlowFilter)');
var stackGlowFilterId = this.workspace.options.stackGlowFilterId || 'blocklyStackGlowFilter';
svg.setAttribute('filter', 'url(#' + stackGlowFilterId + ')');
} else if (!this.isGlowingStack_ && svg.hasAttribute('filter')) {
svg.removeAttribute('filter');
}
Expand Down
6 changes: 4 additions & 2 deletions core/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Blockly.createDom_ = function(container, options) {
// Instead use a gaussian blur, and then set all alpha to 1 with a transfer.
var stackGlowFilter = Blockly.utils.createSvgElement('filter',
{
'id': 'blocklyStackGlowFilter',
'id': 'blocklyStackGlowFilter' + rnd,
'height': '160%',
'width': '180%',
y: '-30%',
Expand Down Expand Up @@ -180,7 +180,7 @@ Blockly.createDom_ = function(container, options) {
// Filter for replacement marker
var replacementGlowFilter = Blockly.utils.createSvgElement('filter',
{
'id': 'blocklyReplacementGlowFilter',
'id': 'blocklyReplacementGlowFilter' + rnd,
'height': '160%',
'width': '180%',
y: '-30%',
Expand Down Expand Up @@ -253,6 +253,8 @@ Blockly.createDom_ = function(container, options) {
'stroke': '#cc0'
},
disabledPattern);
options.stackGlowFilterId = stackGlowFilter.id;
options.replacementGlowFilterId = replacementGlowFilter.id;
options.disabledPatternId = disabledPattern.id;

options.gridPattern = Blockly.Grid.createDom(rnd, options.gridOptions, defs);
Expand Down

0 comments on commit 67381a7

Please sign in to comment.