Beispiel #1
0
        private void DrawViewGeneral()
        {
            if (CurrentView != View.General)
            {
                return;
            }
            m_mode = GraphMode.None;

            var graphArea = new Rect(0, 0, position.width, position.height);

            GraphBackground.DrawGrid(graphArea, 1f, Vector2.zero);

            float splashPadding   = 16f;
            float splashTopOffset = 48f;

            bool drawRecentlyOpenedGraphsBar = NodyWindowSettings.Instance.RecentlyOpenedGraphs.Count > 0;
            var  recentAreaRect = new Rect(graphArea.width - NodyWindowSettings.RECENT_GRAPHS_AREA_WIDTH, 0, NodyWindowSettings.RECENT_GRAPHS_AREA_WIDTH, graphArea.height);

            var splashArea = new Rect(graphArea.x + splashPadding + ToolbarWidth,
                                      graphArea.y + splashPadding,
                                      graphArea.width - splashPadding * 2 - ToolbarWidth - (drawRecentlyOpenedGraphsBar ? recentAreaRect.width : 0),
                                      graphArea.height - splashPadding * 2);

            float width  = 1024;
            float height = 1024;

            float sizeWidthRatio  = 1;
            float sizeHeightRatio = 1;

            if (splashArea.width < width)
            {
                sizeWidthRatio = splashArea.width / width;
            }
            if (splashArea.height - splashTopOffset < height)
            {
                sizeHeightRatio = (splashArea.height - splashTopOffset) / height;
            }

            float sizeRatio = Mathf.Min(sizeWidthRatio, sizeHeightRatio);

            width  *= sizeRatio;
            height *= sizeRatio;

            float x = splashArea.x + splashArea.width / 2 - width / 2;
            float y = splashArea.y + +splashTopOffset + splashArea.height / 2 - height / 2;


            var splashScreenRect = new Rect(x, y, width, height);

            GUI.Box(splashScreenRect, GUIContent.none, SplashScreen);

            if (!drawRecentlyOpenedGraphsBar)
            {
                return;
            }


            //Recent Area
            EditorGUI.DrawRect(recentAreaRect, (EditorGUIUtility.isProSkin ? Color.black.Lighter() : Color.white.Darker()).WithAlpha(NodyWindowSettings.TOOLBAR_OPACITY * 0.6f));
            GUILayout.BeginArea(recentAreaRect);
            {
                DrawRecentOpenedGraphs();
            }
            GUILayout.EndArea();
        }
Beispiel #2
0
        private void DrawViewGraph()
        {
            if (CurrentView != View.Graph)
            {
                return;
            }
            Event current = Event.current;

            if (m_recalculateAllPointRects && current.type == EventType.Repaint)
            {
                CalculateAllPointRects();
                CalculateAllConnectionCurves();
            }

            var graphArea = new Rect(0, 0, position.width, position.height);

            GraphBackground.DrawGrid(graphArea, CurrentZoom, CurrentPanOffset);

            m_graphAreaIncludingTab = new Rect(0, DGUI.Properties.StandardWindowTabHeight, position.width, position.height);
            m_scaledGraphArea       = new Rect(0,
                                               0,
                                               graphArea.width / CurrentZoom,
                                               graphArea.height / CurrentZoom);

            Matrix4x4 initialMatrix = GUI.matrix; //save initial matrix

            GUI.EndClip();
            GUI.BeginClip(new Rect(m_graphAreaIncludingTab.position, m_scaledGraphArea.size));
            {
                Matrix4x4 translation = Matrix4x4.TRS(m_graphAreaIncludingTab.position, Quaternion.identity, Vector3.one);
                Matrix4x4 scale       = Matrix4x4.Scale(Vector3.one * CurrentZoom);
                GUI.matrix = translation * scale * translation.inverse;
                {
                    DrawConnections();
                    DrawNodes(graphArea);
                    DrawSocketsConnectionPoints();
                    DrawLineFromSocketToPosition(m_activeSocket, CurrentMousePosition);
                    DrawSelectionBox();
                }
            }
            GUI.EndClip();
            GUI.BeginClip(m_graphAreaIncludingTab);
            GUI.matrix = initialMatrix; //reset the matrix to the initial value

//            DrawOverlay();

//            DrawGraphName();
//            DrawGraphBottomInfoBar();
//            DrawGraphToolbar();

//            DrawGraphModes();
//            DrawGraphInfo();
//            DrawWindowInfo();

            HandleZoom();
            HandlePanning();


            if (current.mousePosition.x > ToolbarWidth &&
                current.mousePosition.y > NodySettings.Instance.GraphTabsAreaHeight + DGUI.Properties.Space() ||
                m_mode != GraphMode.None)
            {
                HandleMouseHover();
                HandleMouseMiddleClicks();
                HandleMouseLeftClicks();
                HandleMouseRightClicks();
            }

            HandleKeys();

            WhileDraggingUpdateSelectedNodes();

            UpdateNodesActiveNode();
        }