-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraint_base.go
64 lines (51 loc) · 1.69 KB
/
constraint_base.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package zgui
import "fmt"
type baseConstraint struct {
parentConstraints IConstraints
}
// NewBaseConstraint creates the base of all constraints and already implements
// the most basic functions. By the way, a baseConstraint by itself does
// absolutely nothing.
func NewBaseConstraint() *baseConstraint {
return &baseConstraint{}
}
// setParent sets parent constraints. Parent constraints are
// called <self> object and object parent is <parent>
func (c *baseConstraint) setParent(parent IConstraints) {
c.parentConstraints = parent
}
// self returns the constraints object which the constraint belongs to.
func (c baseConstraint) self() IConstraints {
return c.parentConstraints
}
// parent returns the constraints object of the parent of the object which the
// constraint belongs to.
func (c baseConstraint) parent() IConstraints {
return c.self().getParent()
}
// GetX returns always 0. It is gonna be overriden by inheritance.
func (c baseConstraint) GetX() float32 {
return 0
}
// GetY returns always 0. It is gonna be overriden by inheritance.
func (c baseConstraint) GetY() float32 {
return 0
}
// GetWidth returns always 0. It is gonna be overriden by inheritance.
func (c baseConstraint) GetWidth() float32 {
return 0
}
// GetHeight returns always 0. It is gonna be overriden by inheritance.
func (c baseConstraint) GetHeight() float32 {
return 0
}
func (c *baseConstraint) move(d float32) {
return
}
func (c *baseConstraint) SetRelativeValue(val float32) {
fmt.Println("zgui: constraint doesn't implement SetRelativeValue")
}
// String returns a string representation of the constraint.
func (c baseConstraint) String() string {
return fmt.Sprintf("baseConstraint{%v}", c.parentConstraints)
}