示例#1
0
        void OnFocusInEvent(FocusInEvent evt)
        {
            m_TextElement.edition.SaveValueAndText();

            // When this input field receives focus, make sure the correct text editor is initialized
            // (i.e. hardware keyboard or touchscreen keyboard).
            if (touchScreenTextFieldChanged)
            {
                InitTextEditorEventHandler();
            }

            // When focused and the keyboard availability changes, make sure the correct text editor is
            // initialized under these new conditions and un-focus this input field.
            if (m_HardwareKeyboardPoller == null)
            {
                m_HardwareKeyboardPoller = m_TextElement.schedule.Execute(() =>
                {
                    if (touchScreenTextFieldChanged)
                    {
                        InitTextEditorEventHandler();
                        m_TextElement.Blur();
                    }
                }).Every(250);
            }
            else
            {
                m_HardwareKeyboardPoller.Resume();
            }
        }
示例#2
0
 public void Execute()
 {
     if (!m_ScheduledTask.isActive)
     {
         m_ScheduledTask.Resume();
     }
 }
        void Activate()
        {
            if (m_IsActive)
            {
                return;
            }

            m_RotationAngle = 0;
            m_ScheduledUpdate.Resume();

            m_IsActive = true;
        }
示例#4
0
 void PollTouchScreenKeyboard()
 {
     if (TouchScreenKeyboard.isSupported)
     {
         if (m_TouchKeyboardPoller == null)
         {
             m_TouchKeyboardPoller = (textInputField as VisualElement)?.schedule.Execute(DoPollTouchScreenKeyboard).Every(100);
         }
         else
         {
             m_TouchKeyboardPoller.Resume();
         }
     }
 }
示例#5
0
 void PollTouchScreenKeyboard()
 {
     if (TouchScreenKeyboard.isSupported && !TouchScreenKeyboard.isInPlaceEditingAllowed)
     {
         if (m_TouchKeyboardPoller == null)
         {
             m_TouchKeyboardPoller = textElement?.schedule.Execute(DoPollTouchScreenKeyboard).Every(100);
         }
         else
         {
             m_TouchKeyboardPoller.Resume();
         }
     }
 }
        public RefreshScheduler(IVisualElementScheduler scheduler)
        {
            m_Scheduler = scheduler.Execute(InvokeRefresh).Every(100);
            m_Scheduler.Pause();

            EditorApplication.playModeStateChanged += (state) =>
            {
                if (state == PlayModeStateChange.EnteredPlayMode)
                {
                    m_Scheduler.Resume();
                }
                else if (state == PlayModeStateChange.ExitingPlayMode)
                {
                    m_Scheduler.Pause();
                    InvokeExitPlayMode();
                }
            };
        }
示例#7
0
        void OnPointerUp(PointerUpEvent evt)
        {
            if (evt.pointerId == m_ScrollingPointerId)
            {
                evt.currentTarget.ReleasePointer(evt.pointerId);
                evt.StopPropagation();

                if (touchScrollBehavior == TouchScrollBehavior.Elastic || hasInertia)
                {
                    ComputeInitialSpringBackVelocity();

                    if (m_PostPointerUpAnimation == null)
                    {
                        m_PostPointerUpAnimation = schedule.Execute(PostPointerUpAnimation).Every(30);
                    }
                    else
                    {
                        m_PostPointerUpAnimation.Resume();
                    }
                }

                m_ScrollingPointerId = PointerId.invalidPointerId;
            }
        }
