浏览代码

panel z coordinate calc...

leonsal 8 年之前
父节点
当前提交
d92e00a12e
共有 3 个文件被更改,包括 41 次插入26 次删除
  1. 3 0
      gui/folder.go
  2. 37 26
      gui/panel.go
  3. 1 0
      gui/scrollbar.go

+ 3 - 0
gui/folder.go

@@ -111,6 +111,9 @@ func (f *Folder) onMouse(evname string, ev interface{}) {
 		if !cont.Visible() {
 			cont.SetVisible(true)
 			log.Error("Folder PanelZ:%6.5f", cont.Position().Z)
+			for _, c := range cont.Children() {
+				log.Error("Folder child  PanelZ:%6.5f", c.GetNode().Position().Z)
+			}
 		} else {
 			cont.SetVisible(false)
 		}

+ 37 - 26
gui/panel.go

@@ -201,38 +201,49 @@ func (p *Panel) SetTopChild(ipan IPanel) {
 	}
 }
 
-// SetTopChild sets this panel to be on the foreground
+// SetForeground sets this panel to be on the foreground
 // in relation to all its siblings.
 func (p *Panel) SetForeground() {
 
-	// internal function to calculate the total minimum Z
-	// for a panel hierarchy
-	var getTopZ func(*Panel) float32
-	getTopZ = func(pan *Panel) float32 {
-		topZ := pan.Position().Z
-		for _, iobj := range pan.Children() {
-			child := iobj.(IPanel).GetPanel()
-			cz := pan.Position().Z + getTopZ(child)
-			if cz < topZ {
-				topZ = cz
-			}
-		}
-		return topZ
-	}
-
-	// Find the child of this panel with the minimum Z
+	log.Error("setForeground: %6.5f", p.Position().Z)
 	par := p.Parent().(IPanel).GetPanel()
-	topZ := float32(10)
-	for _, iobj := range par.Children() {
-		child := iobj.(IPanel).GetPanel()
-		cz := getTopZ(child)
-		if cz < topZ {
-			topZ = cz
-		}
+	for _, c := range par.Children() {
+		log.Error("setForeground child z: %6.5f", c.(IPanel).GetPanel().Position().Z)
+
 	}
-	if p.Position().Z > topZ {
-		p.SetPositionZ(topZ + deltaZ)
+	found := par.Remove(p)
+	if found {
+		par.Add(p)
 	}
+
+	//	// internal function to calculate the total minimum Z
+	//	// for a panel hierarchy
+	//	var getTopZ func(*Panel) float32
+	//	getTopZ = func(pan *Panel) float32 {
+	//		topZ := pan.Position().Z
+	//		for _, iobj := range pan.Children() {
+	//			child := iobj.(IPanel).GetPanel()
+	//			cz := pan.Position().Z + getTopZ(child)
+	//			if cz < topZ {
+	//				topZ = cz
+	//			}
+	//		}
+	//		return topZ
+	//	}
+	//
+	//	// Find the child of this panel with the minimum Z
+	//	par := p.Parent().(IPanel).GetPanel()
+	//	topZ := float32(10)
+	//	for _, iobj := range par.Children() {
+	//		child := iobj.(IPanel).GetPanel()
+	//		cz := getTopZ(child)
+	//		if cz < topZ {
+	//			topZ = cz
+	//		}
+	//	}
+	//	if p.Position().Z > topZ {
+	//		p.SetPositionZ(topZ + deltaZ)
+	//	}
 }
 
 // SetPosition sets this panel absolute position in pixel coordinates

+ 1 - 0
gui/scrollbar.go

@@ -167,6 +167,7 @@ func (sb *ScrollBar) update() {
 // onMouse receives subscribed mouse events for the scroll bar button
 func (button *scrollBarButton) onMouse(evname string, ev interface{}) {
 
+	log.Error("scrollbutton Z:%6.5f", button.Position().Z)
 	e := ev.(*window.MouseEvent)
 	if e.Button != window.MouseButtonLeft {
 		return