diff --git a/ui/debug.go b/ui/debug.go index bdd7da9..ad28060 100644 --- a/ui/debug.go +++ b/ui/debug.go @@ -77,8 +77,9 @@ func NewDebugOverlay(root Control) *debugOverlay { func (o *debugOverlay) renderControl(ctx Context, control Control) { renderer := ctx.Renderer() - // bounds := control.Bounds() - // renderer.Rectangle(bounds, o.boundsColor, 1) + + currentColor := zntg.MustHexColor("#FF0000") + parentColor := zntg.MustHexColor("#0000FF") var maxY float32 var renderHoverNode func(pos geom.PointF32, node *controlNode) @@ -96,6 +97,10 @@ func (o *debugOverlay) renderControl(ctx Context, control Control) { renderer.FillRectangle(pos.RectRel2D(nameTextureWidth, nameTextureHeight), color.Black) renderer.DrawTexturePoint(nameTexture, pos) childPos := pos.Add2D(nameTextureWidth+ctx.Style().Dimensions.Margin, 0) + if len(node.Children) == 0 { + renderer.Rectangle(node.Parent.Bounds, parentColor, 1) + renderer.Rectangle(node.Bounds, currentColor, 1) + } for _, child := range node.Children { if childPos.Y == maxY { childPos.Y = maxY + nameTextureHeight @@ -114,15 +119,18 @@ func (o *debugOverlay) renderControl(ctx Context, control Control) { } func createHoverNodes(hover geom.PointF32, control Control) *controlNode { - if !hover.In(control.Bounds()) { + bounds := control.Bounds() + if !hover.In(bounds) { return nil } - node := &controlNode{Name: controlName(control)} + node := &controlNode{Name: controlName(control), Bounds: bounds} for _, child := range controlChildren(control) { childNode := createHoverNodes(hover, child) - if childNode != nil { - node.Children = append(node.Children, childNode) + if childNode == nil { + continue } + childNode.Parent = node + node.Children = append(node.Children, childNode) } return node } @@ -147,5 +155,7 @@ func (o *debugOverlay) Shown() {} type controlNode struct { Name string + Bounds geom.RectangleF32 + Parent *controlNode Children []*controlNode }