示例#8
0
        protected new void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);


            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positioning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_originalMouse - e.mousePosition;

            var groupElementsDraggedOut = e.shiftKey ? new Dictionary <Group, List <GraphElement> >() : null;

            // Handle the selected element
            Rect selectedElementGeom = GetSelectedElementGeom();

            m_ShiftClicked = e.shiftKey;

            if (snapEnabled && !m_ShiftClicked)
            {
                ComputeSnappedRect(ref selectedElementGeom, m_XScale);
            }

            if (snapEnabled && m_ShiftClicked)
            {
                m_Snapper.ClearSnapLines();
            }

            foreach (KeyValuePair <GraphElement, OriginalPos> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                // Protect against stale visual elements that have been deparented since the start of the manipulation
                if (ce.hierarchy.parent == null)
                {
                    continue;
                }

                if (!v.Value.dragStarted)
                {
                    // TODO Would probably be a good idea to batch stack items as we do for group ones.
                    var stackParent = ce.GetFirstAncestorOfType <StackNode>();
                    if (stackParent != null)
                    {
                        stackParent.OnStartDragging(ce);
                    }

                    if (groupElementsDraggedOut != null)
                    {
                        var groupParent = ce.GetContainingScope() as Group;
                        if (groupParent != null)
                        {
                            if (!groupElementsDraggedOut.ContainsKey(groupParent))
                            {
                                groupElementsDraggedOut[groupParent] = new List <GraphElement>();
                            }
                            groupElementsDraggedOut[groupParent].Add(ce);
                        }
                    }
                    v.Value.dragStarted = true;
                }

                SnapOrMoveElement(v, selectedElementGeom);
            }

            // Needed to ensure nodes can be dragged out of multiple groups all at once.
            if (groupElementsDraggedOut != null)
            {
                foreach (KeyValuePair <Group, List <GraphElement> > kvp in groupElementsDraggedOut)
                {
                    kvp.Key.OnStartDragging(e, kvp.Value);
                }
            }

            List <ISelectable> selection = m_GraphView.selection;

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            IDropTarget dropTarget = GetDropTargetAt(e.mousePosition, selection.OfType <VisualElement>());

            if (m_PrevDropTarget != dropTarget)
            {
                if (m_PrevDropTarget != null)
                {
                    using (DragLeaveEvent eexit = DragLeaveEvent.GetPooled(e))
                    {
                        SendDragAndDropEvent(eexit, selection, m_PrevDropTarget, m_GraphView);
                    }
                }

                using (DragEnterEvent eenter = DragEnterEvent.GetPooled(e))
                {
                    SendDragAndDropEvent(eenter, selection, dropTarget, m_GraphView);
                }
            }

            using (DragUpdatedEvent eupdated = DragUpdatedEvent.GetPooled(e))
            {
                SendDragAndDropEvent(eupdated, selection, dropTarget, m_GraphView);
            }

            m_PrevDropTarget = dropTarget;

            m_Dragging = true;
            e.StopPropagation();
        }
        protected new void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);

#if USE_DRAG_RESET_WHEN_OUT_OF_GRAPH_VIEW
            // We currently don't have a real use case for this and it just appears to annoy users.
            // If and when the use case arise, we can revive this functionality.

            if (gvMousePos.x < 0 || gvMousePos.y < 0 || gvMousePos.x > m_GraphView.layout.width ||
                gvMousePos.y > m_GraphView.layout.height)
            {
                if (!m_GoneOut)
                {
                    m_PanSchedule.Pause();

                    foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos)
                    {
                        v.Key.SetPosition(v.Value);
                    }
                    m_GoneOut = true;
                }

                e.StopPropagation();
                return;
            }

            if (m_GoneOut)
            {
                m_GoneOut = false;
            }
