Просмотр исходного кода

Merge branch 'master' into chart

leonsal 8 лет назад
Родитель
Сommit
3ef7621265
5 измененных файлов с 24 добавлено и 15 удалено
  1. 3 4
      gui/button.go
  2. 2 0
      gui/checkradio.go
  3. 2 1
      gui/list.go
  4. 9 10
      gui/panel.go
  5. 8 0
      gui/tree.go

+ 3 - 4
gui/button.go

@@ -65,6 +65,7 @@ func NewButton(text string) *Button {
 	b.Panel.Subscribe(OnKeyUp, b.onKey)
 	b.Panel.Subscribe(OnMouseUp, b.onMouse)
 	b.Panel.Subscribe(OnMouseDown, b.onMouse)
+	b.Panel.Subscribe(OnCursor, b.onCursor)
 	b.Panel.Subscribe(OnCursorEnter, b.onCursor)
 	b.Panel.Subscribe(OnCursorLeave, b.onCursor)
 	b.Panel.Subscribe(OnEnable, func(name string, ev interface{}) { b.update() })
@@ -131,14 +132,12 @@ func (b *Button) onCursor(evname string, ev interface{}) {
 	case OnCursorEnter:
 		b.mouseOver = true
 		b.update()
-		b.root.StopPropagation(Stop3D)
 	case OnCursorLeave:
 		b.pressed = false
 		b.mouseOver = false
 		b.update()
-	default:
-		return
 	}
+	b.root.StopPropagation(StopAll)
 }
 
 // onMouseEvent process subscribed mouse events
@@ -156,7 +155,7 @@ func (b *Button) onMouse(evname string, ev interface{}) {
 	default:
 		return
 	}
-	b.root.StopPropagation(Stop3D)
+	b.root.StopPropagation(StopAll)
 }
 
 // onKey processes subscribed key events

+ 2 - 0
gui/checkradio.go

@@ -185,6 +185,7 @@ func (cb *CheckRadio) onMouse(evname string, ev interface{}) {
 			cb.Dispatch(OnClick, nil)
 		}
 	}
+	cb.root.StopPropagation(StopAll)
 }
 
 // onCursor process OnCursor* events
@@ -196,6 +197,7 @@ func (cb *CheckRadio) onCursor(evname string, ev interface{}) {
 		cb.cursorOver = false
 	}
 	cb.update()
+	cb.root.StopPropagation(StopAll)
 }
 
 // onKey receives subscribed key events

+ 2 - 1
gui/list.go

@@ -364,6 +364,7 @@ func (li *List) highlighted() (pos int) {
 func (li *List) onMouseEvent(evname string, ev interface{}) {
 
 	li.root.SetKeyFocus(li)
+	li.root.StopPropagation(StopAll)
 }
 
 // onKeyEvent receives subscribed key events for the list
@@ -478,7 +479,7 @@ func (litem *ListItem) onMouse(evname string, ev interface{}) {
 	}
 }
 
-// onCursor receives cursor enter events over the list item
+// onCursor receives subscribed cursor events over the list item
 func (litem *ListItem) onCursor(evname string, ev interface{}) {
 
 	if litem.list.dropdown {

+ 9 - 10
gui/panel.go

@@ -11,6 +11,7 @@ import (
 	"github.com/g3n/engine/graphic"
 	"github.com/g3n/engine/material"
 	"github.com/g3n/engine/math32"
+	"math"
 )
 
 /*********************************************
@@ -563,24 +564,22 @@ func (p *Panel) updateBounds(par *Panel) {
 
 	if par == nil {
 		p.pospix = p.Position()
-		p.xmin = p.pospix.X
-		p.ymin = p.pospix.Y
-		p.xmax = p.pospix.X + p.width
-		p.ymax = p.pospix.Y + p.height
+		p.xmin = -math.MaxFloat32
+		p.ymin = -math.MaxFloat32
+		p.xmax = math.MaxFloat32
+		p.ymax = math.MaxFloat32
 		p.boundsUni.Set(0, 0, 1, 1)
 		return
 	}
 	// If this panel is bounded to its parent, its coordinates are relative
 	// to the parent internal content rectangle.
 	if p.bounded {
-		p.pospix.X = p.Position().X + par.pospix.X + float32(par.marginSizes.Left+par.borderSizes.Left+par.paddingSizes.Left)
-		p.pospix.Y = p.Position().Y + par.pospix.Y + float32(par.marginSizes.Top+par.borderSizes.Top+par.paddingSizes.Top)
-		p.pospix.Z = p.Position().Z + par.pospix.Z
+		p.pospix.X = p.Position().X + par.pospix.X + par.marginSizes.Left + par.borderSizes.Left + par.paddingSizes.Left
+		p.pospix.Y = p.Position().Y + par.pospix.Y + par.marginSizes.Top + par.borderSizes.Top + par.paddingSizes.Top
 		// Otherwise its coordinates are relative to the parent outer coordinates.
 	} else {
 		p.pospix.X = p.Position().X + par.pospix.X
 		p.pospix.Y = p.Position().Y + par.pospix.Y
-		p.pospix.Z = p.Position().Z + par.pospix.Z
 	}
 	// Maximum x,y coordinates for this panel
 	p.xmin = p.pospix.X
@@ -589,8 +588,8 @@ func (p *Panel) updateBounds(par *Panel) {
 	p.ymax = p.pospix.Y + p.height
 	if p.bounded {
 		// Get the parent minimum X and Y absolute coordinates in pixels
-		pxmin := par.xmin + par.marginSizes.Right + par.borderSizes.Right + par.paddingSizes.Right
-		pymin := par.ymin + par.marginSizes.Bottom + par.borderSizes.Bottom + par.paddingSizes.Bottom
+		pxmin := par.xmin + par.marginSizes.Left + par.borderSizes.Left + par.paddingSizes.Left
+		pymin := par.ymin + par.marginSizes.Top + par.borderSizes.Top + par.paddingSizes.Top
 		// Get the parent maximum X and Y absolute coordinates in pixels
 		pxmax := par.xmax - (par.marginSizes.Right + par.borderSizes.Right + par.paddingSizes.Right)
 		pymax := par.ymax - (par.marginSizes.Bottom + par.borderSizes.Bottom + par.paddingSizes.Bottom)

+ 8 - 0
gui/tree.go

@@ -60,6 +60,7 @@ func (t *Tree) Initialize(width, height float32) {
 	t.SetStyles(&StyleDefault.Tree)
 	t.List.Subscribe(OnKeyDown, t.onKey)
 	t.List.Subscribe(OnKeyUp, t.onKey)
+	t.List.Subscribe(OnCursor, t.onCursor)
 }
 
 // SetStyles set the tree styles overriding the default style
@@ -174,6 +175,13 @@ func (t *Tree) FindChild(child IPanel) (*TreeNode, int) {
 	return nil, -1
 }
 
+// onCursor receives subscribed cursor events over the tree
+func (t *Tree) onCursor(evname string, ev interface{}) {
+
+	// Do not propagate any cursor events
+	t.root.StopPropagation(StopAll)
+}
+
 // onKey receives key down events for the embedded list
 func (t *Tree) onKey(evname string, ev interface{}) {