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

[feature] add toolbar to EditorWindow with NodeGraph title and zoom slider

This commit is contained in:
Stefano Cecere 2019-11-19 19:02:07 +01:00 committed by GitHub
parent 30b825ff1c
commit 13988a7368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@ namespace XNodeEditor {
DrawNodes();
DrawSelectionBox();
DrawTooltip();
DrawToolbar();
graphEditor.OnGUI();
// Run and reset onLateGUI
@ -85,6 +86,28 @@ namespace XNodeEditor {
GUI.DrawTextureWithTexCoords(rect, gridTex, new Rect(tileOffset, tileAmount));
GUI.DrawTextureWithTexCoords(rect, crossTex, new Rect(tileOffset + new Vector2(0.5f, 0.5f), tileAmount));
}
private void DrawToolbar() {
GUILayout.BeginHorizontal(EditorStyles.toolbar);
{
GUILayout.Space(2);
GUILayout.Label(graph.name, EditorStyles.boldLabel);
GUILayout.Space(10);
// Draw scale bar
GUILayout.Label("Scale", EditorStyles.miniLabel);
var newZoom = GUILayout.HorizontalSlider(
zoom, 1f, 5f, GUILayout.MinWidth(40), GUILayout.MaxWidth(100)
);
GUILayout.Label(zoom.ToString("0.0#x"), EditorStyles.miniLabel, GUILayout.Width(30));
if (Math.Abs(newZoom - zoom) > Mathf.Epsilon) {
zoom = newZoom;
}
GUILayout.FlexibleSpace();
}
GUILayout.EndHorizontal();
}
public void DrawSelectionBox() {
if (currentActivity == NodeActivity.DragGrid) {
@ -524,4 +547,4 @@ namespace XNodeEditor {
}
}
}
}
}