/// <summary> /// Creates a new PopupAnimator specifying the pop behavior values /// </summary> /// <param name="form">The <see cref="NotificationWindow"/> to animate</param> /// <param name="popInDuration">The amount of time (in milliseconds) over which the pop-in should occur</param> /// <param name="popOutDuration">The amount of time (in milliseconds) over which the pop-out should occur</param> /// <param name="direction">The direction the window should pop</param> public PopupAnimator(NotificationWindow form, int popInDuration, int popOutDuration, PopupDirection direction) : this(form) { this.popInDuration = popInDuration; this.popOutDuration = popOutDuration; this.direction = direction; }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="dir"></param> /// <param name="parentMenu"></param> public void Show(GObject target, PopupDirection dir, PopupMenu parentMenu) { GRoot r = target != null ? target.root : GRoot.inst; r.ShowPopup(this.contentPane, (target is GRoot) ? null : target, dir); _parentMenu = parentMenu; }
/// <summary> /// /// </summary> /// <param name="popup"></param> /// <param name="target"></param> /// <param name="dir"></param> /// <returns></returns> public Vector2 GetPoupPosition(GObject popup, GObject target, PopupDirection dir) { Vector2 pos; Vector2 size = Vector2.zero; if (target != null) { pos = target.LocalToRoot(Vector2.zero, this); size = target.LocalToRoot(target.size, this) - pos; } else { pos = this.GlobalToLocal(Stage.inst.touchPosition); } float xx, yy; xx = pos.x; if (xx + popup.width > this.width) { xx = xx + size.x - popup.width; } yy = pos.y + size.y; if ((dir == PopupDirection.Auto && yy + popup.height > this.height) || dir == PopupDirection.Up) { yy = pos.y - popup.height - 1; if (yy < 0) { yy = 0; xx += size.x / 2; } } return(new Vector2(Mathf.RoundToInt(xx), Mathf.RoundToInt(yy))); }
Point CalcPlacementPosition(Point basePoint, Size popSize, PopupDirection popDirection) { Point point = new Point(); switch (popDirection) { case PopupDirection.UpperLeft: point.X = basePoint.X - popSize.Width; point.Y = basePoint.Y - popSize.Height; return(point); case PopupDirection.UpperRight: point.X = basePoint.X; point.Y = basePoint.Y - popSize.Height; return(point); case PopupDirection.BottomLeft: point.X = basePoint.X - popSize.Width; point.Y = basePoint.Y; return(point); case PopupDirection.BottomRight: point.X = basePoint.X; point.Y = basePoint.Y; return(point); } return(point); }
public GComboBox() { visibleItemCount = UIConfig.defaultComboBoxVisibleItemCount; _itemsUpdated = true; _selectedIndex = -1; _items = new string[0]; _values = new string[0]; _popupDirection = PopupDirection.Auto; }
/// <summary> /// /// </summary> /// <param name="popup"></param> /// <param name="target"></param> /// <param name="dir"></param> /// <param name="closeUntilUpEvent"></param> public void TogglePopup(GObject popup, GObject target, PopupDirection dir, bool closeUntilUpEvent) { if (_justClosedPopups.IndexOf(popup) != -1) { return; } ShowPopup(popup, target, dir, closeUntilUpEvent); }
public GComboBox() { visibleItemCount = UIConfig.defaultComboBoxVisibleItemCount; _itemsUpdated = true; _selectedIndex = -1; _items = new List <string>(); _values = new List <string>(); _popupDirection = PopupDirection.Auto; soundVolumeScale = 1; }
public GComboBox() { visibleItemCount = UIConfig.defaultComboBoxVisibleItemCount; _itemsUpdated = true; _selectedIndex = -1; _items = new string[0]; _values = new string[0]; _popupDirection = PopupDirection.Auto; onChanged = new EventListener(this, "onChanged"); }
/// <summary> /// Show a popup object along with the specific target object. /// 显示一个popup。将popup显示在指定对象的上方或者下方。 /// popup的特点是点击popup对象外的区域,popup对象将自动消失。 /// 默认情况下,popup在touchEnd事件中关闭;特别设置closeUntilUpEvent=true则可使该popup在touchEnd中才关闭。 /// </summary> /// <param name="popup"></param> /// <param name="target"></param> /// <param name="dir"></param> /// <param name="closeUntilUpEvent"></param> public void ShowPopup(GObject popup, GObject target, PopupDirection dir, bool closeUntilUpEvent) { if (_popupStack.Count > 0) { int k = _popupStack.IndexOf(popup); if (k != -1) { for (int i = _popupStack.Count - 1; i >= k; i--) { int last = _popupStack.Count - 1; GObject obj = _popupStack[last]; ClosePopup(obj); _popupStack.RemoveAt(last); _specialPopups.Remove(obj); } } } _popupStack.Add(popup); if (closeUntilUpEvent) { _specialPopups.Add(popup); } if (target != null) { GObject p = target; while (p != null) { if (p.parent == this) { if (popup.sortingOrder < p.sortingOrder) { popup.sortingOrder = p.sortingOrder; } break; } p = p.parent; } } AddChild(popup); AdjustModalLayer(); if ((popup is Window) && target == null && dir == PopupDirection.Auto) { return; } Vector2 pos = GetPoupPosition(popup, target, dir); popup.xy = pos; }
public void ShowAsModal(FrameworkElement placeElement, Control contentElement, Point relativePoint, PopupDirection popDirection) { _popupContentHost.Child = contentElement; _placeElement = placeElement; // 相对整个视图的位置 _relativePoint = placeElement.TransformToVisual(null).Transform(relativePoint); _popDirection = popDirection; _popupContentHost.Background = new SolidColorBrush(Colors.Transparent); _popupOutsideCanvas.Background = new SolidColorBrush(Colors.Transparent); _popupOutsideCanvas.Margin = new Thickness(-10000.0); placeElement.ReleasePointerCaptures(); _popup.IsOpen = true; }
public void ShowPopup(FObject popup, FObject target, PopupDirection dir, bool closeUntilUpEvent) { _root.ShowPopup(popup.GetObject(), target.GetObject(), dir, closeUntilUpEvent); }
public void ShowPopup(FObject popup, FObject target, PopupDirection dir) { _root.ShowPopup(popup.GetObject(), target.GetObject(), dir); }
/// <summary> /// /// </summary> /// <param name="target"></param> /// <param name="dir"></param> public void Show(GObject target, PopupDirection dir) { Show(target, PopupDirection.Auto, null); }
/// <summary> /// /// </summary> /// <param name="popup"></param> /// <param name="target"></param> /// <param name="dir"></param> public void TogglePopup(GObject popup, GObject target, PopupDirection dir) { TogglePopup(popup, target, dir, false); }
/// <summary> /// Show a popup object along with the specific target object. /// 显示一个popup。将popup显示在指定对象的上方或者下方。 /// popup的特点是点击popup对象外的区域,popup对象将自动消失。 /// </summary> /// <param name="popup"></param> /// <param name="target"></param> /// <param name="dir"></param> public void ShowPopup(GObject popup, GObject target, PopupDirection dir) { ShowPopup(popup, target, dir, false); }
override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos) { base.Setup_AfterAdd(buffer, beginPos); if (!buffer.Seek(beginPos, 6)) { return; } if ((ObjectType)buffer.ReadByte() != packageItem.objectType) { return; } string str; int itemCount = buffer.ReadShort(); for (int i = 0; i < itemCount; i++) { int nextPos = buffer.ReadUshort(); nextPos += buffer.position; _items.Add(buffer.ReadS()); _values.Add(buffer.ReadS()); str = buffer.ReadS(); if (str != null) { if (_icons == null) { _icons = new List <string>(); } _icons.Add(str); } buffer.position = nextPos; } str = buffer.ReadS(); if (str != null) { this.text = str; _selectedIndex = _items.IndexOf(str); } else if (_items.Count > 0) { _selectedIndex = 0; this.text = _items[0]; } else { _selectedIndex = -1; } str = buffer.ReadS(); if (str != null) { this.icon = str; } if (buffer.ReadBool()) { this.titleColor = buffer.ReadColor(); } int iv = buffer.ReadInt(); if (iv > 0) { visibleItemCount = iv; } _popupDirection = (PopupDirection)buffer.ReadByte(); iv = buffer.ReadShort(); if (iv >= 0) { _selectionController = parent.GetControllerAt(iv); } if (buffer.version >= 5) { str = buffer.ReadS(); if (str != null) { sound = UIPackage.GetItemAssetByURL(str) as NAudioClip; } soundVolumeScale = buffer.ReadFloat(); } }
/* * FairyGUI.PopupDirection * Auto * Up * Down */ public void SetPopupDirection(PopupDirection dir) { _obj.asComboBox.popupDirection = dir; }
public void ShowPopup(GObject popup, GObject owner, PopupDirection direction, PopupConstraint constraint, PopupHideCallback hideCallback = null) { this._popupHideCallback = hideCallback; this._blocker = new GObject(); this._blocker.onClick.Add(this.OnPopupHide); this.AddChild(this._blocker); DisplayObject displayObj = this._blocker.displayObject; ToolSet.SetAnchor(displayObj.rectTransform, AnchorType.Stretch_Stretch); displayObj.RegisterEventTriggerType(EventTriggerType.PointerClick); displayObj.name = "Blocker"; displayObj.size = Vector2.zero; this.popup = popup; this.AddChild(this.popup); owner = owner ?? this; Vector3[] corners = new Vector3[4]; owner.displayObject.rectTransform.GetWorldCorners(corners); Vector3 min = this.displayObject.rectTransform.InverseTransformPoint(corners[0]); Vector3 max = this.displayObject.rectTransform.InverseTransformPoint(corners[2]); PointerEventData pointerEventData = EventSystem.instance.pointerInput.GetLastPointerEventData(PointerInput.K_MOUSE_LEFT_ID); switch (direction) { case PopupDirection.TouchPosition: this.popup.position = this.ScreenToLocal(pointerEventData.position); break; case PopupDirection.Left: this.popup.position = new Vector2(min.x - this.popup.actualSize.x, -max.y); break; case PopupDirection.Upward: this.popup.position = new Vector2(min.x, -max.y - this.popup.actualSize.y); break; case PopupDirection.Right: this.popup.position = new Vector2(max.x, -max.y); break; case PopupDirection.Downward: this.popup.position = new Vector2(min.x, -min.y); break; } if (constraint > 0) { corners = new Vector3[4]; this.popup.displayObject.rectTransform.GetWorldCorners(corners); min = this.displayObject.rectTransform.InverseTransformPoint(corners[0]); max = this.displayObject.rectTransform.InverseTransformPoint(corners[2]); if ((constraint & PopupConstraint.Right) > 0 && max.x > this.size.x) { this.popup.position = new Vector2(this.size.x - this.popup.size.x, this.popup.position.y); } if ((constraint & PopupConstraint.Left) > 0 && min.x < 0) { this.popup.position = new Vector2(0, this.popup.position.y); } if ((constraint & PopupConstraint.Bottom) > 0 && -min.y > this.size.y) { this.popup.position = new Vector2(this.popup.position.x, this.size.y - this.popup.size.y); } if ((constraint & PopupConstraint.Top) > 0 && -max.y < 0) { this.popup.position = new Vector2(this.popup.position.x, 0); } } }
override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos) { base.Setup_AfterAdd(buffer, beginPos); if (!buffer.Seek(beginPos, 6)) { return; } if ((ObjectType)buffer.ReadByte() != packageItem.objectType) { return; } string str; int itemCount = buffer.ReadShort(); _items = new string[itemCount]; _values = new string[itemCount]; for (int i = 0; i < itemCount; i++) { int nextPos = buffer.ReadShort(); nextPos += buffer.position; _items[i] = buffer.ReadS(); _values[i] = buffer.ReadS(); str = buffer.ReadS(); if (str != null) { if (_icons == null) { _icons = new string[itemCount]; } _icons[i] = str; } buffer.position = nextPos; } str = buffer.ReadS(); if (str != null) { this.text = str; _selectedIndex = Array.IndexOf(_items, str); } else if (_items.Length > 0) { _selectedIndex = 0; this.text = _items[0]; } else { _selectedIndex = -1; } str = buffer.ReadS(); if (str != null) { this.icon = str; } if (buffer.ReadBool()) { this.titleColor = buffer.ReadColor(); } int iv = buffer.ReadInt(); if (iv > 0) { visibleItemCount = iv; } _popupDirection = (PopupDirection)buffer.ReadByte(); iv = buffer.ReadShort(); if (iv >= 0) { _selectionController = parent.GetControllerAt(iv); } }
void SetDirection(PopupDirection direction) { _direction = direction; }