/// <summary> /// /// </summary> /// <param name="gameTime"></param> /// <param name="sb"></param> static internal void DrawNonRecursive(Frame rootFrame, GameTime gameTime, SpriteLayer spriteLayer) { if (rootFrame == null) { return; } var stack = new Stack <DrawFrameItem>(); var list = new List <DrawFrameItem>(); stack.Push(new DrawFrameItem(rootFrame, Color.White, rootFrame.GlobalRectangle, rootFrame.GetBorderedRectangle(), rootFrame.Text)); while (stack.Any()) { var currentDrawFrame = stack.Pop(); if (!currentDrawFrame.Frame.IsDrawable) { continue; } list.Add(currentDrawFrame); foreach (var child in currentDrawFrame.Frame.Children.Reverse()) { var color = currentDrawFrame.Color * child.OverallColor; var inner = Clip(child.GetBorderedRectangle(), currentDrawFrame.InnerClip); var outer = Clip(child.GlobalRectangle, currentDrawFrame.InnerClip); if (MathUtil.IsRectInsideRect(child.GlobalRectangle, currentDrawFrame.InnerClip)) { stack.Push(new DrawFrameItem(child, color, outer, inner, currentDrawFrame.Text + "-" + child.Text)); } } } for (int i = 0; i < list.Count; i++) { var drawFrame = list[i]; spriteLayer.SetClipRectangle(i * 2 + 0, drawFrame.OuterClip, drawFrame.Color); spriteLayer.SetClipRectangle(i * 2 + 1, drawFrame.InnerClip, drawFrame.Color); drawFrame.Frame.DrawFrameBorders(spriteLayer, i * 2 + 0); drawFrame.Frame.DrawFrame(gameTime, spriteLayer, i * 2 + 1); } }