mirror of
https://github.com/google/blockly.git
synced 2026-03-16 18:20:11 +01:00
Quarantine highlights.
This commit is contained in:
@@ -913,7 +913,9 @@ Blockly.Touch.isMouseOrTouchEvent=function(a){return Blockly.utils.string.starts
|
||||
Blockly.Touch.splitEventByTouches=function(a){var b=[];if(a.changedTouches)for(var c=0;c<a.changedTouches.length;c++)b[c]={type:a.type,changedTouches:[a.changedTouches[c]],target:a.target,stopPropagation:function(){a.stopPropagation()},preventDefault:function(){a.preventDefault()}};else b.push(a);return b};Blockly.utils.dom={};Blockly.utils.dom.SVG_NS="http://www.w3.org/2000/svg";Blockly.utils.dom.HTML_NS="http://www.w3.org/1999/xhtml";Blockly.utils.dom.XLINK_NS="http://www.w3.org/1999/xlink";Blockly.utils.dom.createSvgElement=function(a,b,c){a=document.createElementNS(Blockly.utils.dom.SVG_NS,a);for(var d in b)a.setAttribute(d,b[d]);document.body.runtimeStyle&&(a.runtimeStyle=a.currentStyle=a.style);c&&c.appendChild(a);return a};
|
||||
Blockly.utils.dom.addClass=function(a,b){var c=a.getAttribute("class")||"";if(-1!=(" "+c+" ").indexOf(" "+b+" "))return!1;c&&(c+=" ");a.setAttribute("class",c+b);return!0};Blockly.utils.dom.removeClass=function(a,b){var c=a.getAttribute("class");if(-1==(" "+c+" ").indexOf(" "+b+" "))return!1;c=c.split(/\s+/);for(var d=0;d<c.length;d++)c[d]&&c[d]!=b||(c.splice(d,1),d--);c.length?a.setAttribute("class",c.join(" ")):a.removeAttribute("class");return!0};
|
||||
Blockly.utils.dom.hasClass=function(a,b){return-1!=(" "+a.getAttribute("class")+" ").indexOf(" "+b+" ")};Blockly.utils.dom.removeNode=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};Blockly.utils.dom.insertAfter=function(a,b){var c=b.nextSibling,d=b.parentNode;if(!d)throw Error("Reference node has no parent.");c?d.insertBefore(a,c):d.appendChild(a)};Blockly.utils.dom.containsNode=function(a,b){return!!(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_CONTAINED_BY)};
|
||||
Blockly.utils.dom.setCssTransform=function(a,b){a.style.transform=b;a.style["-webkit-transform"]=b};Blockly.utils.math={};Blockly.utils.math.toRadians=function(a){return a*Math.PI/180};Blockly.utils.math.toDegrees=function(a){return 180*a/Math.PI};Blockly.utils.math.clamp=function(a,b,c){if(c<a){var d=c;c=a;a=d}return Math.max(a,Math.min(b,c))};Blockly.Events={};Blockly.Events.group_="";Blockly.Events.recordUndo=!0;Blockly.Events.disabled_=0;Blockly.Events.CREATE="create";Blockly.Events.BLOCK_CREATE=Blockly.Events.CREATE;Blockly.Events.DELETE="delete";Blockly.Events.BLOCK_DELETE=Blockly.Events.DELETE;Blockly.Events.CHANGE="change";Blockly.Events.BLOCK_CHANGE=Blockly.Events.CHANGE;Blockly.Events.MOVE="move";Blockly.Events.BLOCK_MOVE=Blockly.Events.MOVE;Blockly.Events.VAR_CREATE="var_create";Blockly.Events.VAR_DELETE="var_delete";
|
||||
Blockly.utils.dom.setCssTransform=function(a,b){a.style.transform=b;a.style["-webkit-transform"]=b};Blockly.utils.math={};Blockly.utils.math.toRadians=function(a){return a*Math.PI/180};Blockly.utils.math.toDegrees=function(a){return 180*a/Math.PI};Blockly.utils.math.clamp=function(a,b,c){if(c<a){var d=c;c=a;a=d}return Math.max(a,Math.min(b,c))};Blockly.Cursor=function(){this.curNode_=null};Blockly.Cursor.prototype.types={FIELD:"field",BLOCK:"block",INPUT:"input",OUTPUT:"output",NEXT:"next",PREVIOUS:"previous",STACK:"stack",WORKSPACE:"workspace"};Blockly.Cursor.prototype.getCurNode=function(){return this.curNode_};Blockly.Cursor.prototype.setLocation=function(a){this.curNode_=a;this.update_()};Blockly.Cursor.prototype.update_=function(){};
|
||||
Blockly.Cursor.prototype.next=function(){var a=this.getCurNode();if(!a)return null;(a=a.next())&&a.getType()===Blockly.ASTNode.types.NEXT&&(a=a.next()||a);a&&this.setLocation(a);return a};Blockly.Cursor.prototype["in"]=function(){var a=this.getCurNode();if(!a)return null;(a=a["in"]())&&a.getType()===Blockly.ASTNode.types.OUTPUT&&(a=a.next()||a);a&&this.setLocation(a);return a};
|
||||
Blockly.Cursor.prototype.prev=function(){var a=this.getCurNode();if(!a)return null;(a=a.prev())&&a.getType()===Blockly.ASTNode.types.NEXT&&(a=a.prev()||a);a&&this.setLocation(a);return a};Blockly.Cursor.prototype.out=function(){var a=this.getCurNode();if(!a)return null;(a=a.out())&&this.setLocation(a);return a};Blockly.Events={};Blockly.Events.group_="";Blockly.Events.recordUndo=!0;Blockly.Events.disabled_=0;Blockly.Events.CREATE="create";Blockly.Events.BLOCK_CREATE=Blockly.Events.CREATE;Blockly.Events.DELETE="delete";Blockly.Events.BLOCK_DELETE=Blockly.Events.DELETE;Blockly.Events.CHANGE="change";Blockly.Events.BLOCK_CHANGE=Blockly.Events.CHANGE;Blockly.Events.MOVE="move";Blockly.Events.BLOCK_MOVE=Blockly.Events.MOVE;Blockly.Events.VAR_CREATE="var_create";Blockly.Events.VAR_DELETE="var_delete";
|
||||
Blockly.Events.VAR_RENAME="var_rename";Blockly.Events.UI="ui";Blockly.Events.COMMENT_CREATE="comment_create";Blockly.Events.COMMENT_DELETE="comment_delete";Blockly.Events.COMMENT_CHANGE="comment_change";Blockly.Events.COMMENT_MOVE="comment_move";Blockly.Events.FINISHED_LOADING="finished_loading";Blockly.Events.BUMP_EVENTS=[Blockly.Events.BLOCK_CREATE,Blockly.Events.BLOCK_MOVE,Blockly.Events.COMMENT_CREATE,Blockly.Events.COMMENT_MOVE];Blockly.Events.FIRE_QUEUE_=[];
|
||||
Blockly.Events.fire=function(a){Blockly.Events.isEnabled()&&(Blockly.Events.FIRE_QUEUE_.length||setTimeout(Blockly.Events.fireNow_,0),Blockly.Events.FIRE_QUEUE_.push(a))};Blockly.Events.fireNow_=function(){for(var a=Blockly.Events.filter(Blockly.Events.FIRE_QUEUE_,!0),b=Blockly.Events.FIRE_QUEUE_.length=0,c;c=a[b];b++){var d=Blockly.Workspace.getById(c.workspaceId);d&&d.fireChangeListener(c)}};
|
||||
Blockly.Events.filter=function(a,b){var c=a.slice();b||c.reverse();for(var d=[],e=Object.create(null),f=0,g;g=c[f];f++)if(!g.isNull()){var h=[g.type,g.blockId,g.workspaceId].join(" "),k=e[h],l=k?k.event:null;if(!k)e[h]={event:g,index:f},d.push(g);else if(g.type==Blockly.Events.MOVE&&k.index==f-1)l.newParentId=g.newParentId,l.newInputName=g.newInputName,l.newCoordinate=g.newCoordinate,k.index=f;else if(g.type==Blockly.Events.CHANGE&&g.element==l.element&&g.name==l.name)l.newValue=g.newValue;else if(g.type!=
|
||||
@@ -922,7 +924,9 @@ Blockly.Events.enable=function(){Blockly.Events.disabled_--};Blockly.Events.isEn
|
||||
Blockly.Events.fromJson=function(a,b){switch(a.type){case Blockly.Events.CREATE:var c=new Blockly.Events.Create(null);break;case Blockly.Events.DELETE:c=new Blockly.Events.Delete(null);break;case Blockly.Events.CHANGE:c=new Blockly.Events.Change(null,"","","","");break;case Blockly.Events.MOVE:c=new Blockly.Events.Move(null);break;case Blockly.Events.VAR_CREATE:c=new Blockly.Events.VarCreate(null);break;case Blockly.Events.VAR_DELETE:c=new Blockly.Events.VarDelete(null);break;case Blockly.Events.VAR_RENAME:c=
|
||||
new Blockly.Events.VarRename(null,"");break;case Blockly.Events.UI:c=new Blockly.Events.Ui(null);break;case Blockly.Events.COMMENT_CREATE:c=new Blockly.Events.CommentCreate(null);break;case Blockly.Events.COMMENT_CHANGE:c=new Blockly.Events.CommentChange(null);break;case Blockly.Events.COMMENT_MOVE:c=new Blockly.Events.CommentMove(null);break;case Blockly.Events.COMMENT_DELETE:c=new Blockly.Events.CommentDelete(null);break;default:throw Error("Unknown event type.");}c.fromJson(a);c.workspaceId=b.id;
|
||||
return c};Blockly.Events.disableOrphans=function(a){if(a.type==Blockly.Events.MOVE||a.type==Blockly.Events.CREATE){var b=Blockly.Workspace.getById(a.workspaceId);if(a=b.getBlockById(a.blockId)){var c=a.getParent();if(c&&c.isEnabled())for(b=a.getDescendants(!1),a=0;c=b[a];a++)c.setEnabled(!0);else if((a.outputConnection||a.previousConnection)&&!b.isDragging()){do a.setEnabled(!1),a=a.getNextBlock();while(a)}}}};
|
||||
Blockly.Events.Abstract=function(){this.workspaceId=void 0;this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.Events.Abstract.prototype.toJson=function(){var a={type:this.type};this.group&&(a.group=this.group);return a};Blockly.Events.Abstract.prototype.fromJson=function(a){this.group=a.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};Blockly.Events.Abstract.prototype.run=function(a){};
|
||||
Blockly.Theme=function(a,b){this.blockStyles_=a;this.categoryStyles_=b};Blockly.Theme.prototype.setAllBlockStyles=function(a){for(var b in a)this.setBlockStyle(b,a[b])};Blockly.Theme.prototype.getAllBlockStyles=function(){return this.blockStyles_};Blockly.Theme.prototype.getBlockStyle=function(a){return this.blockStyles_[a]};Blockly.Theme.prototype.setBlockStyle=function(a,b){this.blockStyles_[a]=b};Blockly.Theme.prototype.getCategoryStyle=function(a){return this.categoryStyles_[a]};
|
||||
Blockly.Theme.prototype.setCategoryStyle=function(a,b){this.categoryStyles_[a]=b};Blockly.Themes={};Blockly.Themes.Classic={};Blockly.Themes.Classic.defaultBlockStyles={colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}};
|
||||
Blockly.Themes.Classic.categoryStyles={colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}};Blockly.Themes.Classic=new Blockly.Theme(Blockly.Themes.Classic.defaultBlockStyles,Blockly.Themes.Classic.categoryStyles);Blockly.Events.Abstract=function(){this.workspaceId=void 0;this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.Events.Abstract.prototype.toJson=function(){var a={type:this.type};this.group&&(a.group=this.group);return a};Blockly.Events.Abstract.prototype.fromJson=function(a){this.group=a.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};Blockly.Events.Abstract.prototype.run=function(a){};
|
||||
Blockly.Events.Abstract.prototype.getEventWorkspace_=function(){var a=Blockly.Workspace.getById(this.workspaceId);if(!a)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return a};Blockly.Events.VarBase=function(a){Blockly.Events.VarBase.superClass_.constructor.call(this);this.varId=a.getId();this.workspaceId=a.workspace.id};goog.inherits(Blockly.Events.VarBase,Blockly.Events.Abstract);Blockly.Events.VarBase.prototype.toJson=function(){var a=Blockly.Events.VarBase.superClass_.toJson.call(this);a.varId=this.varId;return a};Blockly.Events.VarBase.prototype.fromJson=function(a){Blockly.Events.VarBase.superClass_.toJson.call(this);this.varId=a.varId};
|
||||
Blockly.Events.VarCreate=function(a){a&&(Blockly.Events.VarCreate.superClass_.constructor.call(this,a),this.varType=a.type,this.varName=a.name)};goog.inherits(Blockly.Events.VarCreate,Blockly.Events.VarBase);Blockly.Events.VarCreate.prototype.type=Blockly.Events.VAR_CREATE;Blockly.Events.VarCreate.prototype.toJson=function(){var a=Blockly.Events.VarCreate.superClass_.toJson.call(this);a.varType=this.varType;a.varName=this.varName;return a};
|
||||
Blockly.Events.VarCreate.prototype.fromJson=function(a){Blockly.Events.VarCreate.superClass_.fromJson.call(this,a);this.varType=a.varType;this.varName=a.varName};Blockly.Events.VarCreate.prototype.run=function(a){var b=this.getEventWorkspace_();a?b.createVariable(this.varName,this.varType,this.varId):b.deleteVariableById(this.varId)};Blockly.Events.VarDelete=function(a){a&&(Blockly.Events.VarDelete.superClass_.constructor.call(this,a),this.varType=a.type,this.varName=a.name)};
|
||||
@@ -996,11 +1000,7 @@ Blockly.WorkspaceComment.prototype.setDeletable=function(a){this.deletable_=a};B
|
||||
Blockly.WorkspaceComment.prototype.setContent=function(a){this.content_!=a&&(Blockly.Events.fire(new Blockly.Events.CommentChange(this,this.content_,a)),this.content_=a)};Blockly.WorkspaceComment.prototype.toXmlWithXY=function(a){a=this.toXml(a);a.setAttribute("x",Math.round(this.xy_.x));a.setAttribute("y",Math.round(this.xy_.y));a.setAttribute("h",this.height_);a.setAttribute("w",this.width_);return a};
|
||||
Blockly.WorkspaceComment.prototype.toXml=function(a){var b=Blockly.utils.xml.createElement("comment");a||(b.id=this.id);b.textContent=this.getContent();return b};Blockly.WorkspaceComment.fireCreateEvent=function(a){if(Blockly.Events.isEnabled()){var b=Blockly.Events.getGroup();b||Blockly.Events.setGroup(!0);try{Blockly.Events.fire(new Blockly.Events.CommentCreate(a))}finally{b||Blockly.Events.setGroup(!1)}}};
|
||||
Blockly.WorkspaceComment.fromXml=function(a,b){var c=Blockly.WorkspaceComment.parseAttributes(a);c=new Blockly.WorkspaceComment(b,c.content,c.h,c.w,c.id);var d=parseInt(a.getAttribute("x"),10),e=parseInt(a.getAttribute("y"),10);isNaN(d)||isNaN(e)||c.moveBy(d,e);Blockly.WorkspaceComment.fireCreateEvent(c);return c};
|
||||
Blockly.WorkspaceComment.parseAttributes=function(a){var b=a.getAttribute("h"),c=a.getAttribute("w");return{id:a.getAttribute("id"),h:b?parseInt(b,10):100,w:c?parseInt(c,10):100,x:parseInt(a.getAttribute("x"),10),y:parseInt(a.getAttribute("y"),10),content:a.textContent}};Blockly.Cursor=function(){this.curNode_=null};Blockly.Cursor.prototype.types={FIELD:"field",BLOCK:"block",INPUT:"input",OUTPUT:"output",NEXT:"next",PREVIOUS:"previous",STACK:"stack",WORKSPACE:"workspace"};Blockly.Cursor.prototype.getCurNode=function(){return this.curNode_};Blockly.Cursor.prototype.setLocation=function(a){this.curNode_=a;this.update_()};Blockly.Cursor.prototype.update_=function(){};
|
||||
Blockly.Cursor.prototype.next=function(){var a=this.getCurNode();if(!a)return null;(a=a.next())&&a.getType()===Blockly.ASTNode.types.NEXT&&(a=a.next()||a);a&&this.setLocation(a);return a};Blockly.Cursor.prototype["in"]=function(){var a=this.getCurNode();if(!a)return null;(a=a["in"]())&&a.getType()===Blockly.ASTNode.types.OUTPUT&&(a=a.next()||a);a&&this.setLocation(a);return a};
|
||||
Blockly.Cursor.prototype.prev=function(){var a=this.getCurNode();if(!a)return null;(a=a.prev())&&a.getType()===Blockly.ASTNode.types.NEXT&&(a=a.prev()||a);a&&this.setLocation(a);return a};Blockly.Cursor.prototype.out=function(){var a=this.getCurNode();if(!a)return null;(a=a.out())&&this.setLocation(a);return a};Blockly.Theme=function(a,b){this.blockStyles_=a;this.categoryStyles_=b};Blockly.Theme.prototype.setAllBlockStyles=function(a){for(var b in a)this.setBlockStyle(b,a[b])};Blockly.Theme.prototype.getAllBlockStyles=function(){return this.blockStyles_};Blockly.Theme.prototype.getBlockStyle=function(a){return this.blockStyles_[a]};Blockly.Theme.prototype.setBlockStyle=function(a,b){this.blockStyles_[a]=b};Blockly.Theme.prototype.getCategoryStyle=function(a){return this.categoryStyles_[a]};
|
||||
Blockly.Theme.prototype.setCategoryStyle=function(a,b){this.categoryStyles_[a]=b};Blockly.Themes={};Blockly.Themes.Classic={};Blockly.Themes.Classic.defaultBlockStyles={colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}};
|
||||
Blockly.Themes.Classic.categoryStyles={colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}};Blockly.Themes.Classic=new Blockly.Theme(Blockly.Themes.Classic.defaultBlockStyles,Blockly.Themes.Classic.categoryStyles);Blockly.Workspace=function(a){this.id=Blockly.utils.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.topBlocks_=[];this.topComments_=[];this.commentDB_=Object.create(null);this.listeners_=[];this.undoStack_=[];this.redoStack_=[];this.blockDB_=Object.create(null);this.typedBlocksDB_=Object.create(null);this.variableMap_=new Blockly.VariableMap(this);
|
||||
Blockly.WorkspaceComment.parseAttributes=function(a){var b=a.getAttribute("h"),c=a.getAttribute("w");return{id:a.getAttribute("id"),h:b?parseInt(b,10):100,w:c?parseInt(c,10):100,x:parseInt(a.getAttribute("x"),10),y:parseInt(a.getAttribute("y"),10),content:a.textContent}};Blockly.Workspace=function(a){this.id=Blockly.utils.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.topBlocks_=[];this.topComments_=[];this.commentDB_=Object.create(null);this.listeners_=[];this.undoStack_=[];this.redoStack_=[];this.blockDB_=Object.create(null);this.typedBlocksDB_=Object.create(null);this.variableMap_=new Blockly.VariableMap(this);
|
||||
this.potentialVariableMap_=null;this.cursor=this.createCursor();Blockly.getTheme()||Blockly.setTheme(Blockly.Themes.Classic)};Blockly.Workspace.prototype.rendered=!1;Blockly.Workspace.prototype.isClearing=!1;Blockly.Workspace.prototype.MAX_UNDO=1024;Blockly.Workspace.prototype.connectionDBList=null;Blockly.Workspace.prototype.createCursor=function(){return new Blockly.Cursor};Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};
|
||||
Blockly.Workspace.SCAN_ANGLE=3;Blockly.Workspace.prototype.sortObjects_=function(a,b){var c=a.getRelativeToSurfaceXY(),d=b.getRelativeToSurfaceXY();return c.y+Blockly.Workspace.prototype.sortObjects_.offset*c.x-(d.y+Blockly.Workspace.prototype.sortObjects_.offset*d.x)};Blockly.Workspace.prototype.addTopBlock=function(a){this.topBlocks_.push(a)};
|
||||
Blockly.Workspace.prototype.removeTopBlock=function(a){if(!Blockly.utils.arrayRemove(this.topBlocks_,a))throw Error("Block not present in workspace's list of top-most blocks.");};Blockly.Workspace.prototype.getTopBlocks=function(a){var b=[].concat(this.topBlocks_);a&&1<b.length&&(this.sortObjects_.offset=Math.sin(Blockly.utils.math.toRadians(Blockly.Workspace.SCAN_ANGLE)),this.RTL&&(this.sortObjects_.offset*=-1),b.sort(this.sortObjects_));return b};
|
||||
@@ -1104,7 +1104,7 @@ this.showWithCoordinates_():a.getType()===Blockly.ASTNode.types.STACK&&this.show
|
||||
Blockly.CursorSvg.prototype.createCursorSvg_=function(){var a=this.isMarker_?Blockly.CursorSvg.MARKER_COLOR:Blockly.CursorSvg.CURSOR_COLOR;this.cursorSvg_=Blockly.utils.dom.createSvgElement("g",{width:Blockly.CursorSvg.CURSOR_WIDTH,height:Blockly.CursorSvg.CURSOR_HEIGHT},this.svgGroup_);this.cursorSvgLine_=Blockly.utils.dom.createSvgElement("rect",{x:"0",y:"0",fill:a,width:Blockly.CursorSvg.CURSOR_WIDTH,height:Blockly.CursorSvg.CURSOR_HEIGHT,style:"display: none;"},this.cursorSvg_);this.cursorSvgRect_=
|
||||
Blockly.utils.dom.createSvgElement("rect",{"class":"blocklyVerticalCursor",x:"0",y:"0",rx:"10",ry:"10",style:"display: none;",stroke:a},this.cursorSvg_);this.cursorInputOutput_=Blockly.utils.dom.createSvgElement("path",{width:Blockly.CursorSvg.CURSOR_WIDTH,height:Blockly.CursorSvg.CURSOR_HEIGHT,d:"m 0,0 "+Blockly.BlockSvg.TAB_PATH_DOWN+" v 5",transform:"",style:"display: none;",fill:a},this.cursorSvg_);this.isMarker_||(Blockly.utils.dom.createSvgElement("animate",{attributeType:"XML",attributeName:"fill",
|
||||
dur:"1s",values:Blockly.CursorSvg.CURSOR_COLOR+";transparent;transparent;",repeatCount:"indefinite"},this.cursorSvgLine_),Blockly.utils.dom.createSvgElement("animate",{attributeType:"XML",attributeName:"fill",dur:"1s",values:Blockly.CursorSvg.CURSOR_COLOR+";transparent;transparent;",repeatCount:"indefinite"},this.cursorInputOutput_));return this.cursorSvg_};Blockly.CursorSvg.prototype.next=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_.next.call(this)};
|
||||
Blockly.CursorSvg.prototype["in"]=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_["in"].call(this)};Blockly.CursorSvg.prototype.prev=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_.prev.call(this)};Blockly.CursorSvg.prototype.out=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_.out.call(this)};Blockly.blockAnimations={};Blockly.blockAnimations.disconnectPid_=0;Blockly.blockAnimations.disconnectGroup_=null;Blockly.blockAnimations.disposeUiEffect=function(a){var b=a.workspace,c=a.getSvgRoot();b.getAudioManager().play("delete");a=b.getSvgXY(c);c=c.cloneNode(!0);c.translateX_=a.x;c.translateY_=a.y;c.setAttribute("transform","translate("+a.x+","+a.y+")");b.getParentSvg().appendChild(c);c.bBox_=c.getBBox();Blockly.blockAnimations.disposeUiStep_(c,b.RTL,new Date,b.scale)};
|
||||
Blockly.CursorSvg.prototype["in"]=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_["in"].call(this)};Blockly.CursorSvg.prototype.prev=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_.prev.call(this)};Blockly.CursorSvg.prototype.out=function(){return this.isMarker_?null:Blockly.CursorSvg.superClass_.out.call(this)};Blockly.CursorSvg.prototype.dispose=function(){this.svgGroup_&&Blockly.utils.dom.removeNode(this.svgGroup_)};Blockly.blockAnimations={};Blockly.blockAnimations.disconnectPid_=0;Blockly.blockAnimations.disconnectGroup_=null;Blockly.blockAnimations.disposeUiEffect=function(a){var b=a.workspace,c=a.getSvgRoot();b.getAudioManager().play("delete");a=b.getSvgXY(c);c=c.cloneNode(!0);c.translateX_=a.x;c.translateY_=a.y;c.setAttribute("transform","translate("+a.x+","+a.y+")");b.getParentSvg().appendChild(c);c.bBox_=c.getBBox();Blockly.blockAnimations.disposeUiStep_(c,b.RTL,new Date,b.scale)};
|
||||
Blockly.blockAnimations.disposeUiStep_=function(a,b,c,d){var e=(new Date-c)/150;1<e?Blockly.utils.dom.removeNode(a):(a.setAttribute("transform","translate("+(a.translateX_+(b?-1:1)*a.bBox_.width*d/2*e)+","+(a.translateY_+a.bBox_.height*d*e)+") scale("+(1-e)*d+")"),setTimeout(Blockly.blockAnimations.disposeUiStep_,10,a,b,c,d))};
|
||||
Blockly.blockAnimations.connectionUiEffect=function(a){var b=a.workspace,c=b.scale;b.getAudioManager().play("click");if(!(1>c)){var d=b.getSvgXY(a.getSvgRoot());a.outputConnection?(d.x+=(a.RTL?3:-3)*c,d.y+=13*c):a.previousConnection&&(d.x+=(a.RTL?-23:23)*c,d.y+=3*c);a=Blockly.utils.dom.createSvgElement("circle",{cx:d.x,cy:d.y,r:0,fill:"none",stroke:"#888","stroke-width":10},b.getParentSvg());Blockly.blockAnimations.connectionUiStep_(a,new Date,c)}};
|
||||
Blockly.blockAnimations.connectionUiStep_=function(a,b,c){var d=(new Date-b)/150;1<d?Blockly.utils.dom.removeNode(a):(a.setAttribute("r",25*d*c),a.style.opacity=1-d,Blockly.blockAnimations.disconnectPid_=setTimeout(Blockly.blockAnimations.connectionUiStep_,10,a,b,c))};
|
||||
@@ -1334,8 +1334,9 @@ Blockly.WorkspaceSvg.prototype.createDom=function(a){this.svgGroup_=Blockly.util
|
||||
Blockly.utils.dom.createSvgElement("g",{"class":"blocklyBubbleCanvas"},this.svgGroup_);this.isFlyout||(Blockly.bindEventWithChecks_(this.svgGroup_,"mousedown",this,this.onMouseDown_,!1,!0),Blockly.bindEventWithChecks_(this.svgGroup_,"wheel",this,this.onMouseWheel_));this.options.hasCategories&&(this.toolbox_=new Blockly.Toolbox(this));this.grid_&&this.grid_.update(this.scale);this.recordDeleteAreas();a=this.cursor.createDom();this.svgGroup_.appendChild(a);a=this.marker.createDom();this.svgGroup_.appendChild(a);
|
||||
return this.svgGroup_};
|
||||
Blockly.WorkspaceSvg.prototype.dispose=function(){this.rendered=!1;this.currentGesture_&&this.currentGesture_.cancel();Blockly.WorkspaceSvg.superClass_.dispose.call(this);this.svgGroup_&&(Blockly.utils.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.svgBubbleCanvas_=this.svgBlockCanvas_=null;this.toolbox_&&(this.toolbox_.dispose(),this.toolbox_=null);this.flyout_&&(this.flyout_.dispose(),this.flyout_=null);this.trashcan&&(this.trashcan.dispose(),this.trashcan=null);this.scrollbar&&(this.scrollbar.dispose(),
|
||||
this.scrollbar=null);this.zoomControls_&&(this.zoomControls_.dispose(),this.zoomControls_=null);this.cursor_&&(this.cursor_.dispose(),this.cursor_=null);this.audioManager_&&(this.audioManager_.dispose(),this.audioManager_=null);this.grid_&&(this.grid_.dispose(),this.grid_=null);this.flyoutButtonCallbacks_=this.toolboxCategoryCallbacks_=this.connectionDBList=null;if(!this.options.parentWorkspace){var a=this.getParentSvg().parentNode;a&&Blockly.utils.dom.removeNode(a)}this.resizeHandlerWrapper_&&(Blockly.unbindEvent_(this.resizeHandlerWrapper_),
|
||||
this.resizeHandlerWrapper_=null)};Blockly.WorkspaceSvg.prototype.newBlock=function(a,b){return new Blockly.BlockSvg(this,a,b)};Blockly.WorkspaceSvg.prototype.addTrashcan=function(){this.trashcan=new Blockly.Trashcan(this);var a=this.trashcan.createDom();this.svgGroup_.insertBefore(a,this.svgBlockCanvas_)};Blockly.WorkspaceSvg.prototype.addZoomControls=function(){this.zoomControls_=new Blockly.ZoomControls(this);var a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)};
|
||||
this.scrollbar=null);this.zoomControls_&&(this.zoomControls_.dispose(),this.zoomControls_=null);this.marker&&this.marker.dispose();this.cursor&&this.cursor.dispose();this.audioManager_&&(this.audioManager_.dispose(),this.audioManager_=null);this.grid_&&(this.grid_.dispose(),this.grid_=null);this.flyoutButtonCallbacks_=this.toolboxCategoryCallbacks_=this.connectionDBList=null;if(!this.options.parentWorkspace){var a=this.getParentSvg().parentNode;a&&Blockly.utils.dom.removeNode(a)}this.resizeHandlerWrapper_&&
|
||||
(Blockly.unbindEvent_(this.resizeHandlerWrapper_),this.resizeHandlerWrapper_=null)};Blockly.WorkspaceSvg.prototype.newBlock=function(a,b){return new Blockly.BlockSvg(this,a,b)};Blockly.WorkspaceSvg.prototype.addTrashcan=function(){this.trashcan=new Blockly.Trashcan(this);var a=this.trashcan.createDom();this.svgGroup_.insertBefore(a,this.svgBlockCanvas_)};
|
||||
Blockly.WorkspaceSvg.prototype.addZoomControls=function(){this.zoomControls_=new Blockly.ZoomControls(this);var a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)};
|
||||
Blockly.WorkspaceSvg.prototype.addFlyout_=function(a){var b={disabledPatternId:this.options.disabledPatternId,parentWorkspace:this,RTL:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,toolboxPosition:this.options.toolboxPosition};this.flyout_=this.horizontalLayout?new Blockly.HorizontalFlyout(b):new Blockly.VerticalFlyout(b);this.flyout_.autoClose=!1;return this.flyout_.createDom(a)};
|
||||
Blockly.WorkspaceSvg.prototype.getFlyout=function(){return this.flyout_?this.flyout_:this.toolbox_?this.toolbox_.flyout_:null};Blockly.WorkspaceSvg.prototype.getToolbox=function(){return this.toolbox_};Blockly.WorkspaceSvg.prototype.updateScreenCalculations_=function(){this.updateInverseScreenCTM();this.recordDeleteAreas()};
|
||||
Blockly.WorkspaceSvg.prototype.resizeContents=function(){if(this.resizesEnabled_&&this.rendered){if(this.scrollbar){var a=this.getMetrics();this.scrollbar.hScroll.resizeContentHorizontal(a);this.scrollbar.vScroll.resizeContentVertical(a)}this.updateInverseScreenCTM()}};
|
||||
@@ -1503,50 +1504,40 @@ Blockly.BlockDragSurfaceSvg.prototype.setBlocksAndShow=function(a){if(this.dragG
|
||||
Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_=function(){var a=this.surfaceXY_.x,b=this.surfaceXY_.y;a=a.toFixed(0);b=b.toFixed(0);this.SVG_.style.display="block";Blockly.utils.dom.setCssTransform(this.SVG_,"translate3d("+a+"px, "+b+"px, 0px)")};Blockly.BlockDragSurfaceSvg.prototype.translateSurface=function(a,b){this.surfaceXY_=new Blockly.utils.Coordinate(a*this.scale_,b*this.scale_);this.translateSurfaceInternal_()};
|
||||
Blockly.BlockDragSurfaceSvg.prototype.getSurfaceTranslation=function(){var a=Blockly.utils.getRelativeXY(this.SVG_);return new Blockly.utils.Coordinate(a.x/this.scale_,a.y/this.scale_)};Blockly.BlockDragSurfaceSvg.prototype.getGroup=function(){return this.dragGroup_};Blockly.BlockDragSurfaceSvg.prototype.getCurrentBlock=function(){return this.dragGroup_.firstChild};
|
||||
Blockly.BlockDragSurfaceSvg.prototype.clearAndHide=function(a){a?a.appendChild(this.getCurrentBlock()):this.dragGroup_.removeChild(this.getCurrentBlock());this.SVG_.style.display="none";if(this.dragGroup_.childNodes.length)throw Error("Drag group was not cleared.");this.surfaceXY_=null};Blockly.utils.svgPaths={};Blockly.utils.svgPaths.point=function(a,b){return" "+a+","+b+" "};Blockly.utils.svgPaths.curve=function(a,b){return" "+a+b.join("")};Blockly.utils.svgPaths.moveTo=function(a,b){return" M "+a+","+b+" "};Blockly.utils.svgPaths.moveBy=function(a,b){return" m "+a+","+b+" "};Blockly.utils.svgPaths.lineTo=function(a,b){return" l "+a+","+b+" "};Blockly.utils.svgPaths.line=function(a){return" l"+a.join("")};Blockly.utils.svgPaths.lineOnAxis=function(a,b){return" "+a+" "+b+" "};
|
||||
Blockly.utils.svgPaths.arc=function(a,b,c,d){return a+" "+c+" "+c+" "+b+d};Blockly.blockRendering={};Blockly.blockRendering.constants={};Blockly.blockRendering.constants.NO_PADDING=0;Blockly.blockRendering.constants.SMALL_PADDING=3;Blockly.blockRendering.constants.MEDIUM_PADDING=5;Blockly.blockRendering.constants.MEDIUM_LARGE_PADDING=8;Blockly.blockRendering.constants.LARGE_PADDING=10;Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y=Blockly.blockRendering.constants.MEDIUM_PADDING;Blockly.blockRendering.constants.HIGHLIGHT_OFFSET=.5;
|
||||
Blockly.blockRendering.constants.DARK_PATH_OFFSET=1;Blockly.blockRendering.constants.TAB_HEIGHT=15;Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP=5;Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP=2.5;Blockly.blockRendering.constants.TAB_WIDTH=8;Blockly.blockRendering.constants.NOTCH_WIDTH=15;Blockly.blockRendering.constants.NOTCH_HEIGHT=4;Blockly.blockRendering.constants.MIN_BLOCK_WIDTH=12;Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT=16;
|
||||
Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT=Blockly.blockRendering.constants.NOTCH_WIDTH;Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV=7;Blockly.blockRendering.constants.NOTCH_OFFSET_RIGHT=Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+Blockly.blockRendering.constants.NOTCH_WIDTH;Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER=5;Blockly.blockRendering.constants.STATEMENT_INPUT_PADDING_LEFT=20;Blockly.blockRendering.constants.BETWEEN_STATEMENT_PADDING_Y=4;
|
||||
Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH=66.5;Blockly.blockRendering.constants.CORNER_RADIUS=8;Blockly.blockRendering.constants.START_HAT_HEIGHT=15;Blockly.blockRendering.constants.START_HAT_WIDTH=100;Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT=15;Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT=24;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH=22.5;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT=26;
|
||||
Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH=10;Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT;Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH=32;Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH=25;Blockly.blockRendering.constants.START_POINT=Blockly.utils.svgPaths.moveBy(0,0);
|
||||
Blockly.blockRendering.constants.START_POINT_HIGHLIGHT=Blockly.utils.svgPaths.moveBy(Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,Blockly.blockRendering.constants.HIGHLIGHT_OFFSET);Blockly.blockRendering.constants.DISTANCE_45_INSIDE=(1-Math.SQRT1_2)*(Blockly.blockRendering.constants.CORNER_RADIUS-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;
|
||||
Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;Blockly.blockRendering.constants.TAB_PATH_DOWN="c 0,10 -"+Blockly.blockRendering.constants.TAB_WIDTH+",-8 -"+Blockly.blockRendering.constants.TAB_WIDTH+",7.5 s "+Blockly.blockRendering.constants.TAB_WIDTH+",-2.5 "+Blockly.blockRendering.constants.TAB_WIDTH+",7.5";
|
||||
Blockly.blockRendering.constants.TAB_PATH_DOWN_HIGHLIGHT_RTL="m -"+.97*Blockly.blockRendering.constants.TAB_WIDTH+",2.5 q -"+.05*Blockly.blockRendering.constants.TAB_WIDTH+",10 "+.3*Blockly.blockRendering.constants.TAB_WIDTH+",9.5 m "+.67*Blockly.blockRendering.constants.TAB_WIDTH+",-1.9";
|
||||
Blockly.blockRendering.constants.TAB_PATH_UP="c 0,-10 -"+Blockly.blockRendering.constants.TAB_WIDTH+",8 -"+Blockly.blockRendering.constants.TAB_WIDTH+",-7.5 s "+Blockly.blockRendering.constants.TAB_WIDTH+",2.5 "+Blockly.blockRendering.constants.TAB_WIDTH+",-7.5";
|
||||
Blockly.blockRendering.constants.START_HAT_PATH=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(30,-Blockly.blockRendering.constants.START_HAT_HEIGHT),Blockly.utils.svgPaths.point(70,-Blockly.blockRendering.constants.START_HAT_HEIGHT),Blockly.utils.svgPaths.point(Blockly.blockRendering.constants.START_HAT_WIDTH,0)]);Blockly.blockRendering.constants.NOTCH_PATH_LEFT="l 6,4 3,0 6,-4";
|
||||
Blockly.blockRendering.constants.NOTCH_PATH_LEFT_HIGHLIGHT="h "+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET+" "+Blockly.blockRendering.constants.NOTCH_PATH_LEFT;Blockly.blockRendering.constants.NOTCH_PATH_RIGHT="l -6,4 -3,0 -6,-4";
|
||||
Blockly.blockRendering.constants.INNER_TOP_LEFT_CORNER=Blockly.blockRendering.constants.NOTCH_PATH_RIGHT+" h -"+(Blockly.blockRendering.constants.NOTCH_WIDTH-Blockly.blockRendering.constants.CORNER_RADIUS)+" a "+Blockly.blockRendering.constants.CORNER_RADIUS+","+Blockly.blockRendering.constants.CORNER_RADIUS+" 0 0,0 -"+Blockly.blockRendering.constants.CORNER_RADIUS+","+Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER=Blockly.utils.svgPaths.arc("a","0 0,0",Blockly.blockRendering.constants.CORNER_RADIUS,Blockly.utils.svgPaths.point(Blockly.blockRendering.constants.CORNER_RADIUS,Blockly.blockRendering.constants.CORNER_RADIUS));
|
||||
Blockly.blockRendering.constants.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL=Blockly.utils.svgPaths.arc("a","0 0,0",Blockly.blockRendering.constants.CORNER_RADIUS,Blockly.utils.svgPaths.point(-Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,Blockly.blockRendering.constants.CORNER_RADIUS-Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE));
|
||||
Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL=Blockly.utils.svgPaths.arc("a","0 0,0",Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,Blockly.utils.svgPaths.point(Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET));
|
||||
Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR=Blockly.utils.svgPaths.arc("a","0 0,0",Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,Blockly.utils.svgPaths.point(Blockly.blockRendering.constants.CORNER_RADIUS-Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE,Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET));
|
||||
Blockly.blockRendering.constants.TOP_LEFT_CORNER_START="m 0,"+Blockly.blockRendering.constants.CORNER_RADIUS;Blockly.blockRendering.constants.TOP_LEFT_CORNER="A "+Blockly.blockRendering.constants.CORNER_RADIUS+","+Blockly.blockRendering.constants.CORNER_RADIUS+" 0 0,1 "+Blockly.blockRendering.constants.CORNER_RADIUS+",0";
|
||||
Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER="a"+Blockly.blockRendering.constants.CORNER_RADIUS+","+Blockly.blockRendering.constants.CORNER_RADIUS+" 0 0,1 -"+Blockly.blockRendering.constants.CORNER_RADIUS+",-"+Blockly.blockRendering.constants.CORNER_RADIUS;Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER_HIGHLIGHT_START="M "+Blockly.blockRendering.constants.DISTANCE_45_INSIDE+", ";
|
||||
Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER_HIGHLIGHT_MID="A "+(Blockly.blockRendering.constants.CORNER_RADIUS-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)+","+(Blockly.blockRendering.constants.CORNER_RADIUS-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)+" 0 0,1 "+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET+",";
|
||||
Blockly.blockRendering.constants.OUTPUT_CONNECTION_HIGHLIGHT_LTR="V "+(Blockly.blockRendering.constants.TAB_HEIGHT+Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP-1.5)+" m "+-.92*Blockly.blockRendering.constants.TAB_WIDTH+",-0.5 q "+-.19*Blockly.blockRendering.constants.TAB_WIDTH+",-5.5 0,-11 m "+.92*Blockly.blockRendering.constants.TAB_WIDTH+",1 V 0.5 H 1";
|
||||
Blockly.blockRendering.constants.OUTPUT_CONNECTION_HIGHLIGHT_RTL="M "+-.25*Blockly.blockRendering.constants.TAB_WIDTH+",8.4 l "+-.45*Blockly.blockRendering.constants.TAB_WIDTH+",-2.1";Blockly.blockRendering.constants.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL="m "+Blockly.blockRendering.constants.DISTANCE_45_INSIDE+","+Blockly.blockRendering.constants.DISTANCE_45_INSIDE;Blockly.blockRendering.constants.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR="m 0.5,"+(Blockly.blockRendering.constants.CORNER_RADIUS-.5);
|
||||
Blockly.blockRendering.constants.TOP_LEFT_CORNER_HIGHLIGHT="A "+(Blockly.blockRendering.constants.CORNER_RADIUS-.5)+","+(Blockly.blockRendering.constants.CORNER_RADIUS-.5)+" 0 0,1 "+Blockly.blockRendering.constants.CORNER_RADIUS+",0.5";Blockly.blockRendering.constants.START_HAT_HIGHLIGHT_LTR=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(17.8,-9.2),Blockly.utils.svgPaths.point(45.3,-14.9),Blockly.utils.svgPaths.point(75,-8.7)])+Blockly.utils.svgPaths.moveTo(100.5,.5);
|
||||
Blockly.blockRendering.constants.START_HAT_HIGHLIGHT_RTL=Blockly.utils.svgPaths.moveBy(25,-8.7)+Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(29.7,-6.2),Blockly.utils.svgPaths.point(57.2,-.5),Blockly.utils.svgPaths.point(75,8.7)]);Blockly.blockRendering.Measurable=function(){this.isInput=!1;this.height=this.width=0;this.type=null;this.centerline=this.xPos=0};Blockly.blockRendering.Measurable.prototype.isField=function(){return"field"==this.type};Blockly.blockRendering.Measurable.prototype.isHat=function(){return"hat"==this.type};Blockly.blockRendering.Measurable.prototype.isIcon=function(){return"icon"==this.type};
|
||||
Blockly.utils.svgPaths.arc=function(a,b,c,d){return a+" "+c+" "+c+" "+b+d};Blockly.blockRendering={};Blockly.blockRendering.constants={};Blockly.blockRendering.constants.NO_PADDING=0;Blockly.blockRendering.constants.SMALL_PADDING=3;Blockly.blockRendering.constants.MEDIUM_PADDING=5;Blockly.blockRendering.constants.MEDIUM_LARGE_PADDING=8;Blockly.blockRendering.constants.LARGE_PADDING=10;Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y=Blockly.blockRendering.constants.MEDIUM_PADDING;Blockly.blockRendering.constants.DARK_PATH_OFFSET=1;
|
||||
Blockly.blockRendering.constants.TAB_HEIGHT=15;Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP=5;Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP=2.5;Blockly.blockRendering.constants.TAB_WIDTH=8;Blockly.blockRendering.constants.NOTCH_WIDTH=15;Blockly.blockRendering.constants.NOTCH_HEIGHT=4;Blockly.blockRendering.constants.MIN_BLOCK_WIDTH=12;Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT=16;Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT=Blockly.blockRendering.constants.NOTCH_WIDTH;
|
||||
Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV=7;Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER=5;Blockly.blockRendering.constants.STATEMENT_INPUT_PADDING_LEFT=20;Blockly.blockRendering.constants.BETWEEN_STATEMENT_PADDING_Y=4;Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH=66.5;Blockly.blockRendering.constants.CORNER_RADIUS=8;Blockly.blockRendering.constants.START_HAT_HEIGHT=15;Blockly.blockRendering.constants.START_HAT_WIDTH=100;
|
||||
Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT=15;Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT=24;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH=Blockly.blockRendering.constants.TAB_WIDTH+14.5;Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT=Blockly.blockRendering.constants.TAB_HEIGHT+11;Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH=10;Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT;
|
||||
Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH=32;Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH=25;Blockly.blockRendering.constants.START_POINT=Blockly.utils.svgPaths.moveBy(0,0);Blockly.blockRendering.constants.TOP_LEFT_CORNER_START="m 0,"+Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
Blockly.blockRendering.constants.START_HAT=function(){var a=Blockly.blockRendering.constants.START_HAT_HEIGHT,b=Blockly.blockRendering.constants.START_HAT_WIDTH,c=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(30,-a),Blockly.utils.svgPaths.point(70,-a),Blockly.utils.svgPaths.point(b,0)]);return{height:a,width:b,path:c}}();
|
||||
Blockly.blockRendering.constants.PUZZLE_TAB=function(){function a(a){a=a?-1:1;var d=-a,e=c/2,f=e+2.5,l=e+.5,n=Blockly.utils.svgPaths.point(-b,a*e);e=Blockly.utils.svgPaths.point(b,a*e);return Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(0,a*f),Blockly.utils.svgPaths.point(-b,d*l),n])+Blockly.utils.svgPaths.curve("s",[Blockly.utils.svgPaths.point(b,2.5*d),e])}var b=Blockly.blockRendering.constants.TAB_WIDTH,c=Blockly.blockRendering.constants.TAB_HEIGHT,d=a(!0),e=a(!1);return{width:b,
|
||||
height:c,pathDown:e,pathUp:d}}();Blockly.blockRendering.constants.NOTCH=function(){function a(a){return Blockly.utils.svgPaths.line([Blockly.utils.svgPaths.point(a*d,c),Blockly.utils.svgPaths.point(3*a,0),Blockly.utils.svgPaths.point(a*d,-c)])}var b=Blockly.blockRendering.constants.NOTCH_WIDTH,c=Blockly.blockRendering.constants.NOTCH_HEIGHT,d=(b-3)/2,e=a(1),f=a(-1);return{width:b,height:c,pathLeft:e,pathRight:f}}();
|
||||
Blockly.blockRendering.constants.INSIDE_CORNERS=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(-a,a)),c=Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(a,a));return{height:a,pathTop:b,pathBottom:c}}();
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.utils.svgPaths.arc("A","0 0,1",a,Blockly.utils.svgPaths.point(a,0));a=Blockly.utils.svgPaths.arc("a","0 0,1",a,Blockly.utils.svgPaths.point(-a,-a));return{topLeft:b,bottomLeft:a}}();Blockly.blockRendering.Measurable=function(){this.isInput=!1;this.height=this.width=0;this.type=null;this.centerline=this.xPos=0};Blockly.blockRendering.Measurable.prototype.isField=function(){return"field"==this.type};Blockly.blockRendering.Measurable.prototype.isHat=function(){return"hat"==this.type};Blockly.blockRendering.Measurable.prototype.isIcon=function(){return"icon"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isSpacer=function(){return"between-row spacer"==this.type||"in-row spacer"==this.type};Blockly.blockRendering.Measurable.prototype.isExternalInput=function(){return"external value input"==this.type};Blockly.blockRendering.Measurable.prototype.isInlineInput=function(){return"inline input"==this.type};Blockly.blockRendering.Measurable.prototype.isStatementInput=function(){return"statement input"==this.type};
|
||||
Blockly.blockRendering.Measurable.prototype.isPreviousConnection=function(){return"previous connection"==this.type};Blockly.blockRendering.Measurable.prototype.isNextConnection=function(){return"next connection"==this.type};Blockly.blockRendering.Measurable.prototype.isRoundedCorner=function(){return"round corner"==this.type};Blockly.blockRendering.Measurable.prototype.isSquareCorner=function(){return"square corner"==this.type};
|
||||
Blockly.blockRendering.Input=function(a){Blockly.blockRendering.Input.superClass_.constructor.call(this);this.isInput=!0;this.input=a;this.align=a.align;if(this.connectedBlock=a.connection&&a.connection.targetBlock()?a.connection.targetBlock():null){var b=this.connectedBlock.getHeightWidth();this.connectedBlockWidth=b.width;this.connectedBlockHeight=b.height}else this.connectedBlockHeight=this.connectedBlockWidth=0;this.connection=a.connection;this.connectionOffsetY=this.connectionOffsetX=0};
|
||||
goog.inherits(Blockly.blockRendering.Input,Blockly.blockRendering.Measurable);Blockly.blockRendering.Icon=function(a){Blockly.blockRendering.Icon.superClass_.constructor.call(this);this.icon=a;this.isVisible=a.isVisible();this.type="icon";a=a.getCorrectedSize();this.height=a.height;this.width=a.width};goog.inherits(Blockly.blockRendering.Icon,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Field=function(a,b){Blockly.blockRendering.Field.superClass_.constructor.call(this);this.field=a;this.isEditable=a.isCurrentlyEditable();this.type="field";var c=this.field.getCorrectedSize();this.height=c.height;this.width=c.width;this.parentInput=b};goog.inherits(Blockly.blockRendering.Field,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.InlineInput=function(a){Blockly.blockRendering.InlineInput.superClass_.constructor.call(this,a);this.type="inline input";this.connectedBlock?(this.width=this.connectedBlockWidth+Blockly.blockRendering.constants.TAB_WIDTH+Blockly.blockRendering.constants.DARK_PATH_OFFSET,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.DARK_PATH_OFFSET):(this.height=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT,this.width=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH)};
|
||||
goog.inherits(Blockly.blockRendering.InlineInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.StatementInput=function(a){Blockly.blockRendering.StatementInput.superClass_.constructor.call(this,a);this.type="statement input";this.connectedBlock?(this.width=Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER,this.connectedBlock.nextConnection&&(this.height-=Blockly.blockRendering.constants.NOTCH_HEIGHT)):(this.height=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT,
|
||||
this.width=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH)};goog.inherits(Blockly.blockRendering.StatementInput,Blockly.blockRendering.Input);Blockly.blockRendering.ExternalValueInput=function(a){Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this,a);this.type="external value input";this.height=this.connectedBlock?this.connectedBlockHeight-2*Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP:Blockly.blockRendering.constants.TAB_HEIGHT;this.width=Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH};
|
||||
goog.inherits(Blockly.blockRendering.ExternalValueInput,Blockly.blockRendering.Input);Blockly.blockRendering.PreviousConnection=function(){Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this);this.type="previous connection";this.height=Blockly.blockRendering.constants.NOTCH_HEIGHT;this.width=Blockly.blockRendering.constants.NOTCH_WIDTH};goog.inherits(Blockly.blockRendering.PreviousConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.NextConnection=function(){Blockly.blockRendering.NextConnection.superClass_.constructor.call(this);this.type="next connection";this.height=Blockly.blockRendering.constants.NOTCH_HEIGHT;this.width=Blockly.blockRendering.constants.NOTCH_WIDTH};goog.inherits(Blockly.blockRendering.NextConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Hat=function(){Blockly.blockRendering.Hat.superClass_.constructor.call(this);this.type="hat";this.height=Blockly.blockRendering.constants.NO_PADDING;this.width=Blockly.blockRendering.constants.START_HAT_WIDTH};goog.inherits(Blockly.blockRendering.Hat,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.SquareCorner=function(){Blockly.blockRendering.SquareCorner.superClass_.constructor.call(this);this.type="square corner";this.height=Blockly.blockRendering.constants.NOTCH_HEIGHT;this.width=Blockly.blockRendering.constants.NO_PADDING};goog.inherits(Blockly.blockRendering.SquareCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.RoundCorner=function(){Blockly.blockRendering.RoundCorner.superClass_.constructor.call(this);this.type="round corner";this.width=Blockly.blockRendering.constants.CORNER_RADIUS;this.height=Blockly.blockRendering.constants.NOTCH_HEIGHT};goog.inherits(Blockly.blockRendering.RoundCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.InlineInput=function(a){Blockly.blockRendering.InlineInput.superClass_.constructor.call(this,a);this.type="inline input";this.connectedBlock?(this.width=this.connectedBlockWidth+Blockly.blockRendering.constants.TAB_WIDTH+Blockly.blockRendering.constants.DARK_PATH_OFFSET,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.DARK_PATH_OFFSET):(this.height=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT,this.width=Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH);
|
||||
this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=Blockly.blockRendering.constants.PUZZLE_TAB.height;this.connectionWidth=Blockly.blockRendering.constants.PUZZLE_TAB.width};goog.inherits(Blockly.blockRendering.InlineInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.StatementInput=function(a){Blockly.blockRendering.StatementInput.superClass_.constructor.call(this,a);this.type="statement input";this.connectedBlock?(this.width=Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH,this.height=this.connectedBlockHeight+Blockly.blockRendering.constants.STATEMENT_BOTTOM_SPACER,this.connectedBlock.nextConnection&&(this.height-=Blockly.blockRendering.constants.NOTCH.height)):(this.height=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_HEIGHT,
|
||||
this.width=Blockly.blockRendering.constants.EMPTY_STATEMENT_INPUT_WIDTH)};goog.inherits(Blockly.blockRendering.StatementInput,Blockly.blockRendering.Input);
|
||||
Blockly.blockRendering.ExternalValueInput=function(a){Blockly.blockRendering.ExternalValueInput.superClass_.constructor.call(this,a);this.type="external value input";this.height=this.connectedBlock?this.connectedBlockHeight-2*Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP:Blockly.blockRendering.constants.TAB_HEIGHT;this.width=Blockly.blockRendering.constants.EXTERNAL_VALUE_INPUT_WIDTH;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP;this.connectionHeight=Blockly.blockRendering.constants.PUZZLE_TAB.height;
|
||||
this.connectionWidth=Blockly.blockRendering.constants.PUZZLE_TAB.width};goog.inherits(Blockly.blockRendering.ExternalValueInput,Blockly.blockRendering.Input);Blockly.blockRendering.OutputConnection=function(){Blockly.blockRendering.OutputConnection.superClass_.constructor.call(this);this.type="output connection";this.height=Blockly.blockRendering.constants.PUZZLE_TAB.height;this.width=Blockly.blockRendering.constants.PUZZLE_TAB.width;this.connectionOffsetY=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP};
|
||||
goog.inherits(Blockly.blockRendering.OutputConnection,Blockly.blockRendering.Measurable);Blockly.blockRendering.PreviousConnection=function(){Blockly.blockRendering.PreviousConnection.superClass_.constructor.call(this);this.type="previous connection";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NOTCH.width};goog.inherits(Blockly.blockRendering.PreviousConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.NextConnection=function(){Blockly.blockRendering.NextConnection.superClass_.constructor.call(this);this.type="next connection";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NOTCH.width};goog.inherits(Blockly.blockRendering.NextConnection,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Hat=function(){Blockly.blockRendering.Hat.superClass_.constructor.call(this);this.type="hat";this.height=Blockly.blockRendering.constants.NO_PADDING;this.width=Blockly.blockRendering.constants.START_HAT.width};goog.inherits(Blockly.blockRendering.Hat,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.SquareCorner=function(){Blockly.blockRendering.SquareCorner.superClass_.constructor.call(this);this.type="square corner";this.height=Blockly.blockRendering.constants.NOTCH.height;this.width=Blockly.blockRendering.constants.NO_PADDING};goog.inherits(Blockly.blockRendering.SquareCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.RoundCorner=function(){Blockly.blockRendering.RoundCorner.superClass_.constructor.call(this);this.type="round corner";this.width=Blockly.blockRendering.constants.CORNER_RADIUS;this.height=Blockly.blockRendering.constants.NOTCH.height};goog.inherits(Blockly.blockRendering.RoundCorner,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.Row=function(){this.type="row";this.yPos=0;this.elements=[];this.height=this.width=0;this.hasDummyInput=this.hasInlineInput=this.hasStatement=this.hasExternalInput=!1};Blockly.blockRendering.Row.prototype.isSpacer=function(){return!1};
|
||||
Blockly.blockRendering.Row.prototype.measure=function(){for(var a=0,b=0;b<this.elements.length;b++){var c=this.elements[b];this.width+=c.width;!c.isInput||"statement input"!=c.type&&"external value input"!=c.type||(a+=c.connectedBlockWidth);c.isSpacer()||(this.height=Math.max(this.height,c.height))}this.widthWithConnectedBlocks=this.width+a};Blockly.blockRendering.Row.prototype.getLastInput=function(){if(1<this.elements.length){var a=this.elements[this.elements.length-2];if(a.isInput)return a;if(a.isField())return a.parentInput}return null};
|
||||
Blockly.blockRendering.Row.prototype.getFirstSpacer=function(){return this.elements[0]};Blockly.blockRendering.Row.prototype.getLastSpacer=function(){return this.elements[this.elements.length-1]};Blockly.blockRendering.BetweenRowSpacer=function(a,b){this.type="between-row spacer";this.width=b;this.height=a;this.followsStatement=!1};goog.inherits(Blockly.blockRendering.BetweenRowSpacer,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.InRowSpacer=function(a){this.type="in-row spacer";this.width=a;this.height=Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT};goog.inherits(Blockly.blockRendering.InRowSpacer,Blockly.blockRendering.Measurable);
|
||||
Blockly.blockRendering.TopRow=function(a){Blockly.blockRendering.TopRow.superClass_.constructor.call(this);this.elements=[];this.type="top row";this.hasPreviousConnection=!!a.previousConnection;this.connection=a.previousConnection;this.height=a.inputList.length&&a.inputList[0].type==Blockly.NEXT_STATEMENT?Blockly.blockRendering.constants.LARGE_PADDING:Blockly.blockRendering.constants.MEDIUM_PADDING};goog.inherits(Blockly.blockRendering.TopRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.TopRow.prototype.isSpacer=function(){return!0};Blockly.blockRendering.BottomRow=function(a){Blockly.blockRendering.BottomRow.superClass_.constructor.call(this);this.type="bottom row";this.hasNextConnection=!!a.nextConnection;this.connection=a.nextConnection;var b=a.inputList.length&&a.inputList[a.inputList.length-1].type==Blockly.NEXT_STATEMENT;this.hasFixedWidth=b&&a.getInputsInline();this.height=b?Blockly.blockRendering.constants.LARGE_PADDING:Blockly.blockRendering.constants.NOTCH_HEIGHT};
|
||||
goog.inherits(Blockly.blockRendering.BottomRow,Blockly.blockRendering.Row);Blockly.blockRendering.BottomRow.prototype.isSpacer=function(){return!0};Blockly.blockRendering.RenderInfo=function(a){this.block_=a;this.hasOutputConnection=!!a.outputConnection;this.isInline=a.getInputsInline()&&!a.isCollapsed();this.isInsertionMarker=a.isInsertionMarker();this.RTL=a.RTL;this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.bottomRow=this.topRow=null;this.measure_()};
|
||||
Blockly.blockRendering.TopRow.prototype.getPreviousConnection=function(){return this.hasPreviousConnection?this.elements[2]:null};
|
||||
Blockly.blockRendering.BottomRow=function(a){Blockly.blockRendering.BottomRow.superClass_.constructor.call(this);this.type="bottom row";this.hasNextConnection=!!a.nextConnection;this.connection=a.nextConnection;var b=a.inputList.length&&a.inputList[a.inputList.length-1].type==Blockly.NEXT_STATEMENT;this.hasFixedWidth=b&&a.getInputsInline();this.height=b?Blockly.blockRendering.constants.LARGE_PADDING:Blockly.blockRendering.constants.NOTCH.height};goog.inherits(Blockly.blockRendering.BottomRow,Blockly.blockRendering.Row);
|
||||
Blockly.blockRendering.BottomRow.prototype.getNextConnection=function(){return this.hasNextConnection?this.elements[2]:null};Blockly.blockRendering.RenderInfo=function(a){this.block_=a;this.outputConnection=a.outputConnection?new Blockly.blockRendering.OutputConnection:null;this.isInline=a.getInputsInline()&&!a.isCollapsed();this.isInsertionMarker=a.isInsertionMarker();this.RTL=a.RTL;this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.bottomRow=this.topRow=null;this.measure_()};
|
||||
Blockly.blockRendering.RenderInfo.prototype.measure_=function(){this.createRows_();this.addElemSpacing_();this.computeBounds_();this.alignRowElements_();this.addRowSpacing_();this.finalize_();console.log(this)};
|
||||
Blockly.blockRendering.RenderInfo.prototype.createRows_=function(){this.createTopRow_();this.rows.push(this.topRow);var a=new Blockly.blockRendering.Row,b=this.block_.getIcons();if(b.length)for(var c=0;c<b.length;c++)a.elements.push(new Blockly.blockRendering.Icon(b[c]));for(c=0;c<this.block_.inputList.length;c++){b=this.block_.inputList[c];this.shouldStartNewRow_(b,this.block_.inputList[c-1])&&(this.rows.push(a),a=new Blockly.blockRendering.Row);for(var d=0;d<b.fieldRow.length;d++)a.elements.push(new Blockly.blockRendering.Field(b.fieldRow[d],
|
||||
b));this.addInput_(b,a)}a.elements.length&&this.rows.push(a);this.createBottomRow_();this.rows.push(this.bottomRow)};
|
||||
@@ -1558,9 +1549,8 @@ Blockly.blockRendering.RenderInfo.prototype.addElemSpacing_=function(){for(var a
|
||||
Blockly.blockRendering.RenderInfo.prototype.getInRowSpacing_=function(a,b){if(!a)return b.isField()&&b.isEditable?Blockly.blockRendering.constants.MEDIUM_PADDING:b.isInput&&b.isInlineInput()?Blockly.blockRendering.constants.MEDIUM_LARGE_PADDING:b.isStatementInput()?Blockly.blockRendering.constants.STATEMENT_INPUT_PADDING_LEFT:Blockly.blockRendering.constants.LARGE_PADDING;if(!a.isInput&&!b)return a.isField()&&a.isEditable?Blockly.blockRendering.constants.MEDIUM_PADDING:a.isIcon()?2*Blockly.blockRendering.constants.LARGE_PADDING+
|
||||
1:a.isHat()?Blockly.blockRendering.constants.NO_PADDING:a.isPreviousConnection()||a.isNextConnection()?Blockly.blockRendering.constants.LARGE_PADDING:a.isRoundedCorner()?Blockly.blockRendering.constants.MIN_BLOCK_WIDTH:Blockly.blockRendering.constants.LARGE_PADDING;if(a.isInput&&!b){if(a.isExternalInput())return Blockly.blockRendering.constants.NO_PADDING;if(a.isInlineInput())return Blockly.blockRendering.constants.LARGE_PADDING;if(a.isStatementInput())return Blockly.blockRendering.constants.NO_PADDING}if(!a.isInput&&
|
||||
b.isInput){if(a.isEditable){if(b.isInlineInput()||b.isExternalInput())return Blockly.blockRendering.constants.SMALL_PADDING}else{if(b.isInlineInput()||b.isExternalInput())return Blockly.blockRendering.constants.MEDIUM_LARGE_PADDING;if(b.isStatementInput())return Blockly.blockRendering.constants.LARGE_PADDING}return Blockly.blockRendering.constants.LARGE_PADDING-1}if(a.isIcon()&&!b.isInput)return Blockly.blockRendering.constants.LARGE_PADDING;if(a.isInlineInput()&&!b.isInput)return b.isEditable?Blockly.blockRendering.constants.MEDIUM_PADDING:
|
||||
Blockly.blockRendering.constants.LARGE_PADDING;if(a.isSquareCorner()){if(b.isHat())return Blockly.blockRendering.constants.NO_PADDING;if(b.isPreviousConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT;if(b.isNextConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+(this.RTL?.5:-.5)}if(a.isRoundedCorner()){if(b.isPreviousConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV;if(b.isNextConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV+
|
||||
(this.RTL?.5:-.5)}return a.isInput||b.isInput||a.isEditable!=b.isEditable?Blockly.blockRendering.constants.MEDIUM_PADDING:Blockly.blockRendering.constants.LARGE_PADDING};
|
||||
Blockly.blockRendering.RenderInfo.prototype.computeBounds_=function(){for(var a=0,b=0,c=0,d=0;d<this.rows.length;d++){var e=this.rows[d];e.measure();e.hasStatement||(b=Math.max(b,e.width));if(e.hasStatement){var f=e.getLastInput();a=Math.max(a,e.width-f.width)}c=Math.max(c,e.widthWithConnectedBlocks)}this.width=(this.statementEdge=a)?Math.max(b,a+2*Blockly.blockRendering.constants.NOTCH_WIDTH):b;for(d=0;d<this.rows.length;d++)e=this.rows[d],e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=
|
||||
Blockly.blockRendering.constants.LARGE_PADDING;if(a.isSquareCorner()){if(b.isHat())return Blockly.blockRendering.constants.NO_PADDING;if(b.isPreviousConnection()||b.isNextConnection())return Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT}return a.isRoundedCorner()&&(b.isPreviousConnection()||b.isNextConnection())?Blockly.blockRendering.constants.NOTCH_OFFSET_ROUNDED_CORNER_PREV:a.isInput||b.isInput||a.isEditable!=b.isEditable?Blockly.blockRendering.constants.MEDIUM_PADDING:Blockly.blockRendering.constants.LARGE_PADDING};
|
||||
Blockly.blockRendering.RenderInfo.prototype.computeBounds_=function(){for(var a=0,b=0,c=0,d=0;d<this.rows.length;d++){var e=this.rows[d];e.measure();e.hasStatement||(b=Math.max(b,e.width));if(e.hasStatement){var f=e.getLastInput();a=Math.max(a,e.width-f.width)}c=Math.max(c,e.widthWithConnectedBlocks)}this.width=(this.statementEdge=a)?Math.max(b,a+2*Blockly.blockRendering.constants.NOTCH.width):b;for(d=0;d<this.rows.length;d++)e=this.rows[d],e.hasStatement&&(e.statementEdge=this.statementEdge);this.widthWithChildren=
|
||||
Math.max(b,c)};Blockly.blockRendering.RenderInfo.prototype.alignRowElements_=function(){for(var a=0;a<this.rows.length;a++){var b=this.rows[a];if(!b.hasStatement&&!b.hasInlineInput){var c=b.width,d=this.width;"bottom row"===b.type&&b.hasFixedWidth&&(d=Blockly.blockRendering.constants.MAX_BOTTOM_WIDTH);(c=d-c)&&this.addAlignmentPadding_(b,c)}}};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addAlignmentPadding_=function(a,b){var c=a.elements,d=a.getLastInput();if(d){var e=a.getFirstSpacer(),f=a.getLastSpacer();a.hasExternalInput&&(f=c[c.length-3]);d.align==Blockly.ALIGN_LEFT?f.width+=b:d.align==Blockly.ALIGN_CENTRE?(e.width+=b/2,f.width+=b/2):d.align==Blockly.ALIGN_RIGHT&&(e.width+=b);a.width+=b}else if("top row"===a.type||"bottom row"===a.type)a.getLastSpacer().width+=b,a.width+=b};
|
||||
Blockly.blockRendering.RenderInfo.prototype.addRowSpacing_=function(){var a=this.rows;this.rows=[];for(var b=0;b<a.length;b++)this.rows.push(a[b]),b!==a.length-1&&this.rows.push(this.makeSpacerRow_(a[b],a[b+1]))};Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_=function(a,b){var c=this.getSpacerRowHeight_(a,b),d=this.getSpacerRowWidth_(a,b);c=new Blockly.blockRendering.BetweenRowSpacer(c,d);a.hasStatement&&(c.followsStatement=!0);return c};
|
||||
@@ -1568,44 +1558,50 @@ Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_=function(a,b){ret
|
||||
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowHeight_=function(a,b){return"top row"===a.type&&"bottom row"===b.type?Blockly.blockRendering.constants.EMPTY_BLOCK_SPACER_HEIGHT:"top row"===a.type||"bottom row"===b.type?Blockly.blockRendering.constants.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?Blockly.blockRendering.constants.LARGE_PADDING:!a.hasStatement&&b.hasStatement?Blockly.blockRendering.constants.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||b.hasDummyInput?Blockly.blockRendering.constants.LARGE_PADDING:
|
||||
Blockly.blockRendering.constants.MEDIUM_PADDING};Blockly.blockRendering.RenderInfo.prototype.getElemCenterline_=function(a,b){var c=a.yPos;if(b.isField()){if(c+=b.height/2,a.hasInlineInput||a.hasStatement)c+=Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y}else c=b.isInlineInput()?c+b.height/2:c+a.height/2;return c};
|
||||
Blockly.blockRendering.RenderInfo.prototype.finalize_=function(){for(var a=0,b=0;b<this.rows.length;b++){var c=this.rows[b];c.yPos=a;var d=0;if(!c.isSpacer())for(var e=0;e<c.elements.length;e++){var f=c.elements[e];f.xPos=d;f.centerline=this.getElemCenterline_(c,f);d+=f.width}a+=c.height}this.blockBottom=a;a<Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT&&(this.bottomRow.height+=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT-a,a=Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT);this.height=
|
||||
a};Blockly.blockRendering.Highlighter=function(a,b){this.info_=a;this.pathObject_=b;this.highlightSteps_=this.pathObject_.highlightSteps;this.highlightInlineSteps_=this.pathObject_.highlightInlineSteps};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner=function(a){for(var b=0,c;c=a.elements[b];b++)"square corner"===c.type?this.highlightSteps_.push(Blockly.blockRendering.constants.START_POINT_HIGHLIGHT):"round corner"===c.type?(this.highlightSteps_.push(this.info_.RTL?Blockly.blockRendering.constants.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL:Blockly.blockRendering.constants.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR),this.highlightSteps_.push(Blockly.blockRendering.constants.TOP_LEFT_CORNER_HIGHLIGHT)):
|
||||
"previous connection"===c.type?this.highlightSteps_.push(Blockly.blockRendering.constants.NOTCH_PATH_LEFT_HIGHLIGHT):"hat"===c.type?this.highlightSteps_.push(this.info_.RTL?Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL:Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR):c.isSpacer()&&this.highlightSteps_.push("h",c.width-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET);this.highlightSteps_.push("H",a.width-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawValueInput=function(a){this.info_.RTL?(a=a.height-(Blockly.blockRendering.constants.TAB_HEIGHT-Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP)+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,this.highlightSteps_.push("v",Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET),this.highlightSteps_.push(Blockly.blockRendering.constants.TAB_PATH_DOWN_HIGHLIGHT_RTL),this.highlightSteps_.push("v",
|
||||
a)):(this.highlightSteps_.push("M",a.width-5+","+(a.yPos+Blockly.blockRendering.constants.TAB_HEIGHT-.7)),this.highlightSteps_.push("l",.46*Blockly.blockRendering.constants.TAB_WIDTH+",-2.1"))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput=function(a){var b=a.statementEdge;this.info_.RTL?(this.highlightSteps_.push("M",b+Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE+","+(a.yPos+Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE)),this.highlightSteps_.push(Blockly.blockRendering.constants.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),this.highlightSteps_.push("v",a.height-2*Blockly.blockRendering.constants.CORNER_RADIUS),this.highlightSteps_.push(Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL)):
|
||||
(this.highlightSteps_.push("M",b+Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE+","+(a.yPos+a.height-Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE)),this.highlightSteps_.push(Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow=function(a){a.followsStatement&&this.highlightSteps_.push("H",a.width);this.info_.RTL&&(this.highlightSteps_.push("H",a.width-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET),this.highlightSteps_.push("v",a.height))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomCorner=function(a){a=this.info_.height;var b=this.info_.bottomRow.elements;this.info_.RTL&&this.highlightSteps_.push("V",a);for(var c=b.length-1;0<=c;c--){var d=b[c];"square corner"===d.type?this.info_.RTL||this.highlightSteps_.push("M",Blockly.blockRendering.constants.HIGHLIGHT_OFFSET+","+(a-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)):"round corner"===d.type&&(this.info_.RTL||this.highlightSteps_.push(Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER_HIGHLIGHT_START+
|
||||
(a-Blockly.BlockSvg.DISTANCE_45_INSIDE)+Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER_HIGHLIGHT_MID+(a-Blockly.BlockSvg.CORNER_RADIUS)))}};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawLeft=function(){this.info_.hasOutputConnection&&(this.info_.RTL?this.highlightSteps_.push(Blockly.blockRendering.constants.OUTPUT_CONNECTION_HIGHLIGHT_RTL):this.highlightSteps_.push(Blockly.blockRendering.constants.OUTPUT_CONNECTION_HIGHLIGHT_LTR));this.info_.RTL||(this.info_.topRow.elements[0].isSquareCorner()?this.highlightSteps_.push("V",Blockly.blockRendering.constants.HIGHLIGHT_OFFSET):this.highlightSteps_.push("V",Blockly.blockRendering.constants.CORNER_RADIUS))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawInlineInput=function(a){var b=a.width,c=a.height,d=a.xPos;a=a.centerline-c/2;var e=b-Blockly.blockRendering.constants.TAB_WIDTH;this.info_.RTL?(b=Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP+Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,c=c-(Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP+Blockly.blockRendering.constants.TAB_HEIGHT-Blockly.blockRendering.constants.TAB_VERTICAL_OVERLAP)+
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,this.highlightInlineSteps_.push("M",d+Blockly.blockRendering.constants.TAB_WIDTH-Blockly.blockRendering.constants.HIGHLIGHT_OFFSET+","+(a+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)),this.highlightInlineSteps_.push("v",b),this.highlightInlineSteps_.push(Blockly.blockRendering.constants.TAB_PATH_DOWN_HIGHLIGHT_RTL),this.highlightInlineSteps_.push("v",c),this.highlightInlineSteps_.push("h",e)):(this.highlightInlineSteps_.push("M",d+b+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET+
|
||||
","+(a+Blockly.blockRendering.constants.HIGHLIGHT_OFFSET)),this.highlightInlineSteps_.push("v",c),this.highlightInlineSteps_.push("h ",-e),this.highlightInlineSteps_.push("M",d+2.9+","+(a+Blockly.BlockSvg.INLINE_PADDING_Y+Blockly.blockRendering.constants.TAB_HEIGHT-.7)),this.highlightInlineSteps_.push("l",.46*Blockly.blockRendering.constants.TAB_WIDTH+",-2.1"))};Blockly.blockRendering.Debug=function(){this.debugElements_=[];this.svgRoot_=null};Blockly.blockRendering.Debug.prototype.clearElems=function(){for(var a=0,b;b=this.debugElements_[a];a++)Blockly.utils.dom.removeNode(b);this.debugElements_=[]};Blockly.blockRendering.Debug.prototype.drawSpacerRow=function(a,b){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowSpacerRect blockRenderDebug",x:0,y:b,width:a.width,height:a.height},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawSpacerElem=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemSpacerRect blockRenderDebug",x:b,y:c-a.height/2,width:a.width,height:15},this.svgRoot_))};
|
||||
a};Blockly.blockRendering.highlightConstants={};Blockly.blockRendering.highlightConstants.OFFSET=.5;Blockly.blockRendering.highlightConstants.START_POINT=Blockly.utils.svgPaths.moveBy(Blockly.blockRendering.highlightConstants.OFFSET,Blockly.blockRendering.highlightConstants.OFFSET);Blockly.blockRendering.highlightConstants.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(Blockly.blockRendering.constants.CORNER_RADIUS+Blockly.blockRendering.highlightConstants.OFFSET)-Blockly.blockRendering.highlightConstants.OFFSET;
|
||||
Blockly.blockRendering.highlightConstants.INSIDE_CORNER=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.blockRendering.highlightConstants.OFFSET,c=(1-Math.SQRT1_2)*(a+b)-b,d=Blockly.utils.svgPaths.arc("a","0 0,0",a,Blockly.utils.svgPaths.point(-c-b,a-c)),e=Blockly.utils.svgPaths.arc("a","0 0,0",a+b,Blockly.utils.svgPaths.point(a+b,a+b)),f=Blockly.utils.svgPaths.arc("a","0 0,0",a+b,Blockly.utils.svgPaths.point(a-c,c+b));return{height:a,pathTop:function(a){return a?d:""},pathBottom:function(a){return a?
|
||||
e:f}}}();
|
||||
Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER=function(){var a=Blockly.blockRendering.constants.CORNER_RADIUS,b=Blockly.blockRendering.highlightConstants.OFFSET,c=(1-Math.SQRT1_2)*(a-b)+b,d=Blockly.utils.svgPaths.moveBy(c,c),e=Blockly.utils.svgPaths.moveBy(b,a-b),f=Blockly.utils.svgPaths.arc("A","0 0,1",a-b,Blockly.utils.svgPaths.point(a,b));return{height:a,topLeft:function(a){return(a?d:e)+f},bottomLeft:function(d){return Blockly.utils.svgPaths.moveTo(c,d-c)+Blockly.utils.svgPaths.arc("A","0 0,1",
|
||||
a-b,Blockly.utils.svgPaths.point(b,d-a))}}}();
|
||||
Blockly.blockRendering.highlightConstants.PUZZLE_TAB=function(){var a=Blockly.blockRendering.constants.TAB_WIDTH,b=Blockly.blockRendering.constants.TAB_HEIGHT,c=Blockly.utils.svgPaths.moveTo(-.25*a,8.4)+Blockly.utils.svgPaths.lineTo(-.45*a,-2.1),d=Blockly.utils.svgPaths.lineOnAxis("v",2.5)+Blockly.utils.svgPaths.moveBy(.97*-a,2.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(.05*-a,10),Blockly.utils.svgPaths.point(.3*a,9.5)])+Blockly.utils.svgPaths.moveBy(.67*a,-1.9)+Blockly.utils.svgPaths.lineOnAxis("v",
|
||||
2.5),e=Blockly.utils.svgPaths.lineOnAxis("V",b+Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP-1.5)+Blockly.utils.svgPaths.moveBy(-.92*a,-.5)+Blockly.utils.svgPaths.curve("q",[Blockly.utils.svgPaths.point(-.19*a,-5.5),Blockly.utils.svgPaths.point(0,-11)])+Blockly.utils.svgPaths.moveBy(.92*a,1)+Blockly.utils.svgPaths.lineOnAxis("V",.5)+Blockly.utils.svgPaths.lineOnAxis("H",1),f=Blockly.utils.svgPaths.moveBy(-5,b-.7)+Blockly.utils.svgPaths.lineTo(.46*a,-2.1);return{width:a,height:b,pathUp:function(a){return a?
|
||||
c:e},pathDown:function(a){return a?d:f}}}();Blockly.blockRendering.highlightConstants.NOTCH=function(){return{pathLeft:Blockly.utils.svgPaths.lineOnAxis("h",Blockly.blockRendering.highlightConstants.OFFSET)+Blockly.blockRendering.constants.NOTCH.pathLeft}}();
|
||||
Blockly.blockRendering.highlightConstants.START_HAT=function(){var a=Blockly.utils.svgPaths.moveBy(25,-8.7)+Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(29.7,-6.2),Blockly.utils.svgPaths.point(57.2,-.5),Blockly.utils.svgPaths.point(75,8.7)]),b=Blockly.utils.svgPaths.curve("c",[Blockly.utils.svgPaths.point(17.8,-9.2),Blockly.utils.svgPaths.point(45.3,-14.9),Blockly.utils.svgPaths.point(75,-8.7)])+Blockly.utils.svgPaths.moveTo(100.5,.5);return{path:function(c){return c?a:b}}}();Blockly.blockRendering.Highlighter=function(a,b){this.info_=a;this.pathObject_=b;this.highlightSteps_=this.pathObject_.highlightSteps;this.highlightInlineSteps_=this.pathObject_.highlightInlineSteps;this.highlightOffset_=Blockly.blockRendering.highlightConstants.OFFSET;this.outsideCornerPaths_=Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER;this.insideCornerPaths_=Blockly.blockRendering.highlightConstants.INSIDE_CORNER;this.puzzleTabPaths_=Blockly.blockRendering.highlightConstants.PUZZLE_TAB;
|
||||
this.notchPaths_=Blockly.blockRendering.highlightConstants.NOTCH;this.startPaths_=Blockly.blockRendering.highlightConstants.START_HAT};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner=function(a){for(var b=0,c;c=a.elements[b];b++)"square corner"===c.type?this.highlightSteps_.push(Blockly.blockRendering.highlightConstants.START_POINT):"round corner"===c.type?this.highlightSteps_.push(this.outsideCornerPaths_.topLeft(this.info_.RTL)):"previous connection"===c.type?(this.highlightSteps_.push("h",this.RTL?.5:-.5),this.highlightSteps_.push(this.notchPaths_.pathLeft),this.highlightSteps_.push("h",this.RTL?-.5:.5)):"hat"===c.type?
|
||||
this.highlightSteps_.push(this.startPaths_.path(this.info_.RTL)):c.isSpacer()&&this.highlightSteps_.push("h",c.width-this.highlightOffset_);this.highlightSteps_.push("H",a.width-this.highlightOffset_)};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawValueInput=function(a){var b=a.getLastInput();this.info_.RTL?(a=a.height-b.connectionHeight+this.highlightOffset_,this.highlightSteps_.push("v",-this.highlightOffset_),this.highlightSteps_.push(this.puzzleTabPaths_.pathDown(this.info_.RTL)),this.highlightSteps_.push("v",a)):(this.highlightSteps_.push(Blockly.utils.svgPaths.moveTo(a.width,a.yPos)),this.highlightSteps_.push(this.puzzleTabPaths_.pathDown(this.info_.RTL)))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput=function(a){var b=a.statementEdge,c=Blockly.blockRendering.highlightConstants.DISTANCE_45_OUTSIDE;this.info_.RTL?(this.highlightSteps_.push("M",b+c+","+(a.yPos+c)),this.highlightSteps_.push(this.insideCornerPaths_.pathTop(this.info_.RTL)),this.highlightSteps_.push("v",a.height-2*this.insideCornerPaths_.height)):this.highlightSteps_.push("M",b+c+","+(a.yPos+a.height-c));this.highlightSteps_.push(this.insideCornerPaths_.pathBottom(this.info_.RTL))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawRightSideRow=function(a){a.followsStatement&&this.highlightSteps_.push("H",a.width);this.info_.RTL&&(this.highlightSteps_.push("H",a.width-this.highlightOffset_),this.highlightSteps_.push("v",a.height))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawBottomCorner=function(a){a=this.info_.height;var b=this.info_.bottomRow.elements;this.info_.RTL&&this.highlightSteps_.push("V",a);for(var c=b.length-1;0<=c;c--){var d=b[c];"square corner"===d.type?this.info_.RTL||this.highlightSteps_.push("M",this.highlightOffset_+","+(a-this.highlightOffset_)):"round corner"===d.type&&(this.info_.RTL||this.highlightSteps_.push(this.outsideCornerPaths_.bottomLeft(a)))}};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawLeft=function(){this.info_.outputConnection&&this.highlightSteps_.push(this.puzzleTabPaths_.pathUp(this.info_.RTL));this.info_.RTL||(this.info_.topRow.elements[0].isSquareCorner()?this.highlightSteps_.push("V",this.highlightOffset_):this.highlightSteps_.push("V",this.outsideCornerPaths_.height))};
|
||||
Blockly.blockRendering.Highlighter.prototype.drawInlineInput=function(a){var b=this.highlightOffset_,c=a.xPos+a.connectionWidth,d=a.centerline-a.height/2,e=a.width-a.connectionWidth,f=d+b;this.info_.RTL?(d=a.connectionOffsetY-b,a=a.height-(a.connectionOffsetY+a.connectionHeight)+b,this.highlightInlineSteps_.push("M",c-b+","+f),this.highlightInlineSteps_.push("v",d),this.highlightInlineSteps_.push(this.puzzleTabPaths_.pathDown(this.info_.RTL)),this.highlightInlineSteps_.push("v",a),this.highlightInlineSteps_.push("h",
|
||||
e)):(this.highlightInlineSteps_.push(Blockly.utils.svgPaths.moveTo(a.xPos+a.width+b,f)),this.highlightInlineSteps_.push("v",a.height),this.highlightInlineSteps_.push("h ",-e),this.highlightSteps_.push(Blockly.utils.svgPaths.moveTo(c,d+a.connectionOffsetY)),this.highlightSteps_.push(this.puzzleTabPaths_.pathDown(this.info_.RTL)))};Blockly.blockRendering.Debug=function(){this.debugElements_=[];this.svgRoot_=null};Blockly.blockRendering.Debug.prototype.clearElems=function(){for(var a=0,b;b=this.debugElements_[a];a++)Blockly.utils.dom.removeNode(b);this.debugElements_=[]};Blockly.blockRendering.Debug.prototype.drawSpacerRow=function(a,b){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowSpacerRect blockRenderDebug",x:0,y:b,width:a.width,height:a.height},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawSpacerElem=function(a,b,c,d){d=Math.min(15,d);this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemSpacerRect blockRenderDebug",x:b,y:c-d/2,width:a.width,height:d},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedElem=function(a,b,c){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"rowRenderingRect blockRenderDebug",x:b,y:c-a.height/2,width:a.width,height:a.height},this.svgRoot_));a.isInput&&this.drawConnection(a.connection)};
|
||||
Blockly.blockRendering.Debug.prototype.drawConnection=function(a){if(a.type==Blockly.INPUT_VALUE){var b=4;var c="magenta";var d="none"}else a.type==Blockly.OUTPUT_VALUE?(b=2,d=c="magenta"):a.type==Blockly.NEXT_STATEMENT?(b=4,c="goldenrod",d="none"):a.type==Blockly.PREVIOUS_STATEMENT&&(b=2,d=c="goldenrod");this.debugElements_.push(Blockly.utils.dom.createSvgElement("circle",{"class":"blockRenderDebug",cx:a.offsetInBlock_.x,cy:a.offsetInBlock_.y,r:b,fill:d,stroke:c},this.svgRoot_))};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedRow=function(a,b){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemRenderingRect blockRenderDebug",x:0,y:b,width:a.width,height:a.height},this.svgRoot_))};Blockly.blockRendering.Debug.prototype.drawRowWithElements=function(a,b){for(var c=b+a.height/2,d=0,e=0;e<a.elements.length;e++){var f=a.elements[e];f.isSpacer()?this.drawSpacerElem(f,d,c):this.drawRenderedElem(f,d,c);d+=f.width}this.drawRenderedRow(a,b)};
|
||||
Blockly.blockRendering.Debug.prototype.drawRenderedRow=function(a,b){this.debugElements_.push(Blockly.utils.dom.createSvgElement("rect",{"class":"elemRenderingRect blockRenderDebug",x:0,y:b,width:a.width,height:a.height},this.svgRoot_))};Blockly.blockRendering.Debug.prototype.drawRowWithElements=function(a,b){for(var c=b+a.height/2,d=0,e=0;e<a.elements.length;e++){var f=a.elements[e];f.isSpacer()?this.drawSpacerElem(f,d,c,a.height):this.drawRenderedElem(f,d,c);d+=f.width}this.drawRenderedRow(a,b)};
|
||||
Blockly.blockRendering.Debug.prototype.drawDebug=function(a,b){this.clearElems();this.svgRoot_=a.getSvgRoot();for(var c=0,d=0;d<b.rows.length;d++){var e=b.rows[d];e.isSpacer()?this.drawSpacerRow(e,c):this.drawRowWithElements(e,c);c+=e.height}a.previousConnection&&this.drawConnection(a.previousConnection);a.nextConnection&&this.drawConnection(a.nextConnection);a.outputConnection&&this.drawConnection(a.outputConnection)};Blockly.blockRendering.Drawer=function(a,b){this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.pathObject_=new Blockly.BlockSvg.PathObject;this.steps_=this.pathObject_.steps;this.inlineSteps_=this.pathObject_.inlineSteps;this.highlighter_=new Blockly.blockRendering.Highlighter(this.info_,this.pathObject_)};
|
||||
Blockly.blockRendering.Drawer.prototype.draw_=function(){this.drawOutline_();this.drawInternals_();this.block_.setPaths_(this.pathObject_);this.block_.renderingDebugger.drawDebug(this.block_,this.info_);this.recordSizeOnBlock_()};
|
||||
Blockly.blockRendering.Drawer.prototype.recordSizeOnBlock_=function(){this.block_.height=this.info_.height+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.block_.width=this.info_.widthWithChildren+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.block_.startHat_=this.info_.topRow.startHat};
|
||||
Blockly.blockRendering.Drawer.prototype.drawOutline_=function(){this.drawTop_();for(var a=1;a<this.info_.rows.length-1;a++){var b=this.info_.rows[a];b.hasStatement?this.drawStatementInput_(b):b.hasExternalInput?this.drawValueInput_(b):this.drawRightSideRow_(b)}this.drawBottom_();this.drawLeft_()};
|
||||
Blockly.blockRendering.Drawer.prototype.drawTop_=function(){var a=this.info_.topRow,b=a.elements;this.highlighter_.drawTopCorner(a);this.highlighter_.drawRightSideRow(a);this.positionPreviousConnection_();for(var c=0,d;d=b[c];c++)"square corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_POINT):"round corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.TOP_LEFT_CORNER_START,Blockly.blockRendering.constants.TOP_LEFT_CORNER):"previous connection"===d.type?this.steps_.push(Blockly.blockRendering.constants.NOTCH_PATH_LEFT):
|
||||
"hat"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_HAT_PATH):d.isSpacer()&&this.steps_.push("h",d.width);this.steps_.push("v",a.height)};Blockly.blockRendering.Drawer.prototype.drawValueInput_=function(a){this.highlighter_.drawValueInput(a);this.steps_.push("H",a.width);this.steps_.push(Blockly.blockRendering.constants.TAB_PATH_DOWN);this.steps_.push("v",a.height-Blockly.blockRendering.constants.TAB_HEIGHT);this.positionExternalValueConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawStatementInput_=function(a){this.highlighter_.drawStatementInput(a);this.steps_.push("H",a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_RIGHT);this.steps_.push(Blockly.blockRendering.constants.INNER_TOP_LEFT_CORNER);this.steps_.push("v",a.height-2*Blockly.blockRendering.constants.CORNER_RADIUS);this.steps_.push(Blockly.blockRendering.constants.INNER_BOTTOM_LEFT_CORNER);this.positionStatementInputConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawRightSideRow_=function(a){this.highlighter_.drawRightSideRow(a);this.steps_.push("H",a.width);this.steps_.push("v",a.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawBottom_=function(){var a=this.info_.bottomRow,b=a.elements;this.highlighter_.drawBottomCorner(a);this.positionNextConnection_();this.steps_.push("v",a.height);for(a=b.length-1;0<=a;a--){var c=b[a];"next connection"===c.type?this.steps_.push(Blockly.blockRendering.constants.NOTCH_PATH_RIGHT):"square corner"===c.type?this.steps_.push("H 0"):"round corner"===c.type?this.steps_.push(Blockly.blockRendering.constants.BOTTOM_LEFT_CORNER):c.isSpacer()&&this.steps_.push("h",
|
||||
-1*c.width)}};Blockly.blockRendering.Drawer.prototype.drawLeft_=function(){this.highlighter_.drawLeft();this.positionOutputConnection_();this.info_.hasOutputConnection&&(this.steps_.push("V",Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP+Blockly.blockRendering.constants.TAB_HEIGHT),this.steps_.push(Blockly.blockRendering.constants.TAB_PATH_UP));this.steps_.push("z")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawTop_=function(){var a=this.info_.topRow,b=a.elements;this.highlighter_.drawTopCorner(a);this.highlighter_.drawRightSideRow(a);this.positionPreviousConnection_();for(var c=0,d;d=b[c];c++)"square corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_POINT):"round corner"===d.type?this.steps_.push(Blockly.blockRendering.constants.TOP_LEFT_CORNER_START,Blockly.blockRendering.constants.OUTSIDE_CORNERS.topLeft):"previous connection"===d.type?
|
||||
this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathLeft):"hat"===d.type?this.steps_.push(Blockly.blockRendering.constants.START_HAT.path):d.isSpacer()&&this.steps_.push("h",d.width);this.steps_.push("v",a.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawValueInput_=function(a){var b=a.getLastInput();this.highlighter_.drawValueInput(a);this.steps_.push("H",a.width);this.steps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathDown);this.steps_.push("v",a.height-b.connectionHeight);this.positionExternalValueConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawStatementInput_=function(a){this.highlighter_.drawStatementInput(a);this.steps_.push("H",a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+Blockly.blockRendering.constants.NOTCH.width);this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathRight+" h -"+(Blockly.blockRendering.constants.NOTCH_WIDTH-Blockly.blockRendering.constants.CORNER_RADIUS)+Blockly.blockRendering.constants.INSIDE_CORNERS.pathTop);this.steps_.push("v",a.height-2*
|
||||
Blockly.blockRendering.constants.INSIDE_CORNERS.height);this.steps_.push(Blockly.blockRendering.constants.INSIDE_CORNERS.pathBottom);this.positionStatementInputConnection_(a)};Blockly.blockRendering.Drawer.prototype.drawRightSideRow_=function(a){this.highlighter_.drawRightSideRow(a);this.steps_.push("H",a.width);this.steps_.push("v",a.height)};
|
||||
Blockly.blockRendering.Drawer.prototype.drawBottom_=function(){var a=this.info_.bottomRow,b=a.elements;this.highlighter_.drawBottomCorner(a);this.positionNextConnection_();this.steps_.push("v",a.height);for(a=b.length-1;0<=a;a--){var c=b[a];"next connection"===c.type?this.steps_.push(Blockly.blockRendering.constants.NOTCH.pathRight):"square corner"===c.type?this.steps_.push("H 0"):"round corner"===c.type?this.steps_.push(Blockly.blockRendering.constants.OUTSIDE_CORNERS.bottomLeft):c.isSpacer()&&this.steps_.push("h",
|
||||
-1*c.width)}};Blockly.blockRendering.Drawer.prototype.drawLeft_=function(){this.highlighter_.drawLeft();var a=this.info_.outputConnection;this.positionOutputConnection_();a&&(this.steps_.push("V",a.connectionOffsetY+a.height),this.steps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathUp));this.steps_.push("z")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInternals_=function(){for(var a=0;a<this.info_.rows.length;a++){var b=this.info_.rows[a];if(!b.isSpacer())for(var c=0;c<b.elements.length;c++){var d=b.elements[c];d.isInlineInput()?this.drawInlineInput_(d):(d.isIcon()||d.isField())&&this.layoutField_(d)}}};
|
||||
Blockly.blockRendering.Drawer.prototype.dealWithOffsetFields_=function(a){return a instanceof Blockly.FieldDropdown||a instanceof Blockly.FieldTextInput||a instanceof Blockly.FieldColour||a instanceof Blockly.FieldCheckbox?5:0};
|
||||
Blockly.blockRendering.Drawer.prototype.layoutField_=function(a){if("field"==a.type)var b=a.field.getSvgRoot();else"icon"==a.type&&(b=a.icon.iconGroup_);var c=a.centerline-a.height/2,d=a.xPos;this.info_.RTL&&(d=-(d+a.width));"icon"==a.type?(b.setAttribute("display","block"),b.setAttribute("transform","translate("+d+","+c+")"),a.icon.computeIconLocation()):(d+=this.dealWithOffsetFields_(a.field),b.setAttribute("transform","translate("+d+","+c+")"));this.info_.isInsertionMarker&&b.setAttribute("display",
|
||||
"none")};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInlineInput_=function(a){this.highlighter_.drawInlineInput(a);var b=a.width,c=a.height;this.inlineSteps_.push("M",a.xPos+Blockly.blockRendering.constants.TAB_WIDTH+","+(a.centerline-c/2));this.inlineSteps_.push("v ",Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP);this.inlineSteps_.push(Blockly.blockRendering.constants.TAB_PATH_DOWN);this.inlineSteps_.push("v",c-Blockly.blockRendering.constants.TAB_HEIGHT-Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP);this.inlineSteps_.push("h",
|
||||
b-Blockly.blockRendering.constants.TAB_WIDTH);this.inlineSteps_.push("v",-c);this.inlineSteps_.push("z");this.positionInlineInputConnection_(a)};Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_=function(a){var b=a.centerline-a.height/2;if(a.connection){var c=a.xPos+Blockly.blockRendering.constants.TAB_WIDTH+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);a.connection.setOffsetInBlock(c,b+Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.drawInlineInput_=function(a){this.highlighter_.drawInlineInput(a);var b=a.width,c=a.height,d=a.connectionOffsetY,e=a.connectionHeight+d;this.inlineSteps_.push("M",a.xPos+a.connectionWidth+","+(a.centerline-c/2));this.inlineSteps_.push("v ",d);this.inlineSteps_.push(Blockly.blockRendering.constants.PUZZLE_TAB.pathDown);this.inlineSteps_.push("v",c-e);this.inlineSteps_.push("h",b-a.connectionWidth);this.inlineSteps_.push("v",-c);this.inlineSteps_.push("z");this.positionInlineInputConnection_(a)};
|
||||
Blockly.blockRendering.Drawer.prototype.positionInlineInputConnection_=function(a){var b=a.centerline-a.height/2;if(a.connection){var c=a.xPos+a.connectionWidth+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);a.connection.setOffsetInBlock(c,b+a.connectionOffsetY+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionStatementInputConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.statementEdge+Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c,a.yPos+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionExternalValueConnection_=function(a){var b=a.getLastInput();if(b.connection){var c=a.width+Blockly.blockRendering.constants.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connection.setOffsetInBlock(c,a.yPos)}};
|
||||
Blockly.blockRendering.Drawer.prototype.positionPreviousConnection_=function(){this.info_.topRow.hasPreviousConnection&&this.info_.topRow.connection.setOffsetInBlock(this.info_.RTL?-Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT:Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT,0)};
|
||||
Blockly.blockRendering.Drawer.prototype.positionNextConnection_=function(){var a=this.info_.bottomRow;a.hasNextConnection&&a.connection.setOffsetInBlock(this.info_.RTL?-Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT:Blockly.blockRendering.constants.NOTCH_OFFSET_LEFT,this.info_.height+Blockly.blockRendering.constants.DARK_PATH_OFFSET)};Blockly.blockRendering.Drawer.prototype.positionOutputConnection_=function(){this.info_.hasOutputConnection&&this.block_.outputConnection.setOffsetInBlock(0,Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP)};Blockly.blockRendering.render=function(a){a.renderingDebugger||(a.renderingDebugger=new Blockly.blockRendering.Debug);var b=new Blockly.blockRendering.RenderInfo(a);(new Blockly.blockRendering.Drawer(a,b)).draw_();a.renderMoveConnections_()};Blockly.utils.uiMenu={};Blockly.utils.uiMenu.getSize=function(a){a=a.getElement();var b=goog.style.getSize(a);b.height=a.scrollHeight;return b};Blockly.utils.uiMenu.adjustBBoxesForRTL=function(a,b,c){b.left+=c.width;b.right+=c.width;a.left+=c.width;a.right+=c.width};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_=null;Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=Blockly.ContextMenu.populate_(b,c);goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);Blockly.ContextMenu.position_(d,a,c);setTimeout(function(){d.getElement().focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
||||
Blockly.blockRendering.Drawer.prototype.positionNextConnection_=function(){var a=this.info_.bottomRow;if(a.hasNextConnection){var b=a.getNextConnection();a.connection.setOffsetInBlock(this.info_.RTL?-b.xPos:b.xPos,this.info_.height+Blockly.blockRendering.constants.DARK_PATH_OFFSET)}};Blockly.blockRendering.Drawer.prototype.positionOutputConnection_=function(){this.info_.outputConnection&&this.block_.outputConnection.setOffsetInBlock(0,this.info_.outputConnection.connectionOffsetY)};Blockly.blockRendering.render=function(a){a.renderingDebugger||(a.renderingDebugger=new Blockly.blockRendering.Debug);var b=new Blockly.blockRendering.RenderInfo(a);(new Blockly.blockRendering.Drawer(a,b)).draw_();a.renderMoveConnections_()};Blockly.utils.uiMenu={};Blockly.utils.uiMenu.getSize=function(a){a=a.getElement();var b=goog.style.getSize(a);b.height=a.scrollHeight;return b};Blockly.utils.uiMenu.adjustBBoxesForRTL=function(a,b,c){b.left+=c.width;b.right+=c.width;a.left+=c.width;a.right+=c.width};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_=null;Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=Blockly.ContextMenu.populate_(b,c);goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);Blockly.ContextMenu.position_(d,a,c);setTimeout(function(){d.getElement().focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
|
||||
Blockly.ContextMenu.populate_=function(a,b){var c=new goog.ui.Menu;c.setRightToLeft(b);for(var d=0,e;e=a[d];d++){var f=new goog.ui.MenuItem(e.text);f.setRightToLeft(b);c.addChild(f,!0);f.setEnabled(e.enabled);e.enabled&&(goog.events.listen(f,goog.ui.Component.EventType.ACTION,e.callback),f.handleContextMenu=function(){goog.events.dispatchEvent(this,goog.ui.Component.EventType.ACTION)})}return c};
|
||||
Blockly.ContextMenu.position_=function(a,b,c){var d=Blockly.utils.getViewportBBox();b={top:b.clientY+d.top,bottom:b.clientY+d.top,left:b.clientX+d.left,right:b.clientX+d.left};Blockly.ContextMenu.createWidget_(a);var e=Blockly.utils.uiMenu.getSize(a);c&&Blockly.utils.uiMenu.adjustBBoxesForRTL(d,b,e);Blockly.WidgetDiv.positionWithAnchor(d,b,e,c);a.getElement().focus()};
|
||||
Blockly.ContextMenu.createWidget_=function(a){a.render(Blockly.WidgetDiv.DIV);var b=a.getElement();Blockly.utils.dom.addClass(b,"blocklyContextMenu");Blockly.bindEventWithChecks_(b,"contextmenu",null,Blockly.utils.noEvent);a.setAllowAutoFocus(!0)};Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu);Blockly.ContextMenu.currentBlock=null;Blockly.ContextMenu.eventWrapper_&&Blockly.unbindEvent_(Blockly.ContextMenu.eventWrapper_)};
|
||||
@@ -1771,9 +1767,9 @@ Blockly.FieldDropdown.prototype.renderSelectedImage_=function(){this.imageElemen
|
||||
a),this.textElement_.setAttribute("x",-1)):(this.textElement_.setAttribute("text-anchor","end"),this.textElement_.setAttribute("x",this.size_.width+1))};Blockly.FieldDropdown.prototype.renderSelectedText_=function(){this.textContent_.nodeValue=this.getDisplayText_();this.textElement_.setAttribute("text-anchor","start");this.textElement_.setAttribute("x",0);this.size_.height=Blockly.BlockSvg.MIN_BLOCK_Y;this.size_.width=Blockly.Field.getCachedWidth(this.textElement_)};
|
||||
Blockly.FieldDropdown.validateOptions_=function(a){if(!Array.isArray(a))throw TypeError("FieldDropdown options must be an array.");for(var b=!1,c=0;c<a.length;++c){var d=a[c];Array.isArray(d)?"string"!=typeof d[1]?(b=!0,console.error("Invalid option["+c+"]: Each FieldDropdown option id must be a string. Found "+d[1]+" in: ",d)):"string"!=typeof d[0]&&"string"!=typeof d[0].src&&(b=!0,console.error("Invalid option["+c+"]: Each FieldDropdown option must have a string label or image description. Found"+
|
||||
d[0]+" in: ",d)):(b=!0,console.error("Invalid option["+c+"]: Each FieldDropdown option must be an array. Found: ",d))}if(b)throw TypeError("Found invalid FieldDropdown options.");};Blockly.FieldDropdown.prototype.getCorrectedSize=function(){this.getSize();return new goog.math.Size(this.size_.width+Blockly.BlockSvg.SEP_SPACE_X,this.size_.height-9)};Blockly.Field.register("field_dropdown",Blockly.FieldDropdown);Blockly.FieldLabelSerializable=function(a,b){Blockly.FieldLabelSerializable.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldLabelSerializable,Blockly.FieldLabel);Blockly.FieldLabelSerializable.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.text);return new Blockly.FieldLabelSerializable(b,a["class"])};Blockly.FieldLabelSerializable.prototype.EDITABLE=!1;Blockly.FieldLabelSerializable.prototype.SERIALIZABLE=!0;
|
||||
Blockly.Field.register("field_label_serializable",Blockly.FieldLabelSerializable);Blockly.FieldImage=function(a,b,c,d,e,f){this.sourceBlock_=null;if(isNaN(c)||isNaN(b))throw Error("Height and width values of an image field must cast to numbers.");this.height_=Number(c);this.width_=Number(b);if(0>=this.height_||0>=this.width_)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new goog.math.Size(this.width_,this.height_+2*Blockly.BlockSvg.INLINE_PADDING_Y);this.flipRtl_=f;this.text_=d||"";this.setValue(a||"");"function"==typeof e&&(this.clickHandler_=
|
||||
e)};goog.inherits(Blockly.FieldImage,Blockly.Field);Blockly.FieldImage.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.src),c=Number(Blockly.utils.replaceMessageReferences(a.width)),d=Number(Blockly.utils.replaceMessageReferences(a.height)),e=Blockly.utils.replaceMessageReferences(a.alt);return new Blockly.FieldImage(b,c,d,e,null,!!a.flipRtl)};Blockly.FieldImage.prototype.EDITABLE=!1;Blockly.FieldImage.prototype.isDirty_=!1;
|
||||
Blockly.FieldImage.prototype.initView=function(){this.imageElement_=Blockly.utils.dom.createSvgElement("image",{height:this.height_+"px",width:this.width_+"px",alt:this.text_},this.fieldGroup_);this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,"xlink:href",this.value_)};Blockly.FieldImage.prototype.doClassValidation_=function(a){return"string"!=typeof a?null:a};
|
||||
Blockly.Field.register("field_label_serializable",Blockly.FieldLabelSerializable);Blockly.FieldImage=function(a,b,c,d,e,f){this.sourceBlock_=null;if(!a)throw Error("Src value of an image field is required");if(isNaN(c)||isNaN(b))throw Error("Height and width values of an image field must cast to numbers.");this.height_=Number(c);this.width_=Number(b);if(0>=this.height_||0>=this.width_)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new goog.math.Size(this.width_,this.height_+2*Blockly.BlockSvg.INLINE_PADDING_Y);this.flipRtl_=f;this.text_=
|
||||
d||"";this.setValue(a||"");"function"==typeof e&&(this.clickHandler_=e)};goog.inherits(Blockly.FieldImage,Blockly.Field);Blockly.FieldImage.fromJson=function(a){var b=Blockly.utils.replaceMessageReferences(a.src),c=Number(Blockly.utils.replaceMessageReferences(a.width)),d=Number(Blockly.utils.replaceMessageReferences(a.height)),e=Blockly.utils.replaceMessageReferences(a.alt);return new Blockly.FieldImage(b,c,d,e,null,!!a.flipRtl)};Blockly.FieldImage.prototype.EDITABLE=!1;
|
||||
Blockly.FieldImage.prototype.isDirty_=!1;Blockly.FieldImage.prototype.initView=function(){this.imageElement_=Blockly.utils.dom.createSvgElement("image",{height:this.height_+"px",width:this.width_+"px",alt:this.text_},this.fieldGroup_);this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,"xlink:href",this.value_)};Blockly.FieldImage.prototype.doClassValidation_=function(a){return"string"!=typeof a?null:a};
|
||||
Blockly.FieldImage.prototype.doValueUpdate_=function(a){this.value_=a;this.imageElement_&&this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,"xlink:href",this.value_||"")};Blockly.FieldImage.prototype.getFlipRtl=function(){return this.flipRtl_};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a,this.imageElement_&&this.imageElement_.setAttribute("alt",a||""))};Blockly.FieldImage.prototype.showEditor_=function(){this.clickHandler_&&this.clickHandler_(this)};
|
||||
Blockly.FieldImage.prototype.setOnClickHandler=function(a){this.clickHandler_=a};Blockly.FieldImage.prototype.getCorrectedSize=function(){this.getSize();return new goog.math.Size(this.size_.width,this.height_+1)};Blockly.Field.register("field_image",Blockly.FieldImage);Blockly.FieldNumber=function(a,b,c,d,e){this.setConstraints(b,c,d);a=this.doClassValidation_(a);null===a&&(a=0);Blockly.FieldNumber.superClass_.constructor.call(this,a,e)};goog.inherits(Blockly.FieldNumber,Blockly.FieldTextInput);Blockly.FieldNumber.fromJson=function(a){return new Blockly.FieldNumber(a.value,a.min,a.max,a.precision)};Blockly.FieldNumber.prototype.SERIALIZABLE=!0;
|
||||
Blockly.FieldNumber.prototype.setConstraints=function(a,b,c){c=parseFloat(c);this.precision_=isNaN(c)?0:c;c=this.precision_.toString();var d=c.indexOf(".");this.fractionalDigits_=-1==d?-1:c.length-(d+1);a=parseFloat(a);this.min_=isNaN(a)?-Infinity:a;b=parseFloat(b);this.max_=isNaN(b)?Infinity:b;this.setValue(this.getValue())};
|
||||
|
||||
@@ -92,10 +92,11 @@ goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedur
|
||||
goog.addDependency("../../../" + dir + "/core/rendered_connection.js", ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.Events', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw.js", ['Blockly.blockRendering.Drawer'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Debug', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Highlighter', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw_debug.js", ['Blockly.blockRendering.Debug'], ['Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Highlighter', 'Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js", ['Blockly.blockRendering.Highlighter'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_draw_highlight.js", ['Blockly.blockRendering.Highlighter'], ['Blockly.blockRendering.highlightConstants', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_render_info.js", ['Blockly.blockRendering.RenderInfo'], ['Blockly.blockRendering.constants', 'Blockly.blockRendering.Measurable']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering.js", ['Blockly.blockRendering'], ['Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.RenderInfo']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/block_rendering_constants.js", ['Blockly.blockRendering.constants'], ['Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/highlight_constants.js", ['Blockly.blockRendering.highlightConstants'], ['Blockly.blockRendering.constants', 'Blockly.utils.svgPaths']);
|
||||
goog.addDependency("../../../" + dir + "/core/renderers/block_rendering_rewrite/measurables.js", ['Blockly.blockRendering.Measurable'], ['Blockly.blockRendering.constants']);
|
||||
goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../../" + dir + "/core/theme.js", ['Blockly.Theme'], []);
|
||||
@@ -126,7 +127,7 @@ goog.addDependency("../../../" + dir + "/core/variables.js", ['Blockly.Variables
|
||||
goog.addDependency("../../../" + dir + "/core/variables_dynamic.js", ['Blockly.VariablesDynamic'], ['Blockly.Variables', 'Blockly.Blocks', 'Blockly.Msg', 'Blockly.utils.xml', 'Blockly.VariableModel', 'Blockly.Xml']);
|
||||
goog.addDependency("../../../" + dir + "/core/warning.js", ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.Ui', 'Blockly.Icon', 'Blockly.utils.dom']);
|
||||
goog.addDependency("../../../" + dir + "/core/widgetdiv.js", ['Blockly.WidgetDiv'], ['Blockly.Css', 'goog.style']);
|
||||
goog.addDependency("../../../" + dir + "/core/workspace.js", ['Blockly.Workspace'], ['Blockly.Events', 'Blockly.utils', 'Blockly.utils.math', 'Blockly.VariableMap', 'Blockly.WorkspaceComment', 'Blockly.Cursor', 'Blockly.Themes.Classic']);
|
||||
goog.addDependency("../../../" + dir + "/core/workspace.js", ['Blockly.Workspace'], ['Blockly.Cursor', 'Blockly.Events', 'Blockly.Themes.Classic', 'Blockly.utils', 'Blockly.utils.math', 'Blockly.VariableMap', 'Blockly.WorkspaceComment']);
|
||||
goog.addDependency("../../../" + dir + "/core/workspace_audio.js", ['Blockly.WorkspaceAudio'], ['Blockly.utils', 'Blockly.utils.userAgent']);
|
||||
goog.addDependency("../../../" + dir + "/core/workspace_comment.js", ['Blockly.WorkspaceComment'], ['Blockly.Events', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.xml']);
|
||||
goog.addDependency("../../../" + dir + "/core/workspace_comment_render_svg.js", ['Blockly.WorkspaceCommentSvg.render'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom', 'Blockly.WorkspaceCommentSvg']);
|
||||
@@ -701,10 +702,8 @@ goog.addDependency("html/sanitizer/csssanitizer.js", ['goog.html.sanitizer.CssSa
|
||||
goog.addDependency("html/sanitizer/csssanitizer_test.js", [], []);
|
||||
goog.addDependency("html/sanitizer/elementweakmap.js", [], []);
|
||||
goog.addDependency("html/sanitizer/elementweakmap_test.js", [], []);
|
||||
goog.addDependency("html/sanitizer/html_test_vectors.js", ['goog.html.htmlTestVectors'], []);
|
||||
goog.addDependency("html/sanitizer/htmlsanitizer.js", ['goog.html.sanitizer.HtmlSanitizer', 'goog.html.sanitizer.HtmlSanitizer.Builder', 'goog.html.sanitizer.HtmlSanitizerAttributePolicy', 'goog.html.sanitizer.HtmlSanitizerPolicy', 'goog.html.sanitizer.HtmlSanitizerPolicyContext', 'goog.html.sanitizer.HtmlSanitizerPolicyHints', 'goog.html.sanitizer.HtmlSanitizerUrlPolicy'], ['goog.array', 'goog.asserts', 'goog.dom', 'goog.dom.TagName', 'goog.functions', 'goog.html.SafeHtml', 'goog.html.SafeStyle', 'goog.html.SafeStyleSheet', 'goog.html.SafeUrl', 'goog.html.sanitizer.AttributeSanitizedWhitelist', 'goog.html.sanitizer.AttributeWhitelist', 'goog.html.sanitizer.CssSanitizer', 'goog.html.sanitizer.SafeDomTreeProcessor', 'goog.html.sanitizer.TagBlacklist', 'goog.html.sanitizer.TagWhitelist', 'goog.html.sanitizer.noclobber', 'goog.html.uncheckedconversions', 'goog.object', 'goog.string', 'goog.string.Const']);
|
||||
goog.addDependency("html/sanitizer/htmlsanitizer_test.js", [], []);
|
||||
goog.addDependency("html/sanitizer/htmlsanitizer_unified_test.js", [], []);
|
||||
goog.addDependency("html/sanitizer/noclobber.js", [], []);
|
||||
goog.addDependency("html/sanitizer/noclobber_test.js", [], []);
|
||||
goog.addDependency("html/sanitizer/safedomtreeprocessor.js", [], []);
|
||||
@@ -1885,6 +1884,7 @@ goog.require('Blockly.blockRendering.Highlighter');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.blockRendering.highlightConstants');
|
||||
goog.require('Blockly.constants');
|
||||
goog.require('Blockly.inject');
|
||||
goog.require('Blockly.utils');
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
'use strict';
|
||||
goog.provide('Blockly.blockRendering.Highlighter');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.blockRendering.highlightConstants');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.blockRendering.Measurable');
|
||||
|
||||
@@ -53,27 +53,30 @@ Blockly.blockRendering.Highlighter = function(info, pathObject) {
|
||||
this.highlightSteps_ = this.pathObject_.highlightSteps;
|
||||
this.highlightInlineSteps_ = this.pathObject_.highlightInlineSteps;
|
||||
|
||||
this.highlightOffset_ = Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;
|
||||
this.highlightOffset_ = Blockly.blockRendering.highlightConstants.OFFSET;
|
||||
|
||||
this.outsideCornerPaths_ = Blockly.blockRendering.constants.OUTSIDE_CORNER_HIGHLIGHTS;
|
||||
this.insideCornerPaths_ = Blockly.blockRendering.constants.INSIDE_CORNER_HIGHLIGHTS;
|
||||
this.puzzleTabPaths_ = Blockly.blockRendering.constants.PUZZLE_TAB_HIGHLIGHT;
|
||||
this.outsideCornerPaths_ = Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER;
|
||||
this.insideCornerPaths_ = Blockly.blockRendering.highlightConstants.INSIDE_CORNER;
|
||||
this.puzzleTabPaths_ = Blockly.blockRendering.highlightConstants.PUZZLE_TAB;
|
||||
this.notchPaths_ = Blockly.blockRendering.highlightConstants.NOTCH;
|
||||
this.startPaths_ = Blockly.blockRendering.highlightConstants.START_HAT;
|
||||
};
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
for (var i = 0, elem; elem = row.elements[i]; i++) {
|
||||
if (elem.type === 'square corner') {
|
||||
this.highlightSteps_.push(Blockly.blockRendering.constants.START_POINT_HIGHLIGHT);
|
||||
this.highlightSteps_.push(Blockly.blockRendering.highlightConstants.START_POINT);
|
||||
} else if (elem.type === 'round corner') {
|
||||
this.highlightSteps_.push(
|
||||
this.outsideCornerPaths_.topLeft(this.info_.RTL));
|
||||
} else if (elem.type === 'previous connection') {
|
||||
// TODO: move the offsets into the definition of the notch highlight, maybe.
|
||||
this.highlightSteps_.push('h', (this.RTL ? 0.5 : - 0.5));
|
||||
this.highlightSteps_.push(Blockly.blockRendering.constants.NOTCH.pathLeftHighlight);
|
||||
this.highlightSteps_.push(this.notchPaths_.pathLeft);
|
||||
this.highlightSteps_.push('h', (this.RTL ? -0.5 : 0.5));
|
||||
} else if (elem.type === 'hat') {
|
||||
this.highlightSteps_.push(
|
||||
Blockly.blockRendering.constants.START_HAT.highlight(this.info_.RTL));
|
||||
this.startPaths_.path(this.info_.RTL));
|
||||
} else if (elem.isSpacer()) {
|
||||
this.highlightSteps_.push('h', elem.width - this.highlightOffset_);
|
||||
}
|
||||
@@ -104,18 +107,19 @@ Blockly.blockRendering.Highlighter.prototype.drawValueInput = function(row) {
|
||||
|
||||
Blockly.blockRendering.Highlighter.prototype.drawStatementInput = function(row) {
|
||||
var x = row.statementEdge;
|
||||
var distance45outside = Blockly.blockRendering.highlightConstants.DISTANCE_45_OUTSIDE;
|
||||
if (this.info_.RTL) {
|
||||
this.highlightSteps_.push('M',
|
||||
(x + Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE) +
|
||||
',' + (row.yPos + Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE));
|
||||
(x + distance45outside) +
|
||||
',' + (row.yPos + distance45outside));
|
||||
this.highlightSteps_.push(this.insideCornerPaths_.pathTop(this.info_.RTL));
|
||||
this.highlightSteps_.push('v',
|
||||
row.height - 2 * Blockly.blockRendering.constants.CORNER_RADIUS);
|
||||
row.height - 2 * this.insideCornerPaths_.height);
|
||||
this.highlightSteps_.push(this.insideCornerPaths_.pathBottom(this.info_.RTL));
|
||||
} else {
|
||||
this.highlightSteps_.push('M',
|
||||
(x + Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE) + ',' +
|
||||
(row.yPos + row.height - Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE));
|
||||
(x + distance45outside) + ',' +
|
||||
(row.yPos + row.height - distance45outside));
|
||||
this.highlightSteps_.push(this.insideCornerPaths_.pathBottom(this.info_.RTL));
|
||||
}
|
||||
};
|
||||
@@ -164,7 +168,7 @@ Blockly.blockRendering.Highlighter.prototype.drawLeft = function() {
|
||||
if (this.info_.topRow.elements[0].isSquareCorner()) {
|
||||
this.highlightSteps_.push('V', this.highlightOffset_);
|
||||
} else {
|
||||
this.highlightSteps_.push('V', Blockly.blockRendering.constants.CORNER_RADIUS);
|
||||
this.highlightSteps_.push('V', this.outsideCornerPaths_.height);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,6 @@ Blockly.blockRendering.constants.LARGE_PADDING = 10;
|
||||
Blockly.blockRendering.constants.TALL_INPUT_FIELD_OFFSET_Y =
|
||||
Blockly.blockRendering.constants.MEDIUM_PADDING;
|
||||
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET = 0.5;
|
||||
|
||||
// The dark/shadow path in classic rendering is the same as the normal block
|
||||
// path, but translated down one and right one.
|
||||
@@ -132,21 +131,6 @@ Blockly.blockRendering.constants.POPULATED_STATEMENT_INPUT_WIDTH = 25;
|
||||
|
||||
Blockly.blockRendering.constants.START_POINT = Blockly.utils.svgPaths.moveBy(0, 0);
|
||||
|
||||
Blockly.blockRendering.constants.START_POINT_HIGHLIGHT =
|
||||
Blockly.utils.svgPaths.moveBy(
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET,
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET);
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the outside of a curve.
|
||||
* @const
|
||||
*/
|
||||
Blockly.blockRendering.constants.DISTANCE_45_OUTSIDE = (1 - Math.SQRT1_2) *
|
||||
(Blockly.blockRendering.constants.CORNER_RADIUS +
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET) -
|
||||
Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;
|
||||
|
||||
/**
|
||||
* SVG start point for drawing the top-left corner.
|
||||
* @const
|
||||
@@ -161,23 +145,6 @@ Blockly.blockRendering.constants.START_HAT = (function() {
|
||||
// It's really minus 15, which is super unfortunate.
|
||||
var height = Blockly.blockRendering.constants.START_HAT_HEIGHT;
|
||||
var width = Blockly.blockRendering.constants.START_HAT_WIDTH;
|
||||
var highlightRtlPath =
|
||||
Blockly.utils.svgPaths.moveBy(25, -8.7) +
|
||||
Blockly.utils.svgPaths.curve('c',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(29.7, -6.2),
|
||||
Blockly.utils.svgPaths.point(57.2, -0.5),
|
||||
Blockly.utils.svgPaths.point(75, 8.7)
|
||||
]);
|
||||
|
||||
var highlightLtrPath =
|
||||
Blockly.utils.svgPaths.curve('c',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(17.8, -9.2),
|
||||
Blockly.utils.svgPaths.point(45.3, -14.9),
|
||||
Blockly.utils.svgPaths.point(75, -8.7)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveTo(100.5, 0.5);
|
||||
|
||||
var mainPath =
|
||||
Blockly.utils.svgPaths.curve('c',
|
||||
@@ -189,10 +156,7 @@ Blockly.blockRendering.constants.START_HAT = (function() {
|
||||
return {
|
||||
height: height,
|
||||
width: width,
|
||||
path: mainPath,
|
||||
highlight: function(rtl) {
|
||||
return rtl ? highlightRtlPath : highlightLtrPath;
|
||||
}
|
||||
path: mainPath
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -244,60 +208,6 @@ Blockly.blockRendering.constants.PUZZLE_TAB = (function() {
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.constants.PUZZLE_TAB_HIGHLIGHT = (function() {
|
||||
var width = Blockly.blockRendering.constants.TAB_WIDTH;
|
||||
var height = Blockly.blockRendering.constants.TAB_HEIGHT;
|
||||
|
||||
// This is how much of the vertical block edge is actually drawn by the puzzle
|
||||
// tab.
|
||||
var verticalOverlap = 2.5;
|
||||
|
||||
// The highlight paths are not simple offsets of the main paths. Changing
|
||||
// them is fiddly work.
|
||||
var highlightRtlUp =
|
||||
Blockly.utils.svgPaths.moveTo(width * -0.25, 8.4) +
|
||||
Blockly.utils.svgPaths.lineTo(width * -0.45, -2.1);
|
||||
|
||||
var highlightRtlDown =
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', verticalOverlap) +
|
||||
Blockly.utils.svgPaths.moveBy(-width * 0.97, 2.5) +
|
||||
Blockly.utils.svgPaths.curve('q',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(-width * 0.05, 10),
|
||||
Blockly.utils.svgPaths.point(width * 0.3, 9.5)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveBy(width * 0.67, -1.9) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', verticalOverlap);
|
||||
|
||||
var highlightLtrUp =
|
||||
// TODO: Move this 'V' out.
|
||||
Blockly.utils.svgPaths.lineOnAxis('V',
|
||||
height + Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP - 1.5) +
|
||||
Blockly.utils.svgPaths.moveBy(width * -0.92, -0.5) +
|
||||
Blockly.utils.svgPaths.curve('q',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(width * -0.19, -5.5),
|
||||
Blockly.utils.svgPaths.point(0,-11)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveBy(width * 0.92, 1) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('V', 0.5) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('H', 1);
|
||||
|
||||
var highlightLtrDown =
|
||||
Blockly.utils.svgPaths.moveBy(-5, height - 0.7) +
|
||||
Blockly.utils.svgPaths.lineTo(width * 0.46, -2.1);
|
||||
|
||||
return {
|
||||
width: width,
|
||||
height: height,
|
||||
pathUp: function(rtl) {
|
||||
return rtl ? highlightRtlUp : highlightLtrUp;
|
||||
},
|
||||
pathDown: function(rtl) {
|
||||
return rtl ? highlightRtlDown : highlightLtrDown;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.constants.NOTCH = (function() {
|
||||
var width = Blockly.blockRendering.constants.NOTCH_WIDTH;
|
||||
@@ -316,12 +226,10 @@ Blockly.blockRendering.constants.NOTCH = (function() {
|
||||
var pathLeft = makeMainPath(1);
|
||||
var pathRight = makeMainPath(-1);
|
||||
|
||||
var pathLeftHighlight = Blockly.utils.svgPaths.lineOnAxis('h', Blockly.blockRendering.constants.HIGHLIGHT_OFFSET) + pathLeft;
|
||||
return {
|
||||
width: width,
|
||||
height: height,
|
||||
pathLeft: pathLeft,
|
||||
pathLeftHighlight: pathLeftHighlight,
|
||||
pathRight: pathRight
|
||||
};
|
||||
})();
|
||||
@@ -344,44 +252,7 @@ Blockly.blockRendering.constants.INSIDE_CORNERS = (function() {
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Highlight paths for drawing the inside corners of a statement input.
|
||||
*/
|
||||
Blockly.blockRendering.constants.INSIDE_CORNER_HIGHLIGHTS = (function() {
|
||||
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
var offset = Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the outside of a curve.
|
||||
* @const
|
||||
*/
|
||||
var distance45outside = (1 - Math.SQRT1_2) * (radius + offset) - offset;
|
||||
|
||||
var pathTopRtl = Blockly.utils.svgPaths.arc('a', '0 0,0', radius,
|
||||
Blockly.utils.svgPaths.point(
|
||||
-distance45outside - offset,
|
||||
radius - distance45outside));
|
||||
|
||||
var pathBottomRtl = Blockly.utils.svgPaths.arc('a', '0 0,0', radius + offset,
|
||||
Blockly.utils.svgPaths.point(radius + offset, radius + offset));
|
||||
|
||||
var pathBottomLtr = Blockly.utils.svgPaths.arc('a', '0 0,0', radius + offset,
|
||||
Blockly.utils.svgPaths.point(
|
||||
radius - distance45outside,
|
||||
distance45outside + offset));
|
||||
|
||||
return {
|
||||
// width: width,
|
||||
// height: height,
|
||||
pathTop: function(rtl) {
|
||||
return rtl ? pathTopRtl : '';
|
||||
},
|
||||
pathBottom: function(rtl) {
|
||||
return rtl ? pathBottomRtl : pathBottomLtr;
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNERS = (function() {
|
||||
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
@@ -403,49 +274,3 @@ Blockly.blockRendering.constants.OUTSIDE_CORNERS = (function() {
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.constants.OUTSIDE_CORNER_HIGHLIGHTS = (function() {
|
||||
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
var offset = Blockly.blockRendering.constants.HIGHLIGHT_OFFSET;
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the inside of a curve.
|
||||
* @const
|
||||
*/
|
||||
var distance45inside = (1 - Math.SQRT1_2) * (radius - offset) + offset;
|
||||
|
||||
/**
|
||||
* SVG start point for drawing the top-left corner's highlight in RTL.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerStartRtl =
|
||||
Blockly.utils.svgPaths.moveBy(distance45inside, distance45inside);
|
||||
|
||||
/**
|
||||
* SVG start point for drawing the top-left corner's highlight in LTR.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerStartLtr =
|
||||
Blockly.utils.svgPaths.moveBy(offset, radius - offset);
|
||||
|
||||
/**
|
||||
* SVG path for drawing the highlight on the rounded top-left corner.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerHighlight =
|
||||
Blockly.utils.svgPaths.arc('A', '0 0,1', radius - offset,
|
||||
Blockly.utils.svgPaths.point(radius, offset));
|
||||
|
||||
return {
|
||||
topLeft: function(rtl) {
|
||||
var start = rtl ? topLeftCornerStartRtl : topLeftCornerStartLtr;
|
||||
return start + topLeftCornerHighlight;
|
||||
},
|
||||
bottomLeft: function(yPos) {
|
||||
return Blockly.utils.svgPaths.moveTo(
|
||||
distance45inside,yPos - distance45inside) +
|
||||
Blockly.utils.svgPaths.arc('A', '0 0,1', radius - offset,
|
||||
Blockly.utils.svgPaths.point(offset, yPos - radius));
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
224
core/renderers/block_rendering_rewrite/highlight_constants.js
Normal file
224
core/renderers/block_rendering_rewrite/highlight_constants.js
Normal file
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 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 Methods for graphically rendering a block as SVG.
|
||||
* @author fenichel@google.com (Rachel Fenichel)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
goog.provide('Blockly.blockRendering.highlightConstants');
|
||||
|
||||
goog.require('Blockly.blockRendering.constants');
|
||||
goog.require('Blockly.utils.svgPaths');
|
||||
|
||||
|
||||
Blockly.blockRendering.highlightConstants.OFFSET = 0.5;
|
||||
|
||||
Blockly.blockRendering.highlightConstants.START_POINT =
|
||||
Blockly.utils.svgPaths.moveBy(
|
||||
Blockly.blockRendering.highlightConstants.OFFSET,
|
||||
Blockly.blockRendering.highlightConstants.OFFSET);
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the outside of a curve.
|
||||
* @const
|
||||
*/
|
||||
Blockly.blockRendering.highlightConstants.DISTANCE_45_OUTSIDE = (1 - Math.SQRT1_2) *
|
||||
(Blockly.blockRendering.constants.CORNER_RADIUS +
|
||||
Blockly.blockRendering.highlightConstants.OFFSET) -
|
||||
Blockly.blockRendering.highlightConstants.OFFSET;
|
||||
|
||||
/**
|
||||
* Highlight paths for drawing the inside corners of a statement input.
|
||||
*/
|
||||
Blockly.blockRendering.highlightConstants.INSIDE_CORNER = (function() {
|
||||
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
var offset = Blockly.blockRendering.highlightConstants.OFFSET;
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the outside of a curve.
|
||||
* @const
|
||||
*/
|
||||
var distance45outside = (1 - Math.SQRT1_2) * (radius + offset) - offset;
|
||||
|
||||
var pathTopRtl = Blockly.utils.svgPaths.arc('a', '0 0,0', radius,
|
||||
Blockly.utils.svgPaths.point(
|
||||
-distance45outside - offset,
|
||||
radius - distance45outside));
|
||||
|
||||
var pathBottomRtl = Blockly.utils.svgPaths.arc('a', '0 0,0', radius + offset,
|
||||
Blockly.utils.svgPaths.point(radius + offset, radius + offset));
|
||||
|
||||
var pathBottomLtr = Blockly.utils.svgPaths.arc('a', '0 0,0', radius + offset,
|
||||
Blockly.utils.svgPaths.point(
|
||||
radius - distance45outside,
|
||||
distance45outside + offset));
|
||||
|
||||
return {
|
||||
// width: width,
|
||||
height: radius,
|
||||
pathTop: function(rtl) {
|
||||
return rtl ? pathTopRtl : '';
|
||||
},
|
||||
pathBottom: function(rtl) {
|
||||
return rtl ? pathBottomRtl : pathBottomLtr;
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.highlightConstants.OUTSIDE_CORNER = (function() {
|
||||
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
|
||||
var offset = Blockly.blockRendering.highlightConstants.OFFSET;
|
||||
|
||||
/**
|
||||
* Distance from shape edge to intersect with a curved corner at 45 degrees.
|
||||
* Applies to highlighting on around the inside of a curve.
|
||||
* @const
|
||||
*/
|
||||
var distance45inside = (1 - Math.SQRT1_2) * (radius - offset) + offset;
|
||||
|
||||
/**
|
||||
* SVG start point for drawing the top-left corner's highlight in RTL.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerStartRtl =
|
||||
Blockly.utils.svgPaths.moveBy(distance45inside, distance45inside);
|
||||
|
||||
/**
|
||||
* SVG start point for drawing the top-left corner's highlight in LTR.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerStartLtr =
|
||||
Blockly.utils.svgPaths.moveBy(offset, radius - offset);
|
||||
|
||||
/**
|
||||
* SVG path for drawing the highlight on the rounded top-left corner.
|
||||
* @const
|
||||
*/
|
||||
var topLeftCornerHighlight =
|
||||
Blockly.utils.svgPaths.arc('A', '0 0,1', radius - offset,
|
||||
Blockly.utils.svgPaths.point(radius, offset));
|
||||
|
||||
return {
|
||||
height: radius,
|
||||
topLeft: function(rtl) {
|
||||
var start = rtl ? topLeftCornerStartRtl : topLeftCornerStartLtr;
|
||||
return start + topLeftCornerHighlight;
|
||||
},
|
||||
bottomLeft: function(yPos) {
|
||||
return Blockly.utils.svgPaths.moveTo(
|
||||
distance45inside,yPos - distance45inside) +
|
||||
Blockly.utils.svgPaths.arc('A', '0 0,1', radius - offset,
|
||||
Blockly.utils.svgPaths.point(offset, yPos - radius));
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
Blockly.blockRendering.highlightConstants.PUZZLE_TAB = (function() {
|
||||
var width = Blockly.blockRendering.constants.TAB_WIDTH;
|
||||
var height = Blockly.blockRendering.constants.TAB_HEIGHT;
|
||||
|
||||
// This is how much of the vertical block edge is actually drawn by the puzzle
|
||||
// tab.
|
||||
var verticalOverlap = 2.5;
|
||||
|
||||
var highlightRtlUp =
|
||||
Blockly.utils.svgPaths.moveTo(width * -0.25, 8.4) +
|
||||
Blockly.utils.svgPaths.lineTo(width * -0.45, -2.1);
|
||||
|
||||
var highlightRtlDown =
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', verticalOverlap) +
|
||||
Blockly.utils.svgPaths.moveBy(-width * 0.97, 2.5) +
|
||||
Blockly.utils.svgPaths.curve('q',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(-width * 0.05, 10),
|
||||
Blockly.utils.svgPaths.point(width * 0.3, 9.5)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveBy(width * 0.67, -1.9) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', verticalOverlap);
|
||||
|
||||
var highlightLtrUp =
|
||||
// TODO: Move this 'V' out.
|
||||
Blockly.utils.svgPaths.lineOnAxis('V',
|
||||
height + Blockly.blockRendering.constants.TAB_OFFSET_FROM_TOP - 1.5) +
|
||||
Blockly.utils.svgPaths.moveBy(width * -0.92, -0.5) +
|
||||
Blockly.utils.svgPaths.curve('q',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(width * -0.19, -5.5),
|
||||
Blockly.utils.svgPaths.point(0,-11)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveBy(width * 0.92, 1) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('V', 0.5) +
|
||||
Blockly.utils.svgPaths.lineOnAxis('H', 1);
|
||||
|
||||
var highlightLtrDown =
|
||||
Blockly.utils.svgPaths.moveBy(-5, height - 0.7) +
|
||||
Blockly.utils.svgPaths.lineTo(width * 0.46, -2.1);
|
||||
|
||||
return {
|
||||
width: width,
|
||||
height: height,
|
||||
pathUp: function(rtl) {
|
||||
return rtl ? highlightRtlUp : highlightLtrUp;
|
||||
},
|
||||
pathDown: function(rtl) {
|
||||
return rtl ? highlightRtlDown : highlightLtrDown;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.highlightConstants.NOTCH = (function() {
|
||||
var pathLeft =
|
||||
Blockly.utils.svgPaths.lineOnAxis(
|
||||
'h', Blockly.blockRendering.highlightConstants.OFFSET) +
|
||||
Blockly.blockRendering.constants.NOTCH.pathLeft;
|
||||
return {
|
||||
pathLeft: pathLeft
|
||||
};
|
||||
})();
|
||||
|
||||
Blockly.blockRendering.highlightConstants.START_HAT = (function() {
|
||||
var pathRtl =
|
||||
Blockly.utils.svgPaths.moveBy(25, -8.7) +
|
||||
Blockly.utils.svgPaths.curve('c',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(29.7, -6.2),
|
||||
Blockly.utils.svgPaths.point(57.2, -0.5),
|
||||
Blockly.utils.svgPaths.point(75, 8.7)
|
||||
]);
|
||||
|
||||
var pathLtr =
|
||||
Blockly.utils.svgPaths.curve('c',
|
||||
[
|
||||
Blockly.utils.svgPaths.point(17.8, -9.2),
|
||||
Blockly.utils.svgPaths.point(45.3, -14.9),
|
||||
Blockly.utils.svgPaths.point(75, -8.7)
|
||||
]) +
|
||||
Blockly.utils.svgPaths.moveTo(100.5, 0.5);
|
||||
return {
|
||||
path: function(rtl) {
|
||||
return rtl ? pathRtl : pathLtr;
|
||||
}
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user