|
@@ -84,7 +84,8 @@ type Panel struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
- deltaZ = -0.00001
|
|
|
|
|
|
|
+ deltaZ = -0.00001 // delta Z for bounded panels
|
|
|
|
|
+ deltaZunb = deltaZ * 1000 // delta Z for unbounded panels
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
// NewPanel creates and returns a pointer to a new panel with the
|
|
// NewPanel creates and returns a pointer to a new panel with the
|
|
@@ -485,7 +486,10 @@ func (p *Panel) Add(ichild IPanel) *Panel {
|
|
|
p.Node.Add(ichild)
|
|
p.Node.Add(ichild)
|
|
|
node := ichild.GetPanel()
|
|
node := ichild.GetPanel()
|
|
|
node.SetParent(p)
|
|
node.SetParent(p)
|
|
|
- ichild.SetRoot(p.root)
|
|
|
|
|
|
|
+ if p.root != nil {
|
|
|
|
|
+ ichild.SetRoot(p.root)
|
|
|
|
|
+ p.root.setChildrenZ()
|
|
|
|
|
+ }
|
|
|
if p.layout != nil {
|
|
if p.layout != nil {
|
|
|
p.layout.Recalc(p)
|
|
p.layout.Recalc(p)
|
|
|
}
|
|
}
|
|
@@ -526,7 +530,6 @@ func (p *Panel) UpdateMatrixWorld() {
|
|
|
par := p.Parent()
|
|
par := p.Parent()
|
|
|
if par == nil {
|
|
if par == nil {
|
|
|
p.updateBounds(nil)
|
|
p.updateBounds(nil)
|
|
|
- p.setZ(0)
|
|
|
|
|
// Panel has parent
|
|
// Panel has parent
|
|
|
} else {
|
|
} else {
|
|
|
parpan := par.(*Panel)
|
|
parpan := par.(*Panel)
|
|
@@ -538,28 +541,6 @@ func (p *Panel) UpdateMatrixWorld() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// setZ sets the Z coordinate for this panel and its children recursively
|
|
|
|
|
-// starting at the specified nextZ coordinate.
|
|
|
|
|
-// The Z coordinate is set so panels added later are closed to the screen
|
|
|
|
|
-// For unbounded panels it is used the unbounded panel coordinate to
|
|
|
|
|
-// set the Z coordinate of its children.
|
|
|
|
|
-func (p *Panel) setZ(nextZ float32) float32 {
|
|
|
|
|
-
|
|
|
|
|
- z := nextZ
|
|
|
|
|
- if !p.bounded {
|
|
|
|
|
- z = p.Position().Z
|
|
|
|
|
- }
|
|
|
|
|
- p.SetPositionZ(z)
|
|
|
|
|
- z += deltaZ
|
|
|
|
|
- for _, ichild := range p.Children() {
|
|
|
|
|
- z = ichild.(IPanel).GetPanel().setZ(z)
|
|
|
|
|
- }
|
|
|
|
|
- if !p.bounded {
|
|
|
|
|
- return nextZ
|
|
|
|
|
- }
|
|
|
|
|
- return z
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// ContainsPosition returns indication if this panel contains
|
|
// ContainsPosition returns indication if this panel contains
|
|
|
// the specified screen position in pixels.
|
|
// the specified screen position in pixels.
|
|
|
func (p *Panel) ContainsPosition(x, y float32) bool {
|
|
func (p *Panel) ContainsPosition(x, y float32) bool {
|
|
@@ -631,6 +612,33 @@ func (p *Panel) Pix2NDC(px, py float32) (nx, ny float32) {
|
|
|
return px / w, -py / h
|
|
return px / w, -py / h
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// setZ sets the Z coordinate for this panel and its children recursively
|
|
|
|
|
+// starting at the specified z and zunb coordinates.
|
|
|
|
|
+// The z coordinate is used for bound panels and zunb for unbounded panels.
|
|
|
|
|
+// The z coordinate is set so panels added later are closer to the screen.
|
|
|
|
|
+// All unbounded panels and its children are closer than any of the bounded panels.
|
|
|
|
|
+func (p *Panel) setZ(z, zunb float32) (float32, float32) {
|
|
|
|
|
+
|
|
|
|
|
+ // Bounded panel
|
|
|
|
|
+ if p.bounded {
|
|
|
|
|
+ p.SetPositionZ(z)
|
|
|
|
|
+ z += deltaZ
|
|
|
|
|
+ for _, ichild := range p.Children() {
|
|
|
|
|
+ z, zunb = ichild.(IPanel).GetPanel().setZ(z, zunb)
|
|
|
|
|
+ }
|
|
|
|
|
+ return z, zunb
|
|
|
|
|
+ // Unbounded panel
|
|
|
|
|
+ } else {
|
|
|
|
|
+ p.SetPositionZ(zunb)
|
|
|
|
|
+ zchild := zunb + deltaZ
|
|
|
|
|
+ zunb += deltaZunb
|
|
|
|
|
+ for _, ichild := range p.Children() {
|
|
|
|
|
+ _, zunb = ichild.(IPanel).GetPanel().setZ(zchild, zunb)
|
|
|
|
|
+ }
|
|
|
|
|
+ return z, zunb
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// updateBounds is called by UpdateMatrixWorld() and calculates this panel
|
|
// updateBounds is called by UpdateMatrixWorld() and calculates this panel
|
|
|
// bounds considering the bounds of its parent
|
|
// bounds considering the bounds of its parent
|
|
|
func (p *Panel) updateBounds(par *Panel) {
|
|
func (p *Panel) updateBounds(par *Panel) {
|