Explorar el Código

Fixed z coordinate calculation for unbounded panels

leonsal hace 8 años
padre
commit
bbb7a2db3d
Se han modificado 3 ficheros con 21 adiciones y 6 borrados
  1. 3 0
      gui/dropdown.go
  2. 3 0
      gui/folder.go
  3. 15 6
      gui/panel.go

+ 3 - 0
gui/dropdown.go

@@ -40,6 +40,8 @@ type DropDownStyles struct {
 	Disabled *DropDownStyle
 }
 
+const dropDownZ = -0.5
+
 // NewDropDown creates and returns a pointer to a new drop down widget with the specified width.
 func NewDropDown(width float32, item *ImageLabel) *DropDown {
 
@@ -65,6 +67,7 @@ func NewDropDown(width float32, item *ImageLabel) *DropDown {
 	/// Create list
 	dd.list = NewVList(0, 0)
 	dd.list.bounded = false
+	dd.list.SetPositionZ(dropDownZ)
 	dd.list.dropdown = true
 	dd.list.SetVisible(false)
 

+ 3 - 0
gui/folder.go

@@ -35,6 +35,8 @@ type FolderStyles struct {
 	Disabled *FolderStyle
 }
 
+const folderZ = -0.6
+
 // NewFolder creates and returns a pointer to a new folder widget
 // with the specified text and initial width
 func NewFolder(text string, width float32, contentPanel IPanel) *Folder {
@@ -64,6 +66,7 @@ func (f *Folder) Initialize(text string, width float32, contentPanel IPanel) {
 	f.contentPanel = contentPanel
 	contentPanel.GetPanel().bounded = false
 	contentPanel.GetPanel().SetVisible(false)
+	contentPanel.GetPanel().SetPositionZ(folderZ)
 	f.Panel.Add(f.contentPanel)
 
 	// Set event callbacks

+ 15 - 6
gui/panel.go

@@ -543,17 +543,26 @@ func (p *Panel) UpdateMatrixWorld() {
 	}
 }
 
-// setZ calculates the Z coordinate for each panel recursively
-// starting at the specified receiver with the specified Z coordinate.
+// 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 {
 
-	p.SetPositionZ(nextZ)
-	nextZ += deltaZ
+	z := nextZ
+	if !p.bounded {
+		z = p.Position().Z
+	}
+	p.SetPositionZ(z)
+	z += deltaZ
 	for _, ichild := range p.Children() {
-		nextZ = ichild.(IPanel).GetPanel().setZ(nextZ)
+		z = ichild.(IPanel).GetPanel().setZ(z)
+	}
+	if !p.bounded {
+		return z - p.Position().Z
 	}
-	return nextZ
+	return z
 }
 
 // ContainsPosition returns indication if this panel contains