#endif

            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positioning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_originalMouse - e.mousePosition;

            var groupElementsDraggedOut = e.shiftKey ? new Dictionary <Group, List <GraphElement> >() : null;
            foreach (KeyValuePair <GraphElement, OriginalPos> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                // Protect against stale visual elements that have been deparented since the start of the manipulation
                if (ce.hierarchy.parent == null)
                {
                    continue;
                }

                if (!v.Value.dragStarted)
                {
                    // TODO Would probably be a good idea to batch stack items as we do for group ones.
                    var stackParent = ce.GetFirstAncestorOfType <StackNode>();
                    if (stackParent != null)
                    {
                        stackParent.OnStartDragging(ce);
                    }

                    if (groupElementsDraggedOut != null)
                    {
                        var groupParent = ce.GetContainingScope() as Group;
                        if (groupParent != null)
                        {
                            if (!groupElementsDraggedOut.ContainsKey(groupParent))
                            {
                                groupElementsDraggedOut[groupParent] = new List <GraphElement>();
                            }
                            groupElementsDraggedOut[groupParent].Add(ce);
                        }
                    }
                    v.Value.dragStarted = true;
                }

                MoveElement(ce, v.Value.pos);
            }

            foreach (var edge in m_EdgesToUpdate)
            {
                UpdateEdge(edge);
            }

            // Needed to ensure nodes can be dragged out of multiple groups all at once.
            if (groupElementsDraggedOut != null)
            {
                foreach (KeyValuePair <Group, List <GraphElement> > kvp in groupElementsDraggedOut)
                {
                    kvp.Key.OnStartDragging(e, kvp.Value);
                }
            }

            List <ISelectable> selection = m_GraphView.selection;

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            IDropTarget dropTarget = GetDropTargetAt(e.mousePosition, selection.OfType <VisualElement>());

            if (m_PrevDropTarget != dropTarget)
            {
                if (m_PrevDropTarget != null)
                {
                    using (DragLeaveEvent eexit = DragLeaveEvent.GetPooled(e))
                    {
                        SendDragAndDropEvent(eexit, selection, m_PrevDropTarget, m_GraphView);
                    }
                }

                using (DragEnterEvent eenter = DragEnterEvent.GetPooled(e))
                {
                    SendDragAndDropEvent(eenter, selection, dropTarget, m_GraphView);
                }
            }

            using (DragUpdatedEvent eupdated = DragUpdatedEvent.GetPooled(e))
            {
                SendDragAndDropEvent(eupdated, selection, dropTarget, m_GraphView);
            }

            m_PrevDropTarget = dropTarget;

            selectedElement = null;
            e.StopPropagation();
        }
        public override void HandleMouseMove(MouseMoveEvent evt)
        {
            var     ve         = (VisualElement)evt.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(graphView.contentContainer, evt.localMousePosition);

            panDiff = GetEffectivePanSpeed(gvMousePos);

            if (panDiff != Vector3.zero)
            {
                panSchedule.Resume();
            }
            else
            {
                panSchedule.Pause();
            }

            Vector2 mousePosition = evt.mousePosition;

            lastMousePos = evt.mousePosition;

            edgeCandidate.candidatePosition = mousePosition;

            // Draw ghost edge if possible port exists.
            Port endPort = GetEndPort(mousePosition);

            if (endPort != null)
            {
                if (ghostEdge == null)
                {
                    ghostEdge             = new EdgeView();
                    ghostEdge.isGhostEdge = true;
                    ghostEdge.pickingMode = PickingMode.Ignore;
                    graphView.AddElement(ghostEdge);
                }

                if (edgeCandidate.output == null)
                {
                    ghostEdge.input = edgeCandidate.input;
                    if (ghostEdge.output != null)
                    {
                        ghostEdge.output.portCapLit = false;
                    }
                    ghostEdge.output            = endPort;
                    ghostEdge.output.portCapLit = true;
                }
                else
                {
                    if (ghostEdge.input != null)
                    {
                        ghostEdge.input.portCapLit = false;
                    }
                    ghostEdge.input            = endPort;
                    ghostEdge.input.portCapLit = true;
                    ghostEdge.output           = edgeCandidate.output;
                }
            }
            else if (ghostEdge != null)
            {
                if (edgeCandidate.input == null)
                {
                    if (ghostEdge.input != null)
                    {
                        ghostEdge.input.portCapLit = false;
                    }
                }
                else
                {
                    if (ghostEdge.output != null)
                    {
                        ghostEdge.output.portCapLit = false;
                    }
                }
                graphView.RemoveElement(ghostEdge);
                ghostEdge.input  = null;
                ghostEdge.output = null;
                ghostEdge        = null;
            }
        }
