public void SetTouchCapture(Actor actor, int pointer) { if (pointer < 0 || pointer >= _touchCapture.Length) throw new ArgumentOutOfRangeException("pointer"); Actor oldTouchCapture = _touchCapture[pointer]; _touchCapture[pointer] = actor; if (oldTouchCapture != null) { TouchEventArgs ev = Pools<TouchEventArgs>.Obtain(); ev.RoutedEvent = LostTouchCaptureEvent; ev.Pointer = pointer; bool cancel = oldTouchCapture.RaiseEvent(ev); Pools<TouchEventArgs>.Release(ev); if (cancel) return; } if (actor != null) { TouchEventArgs ev = Pools<TouchEventArgs>.Obtain(); ev.RoutedEvent = GotTouchCaptureEvent; ev.Pointer = pointer; if (actor.RaiseEvent(ev)) SetTouchCapture(oldTouchCapture, pointer); Pools<TouchEventArgs>.Release(ev); } }
public bool IsAscendentOf(Actor actor) { if (actor == null) throw new ArgumentNullException("actor"); while (true) { if (actor == null) return false; if (actor == this) return true; actor = actor.Parent; } }
public void SetScrollFocus(Actor actor) { if (_scrollFocus == actor) return; Actor oldScrollFocus = _scrollFocus; _scrollFocus = actor; if (oldScrollFocus != null) { ScrollFocusChangedEventArgs eva = Pools<ScrollFocusChangedEventArgs>.Obtain(); eva.RoutedEvent = LostScrollFocusEvent; eva.NewFocus = actor; eva.OldFocus = oldScrollFocus; bool cancel = oldScrollFocus.RaiseEvent(eva); Pools<ScrollFocusChangedEventArgs>.Release(eva); if (cancel) return; } if (actor != null) { ScrollFocusChangedEventArgs eva = Pools<ScrollFocusChangedEventArgs>.Obtain(); eva.RoutedEvent = GotScrollFocusEvent; eva.NewFocus = actor; eva.OldFocus = oldScrollFocus; if (actor.RaiseEvent(eva)) SetScrollFocus(oldScrollFocus); Pools<ScrollFocusChangedEventArgs>.Release(eva); } }
public Vector2 LocalToDescendantCoordinates(Actor descendant, Vector2 localCoords) { if (Parent == null) throw new ArgumentException("Child is not a descendant: " + descendant); if (Parent != this) localCoords = LocalToDescendantCoordinates(Parent, localCoords); return descendant.ParentToLocalCoordinates(localCoords); }
public bool SwapActor(Actor first, Actor second) { int firstIndex = Children.IndexOf(first); int secondIndex = Children.IndexOf(second); return SwapActor(firstIndex, secondIndex); }
private Actor FireEnterAndExit(Actor overLast, int screenX, int screenY, int pointer) { Vector2 stageCoords = ScreenToStageCoordinates(new Vector2(screenX, screenY)); Actor over = Hit(stageCoords.X, stageCoords.Y, true); if (over == overLast) return overLast; TouchEventArgs ev = Pools<TouchEventArgs>.Obtain(); ev.Stage = this; ev.StagePosition = stageCoords; ev.Pointer = pointer; if (overLast != null) { ev.RoutedEvent = TouchLeaveEvent; ev.RelatedActor = over; overLast.RaiseEvent(ev); } if (over != null) { ev.RoutedEvent = TouchEnterEvent; ev.RelatedActor = overLast; over.RaiseEvent(ev); } Pools<TouchEventArgs>.Release(ev); return over; }
public virtual void AddActorAt(int index, Actor actor) { actor.Remove(); if (index >= Children.Count) Children.Add(actor); else Children.Insert(index, actor); actor.Parent = this; actor.Stage = Stage; ChildrenChanged(); }
private static void LostTouchCaptureClass(Actor sender, TouchEventArgs e) { if (sender != null) sender.OnLostTouchCapture(e); }
private static void PreviewKeyUpClass(Actor sender, KeyEventArgs e) { if (sender != null) sender.OnPreviewKeyUp(e); }
private static void LostKeyboardFocusClass(Actor sender, KeyboardFocusChangedEventArgs e) { if (sender != null) sender.OnLostKeyboardFocus(e); }
private static void LostScrollFocusClass(Actor sender, ScrollFocusChangedEventArgs e) { if (sender != null) sender.OnLostScrollFocus(e); }
private static void KeyDownClass(Actor sender, KeyEventArgs e) { if (sender != null) sender.OnKeyDown(e); }
public Vector2 LocalToAscendantCoordinates(Actor ascendant, Vector2 localCoords) { Actor actor = this; while (actor.Parent != null) { localCoords = actor.LocalToParentCoordinates(localCoords); actor = actor.Parent; if (actor == ascendant) break; } return localCoords; }
public bool IsDescendentOf(Actor actor) { if (actor == null) throw new ArgumentNullException("actor"); Actor parent = this; while (true) { if (parent == null) return false; if (parent == actor) return true; parent = parent.Parent; } }
public void Unfocus(Actor actor) { if (_scrollFocus != null && _scrollFocus.IsDescendentOf(actor)) _scrollFocus = null; if (_keyboardFocus != null && _keyboardFocus.IsDescendentOf(actor)) _keyboardFocus = null; }
private static void PreviewMouseMoveClass(Actor sender, MouseEventArgs e) { if (sender != null) sender.OnPreviewMouseMove(e); }
public void UnfocusAll() { _scrollFocus = null; _keyboardFocus = null; ReleaseTouchCapture(); }
private static void PreviewTouchUpClass(Actor sender, TouchEventArgs e) { if (sender != null) sender.OnPreviewTouchUp(e); }
public virtual void AddActorAfter(Actor actorAfter, Actor actor) { actor.Remove(); int index = Children.IndexOf(actorAfter); if (index == Children.Count) Children.Add(actor); else Children.Insert(index + 1, actor); actor.Parent = this; actor.Stage = Stage; ChildrenChanged(); }
private static void ScrollClass(Actor sender, ScrollEventArgs e) { if (sender != null) sender.OnScroll(e); }
public virtual void AddActorBefore(Actor actorBefore, Actor actor) { actor.Remove(); int index = Children.IndexOf(actorBefore); Children.Insert(index, actor); actor.Parent = this; actor.Stage = Stage; ChildrenChanged(); }
public void Act(float delta) { // Update over actors. Done in act() because actors may change position, which can fire enter/exit without an input event. for (int pointer = 0, n = _pointerOverActors.Length; pointer < n; pointer++) { Actor overLast = _pointerOverActors[pointer]; // Check if pointer is gone. if (!_pointerTouched[pointer]) { if (overLast != null) { _pointerOverActors[pointer] = null; Vector2 stageCoords = ScreenToStageCoordinates(new Vector2(_pointerScreen[pointer].X, _pointerScreen[pointer].Y)); // Exit over last TouchEventArgs ev = Pools<TouchEventArgs>.Obtain(); ev.RoutedEvent = TouchLeaveEvent; ev.Stage = this; ev.StagePosition = stageCoords; ev.RelatedActor = overLast; ev.Pointer = pointer; overLast.RaiseEvent(ev); Pools<TouchEventArgs>.Release(ev); } continue; } // Update over actor for the pointer _pointerOverActors[pointer] = FireEnterAndExit(overLast, _pointerScreen[pointer].X, _pointerScreen[pointer].Y, pointer); } // Update over actor the mouse on the desktop // ApplicationType type = Gdx.app.getType(); // if (type == ApplicationType.Desktop || type == ApplicationType.Applet || type == ApplicationType.WebGL) _mouseOverActor = FireEnterAndExit(_mouseOverActor, _mouseScreenX, _mouseScreenY, -1); Root.Act(delta); }
public virtual bool RemoveActor(Actor actor) { if (!Children.Remove(actor)) return false; if (Stage != null) Stage.Unfocus(actor); actor.Parent = null; actor.Stage = null; ChildrenChanged(); return true; }
public void AddActor(Actor actor) { Root.AddActor(actor); }
public virtual void AddActor(Actor actor) { actor.Remove(); Children.Add(actor); actor.Parent = this; actor.Stage = Stage; ChildrenChanged(); }
private static void TouchLeaveClass(Actor sender, TouchEventArgs e) { if (sender != null) sender.OnTouchLeave(e); }