Exemplo n.º 1
0
 public void AddChild(EditorGUIWidget widget)
 {
     if (childList.Contains(widget) == false)
     {
         childList.Add(widget);
     }
 }
Exemplo n.º 2
0
 public int GetIndexByWidget(EditorGUIWidget w)
 {
     for (int i = 0; i < AllWidget.Count; i++)
     {
         if (AllWidget[i] == w)
             return i;
     }
     return -1;
 }
Exemplo n.º 3
0
 public int GetIndexByWidget(EditorGUIWidget w)
 {
     for (int i = 0; i < AllWidget.Count; i++)
     {
         if (AllWidget[i] == w)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 4
0
        public void Notify(EditorGUIWidget widget, EventGUIType guiType, object data)
        {
            if (widget == null)
            {
                Debug.Log(" Widget == null guitype " + guiType.ToString());
            }


            if (widget.IsAutoDepth)
            {
                widget.SetAsFirstSibling();
            }

            switch (guiType)
            {
            case EventGUIType.Hover:
                widget.OnHover();
                for (int i = 0; i < mListens.Count; i++)
                {
                    mListens[i].OnHover(widget);
                }
                Debug.Log("Hover");
                break;

            case EventGUIType.Press:
                widget.OnPress((bool)data);
                for (int i = 0; i < mListens.Count; i++)
                {
                    mListens[i].OnPress(widget, (bool)data);
                }
                Debug.Log("Press " + data.ToString());
                break;

            case EventGUIType.Click:
                widget.OnClick();

                for (int i = 0; i < mListens.Count; i++)
                {
                    mListens[i].OnClick(widget);
                }
                Debug.Log("Click ");
                break;

            case EventGUIType.Drag:
                widget.OnDrag(nowEvent.delta);
                for (int i = 0; i < mListens.Count; i++)
                {
                    mListens[i].OnDrag(widget, nowEvent.delta);
                }
                Debug.Log("Drag ");
                break;
            }
        }
Exemplo n.º 5
0
        protected float GetWholeWidth()
        {
            float           result = 0;
            EditorGUIWidget temp   = parent;

            while (temp != null)
            {
                result += 5f;
                temp    = temp.parent;
            }

            return(result);
        }
Exemplo n.º 6
0
        public void Notify(EditorGUIWidget widget, EventGUIType guiType, object data)
        {
            if (widget == null)
            {
                Debug.Log(" Widget == null guitype " + guiType.ToString());
            }

            if (widget.IsAutoDepth)
            {
                widget.SetAsFirstSibling();
            }

            switch (guiType)
            {
                case EventGUIType.Hover:
                    widget.OnHover();
                    for (int i = 0; i < mListens.Count; i++)
                    {
                        mListens[i].OnHover(widget);
                    }
                    Debug.Log("Hover");
                    break;
                case EventGUIType.Press:
                    widget.OnPress((bool)data);
                    for (int i = 0; i < mListens.Count; i++)
                    {
                        mListens[i].OnPress(widget, (bool)data);
                    }
                    Debug.Log("Press " + data.ToString());
                    break;
                case EventGUIType.Click:
                    widget.OnClick();

                    for (int i = 0; i < mListens.Count; i++)
                    {
                        mListens[i].OnClick(widget);
                    }
                    Debug.Log("Click ");
                    break;
                case EventGUIType.Drag:
                    widget.OnDrag(nowEvent.delta);
                    for (int i = 0; i < mListens.Count; i++)
                    {
                        mListens[i].OnDrag(widget, nowEvent.delta);
                    }
                    Debug.Log("Drag ");
                    break;
            }
        }
Exemplo n.º 7
0
        private bool TryGetMouseStayWidget(Vector2 point, out EditorGUIWidget widget)
        {
            widget = null;

            for (int i = mAllWidgets.Count - 1; i >= 0; i--)
            {
                if (mAllWidgets[i].IsTrigger == false)
                {
                    continue;
                }

                if (mAllWidgets[i].AreaRect.Contains(point))
                {
                    widget = mAllWidgets[i];
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        protected void SetParent(EditorGUIWidget widget)
        {
            if (parent == widget || this == widget)
            {
                return;
            }

            if (parent != null)
            {
                parent.RemoveChild(this);
            }

            if (widget != null)
            {
                widget.AddChild(this);
                parent = widget;
            }
            else
            {
                localPostion = worldPostion;
                return;
            }

            float x = 0, y = 0;
            var   tempParent = parent;

            while (tempParent != null)
            {
                x         += tempParent.localPostion.x;
                y         += tempParent.localPostion.y;
                tempParent = tempParent.Parent;
            }

            localPostion.x = worldPostion.x - x;
            localPostion.y = worldPostion.y - y;
            RefreshArea();
        }
Exemplo n.º 9
0
 public void AddGUIWidget(EditorGUIWidget widget)
 {
     widget.GUISource = this;
     mAllWidgets.Add(widget);
 }
Exemplo n.º 10
0
 public void RemoveChild(EditorGUIWidget widget)
 {
     childList.Remove(widget);
 }
Exemplo n.º 11
0
        protected void SetParent(EditorGUIWidget widget)
        {
            if (parent == widget || this == widget)
                return;

            if (parent != null)
            {
                parent.RemoveChild(this);
            }

            if (widget != null)
            {
                widget.AddChild(this);
                parent = widget;
            }
            else
            {
                localPostion = worldPostion;
                return;
            }

            float x = 0, y = 0;
            var tempParent = parent;
            while (tempParent != null)
            {
                x += tempParent.localPostion.x;
                y += tempParent.localPostion.y;
                tempParent = tempParent.Parent;
            }

            localPostion.x = worldPostion.x - x;
            localPostion.y = worldPostion.y - y;
            RefreshArea();
        }
Exemplo n.º 12
0
 public void RemoveChild(EditorGUIWidget widget)
 {
     childList.Remove(widget);
 }
Exemplo n.º 13
0
 public void AddChild(EditorGUIWidget widget)
 {
     if (childList.Contains(widget) == false)
         childList.Add(widget);
 }
Exemplo n.º 14
0
 public void AddGUIWidget(EditorGUIWidget widget)
 {
     widget.GUISource = this;
     mAllWidgets.Add(widget);
 }
Exemplo n.º 15
0
 public void RemoveGUIWidget(EditorGUIWidget widget)
 {
     widget.GUISource = null;
     mAllWidgets.Remove(widget);
 }
Exemplo n.º 16
0
        private bool TryGetMouseStayWidget(Vector2 point, out EditorGUIWidget widget)
        {
            widget = null;

            for (int i = mAllWidgets.Count - 1; i >= 0; i--)
            {
                if (mAllWidgets[i].IsTrigger == false)
                    continue;

                if (mAllWidgets[i].AreaRect.Contains(point))
                {
                    widget = mAllWidgets[i];
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 17
0
 public void RemoveGUIWidget(EditorGUIWidget widget)
 {
     widget.GUISource = null;
     mAllWidgets.Remove(widget);
 }
Exemplo n.º 18
0
        public void OnGUI()
        {
            nowEvent = Event.current;

            if (mAllWidgets.Count == 0)
                return;

            TryGetMouseStayWidget(nowEvent.mousePosition, out pointEnter);

            if (nowEvent.type == EventType.Ignore)
            {
                pointPress = null;
                pointDrag = null;
            }

            if (nowEvent.isMouse)
            {
                if (nowEvent.type == EventType.MouseDown)
                {

                    //  只响应一个button,其余过滤.
                    if (pointPress != null)
                        return;

                    lastPointPress = null;
                    pointPress = pointEnter;

                    if (pointPress != null)
                        Notify(pointPress, EventGUIType.Press, true);
                }

                else if (nowEvent.type == EventType.MouseUp)
                {
                    if (pointPress != null)
                    {
                        if (pointPress == pointEnter && pointPress != pointDrag)
                        {
            #if GUI_WINDOW_LOG
                            Debug.Log("Click!");
            #endif
                            Notify(pointPress, EventGUIType.Click, true);
                        }
                        else
                        {
                            Notify(pointPress, EventGUIType.Press, false);
                        }
                        lastPointPress = pointPress;
                    }
                    pointPress = null;
                    pointDrag = null;
                }

                else if (nowEvent.type == EventType.MouseDrag)
                {
                    if (pointDrag == null)
                        pointDrag = pointPress;
            #if GUI_WINDOW_LOG
                    Debug.Log("drag1");
            #endif
                    if (pointDrag != null)
                    {
            #if GUI_WINDOW_LOG
                        Debug.Log("drag2");
            #endif
                        Notify(pointDrag, EventGUIType.Drag, null);
                    }
                }

            }

            #if GUI_WINDOW_LOG
            string debugInfo = string.Format("pointEnter {0} | pointPress {1} \n lastPointPress {2} | pointDrag {3}",
                pointEnter != null ? pointEnter.ToString() : string.Empty,
               pointPress != null ? pointPress.ToString() : string.Empty,
               lastPointPress != null ? lastPointPress.ToString() : string.Empty,
               pointDrag != null ? pointDrag.ToString() : string.Empty);

            GUILayout.Label(debugInfo);
            #endif
        }
Exemplo n.º 19
0
        public void OnGUI()
        {
            nowEvent = Event.current;

            if (mAllWidgets.Count == 0)
            {
                return;
            }

            TryGetMouseStayWidget(nowEvent.mousePosition, out pointEnter);

            if (nowEvent.type == EventType.Ignore)
            {
                pointPress = null;
                pointDrag  = null;
            }


            if (nowEvent.isMouse)
            {
                if (nowEvent.type == EventType.MouseDown)
                {
                    //  只响应一个button,其余过滤.
                    if (pointPress != null)
                    {
                        return;
                    }

                    lastPointPress = null;
                    pointPress     = pointEnter;

                    if (pointPress != null)
                    {
                        Notify(pointPress, EventGUIType.Press, true);
                    }
                }

                else if (nowEvent.type == EventType.MouseUp)
                {
                    if (pointPress != null)
                    {
                        if (pointPress == pointEnter && pointPress != pointDrag)
                        {
#if GUI_WINDOW_LOG
                            Debug.Log("Click!");
#endif
                            Notify(pointPress, EventGUIType.Click, true);
                        }
                        else
                        {
                            Notify(pointPress, EventGUIType.Press, false);
                        }
                        lastPointPress = pointPress;
                    }
                    pointPress = null;
                    pointDrag  = null;
                }

                else if (nowEvent.type == EventType.MouseDrag)
                {
                    if (pointDrag == null)
                    {
                        pointDrag = pointPress;
                    }
#if GUI_WINDOW_LOG
                    Debug.Log("drag1");
#endif
                    if (pointDrag != null)
                    {
#if GUI_WINDOW_LOG
                        Debug.Log("drag2");
#endif
                        Notify(pointDrag, EventGUIType.Drag, null);
                    }
                }
            }

#if GUI_WINDOW_LOG
            string debugInfo = string.Format("pointEnter {0} | pointPress {1} \n lastPointPress {2} | pointDrag {3}",
                                             pointEnter != null ? pointEnter.ToString() : string.Empty,
                                             pointPress != null ? pointPress.ToString() : string.Empty,
                                             lastPointPress != null ? lastPointPress.ToString() : string.Empty,
                                             pointDrag != null ? pointDrag.ToString() : string.Empty);

            GUILayout.Label(debugInfo);
#endif
        }