示例#1
0
文件: backendmenu.go 项目: sqp/godock
// nextOrder calculates an order position for a new icon, based on the mouse
// position on current icon, and the order of the current icon and the next one.
//
func nextOrder(icon gldi.Icon, dock *gldi.CairoDock) float64 {
	if icon == nil {
		return gldi.IconLastOrder
	}

	if float64(dock.Container().MouseX()) < icon.DrawX()+icon.Width()*icon.Scale()/2 { // on the left.
		prev := dock.GetPreviousIcon(icon)
		if prev == nil {
			return icon.Order() - 1
		}
		return (icon.Order() + prev.Order()) / 2
	}

	next := dock.GetNextIcon(icon) // on the right.
	if next == nil {
		return icon.Order() + 1
	}
	return (icon.Order() + next.Order()) / 2
}