-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.go
More file actions
51 lines (38 loc) · 1.08 KB
/
layout.go
File metadata and controls
51 lines (38 loc) · 1.08 KB
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
42
43
44
45
46
47
48
49
50
51
package orvyn
// Layout interface based on Renderable interface.
type Layout interface {
// Renderable composing the Layout interface.
Renderable
// GetElements returns a slice of every active Renderable of the layout.
GetElements() []Renderable
}
// BaseLayout type is used to simplify the creation of custom layouts.
type BaseLayout struct {
BaseRenderable
elements []Renderable
}
// NewBaseLayout creates and returns a new BaseLayout.
func NewBaseLayout(elements ...Renderable) BaseLayout {
b := BaseLayout{}
b.BaseRenderable = NewBaseRenderable()
b.elements = elements
return b
}
// GetElements returns a slice of activated []Renderable.
func (b *BaseLayout) GetElements() []Renderable {
var visibleElements []Renderable
for _, e := range b.elements {
if !e.IsActive() {
continue
}
visibleElements = append(visibleElements, e)
}
return visibleElements
}
// SetActive change the active state of all elements of the layout and the layout itself.
func (b *BaseLayout) SetActive(active bool) {
for _, e := range b.elements {
e.SetActive(active)
}
b.active = active
}