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; }
protected override bool TriggerAnchorArea(Vector2 position, int depth, SubWindow window, System.Action <SubWindow> preDropAction, System.Action postDropAction) { if (m_TweenParam.isTweening) { return(false); } if (depth >= kMaxNodeDepth) { return(false); } if (m_SubWindows.Count >= kMaxSubWindowCount) { return(false); } if (this.m_SubWindows.Contains(window)) { return(false); } Rect rect = new Rect(this.rect.x, this.rect.y, this.rect.width, 17); if (rect.Contains(position)) { if (preDropAction == null) { tweenParam = GUIEx.ScaleTweenBox(rect, tweenParam, string.Empty, GUIStyleCache.GetStyle("SelectionRect")); } else { if (preDropAction != null) { preDropAction(window); this.AddWindow(window, 0); postDropAction(); } } return(true); } return(false); }
/// <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); }