1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

Renamed DrawOnGUI to DrawGraphOnGUI and moved it up to the other zoom functions

Fixed formatting, added leftPadding
This commit is contained in:
Thor Brigsted 2019-06-18 11:32:43 +02:00
parent d6ae3bedce
commit f10208c8eb

View File

@ -12,6 +12,8 @@ namespace XNodeEditor {
private List<XNode.Node> culledNodes; private List<XNode.Node> culledNodes;
/// <summary> 19 if docked, 22 if not </summary> /// <summary> 19 if docked, 22 if not </summary>
private int topPadding { get { return isDocked() ? 19 : 22; } } private int topPadding { get { return isDocked() ? 19 : 22; } }
/// <summary> 0 if docked, 3 if not </summary>
private int leftPadding { get { return isDocked() ? 2 : 0; } }
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary> /// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
public event Action onLateGUI; public event Action onLateGUI;
@ -30,7 +32,7 @@ namespace XNodeEditor {
DrawNodes(); DrawNodes();
DrawSelectionBox(); DrawSelectionBox();
DrawTooltip(); DrawTooltip();
DrawOnGUI(); DrawGraphOnGUI();
// Run and reset onLateGUI // Run and reset onLateGUI
if (onLateGUI != null) { if (onLateGUI != null) {
@ -64,6 +66,16 @@ namespace XNodeEditor {
GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height)); GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height));
} }
/// <summary> Ends the GUI Group temporarily to draw any additional elements in the NodeGraphEditor. </summary>
private void DrawGraphOnGUI() {
GUI.EndGroup();
Rect rect = new Rect(new Vector2(leftPadding, topPadding), new Vector2(Screen.width, Screen.height));
GUI.BeginGroup(rect);
graphEditor.OnGUI();
GUI.EndGroup();
GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height));
}
public static Rect ScaleSizeBy(Rect rect, float scale, Vector2 pivotPoint) { public static Rect ScaleSizeBy(Rect rect, float scale, Vector2 pivotPoint) {
Rect result = rect; Rect result = rect;
result.x -= pivotPoint.x; result.x -= pivotPoint.x;
@ -443,15 +455,5 @@ namespace XNodeEditor {
Repaint(); Repaint();
} }
} }
private void DrawOnGUI() // Ends the GUI Group temporarily to draw any additional elements in the NodeGraphEditor.
{
GUI.EndGroup();
Rect rect = new Rect(new Vector2(-1f, 20f), new Vector2(Screen.width, Screen.height));
GUI.BeginGroup(rect);
graphEditor.OnGUI();
GUI.EndGroup();
GUI.BeginGroup(new Rect(0.0f, topPadding - (topPadding * zoom), Screen.width, Screen.height));
}
} }
} }