本文整理汇总了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()
}
示例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
}