示例#11
0
    private IEnumerable <Object> X_BindPanel()
    {
        // Root cachen
        var root = _UIRenderer.visualTree;

        #region Placement & Edit

        // Animation Setup
        var animation = root.Q("placement-animation");
        _animationScheduler = animation?.schedule.Execute(() =>
        {
            if (_animationFrames.Count == 0)
            {
                return;
            }
            // Frame update
            _currentFrame = (_currentFrame + 1) % _animationFrames.Count;
            var frame     = _animationFrames[_currentFrame];
            animation.style.backgroundImage = frame;
            // 100ms Schritte bis Flag gesetzt wird
        }).Every(100).Until(() => { return(_stopAnimation); });
        // Zunaechst pausieren
        _animationScheduler.Pause();

        // Placement Mode Free Button binden
        root.Q <Button>("placement-select-free").clickable.clicked += () =>
        {
            root.Q("placement-mode-select").style.display = DisplayStyle.None;
            root.Q("placement-free-info").style.display   = DisplayStyle.Flex;
#if UNITY_IOS
            if (_session.subsystem is ARKitSessionSubsystem sessionSubsystem)
            {
                sessionSubsystem.coachingGoal = ARCoachingGoal.HorizontalPlane;
                sessionSubsystem.SetCoachingActive(true, ARCoachingOverlayTransition.Animated);
            }
#else
            // Animation ausfuehren
            root.Q("animation-area").style.display = DisplayStyle.Flex;
            _animationScheduler.Resume();
#endif
            GameManager.Instance.SetPlacementMode(GameManager.PlacementMode.Free);
        };

        // Placement Mode QR Code Button binden
        root.Q <Button>("placement-select-qr").clickable.clicked += () =>
        {
            root.Q("placement-mode-select").style.display = DisplayStyle.None;
            root.Q("placement-qr-info").style.display     = DisplayStyle.Flex;
            GameManager.Instance.SetPlacementMode(GameManager.PlacementMode.QR);
        };

        // Placement Accept Button binden
        root.Q <Button>("placement-accept").clickable.clicked += () =>
        {
            // Modus wechseln (Placement -> Interaction)
            GameManager.Instance.SwitchMenu(GameManager.MenuMode.Interaction);
        };

        // Placement Edit Button binden
        root.Q <Button>("placement-edit").clickable.clicked += () =>
        {
            root.Q("placement-panel").style.display      = DisplayStyle.None;
            root.Q("placement-edit-panel").style.display = DisplayStyle.Flex;
        };

        // Edit Accept Button binden
        root.Q <Button>("placement-edit-accept").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display = DisplayStyle.None;
            root.Q("placement-panel").style.display      = DisplayStyle.Flex;
        };

        // Scale Edit Button binden
        root.Q <Button>("scale-obj").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display       = DisplayStyle.None;
            root.Q("placement-edit-scale-panel").style.display = DisplayStyle.Flex;
            // Scale Slider Callback speichern
            root.Q <Slider>("scale-edit-slider").RegisterCallback(_floatChange, GameManager.Instance.ChangeScaling);
        };

        // Scale Accept Button binden
        root.Q <Button>("scaling-accept").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display       = DisplayStyle.Flex;
            root.Q("placement-edit-scale-panel").style.display = DisplayStyle.None;
        };

        // Rotation Edit Button binden
        root.Q <Button>("rotate-obj").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display        = DisplayStyle.None;
            root.Q("placement-edit-rotate-panel").style.display = DisplayStyle.Flex;
            // Rotation Slider Callback
            root.Q <Slider>("rotate-edit-slider").RegisterCallback(_floatChange, GameManager.Instance.ChangeRotation);
        };

        // Rotation Accept Button binden
        root.Q <Button>("rotation-accept").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display        = DisplayStyle.Flex;
            root.Q("placement-edit-rotate-panel").style.display = DisplayStyle.None;
        };

        // Move Edit Button binden
        root.Q <Button>("move-obj").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display          = DisplayStyle.None;
            root.Q("placement-edit-position-panel").style.display = DisplayStyle.Flex;
        };

        // Move Accept Button binden
        root.Q <Button>("move-accept").clickable.clicked += () =>
        {
            root.Q("placement-edit-panel").style.display          = DisplayStyle.Flex;
            root.Q("placement-edit-position-panel").style.display = DisplayStyle.None;
        };

        // Move Up Callbacks
        root.Q <Button>("move-up").RegisterCallback(_moveStart, Vector2.up);
        root.Q <Button>("move-up").RegisterCallback(_moveStop, Vector2.up);

        // Move Down Callbacks
        root.Q <Button>("move-down").RegisterCallback(_moveStart, Vector2.down);
        root.Q <Button>("move-down").RegisterCallback(_moveStop, Vector2.down);

        // Move Right Callbacks
        root.Q <Button>("move-right").RegisterCallback(_moveStart, Vector2.right);
        root.Q <Button>("move-right").RegisterCallback(_moveStop, Vector2.right);

        // Move Left Callbacks
        root.Q <Button>("move-left").RegisterCallback(_moveStart, Vector2.left);
        root.Q <Button>("move-left").RegisterCallback(_moveStop, Vector2.left);

        #endregion

        #region Options

        // Optionen Button binden
        root.Q <Button>("interaction-options").clickable.clicked += () =>
        {
            GameManager.Instance.SwitchMenu(GameManager.MenuMode.Options);
            root.Q("interaction-panel").style.display = DisplayStyle.None;
            root.Q("options-panel").style.display     = DisplayStyle.Flex;
        };

        // Options Exit Button binden
        root.Q <Button>("options-exit").clickable.clicked += () =>
        {
            GameManager.Instance.SwitchMenu(GameManager.MenuMode.Interaction);
            root.Q("desc-area").style.display            = DisplayStyle.None;
            root.Q("hideSections-area").style.display    = DisplayStyle.None;
            root.Q("options-panel").style.display        = DisplayStyle.None;
            root.Q("create-section-panel").style.display = DisplayStyle.None;
            root.Q("switch-daytime-panel").style.display = DisplayStyle.None;
            root.Q("interaction-panel").style.display    = DisplayStyle.Flex;
            root.Q <Button>("options-storeys-edit").RemoveFromClassList("clicked-button");
        };

        // Ghost Mode Button binden
        root.Q <Button>("options-switch-ghosted").clickable.clicked += () =>
        {
            // Ghosted umschalten
            var newVis = GameManager.Instance.CameraController.GetVisualization() == CameraController.Visualization.Normal ?
                         CameraController.Visualization.Ghosted : CameraController.Visualization.Normal;

            if (newVis == CameraController.Visualization.Ghosted)
            {
                root.Q <Button>("options-switch-ghosted").AddToClassList("clicked-button");
            }
            else
            {
                root.Q <Button>("options-switch-ghosted").RemoveFromClassList("clicked-button");
            }

            GameManager.Instance.CameraController.SetVisualization(newVis);
        };

        // Storey Button binden
        root.Q <Button>("options-storeys-edit").clickable.clicked += () =>
        {
            var area = root.Q("hideSections-area");
            area.style.display = area.style.display == DisplayStyle.Flex ?
                                 DisplayStyle.None : DisplayStyle.Flex;

            if (area.style.display == DisplayStyle.Flex)
            {
                root.Q <Button>("options-storeys-edit").AddToClassList("clicked-button");
            }
            else
            {
                root.Q <Button>("options-storeys-edit").RemoveFromClassList("clicked-button");
            }
        };

        // Description Box erstellen
        var listView = root.Q <ListView>("desc-box");
        // Werte Anpassen
        listView.selectionType = SelectionType.None;
        listView.makeItem      = X_MakeLine;
        listView.bindItem      = X_BindLine;
        listView.itemsSource   = _currentDesc;

        // Storey Toggles erstellen
        foreach (string storey in _storeyNames)
        {
            // Toggle erstellen
            Toggle storeyToggle = new Toggle(storey);
            // Stylesheets hinzufuegen
            foreach (var sheet in _UIRenderer.stylesheets)
            {
                storeyToggle.styleSheets.Add(sheet);
            }
            // Werte anpassen
            storeyToggle.name  = "toggle-" + storey;
            storeyToggle.value = true;
            // Dem Container hinzufuegen
            root.Q("toggle-area").Add(storeyToggle);
            // Callback speichern
            storeyToggle.RegisterCallback <ChangeEvent <bool> >(evt =>
                                                                TridifyQuery.SetStoreyActive(GameManager.Instance.PlacedIFC.transform, storey, evt.newValue));
        }

        // Reset Button binden
        root.Q <Button>("reset-btn").clickable.clicked += () =>
        {
            foreach (string storey in _storeyNames)
            {
                // Storey aktivieren
                root.Q <Toggle>("toggle-" + storey).value = true;
                TridifyQuery.SetStoreyActive(GameManager.Instance.PlacedIFC.transform, storey, true);
            }
        };

        // Section Edit Button binden
        root.Q <Button>("options-sections-create").clickable.clicked += () =>
        {
            root.Q("options-panel").style.display        = DisplayStyle.None;
            root.Q("create-section-panel").style.display = DisplayStyle.Flex;
            // Section Slider Callback speichern
            root.Q <Slider>("move-section-slider").RegisterCallback(_floatChange, GameManager.Instance.CameraController.SetCutPlane);
        };

        // Sections Accept Button binden
        root.Q <Button>("create-section-panel-exit").clickable.clicked += () =>
        {
            GameManager.Instance.CameraController.SetCutPlane(0f);
            root.Q("create-section-panel").style.display = DisplayStyle.None;
            root.Q("options-panel").style.display        = DisplayStyle.Flex;
        };

        // Scale Mode Button binden
        root.Q <Button>("options-scale").clickable.clicked += () =>
        {
            // Size umschalten
            var newSize = GameManager.Instance.CurrentSize == GameManager.SizeMode.Scaled ?
                          GameManager.SizeMode.Normal : GameManager.SizeMode.Scaled;

            if (newSize == GameManager.SizeMode.Scaled)
            {
                root.Q <Button>("options-scale").AddToClassList("clicked-button");
            }
            else
            {
                root.Q <Button>("options-scale").RemoveFromClassList("clicked-button");
            }

            GameManager.Instance.SwitchSize(newSize);
        };

        // TOD Edit Button binden
        root.Q <Button>("options-switch-daytime").clickable.clicked += () =>
        {
            root.Q("options-panel").style.display        = DisplayStyle.None;
            root.Q("switch-daytime-panel").style.display = DisplayStyle.Flex;
            // TOD Slider Callback speichern
            root.Q <Slider>("daytime-slider").RegisterCallback <ChangeEvent <float> >(evt =>
            {
                int hours   = (int)evt.newValue / 60;
                int minutes = (int)evt.newValue % 60;
                _sunCalculator.SetTime(hours, minutes);
            });
        };

        // TOD Accept Button binden
        root.Q <Button>("switch-daytime-exit").clickable.clicked += () =>
        {
            root.Q("switch-daytime-panel").style.display = DisplayStyle.None;
            root.Q("options-panel").style.display        = DisplayStyle.Flex;
        };

        #endregion

        #region Initialisierung

        root.Q("placement-mode-select").style.display         = DisplayStyle.Flex;
        root.Q("placement-free-info").style.display           = DisplayStyle.None;
        root.Q("placement-qr-info").style.display             = DisplayStyle.None;
        root.Q("placement-panel").style.display               = DisplayStyle.None;
        root.Q("options-panel").style.display                 = DisplayStyle.None;
        root.Q("interaction-panel").style.display             = DisplayStyle.None;
        root.Q("animation-area").style.display                = DisplayStyle.None;
        root.Q("desc-area").style.display                     = DisplayStyle.None;
        root.Q("hideSections-area").style.display             = DisplayStyle.None;
        root.Q("placement-edit-panel").style.display          = DisplayStyle.None;
        root.Q("placement-edit-scale-panel").style.display    = DisplayStyle.None;
        root.Q("placement-edit-rotate-panel").style.display   = DisplayStyle.None;
        root.Q("placement-edit-position-panel").style.display = DisplayStyle.None;
        root.Q("create-section-panel").style.display          = DisplayStyle.None;
        root.Q("switch-daytime-panel").style.display          = DisplayStyle.None;

        #endregion

        // Kein return notwendig
        return(null);
    }
