当前位置: 首页>>代码示例>>Golang>>正文


Golang Rect.Size方法代码示例

本文整理汇总了Golang中github.com/skelterjohn/geom.Rect.Size方法的典型用法代码示例。如果您正苦于以下问题:Golang Rect.Size方法的具体用法?Golang Rect.Size怎么用?Golang Rect.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/skelterjohn/geom.Rect的用法示例。


在下文中一共展示了Rect.Size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: regrid

func (g *Grid) regrid() {

	g.reflex()

	_, minXs, maxXs := g.hflex.constrain(g.Size.X)
	_, minYs, maxYs := g.vflex.constrain(g.Size.Y)

	for child, csh := range g.ChildrenHints {
		bd := g.childrenBlockData[child]
		gridBounds := geom.Rect{
			Min: geom.Coord{
				X: minXs[bd.GridX],
				Y: minYs[bd.GridY],
			},
			Max: geom.Coord{
				X: maxXs[bd.GridX+bd.ExtraX],
				Y: maxYs[bd.GridY+bd.ExtraY],
			},
		}

		gridSizeX, gridSizeY := gridBounds.Size()
		if gridSizeX > csh.MaxSize.X {
			diff := gridSizeX - csh.MaxSize.X
			if bd.AnchorX&AnchorMin != 0 && bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			} else if bd.AnchorX&AnchorMin != 0 {
				gridBounds.Max.X -= diff
			} else if bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.MaxSize.Y {
			diff := gridSizeY - csh.MaxSize.Y
			if bd.AnchorY&AnchorMin == 0 && bd.AnchorY&AnchorMax == 0 {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			} else if bd.AnchorY&AnchorMin != 0 {
				gridBounds.Max.Y -= diff
			} else if bd.AnchorY&AnchorMax != 0 {
				gridBounds.Min.Y += diff
			}
		}

		gridSizeX, gridSizeY = gridBounds.Size()
		if gridSizeX > csh.PreferredSize.X {
			diff := gridSizeX - csh.PreferredSize.X
			if bd.AnchorX&AnchorMin != 0 && bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			} else if bd.AnchorX&AnchorMin != 0 {
				gridBounds.Max.X -= diff
			} else if bd.AnchorX&AnchorMax != 0 {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.PreferredSize.Y {
			diff := gridSizeY - csh.PreferredSize.Y
			if bd.AnchorY&AnchorMin == 0 && bd.AnchorY&AnchorMax == 0 {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			} else if bd.AnchorY&AnchorMin != 0 {
				gridBounds.Max.Y -= diff
			} else if bd.AnchorY&AnchorMax != 0 {
				gridBounds.Min.Y += diff
			}
		}

		g.ChildrenBounds[child] = gridBounds

		gridSizeX, gridSizeY = gridBounds.Size()
		child.UserEventsIn <- uik.ResizeEvent{
			Size: geom.Coord{gridSizeX, gridSizeY},
		}
	}

	g.Invalidate()
}
开发者ID:KarateCode,项目名称:go.uik,代码行数:78,代码来源:grid.go

示例2: GetLayout

func (g *GridEngine) GetLayout(size geom.Coord) (layout Layout) {

	layout = make(Layout)

	_, minXs, maxXs := g.hflex.constrain(size.X)
	_, minYs, maxYs := g.vflex.constrain(size.Y)

	// if g.Block.ID == 2 {
	// 	uik.Report("regrid", g.Block.ID, g.Size, whs, wvs)
	// }

	for child, csh := range g.childrenHints {
		bd := g.childrenGridComponents[child]
		gridBounds := geom.Rect{
			Min: geom.Coord{
				X: minXs[bd.GridX],
				Y: minYs[bd.GridY],
			},
			Max: geom.Coord{
				X: maxXs[bd.GridX+bd.ExtraX],
				Y: maxYs[bd.GridY+bd.ExtraY],
			},
		}

		gridSizeX, gridSizeY := gridBounds.Size()
		if gridSizeX > csh.MaxSize.X {
			diff := gridSizeX - csh.MaxSize.X
			if !bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			}
			if bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Max.X -= diff
			}
			if !bd.AnchorLeft && bd.AnchorRight {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.MaxSize.Y {
			diff := gridSizeY - csh.MaxSize.Y
			if !bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			}
			if bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Max.Y -= diff
			}
			if !bd.AnchorTop && bd.AnchorBottom {
				gridBounds.Min.Y += diff
			}
		}

		gridSizeX, gridSizeY = gridBounds.Size()
		if gridSizeX > csh.PreferredSize.X {
			diff := gridSizeX - csh.PreferredSize.X
			if !bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Min.X += diff / 2
				gridBounds.Max.X -= diff / 2
			}
			if bd.AnchorLeft && !bd.AnchorRight {
				gridBounds.Max.X -= diff
			}
			if !bd.AnchorLeft && bd.AnchorRight {
				gridBounds.Min.X += diff
			}
		}
		if gridSizeY > csh.PreferredSize.Y {
			diff := gridSizeY - csh.PreferredSize.Y
			if !bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Min.Y += diff / 2
				gridBounds.Max.Y -= diff / 2
			}
			if bd.AnchorTop && !bd.AnchorBottom {
				gridBounds.Max.Y -= diff
			}
			if !bd.AnchorTop && bd.AnchorBottom {
				gridBounds.Min.Y += diff
			}
		}

		layout[child] = gridBounds

	}

	return
}
开发者ID:skelterjohn,项目名称:go.uik,代码行数:86,代码来源:grid.go


注:本文中的github.com/skelterjohn/geom.Rect.Size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。