本文整理汇总了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()
}
示例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
}
}
示例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
}
}
示例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,
})
}
}
示例5: SetBounds
func (self *Image) SetBounds(bounds geom.Rect) {
self.Control.SetBounds(bounds)
self.area = self.Layout().Layout(bounds.Size(), self.imageSize())
}
示例6: makeCGRect
func makeCGRect(r geom.Rect) C.CGRect {
return C.CGRect{
origin: makeCGPoint(r.Origin()),
size: makeCGSize(r.Size()),
}
}
示例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()...)
}
示例8: RedrawRect
func RedrawRect(widget Widget, rect geom.Rect) {
bounds := widget.Bounds()
rect.X += bounds.X
rect.Y += bounds.Y
redraw(widget, rect)
}