private void ConstructGraphView() { Instance = this; GraphView = new CodeGraphView(this) { name = "Code Graph" }; GraphView.StretchToParentSize(); rootVisualElement.Add(GraphView); if (GraphObject != null) { SaveUtility.GetInstance(GraphView).LoadGraph(GraphObject); } GraphView.RegisterCallback <KeyDownEvent>(evt => { if (evt.keyCode == KeyCode.S && evt.ctrlKey) { SaveGraph(); evt.StopPropagation(); } if (evt.keyCode == KeyCode.G && evt.ctrlKey && !evt.shiftKey && GraphView.selection.Count > 0) { GraphView.GroupSelection(); evt.StopPropagation(); } if (evt.keyCode == KeyCode.G && evt.ctrlKey && evt.shiftKey && GraphView.selection.Count > 0) { GraphView.UngroupSelection(); evt.StopPropagation(); } }, TrickleDown.TrickleDown); }
public static void CreateGraphViewWindow() { var window = GetWindow <CodeGraph>(); Instance = window; window.titleContent = new GUIContent("CodeGraph Editor", Resources.Load <Texture2D>("codegraph_256")); }
public CodeGraphView(CodeGraph editorWindow) { this.editorWindow = editorWindow; this.AddStyleSheet("CodeGraph"); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); this.AddManipulator(new ContentDragger()); this.AddManipulator(new SelectionDragger()); this.AddManipulator(new RectangleSelector()); this.AddManipulator(new FreehandSelector()); var grid = new GridBackground(); Insert(0, grid); grid.StretchToParentSize(); var searchWindowProvider = ScriptableObject.CreateInstance <SearchWindowProvider>(); searchWindowProvider.Initialize(this.editorWindow, this); nodeCreationRequest = c => SearchWindow.Open(new SearchWindowContext(c.screenMousePosition), searchWindowProvider); graphViewChanged += OnGraphViewChanged; serializeGraphElements += SerializeGraphElementsImplementation; // canPasteSerializedData = CanPasteSerializedDataImplementation; unserializeAndPaste += UnserializeAndPasteImplementation; // deleteSelection = DeleteSelectionImplementation; }
public void Initialize(CodeGraph editorWindow, CodeGraphView graphView) { this.editorWindow = editorWindow; this.graphView = graphView; // Transparent icon to trick search window into indenting items icon = new Texture2D(1, 1); icon.SetPixel(0, 0, new Color(0, 0, 0, 0)); icon.Apply(); }