示例#12
0
        public void HandleMouseMove(MouseMoveEvent evt)
        {
            var     ve         = (VisualElement)evt.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(GraphView.contentContainer, evt.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);

            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            Vector2 mousePosition = evt.mousePosition;

            edgeCandidateModel.EndPoint = mousePosition;
            m_EdgeCandidate.UpdateFromModel();

            // Draw ghost edge if possible port exists.
            Port endPort = GetEndPort(mousePosition);

            if (endPort != null)
            {
                if (m_GhostEdge == null)
                {
                    m_GhostEdge      = CreateGhostEdge(endPort.PortModel.GraphModel);
                    m_GhostEdgeModel = m_GhostEdge.EdgeModel as GhostEdgeModel;

                    m_GhostEdge.pickingMode = PickingMode.Ignore;
                    GraphView.AddElement(m_GhostEdge);
                }

                Debug.Assert(m_GhostEdgeModel != null);

                if (edgeCandidateModel.FromPort == null)
                {
                    m_GhostEdgeModel.ToPort = edgeCandidateModel.ToPort;
                    var portUI = m_GhostEdgeModel?.FromPort?.GetUI <Port>(GraphView);
                    if (portUI != null)
                    {
                        portUI.WillConnect = false;
                    }
                    m_GhostEdgeModel.FromPort = endPort.PortModel;
                    endPort.WillConnect       = true;
                }
                else
                {
                    var portUI = m_GhostEdgeModel?.ToPort?.GetUI <Port>(GraphView);
                    if (portUI != null)
                    {
                        portUI.WillConnect = false;
                    }
                    m_GhostEdgeModel.ToPort   = endPort.PortModel;
                    endPort.WillConnect       = true;
                    m_GhostEdgeModel.FromPort = edgeCandidateModel.FromPort;
                }

                m_GhostEdge.UpdateFromModel();
            }
            else if (m_GhostEdge != null && m_GhostEdgeModel != null)
            {
                if (edgeCandidateModel.ToPort == null)
                {
                    var portUI = m_GhostEdgeModel?.ToPort?.GetUI <Port>(GraphView);
                    if (portUI != null)
                    {
                        portUI.WillConnect = false;
                    }
                }
                else
                {
                    var portUI = m_GhostEdgeModel?.FromPort?.GetUI <Port>(GraphView);
                    if (portUI != null)
                    {
                        portUI.WillConnect = false;
                    }
                }
                GraphView.RemoveElement(m_GhostEdge);
                m_GhostEdgeModel.ToPort   = null;
                m_GhostEdgeModel.FromPort = null;
                m_GhostEdgeModel          = null;
                m_GhostEdge = null;
            }
        }
