Example #1
0
    private static GUITweenParam ScaleTweenInternal(ref Rect rect, GUITweenParam param)
    {
        if (!param.CheckRect(rect))
        {
            param.tweenTime = 0;
        }

        param.tweenTime += 0.03f;
        //float scaleTweenTime = ((float)(EditorApplication.timeSinceStartup - param.tweenTime) / 0.1f);
        if (param.tweenTime > 1)
        {
            param.tweenTime  = 1;
            param.isTweening = false;
        }
        else
        {
            param.isTweening = true;
        }

        float x = Mathf.Lerp(rect.x + rect.width / 2, rect.x, param.tweenTime);
        float y = Mathf.Lerp(rect.y + rect.height / 2, rect.y, param.tweenTime);
        float w = Mathf.Lerp(0, rect.width, param.tweenTime);
        float h = Mathf.Lerp(0, rect.height, param.tweenTime);

        rect = new Rect(x, y, w, h);
        return(param);
    }
        public override void DrawGUI(Rect rect, System.Action repaintAction)
        {
            rect = new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height - 2);


            if (m_TweenParam.isTweening)
            {
                m_TweenParam = GUIEx.ScaleTweenBox(rect, m_TweenParam, m_SubWindows[m_SelectSubWindow].Title,
                                                   GUIStyleCache.GetStyle("dragtabdropwindow"));
                if (repaintAction != null)
                {
                    repaintAction();
                }
                return;
            }

            GUI.BeginGroup(rect, GUIStyleCache.GetStyle("PreBackground"));
            GUI.Box(new Rect(0, 0, rect.width, 18), string.Empty, GUIStyleCache.GetStyle("dockarea"));

            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                GUI.Label(new Rect(m_SelectSubWindow * 110, 0, rect.width - m_SelectSubWindow * 110, 18),
                          m_SubWindows[m_SelectSubWindow].Title, GUIStyleCache.GetStyle("dragtabdropwindow"));
            }
            for (int i = 0; i < m_SubWindows.Count; i++)
            {
                if (m_SelectSubWindow != i)
                {
                    if (GUI.Button(new Rect(i * 110, 0, 110, 17), m_SubWindows[i].Title, GUIStyleCache.GetStyle("dragtab")))
                    {
                        m_SelectSubWindow = i;
                    }
                }
            }
            GUI.Box(new Rect(0, 18, rect.width, rect.height - 18), string.Empty, GUIStyleCache.GetStyle("hostview"));
            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                GUI.BeginGroup(new Rect(0, 18, rect.width, rect.height - 18));
                m_SubWindows[m_SelectSubWindow].DrawSubWindow(new Rect(0, 0, rect.width, rect.height - 18));
                GUI.EndGroup();
                if (repaintAction != null)
                {
                    repaintAction();
                }
            }

            if (m_SelectSubWindow >= 0 && m_SelectSubWindow < m_SubWindows.Count)
            {
                m_SubWindows[m_SelectSubWindow].DrawToolBarExt(new Rect(rect.width - 100, 0, 100, 18));
            }

            GUI.EndGroup();
            this.rect = rect;
        }
Example #3
0
 public static GUITweenParam ScaleTweenBox(Rect rect, GUITweenParam param, GUIContent content, GUIStyle style = null)
 {
     param = ScaleTweenInternal(ref rect, param);
     if (style != null)
     {
         GUI.Box(rect, content, style);
     }
     else
     {
         GUI.Box(rect, content);
     }
     return(param);
 }
 public SubWindowLeaf(SubWindow window, bool isHorizontal, int depth) : base(isHorizontal, depth)
 {
     if (window != null)
     {
         window.Open();
         m_SubWindows.Add(window);
     }
     if (window == null)
     {
         m_TweenParam           = new GUITweenParam(false);
         m_TweenParam.tweenTime = 1;
     }
     else
     {
         m_TweenParam = new GUITweenParam(true);
     }
 }
        /// <summary>
        /// 触发锚点区域
        /// </summary>
        /// <param name="position"></param>
        /// <param name="depth"></param>
        /// <param name="window"></param>
        /// <param name="preDropAction"></param>
        /// <param name="postDropAction"></param>
        /// <returns></returns>
        protected virtual bool TriggerAnchorArea(Vector2 position, int depth, SubWindow window,
                                                 System.Action <SubWindow> preDropAction, System.Action postDropAction)
        {
            if (depth >= kMaxNodeDepth)
            {
                return(false);
            }
            Rect  r      = default(Rect);
            float offset = 0;

            for (int i = 0; i < m_Childs.Count; i++)
            {
                if (m_Childs[i].TriggerAnchorArea(position, depth + 1, window, preDropAction, postDropAction))
                {
                    return(true);
                }
                if (isHorizontal)
                {
                    r = new Rect(rect.x + offset, rect.y, rect.width * m_Childs[i].weight * 0.2f, rect.height);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + offset + rect.width * m_Childs[i].weight * 0.8f, rect.y,
                                 rect.width * m_Childs[i].weight * 0.2f, rect.height);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i + 1);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + offset, rect.y + rect.height * 0.8f, rect.width * m_Childs[i].weight,
                                 rect.height * 0.2f);
                    if (r.Contains(position) && m_Childs.Count > 1)
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, false, i);
                        }
                        return(true);
                    }
                    offset += m_Childs[i].weight * rect.width;
                }
                else
                {
                    r = new Rect(rect.x, rect.y + offset, rect.width, rect.height * m_Childs[i].weight * 0.2f);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x, rect.y + offset + rect.height * m_Childs[i].weight * 0.8f, rect.width,
                                 rect.height * m_Childs[i].weight * 0.2f);
                    if (r.Contains(position))
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, true, i + 1);
                        }
                        return(true);
                    }
                    r = new Rect(rect.x + rect.width * 0.8f, rect.y + offset, rect.width * 0.2f,
                                 rect.height * m_Childs[i].weight);
                    if (r.Contains(position) && m_Childs.Count > 1)
                    {
                        if (preDropAction == null)
                        {
                            tweenParam = GUIEx.ScaleTweenBox(r, tweenParam, string.Empty,
                                                             GUIStyleCache.GetStyle("SelectionRect"));
                        }
                        else
                        {
                            this.DropWindow(window, preDropAction, postDropAction, false, i);
                        }
                        return(true);
                    }
                    offset += m_Childs[i].weight * rect.height;
                }
            }
            return(false);
        }