static void UpdateElementUnderPointer(EventBase evt, IPanel panel, out VisualElement elementUnderPointer) { IPointerEvent pointerEvent = evt as IPointerEvent; BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; bool shouldRecomputeTopElementUnderPointer = true; if (evt is IPointerEventInternal) { shouldRecomputeTopElementUnderPointer = ((IPointerEventInternal)pointerEvent).recomputeTopElementUnderPointer; } elementUnderPointer = shouldRecomputeTopElementUnderPointer ? basePanel?.Pick(pointerEvent.position) : basePanel?.GetTopElementUnderPointer(pointerEvent.pointerId); if (basePanel != null && shouldRecomputeTopElementUnderPointer) { basePanel.SetElementUnderPointer(elementUnderPointer, evt); } }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; if (mouseEvent == null) { return; } BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; // update element under mouse and fire necessary events bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel?.Pick(mouseEvent.mousePosition) : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null && elementUnderMouse != null) { evt.propagateToIMGUI = false; evt.target = elementUnderMouse; } else if (evt.target == null && elementUnderMouse == null) { // Don't modify evt.propagateToIMGUI. evt.target = panel?.visualTree; } else if (evt.target != null) { evt.propagateToIMGUI = false; } if (basePanel != null) { // If mouse leaves the window, make sure element under mouse is null. // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0) { basePanel.SetElementUnderPointer(null, evt); } else if (shouldRecomputeTopElementUnderMouse) { basePanel.SetElementUnderPointer(elementUnderMouse, evt); } } if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } } evt.stopDispatch = true; }
public void DispatchEvent(EventBase evt, IPanel panel) { IMouseEvent mouseEvent = evt as IMouseEvent; if (mouseEvent == null) { return; } BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel; // update element under mouse and fire necessary events bool shouldRecomputeTopElementUnderMouse = true; if ((IMouseEventInternal)mouseEvent != null) { shouldRecomputeTopElementUnderMouse = ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse; } VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ? basePanel?.Pick(mouseEvent.mousePosition) : basePanel?.GetTopElementUnderPointer(PointerId.mousePointerId); if (evt.target == null && elementUnderMouse != null) { evt.propagateToIMGUI = false; evt.target = elementUnderMouse; } else if (evt.target == null && elementUnderMouse == null) { // Event occured outside the window. // Send event to visual tree root and // don't modify evt.propagateToIMGUI. evt.target = panel?.visualTree; } else if (evt.target != null) { evt.propagateToIMGUI = false; } if (basePanel != null) { // If mouse leaves the window, make sure element under mouse is null. // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of // of a drag and drop operation, at the very beginning of the drag. Since // we are not really exiting the window, we do not want to set the element // under mouse to null in this case. if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0) { basePanel.SetElementUnderPointer(null, evt); } else if (shouldRecomputeTopElementUnderMouse) { basePanel.SetElementUnderPointer(elementUnderMouse, evt); } } if (evt.target != null) { EventDispatchUtilities.PropagateEvent(evt); if (evt.target is IMGUIContainer) { evt.propagateToIMGUI = true; evt.skipElements.Add(evt.target); } } if (!evt.isPropagationStopped && panel != null) { if (evt.propagateToIMGUI || evt.eventTypeId == MouseEnterWindowEvent.TypeId() || evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ) { EventDispatchUtilities.PropagateToIMGUIContainer(panel.visualTree, evt); } else if (panel.visualTree.childCount > 0 && panel.visualTree[0] is IMGUIContainer) { // Send the events to the GUIView container so that it can process them. // This avoid elements near the edge of the window preventing the dock area splitter to work. // See case : https://fogbugz.unity3d.com/f/cases/1197851/ var topLevelIMGUI = (IMGUIContainer)panel.visualTree[0]; if (!evt.Skip(topLevelIMGUI) && evt.imguiEvent != null) { topLevelIMGUI.SendEventToIMGUI(evt, false); if (evt.imguiEvent.rawType == EventType.Used) { evt.StopPropagation(); } } } } evt.stopDispatch = true; }
protected RenderChain(BaseVisualElementPanel panel, UIRenderDevice device, AtlasBase atlas, VectorImageManager vectorImageManager) { Constructor(panel, device, atlas, vectorImageManager); }
public RenderChain(BaseVisualElementPanel panel) { Constructor(panel, new UIRenderDevice(), panel.atlas, new VectorImageManager(panel.atlas)); }