Commit 8b57ae53 authored by Neil Fraser's avatar Neil Fraser

More single pixel connection tweaks.

parent 9e8edc8c
......@@ -1113,10 +1113,10 @@ Blockly.BlockSvg.prototype.removeSelect=function(){Blockly.removeClass_(this.svg
Blockly.BlockSvg.prototype.render=function(a){this.rendered=!0;var b=Blockly.BlockSvg.SEP_SPACE_X;this.RTL&&(b=-b);for(var c=this.getIcons(),d=0;d<c.length;d++)b=c[d].renderIcon(b);b+=this.RTL?Blockly.BlockSvg.SEP_SPACE_X:-Blockly.BlockSvg.SEP_SPACE_X;c=this.renderCompute_(b);this.renderDraw_(b,c);!1!==a&&((a=this.getParent())?a.render(!0):Blockly.fireUiEvent(window,"resize"));Blockly.Realtime.blockChanged(this)};
Blockly.BlockSvg.prototype.renderFields_=function(a,b,c){this.RTL&&(b=-b);for(var d=0,e;e=a[d];d++){var f=e.getSvgRoot();f&&(this.RTL?(b-=e.renderSep+e.renderWidth,f.setAttribute("transform","translate("+b+", "+c+")"),e.renderWidth&&(b-=Blockly.BlockSvg.SEP_SPACE_X)):(f.setAttribute("transform","translate("+(b+e.renderSep)+", "+c+")"),e.renderWidth&&(b+=e.renderSep+e.renderWidth+Blockly.BlockSvg.SEP_SPACE_X)))}return this.RTL?-b:b};
Blockly.BlockSvg.prototype.renderCompute_=function(a){var b=this.inputList,c=[];c.rightEdge=a+2*Blockly.BlockSvg.SEP_SPACE_X;if(this.previousConnection||this.nextConnection)c.rightEdge=Math.max(c.rightEdge,Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.SEP_SPACE_X);for(var d=0,e=0,f=!1,g=!1,h=!1,k=void 0,l=this.inputsInline&&!this.isCollapsed(),p=0,m;m=b[p];p++)if(m.isVisible()){var q;l&&k&&k!=Blockly.NEXT_STATEMENT&&m.type!=Blockly.NEXT_STATEMENT?q=c[c.length-1]:(k=m.type,q=[],q.type=l&&m.type!=Blockly.NEXT_STATEMENT?
Blockly.BlockSvg.INLINE:m.type,q.height=0,c.push(q));q.push(m);m.renderHeight=Blockly.BlockSvg.MIN_BLOCK_Y;m.renderWidth=l&&m.type==Blockly.INPUT_VALUE?Blockly.BlockSvg.TAB_WIDTH+1.25*Blockly.BlockSvg.SEP_SPACE_X:0;if(m.connection&&m.connection.targetConnection){var n=m.connection.targetBlock().getHeightWidth();m.renderHeight=Math.max(m.renderHeight,n.height);m.renderWidth=Math.max(m.renderWidth,n.width)}l||p!=b.length-1||m.renderHeight--;q.height=Math.max(q.height,m.renderHeight);m.fieldWidth=0;
1==c.length&&(m.fieldWidth+=this.RTL?-a:a);for(var n=!1,r=0,t;t=m.fieldRow[r];r++){0!=r&&(m.fieldWidth+=Blockly.BlockSvg.SEP_SPACE_X);var u=t.getSize();t.renderWidth=u.width;t.renderSep=n&&t.EDITABLE?Blockly.BlockSvg.SEP_SPACE_X:0;m.fieldWidth+=t.renderWidth+t.renderSep;q.height=Math.max(q.height,u.height);n=t.EDITABLE}q.type!=Blockly.BlockSvg.INLINE&&(q.type==Blockly.NEXT_STATEMENT?(g=!0,e=Math.max(e,m.fieldWidth)):(q.type==Blockly.INPUT_VALUE?f=!0:q.type==Blockly.DUMMY_INPUT&&(h=!0),d=Math.max(d,
m.fieldWidth)))}for(a=0;q=c[a];a++)if(q.thicker=!1,q.type==Blockly.BlockSvg.INLINE)for(b=0;m=q[b];b++)if(m.type==Blockly.INPUT_VALUE){q.height+=2*Blockly.BlockSvg.INLINE_PADDING_Y;q.thicker=!0;break}c.statementEdge=2*Blockly.BlockSvg.SEP_SPACE_X+e;g&&(c.rightEdge=Math.max(c.rightEdge,c.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH));f?c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X+Blockly.BlockSvg.TAB_WIDTH):h&&(c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X));c.hasValue=
f;c.hasStatement=g;c.hasDummy=h;return c};
Blockly.BlockSvg.INLINE:m.type,q.height=0,c.push(q));q.push(m);m.renderHeight=Blockly.BlockSvg.MIN_BLOCK_Y;m.renderWidth=l&&m.type==Blockly.INPUT_VALUE?Blockly.BlockSvg.TAB_WIDTH+1.25*Blockly.BlockSvg.SEP_SPACE_X:0;if(m.connection&&m.connection.targetConnection){var n=m.connection.targetBlock().getHeightWidth();m.renderHeight=Math.max(m.renderHeight,n.height);m.renderWidth=Math.max(m.renderWidth,n.width)}l||p!=b.length-1?!l&&m.type==Blockly.INPUT_VALUE&&b[p+1]&&b[p+1].type==Blockly.NEXT_STATEMENT&&
m.renderHeight--:m.renderHeight--;q.height=Math.max(q.height,m.renderHeight);m.fieldWidth=0;1==c.length&&(m.fieldWidth+=this.RTL?-a:a);for(var n=!1,r=0,t;t=m.fieldRow[r];r++){0!=r&&(m.fieldWidth+=Blockly.BlockSvg.SEP_SPACE_X);var u=t.getSize();t.renderWidth=u.width;t.renderSep=n&&t.EDITABLE?Blockly.BlockSvg.SEP_SPACE_X:0;m.fieldWidth+=t.renderWidth+t.renderSep;q.height=Math.max(q.height,u.height);n=t.EDITABLE}q.type!=Blockly.BlockSvg.INLINE&&(q.type==Blockly.NEXT_STATEMENT?(g=!0,e=Math.max(e,m.fieldWidth)):
(q.type==Blockly.INPUT_VALUE?f=!0:q.type==Blockly.DUMMY_INPUT&&(h=!0),d=Math.max(d,m.fieldWidth)))}for(a=0;q=c[a];a++)if(q.thicker=!1,q.type==Blockly.BlockSvg.INLINE)for(b=0;m=q[b];b++)if(m.type==Blockly.INPUT_VALUE){q.height+=2*Blockly.BlockSvg.INLINE_PADDING_Y;q.thicker=!0;break}c.statementEdge=2*Blockly.BlockSvg.SEP_SPACE_X+e;g&&(c.rightEdge=Math.max(c.rightEdge,c.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH));f?c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X+Blockly.BlockSvg.TAB_WIDTH):
h&&(c.rightEdge=Math.max(c.rightEdge,d+2*Blockly.BlockSvg.SEP_SPACE_X));c.hasValue=f;c.hasStatement=g;c.hasDummy=h;return c};
Blockly.BlockSvg.prototype.renderDraw_=function(a,b){if(this.outputConnection)this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!0;else{this.squareBottomLeftCorner_=this.squareTopLeftCorner_=!1;if(this.previousConnection){var c=this.previousConnection.targetBlock();c&&c.getNextBlock()==this&&(this.squareTopLeftCorner_=!0)}this.getNextBlock()&&(this.squareBottomLeftCorner_=!0)}var d=this.getRelativeToSurfaceXY(),e=[],f=[],c=[],g=[];this.renderDrawTop_(e,c,d,b.rightEdge);var h=this.renderDrawRight_(e,
c,f,g,d,b,a);this.renderDrawBottom_(e,c,d,h);this.renderDrawLeft_(e,c,d,h);d=e.join(" ")+"\n"+f.join(" ");this.svgPath_.setAttribute("d",d);this.svgPathDark_.setAttribute("d",d);d=c.join(" ")+"\n"+g.join(" ");this.svgPathLight_.setAttribute("d",d);this.RTL&&(this.svgPath_.setAttribute("transform","scale(-1 1)"),this.svgPathLight_.setAttribute("transform","scale(-1 1)"),this.svgPathDark_.setAttribute("transform","translate(1,1) scale(-1 1)"))};
Blockly.BlockSvg.prototype.renderDrawTop_=function(a,b,c,d){this.squareTopLeftCorner_?(a.push("m 0,0"),b.push("m 1,1")):(a.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START),b.push(this.RTL?Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL:Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR),a.push(Blockly.BlockSvg.TOP_LEFT_CORNER),b.push(Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT));this.previousConnection&&(a.push("H",Blockly.BlockSvg.NOTCH_WIDTH-15),b.push("H",Blockly.BlockSvg.NOTCH_WIDTH-15),a.push(Blockly.BlockSvg.NOTCH_PATH_LEFT),
......@@ -1130,7 +1130,7 @@ h,l),a.push(Blockly.BlockSvg.TAB_PATH_DOWN),r=q.height-Blockly.BlockSvg.TAB_HEIG
Blockly.BlockSvg.TAB_WIDTH+1))):q.type==Blockly.DUMMY_INPUT?(n=q[0],l=k+Blockly.BlockSvg.FIELD_HEIGHT,n.align!=Blockly.ALIGN_LEFT&&(r=f.rightEdge-n.fieldWidth-2*Blockly.BlockSvg.SEP_SPACE_X,f.hasValue&&(r-=Blockly.BlockSvg.TAB_WIDTH),n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=(r+h)/2)),this.renderFields_(n.fieldRow,h,l),a.push("v",q.height),this.RTL&&b.push("v",q.height-2)):q.type==Blockly.NEXT_STATEMENT&&(n=q[0],0==m&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&
b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y),l=k+Blockly.BlockSvg.FIELD_HEIGHT,n.align!=Blockly.ALIGN_LEFT&&(r=f.statementEdge-n.fieldWidth-2*Blockly.BlockSvg.SEP_SPACE_X,n.align==Blockly.ALIGN_RIGHT?h+=r:n.align==Blockly.ALIGN_CENTRE&&(h+=(r+h)/2)),this.renderFields_(n.fieldRow,h,l),h=f.statementEdge+Blockly.BlockSvg.NOTCH_WIDTH,a.push("H",h),a.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER),a.push("v",q.height-2*Blockly.BlockSvg.CORNER_RADIUS),a.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER),
a.push("H",f.rightEdge),this.RTL?(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),b.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL),b.push("v",q.height-2*Blockly.BlockSvg.CORNER_RADIUS),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL),b.push("H",f.rightEdge-1)):(b.push("M",h-Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.DISTANCE_45_OUTSIDE+","+(k+q.height-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)),b.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR),
b.push("H",f.rightEdge)),l=e.x+(this.RTL?-h:h),p=e.y+k+1,n.connection.moveTo(l,p),n.connection.targetConnection&&(n.connection.tighten_(),this.width=Math.max(this.width,f.statementEdge+n.connection.targetBlock().getHeightWidth().width)),m==f.length-1||f[m+1].type==Blockly.NEXT_STATEMENT)&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y);k+=q.height}f.length||(k=Blockly.BlockSvg.MIN_BLOCK_Y,a.push("V",k),this.RTL&&b.push("V",
b.push("H",f.rightEdge)),l=e.x+(this.RTL?-h:h+1),p=e.y+k+1,n.connection.moveTo(l,p),n.connection.targetConnection&&(n.connection.tighten_(),this.width=Math.max(this.width,f.statementEdge+n.connection.targetBlock().getHeightWidth().width)),m==f.length-1||f[m+1].type==Blockly.NEXT_STATEMENT)&&(a.push("v",Blockly.BlockSvg.SEP_SPACE_Y),this.RTL&&b.push("v",Blockly.BlockSvg.SEP_SPACE_Y-1),k+=Blockly.BlockSvg.SEP_SPACE_Y);k+=q.height}f.length||(k=Blockly.BlockSvg.MIN_BLOCK_Y,a.push("V",k),this.RTL&&b.push("V",
k-1));return k};
Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b,c,d){this.height=d+1;this.nextConnection&&(a.push("H",Blockly.BlockSvg.NOTCH_WIDTH+" "+Blockly.BlockSvg.NOTCH_PATH_RIGHT),this.nextConnection.moveTo(this.RTL?c.x-Blockly.BlockSvg.NOTCH_WIDTH:c.x+Blockly.BlockSvg.NOTCH_WIDTH,c.y+d+1),this.nextConnection.targetConnection&&this.nextConnection.tighten_(),this.height+=4);this.squareBottomLeftCorner_?(a.push("H 0"),this.RTL||b.push("M","1,"+d)):(a.push("H",Blockly.BlockSvg.CORNER_RADIUS),a.push("a",
Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 -"+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),this.RTL||(b.push("M",Blockly.BlockSvg.DISTANCE_45_INSIDE+","+(d-Blockly.BlockSvg.DISTANCE_45_INSIDE)),b.push("A",Blockly.BlockSvg.CORNER_RADIUS-1+","+(Blockly.BlockSvg.CORNER_RADIUS-1)+" 0 0,1 1,"+(d-Blockly.BlockSvg.CORNER_RADIUS))))};
......
......@@ -1445,11 +1445,16 @@ Blockly.BlockSvg.prototype.renderCompute_ = function(iconWidth) {
input.renderHeight = Math.max(input.renderHeight, bBox.height);
input.renderWidth = Math.max(input.renderWidth, bBox.width);
}
// Blocks have a one pixel shadow that should sometimes overhang.
if (!isInline && i == inputList.length - 1) {
// Last element should overhang slightly due to shadow.
// Last value input should overhang.
input.renderHeight--;
} else if (!isInline && input.type == Blockly.INPUT_VALUE &&
inputList[i + 1] && inputList[i + 1].type == Blockly.NEXT_STATEMENT) {
// Value input above statment input should overhang.
input.renderHeight--;
}
row.height = Math.max(row.height, input.renderHeight);
input.fieldWidth = 0;
if (inputRows.length == 1) {
......@@ -1864,7 +1869,7 @@ Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps,
highlightSteps.push('H', inputRows.rightEdge);
}
// Create statement connection.
connectionX = connectionsXY.x + (this.RTL ? -cursorX : cursorX);
connectionX = connectionsXY.x + (this.RTL ? -cursorX : cursorX + 1);
connectionY = connectionsXY.y + cursorY + 1;
input.connection.moveTo(connectionX, connectionY);
if (input.connection.targetConnection) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment