Пример #1
0
        /// <summary>
        /// This hanldes setting up the proper state based on the window's canvas.
        /// </summary>
        internal void InitState()
        {
            // If the window has a valid canvas and editable.
            if (_window.tree != null && _window.GetMode() == BonsaiWindow.Mode.Edit)
            {
                string path = getCurrentTreePath();

                // If the canvas is temp.
                if (path.Contains(kTempCanvasPath))
                {
                    SetState(SaveState.TempTree);
                }

                // If the canvas is saved (not a temp).
                else
                {
                    SetState(SaveState.SavedTree);
                }
            }

            // Window is fresh, no canvas yet set.
            else
            {
                SetState(SaveState.NoTree);
            }
        }
Пример #2
0
        internal void HandleMouseEvents(Event e)
        {
            // Mouse must be inside the editor canvas.
            if (!_window.CanvasInputRect.Contains(e.mousePosition))
            {
                resetState();
                return;
            }

            // NOTE:
            // The order of these matter.
            // For example we want to handle node dragging before
            // area selection.
            handleLinking(e);
            handleCanvasInputs(e);

            if (_window.GetMode() == BonsaiWindow.Mode.Edit)
            {
                handleEditorShortcuts(e);
                handleContextInput(e);
                handleNodeDragging(e);
                handleNodeConnection(e);
                handleAreaSelection(e);
            }
        }