本文整理汇总了Golang中github.com/achille-roussel/go-vu/geom.Rect类的典型用法代码示例。如果您正苦于以下问题:Golang Rect类的具体用法?Golang Rect怎么用?Golang Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rect类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: draw
func draw(widget Widget, gc graphic.Context, clip geom.Rect, origin geom.Point) {
bounds := widget.Bounds()
if clip.Intersect(geom.Rect{
X: bounds.X + origin.X,
Y: bounds.Y + origin.Y,
W: bounds.W,
H: bounds.H,
}).Empty() {
return
}
gc.Save()
gc.Configure(graphic.State{
Transform: graphic.Translation(bounds.X, bounds.Y),
Clip: geom.Rect{W: bounds.W, H: bounds.H},
})
if d, ok := widget.(Drawable); ok {
d.Draw(gc)
}
if c, ok := widget.(Container); ok {
origin = bounds.Origin()
for _, w := range c.Children() {
draw(w, gc, clip, origin)
}
}
gc.Restore()
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:32,代码来源:widget.go
示例2: Layout
func (self HorizontalLayout) Layout(bounds geom.Rect, widgets ...Widget) {
n := len(widgets)
bounds.W -= float64(n-1) * self.Spacing
bounds.W /= float64(n)
for _, w := range widgets {
w.SetBounds(bounds)
bounds.X += bounds.W + self.Spacing
}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:11,代码来源:layout.go
示例3: redraw
func redraw(widget Widget, bounds geom.Rect) {
if view, ok := widget.(*View); ok {
view.redraw(bounds)
return
}
if parent := widget.Parent(); parent != nil {
r := parent.Bounds()
bounds.X += r.X
bounds.Y += r.Y
redraw(parent, bounds)
return
}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:14,代码来源:widget.go
示例4: changeMouseSelection
func (self *View) changeMouseSelection(w driver.Window, p geom.Point, b mouse.ButtonSet) {
if (self.state & viewMouseSelection) == 0 {
self.state |= viewMouseSelection
self.mouseSelectionOrigin = p
self.mouseSelectionButtons = b
if cur, err := w.Display().NewCursor(driver.CursorIBeam); err != nil {
fmt.Fprintf(os.Stderr, "WARN: seting default cursor to I-Beam failed: %s\n", err)
} else {
self.changeDefaultCursor(cur)
}
}
p0 := self.mouseSelectionOrigin
p1 := p
r := geom.Rect{X: p0.X, Y: p0.Y, W: p1.X - p0.X, H: p1.Y - p0.Y}
if r.W >= 0.0 && r.W < 1.0 {
r.W = 1.0
} else if r.W < 0.0 && r.W > -1.0 {
r.W = -1.0
}
if r.H >= 0.0 && r.H < 1.0 {
r.H = 1.0
} else if r.H < 0.0 && r.H > -1.0 {
r.H = -1.0
}
if self.content != nil {
mouseSelection(w, self.content, event.MouseSelection{
Pressed: b,
Bounds: r,
})
}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:37,代码来源:view.go
示例5: SetBounds
func (self *Image) SetBounds(bounds geom.Rect) {
self.Control.SetBounds(bounds)
self.area = self.Layout().Layout(bounds.Size(), self.imageSize())
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:4,代码来源:image.go
示例6: makeCGRect
func makeCGRect(r geom.Rect) C.CGRect {
return C.CGRect{
origin: makeCGPoint(r.Origin()),
size: makeCGSize(r.Size()),
}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:6,代码来源:darwin_amd64.go
示例7: SetBounds
func (self *Frame) SetBounds(bounds geom.Rect) {
self.Control.SetBounds(bounds)
bounds.X = 0
bounds.Y = 0
self.Layout().Layout(bounds, self.Children()...)
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:6,代码来源:frame.go
示例8: RedrawRect
func RedrawRect(widget Widget, rect geom.Rect) {
bounds := widget.Bounds()
rect.X += bounds.X
rect.Y += bounds.Y
redraw(widget, rect)
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:6,代码来源:widget.go
注:本文中的github.com/achille-roussel/go-vu/geom.Rect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论