示例#13
0
        protected new void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);


            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positionning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_originalMouse - e.mousePosition;

            foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                // Detach the selected element from its parent before dragging it
                // TODO: Make it more generic
                if (ce.parent is StackNode)
                {
                    StackNode stackNode = ce.parent as StackNode;

                    ce.RemoveFromHierarchy();

                    m_GraphView.AddElement(ce);
                    // Reselect it because RemoveFromHierarchy unselected it
                    ce.Select(m_GraphView, true);

                    if (m_GraphView.elementRemovedFromStackNode != null)
                    {
                        m_GraphView.elementRemovedFromStackNode(stackNode, ce);
                    }
                }

                MoveElement(ce, v.Value);
            }

            List <ISelectable> selection = m_GraphView.selection;

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            IDropTarget dropTarget = GetDropTargetAt(e.mousePosition, selection.OfType <VisualElement>());

            if (m_PrevDropTarget != dropTarget && m_PrevDropTarget != null)
            {
                using (DragExitedEvent eexit = DragExitedEvent.GetPooled(e))
                {
                    SendDragAndDropEvent(eexit, selection, m_PrevDropTarget);
                }
            }

            using (DragUpdatedEvent eupdated = DragUpdatedEvent.GetPooled(e))
            {
                SendDragAndDropEvent(eupdated, selection, dropTarget);
            }

            m_PrevDropTarget = dropTarget;

            selectedElement = null;
            e.StopPropagation();
        }
