Beispiel #1
0
func insertIndex(holder gxui.PanelHolder, at math.Point) int {
	count := holder.PanelCount()
	bestIndex := count
	bestScore := float32(1e20)
	score := func(point math.Point, index int) {
		score := point.Sub(at).Len()
		if score < bestScore {
			bestIndex = index
			bestScore = score
		}
	}
	for i := 0; i < holder.PanelCount(); i++ {
		tab := holder.Tab(i)
		size := tab.Size()
		ml := math.Point{Y: size.H / 2}
		mr := math.Point{Y: size.H / 2, X: size.W}
		score(gxui.TransformCoordinate(ml, tab, holder), i)
		score(gxui.TransformCoordinate(mr, tab, holder), i+1)
	}
	return bestIndex
}
Beispiel #2
0
func (l *DropDownList) ShowList() bool {
	if l.listShowing || l.overlay == nil {
		return false
	}
	l.listShowing = true
	s := l.Size()
	at := math.Point{X: s.W / 2, Y: s.H}
	l.overlay.Show(l.list, gxui.TransformCoordinate(at, l.outer, l.overlay))
	gxui.SetFocus(l.list)
	if l.onShowList != nil {
		l.onShowList.Fire()
	}
	return true
}