public void CalculateRect(ref Stack positionStack, ref Vector2 maxCoords) { Vector2 p = (Vector2)positionStack.Peek() + m_position; positionStack.Push(p); int i; for (i = 0; i < m_groups.Count; i++) { TPTabletUIGroup grp = m_groups[i] as TPTabletUIGroup; grp.CalculateRect(ref positionStack, ref maxCoords); } positionStack.Pop(); for (i = 0; i < m_buttons.Count; i++) { TPTabletUIButton btn = m_buttons[i] as TPTabletUIButton; btn.CalculateRect(p, ref maxCoords); } m_boundRect = Rect.MinMaxRect(p.x, p.y, maxCoords.x, maxCoords.y); }
/** Updates the bounding rectangles of all the groups and buttons. */ private void CalculateRect() { Stack positionStack = new Stack(); positionStack.Push(new Vector2(0.0f, 0.0f)); int i; for (i = 0; i < m_rootGroups.Count; i++) { TPTabletUIGroup grp = m_rootGroups[i] as TPTabletUIGroup; Vector2 maxCoords = new Vector2(0.0f, 0.0f); grp.CalculateRect(ref positionStack, ref maxCoords); if (maxCoords.x > m_size.x) { m_size.x = maxCoords.x; } if (maxCoords.y > m_size.y) { m_size.y = maxCoords.y; } } }