示例#14
0
        /// <summary>
        /// Callback for the MouseMove event.
        /// </summary>
        /// <param name="e">The event.</param>
        protected void OnMouseMove(MouseMoveEvent e)
        {
            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);

            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positioning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_OriginalMouse - e.mousePosition;

            if (m_SelectedElement.parent != null)
            {
                // Handle the selected element
                Rect selectedElementGeom = GetSelectedElementGeom();

                ComputeSnappedRect(ref selectedElementGeom, m_SelectedElement);

                foreach (KeyValuePair <GraphElement, OriginalPos> v in m_OriginalPos)
                {
                    GraphElement ce = v.Key;

                    // Protect against stale visual elements that have been deparented since the start of the manipulation
                    if (ce.hierarchy.parent == null)
                    {
                        continue;
                    }

                    if (!v.Value.dragStarted)
                    {
                        v.Value.dragStarted = true;
                    }

                    SnapOrMoveElement(v.Key, v.Value.pos, selectedElementGeom);
                }

                foreach (var edge in m_EdgesToUpdate)
                {
                    SnapOrMoveEdge(edge, selectedElementGeom);
                }
            }

            var selection  = m_GraphView.GetSelection();
            var selectedUI = selection.Select(m => m.GetUI(m_GraphView));

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            var previousDropTarget = m_CurrentDropTarget;

            m_CurrentDropTarget = GetDropTargetAt(e.mousePosition, selectedUI.OfType <VisualElement>().ToList());

            if (m_CurrentDropTarget != previousDropTarget)
            {
                if (previousDropTarget != null)
                {
                    using (DragLeaveEvent eLeave = DragLeaveEvent.GetPooled(e))
                    {
                        eLeave.target = previousDropTarget;
                        m_GraphView.SendEvent(eLeave);
                    }
                }

                if (m_CurrentDropTarget != null)
                {
                    using (DragEnterEvent eEnter = DragEnterEvent.GetPooled(e))
                    {
                        eEnter.target = m_CurrentDropTarget;
                        m_GraphView.SendEvent(eEnter);
                    }
                }
            }

            if (m_CurrentDropTarget != null)
            {
                using (DragUpdatedEvent eUpdated = DragUpdatedEvent.GetPooled(e))
                {
                    eUpdated.target = m_CurrentDropTarget;
                    m_GraphView.SendEvent(eUpdated);
                }
            }

            m_Dragging = true;
            e.StopPropagation();
        }
