當前位置: 首頁>>代碼示例>>Golang>>正文


Golang geom.Rect類代碼示例

本文整理匯總了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;未經允許,請勿轉載。