Skip to content

Commit

Permalink
Fix Connection draw on out of view Block
Browse files Browse the repository at this point in the history
Invert the short circuit so we still do the connection draw after all other block drawing logic
  • Loading branch information
stevehalliwell committed May 18, 2020
1 parent 5cdbb9c commit 9cce05e
Showing 1 changed file with 67 additions and 67 deletions.
134 changes: 67 additions & 67 deletions Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2113,87 +2113,87 @@ private void DrawBlock(Block block, Rect scriptViewRect)
windowRelativeRect.position += flowchart.ScrollPos;

//skip if outside of view
if (!scriptViewRect.Overlaps(windowRelativeRect))
return;
if (scriptViewRect.Overlaps(windowRelativeRect))
{

var tmpNormBg = nodeStyle.normal.background;
var tmpNormBg = nodeStyle.normal.background;

// Draw untinted highlight
if (block.IsSelected && !block.IsControlSelected)
{
GUI.backgroundColor = Color.white;
nodeStyle.normal.background = graphics.onTexture;
GUI.Box(windowRelativeRect, "", nodeStyle);
nodeStyle.normal.background = tmpNormBg;
}
// Draw untinted highlight
if (block.IsSelected && !block.IsControlSelected)
{
GUI.backgroundColor = Color.white;
nodeStyle.normal.background = graphics.onTexture;
GUI.Box(windowRelativeRect, "", nodeStyle);
nodeStyle.normal.background = tmpNormBg;
}

if (block.IsControlSelected && !block.IsSelected)
{
GUI.backgroundColor = Color.white;
nodeStyle.normal.background = graphics.onTexture;
var c = GUI.backgroundColor;
c.a = 0.5f;
GUI.backgroundColor = c;
GUI.Box(windowRelativeRect, "", nodeStyle);
nodeStyle.normal.background = tmpNormBg;
}
if (block.IsControlSelected && !block.IsSelected)
{
GUI.backgroundColor = Color.white;
nodeStyle.normal.background = graphics.onTexture;
var c = GUI.backgroundColor;
c.a = 0.5f;
GUI.backgroundColor = c;
GUI.Box(windowRelativeRect, "", nodeStyle);
nodeStyle.normal.background = tmpNormBg;
}

// Draw tinted block; ensure text is readable
var brightness = graphics.tint.r * 0.3 + graphics.tint.g * 0.59 + graphics.tint.b * 0.11;
var tmpNormTxtCol = nodeStyle.normal.textColor;
nodeStyle.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;
// Draw tinted block; ensure text is readable
var brightness = graphics.tint.r * 0.3 + graphics.tint.g * 0.59 + graphics.tint.b * 0.11;
var tmpNormTxtCol = nodeStyle.normal.textColor;
nodeStyle.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;

switch (block.FilterState)
{
case Block.FilteredState.Full:
break;
case Block.FilteredState.Partial:
graphics.tint.a *= 0.65f;
break;
case Block.FilteredState.None:
graphics.tint.a *= 0.2f;
break;
default:
break;
}
switch (block.FilterState)
{
case Block.FilteredState.Full:
break;
case Block.FilteredState.Partial:
graphics.tint.a *= 0.65f;
break;
case Block.FilteredState.None:
graphics.tint.a *= 0.2f;
break;
default:
break;
}

nodeStyle.normal.background = graphics.offTexture;
GUI.backgroundColor = graphics.tint;
GUI.Box(windowRelativeRect, block.BlockName, nodeStyle);
nodeStyle.normal.background = graphics.offTexture;
GUI.backgroundColor = graphics.tint;
GUI.Box(windowRelativeRect, block.BlockName, nodeStyle);

GUI.backgroundColor = Color.white;
GUI.backgroundColor = Color.white;

if (block.Description.Length > 0)
{
var content = new GUIContent(block.Description);
windowRelativeRect.y += windowRelativeRect.height;
windowRelativeRect.height = descriptionStyle.CalcHeight(content, windowRelativeRect.width);
GUI.Label(windowRelativeRect, content, descriptionStyle);
}
if (block.Description.Length > 0)
{
var content = new GUIContent(block.Description);
windowRelativeRect.y += windowRelativeRect.height;
windowRelativeRect.height = descriptionStyle.CalcHeight(content, windowRelativeRect.width);
GUI.Label(windowRelativeRect, content, descriptionStyle);
}

GUI.backgroundColor = Color.white;
GUI.backgroundColor = Color.white;

nodeStyle.normal.textColor = tmpNormTxtCol;
nodeStyle.normal.background = tmpNormBg;
nodeStyle.normal.textColor = tmpNormTxtCol;
nodeStyle.normal.background = tmpNormBg;

// Draw Event Handler labels
if (block._EventHandler != null)
{
string handlerLabel = "";
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block._EventHandler.GetType());
if (info != null)
// Draw Event Handler labels
if (block._EventHandler != null)
{
handlerLabel = "<" + info.EventHandlerName + "> ";
}

Rect rect = new Rect(block._NodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width);
rect.x += flowchart.ScrollPos.x;
rect.y += flowchart.ScrollPos.y - rect.height;
string handlerLabel = "";
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block._EventHandler.GetType());
if (info != null)
{
handlerLabel = "<" + info.EventHandlerName + "> ";
}

GUI.Label(rect, handlerLabel, handlerStyle);
}
Rect rect = new Rect(block._NodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width);
rect.x += flowchart.ScrollPos.x;
rect.y += flowchart.ScrollPos.y - rect.height;

GUI.Label(rect, handlerLabel, handlerStyle);
}
}

DrawConnections(block);
}
Expand Down

0 comments on commit 9cce05e

Please sign in to comment.