示例#15
0
        protected new void OnMouseMove(MouseMoveEvent e)
        {
            if (!target.HasMouseCapture())
            {
                // We lost the capture. Since we still receive mouse events,
                // the MouseDown target must have taken it in its ExecuteDefaultAction().
                // Stop processing the event sequence, then.
                // FIXME: replace this by a handler on the upcoming LostCaptureEvent.

                m_PrevDropTarget = null;
                m_Active         = false;
            }

            if (!m_Active)
            {
                return;
            }

            if (m_GraphView == null)
            {
                return;
            }

            var     ve         = (VisualElement)e.target;
            Vector2 gvMousePos = ve.ChangeCoordinatesTo(m_GraphView.contentContainer, e.localMousePosition);

            m_PanDiff = GetEffectivePanSpeed(gvMousePos);


            if (m_PanDiff != Vector3.zero)
            {
                m_PanSchedule.Resume();
            }
            else
            {
                m_PanSchedule.Pause();
            }

            // We need to monitor the mouse diff "by hand" because we stop positionning the graph elements once the
            // mouse has gone out.
            m_MouseDiff = m_originalMouse - e.mousePosition;

            foreach (KeyValuePair <GraphElement, Rect> v in m_OriginalPos)
            {
                GraphElement ce = v.Key;

                Matrix4x4 g     = ce.worldTransform;
                var       scale = new Vector3(g.m00, g.m11, g.m22);

                Rect ceLayout = ce.GetPosition();

                ce.SetPosition(
                    new Rect(v.Value.x - (m_MouseDiff.x - m_ItemPanDiff.x) * panSpeed.x / scale.x,
                             v.Value.y - (m_MouseDiff.y - m_ItemPanDiff.y) * panSpeed.y / scale.y,
                             ceLayout.width, ceLayout.height));
            }
            List <ISelectable> selection = m_GraphView.selection;

            // TODO: Replace with a temp drawing or something...maybe manipulator could fake position
            // all this to let operation know which element sits under cursor...or is there another way to draw stuff that is being dragged?

            IDropTarget dropTarget = GetDropTargetAt(e.localMousePosition);

            if (m_PrevDropTarget != dropTarget && m_PrevDropTarget != null)
            {
                using (IMGUIEvent eexit = IMGUIEvent.GetPooled(e.imguiEvent))
                {
                    eexit.imguiEvent.type = EventType.DragExited;
                    SendDragAndDropEvent(eexit, selection, m_PrevDropTarget);
                }
            }

            using (IMGUIEvent eupdated = IMGUIEvent.GetPooled(e.imguiEvent))
            {
                eupdated.imguiEvent.type = EventType.DragUpdated;
                SendDragAndDropEvent(eupdated, selection, dropTarget);
            }

            m_PrevDropTarget = dropTarget;

            selectedElement = null;
            e.StopPropagation();
        }