forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paint_children.go
41 lines (34 loc) · 883 Bytes
/
paint_children.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package parts
import (
"github.com/google/gxui"
"github.com/google/gxui/mixins/outer"
)
type PaintChildrenOuter interface {
gxui.Container
outer.PaintChilder
outer.Sized
}
type PaintChildren struct {
outer PaintChildrenOuter
}
func (p *PaintChildren) Init(outer PaintChildrenOuter) {
p.outer = outer
}
func (p *PaintChildren) Paint(c gxui.Canvas) {
for i, v := range p.outer.Children() {
if v.Control.IsVisible() {
c.Push()
c.AddClip(v.Control.Size().Rect().Offset(v.Offset))
p.outer.PaintChild(c, v, i)
c.Pop()
}
}
}
func (p *PaintChildren) PaintChild(c gxui.Canvas, child *gxui.Child, idx int) {
if canvas := child.Control.Draw(); canvas != nil {
c.DrawCanvas(canvas, child.Offset)
}
}