• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang geom.Size类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/achille-roussel/go-vu/geom.Size的典型用法代码示例。如果您正苦于以下问题:Golang Size类的具体用法?Golang Size怎么用?Golang Size使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: run

func (self window) run() {
	var frame geom.Size
	var density float64

	defer self.window.Release()
	defer close(self.events)

	for {
		v := self.window.NextEvent()

		switch e := v.(type) {
		default:
			// This is none of the events that we know the mobile package should send,
			// probably a custom event from the application so we simply forward it.
			self.events <- v

		case paint.Event:
			gc := newGraphicContext(self.window)

			self.events <- event.Redraw{
				GC:       gc,
				Clip:     geom.Rect{W: frame.W, H: frame.H},
				External: e.External,
			}

			gc.join.Wait()

		case size.Event:
			w := float64(e.WidthPt)
			h := float64(e.HeightPt)
			d := float64(e.PixelsPerPt)

			if w != frame.W || h != frame.H || d != density {
				frame.W = w
				frame.H = h
				density = d

				self.events <- event.ChangeScreen{Density: density}
				self.events <- event.Resize{Size: frame}
			}

		case lifecycle.Event:
			if e.To == lifecycle.StageDead {
				self.events <- event.Close{}
				return
			}

			switch e.Crosses(lifecycle.StageVisible) {
			case lifecycle.CrossOn:
				self.events <- event.Focus{Focused: true}

			case lifecycle.CrossOff:
				self.events <- event.Focus{Focused: false}
			}
		}
	}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:57,代码来源:shiny.go


示例2: Layout

func (self UniformFillImageLayout) Layout(widget geom.Size, image geom.Size) (bounds geom.Rect) {
	if r1, r2 := image.Ratio(), widget.Ratio(); r1 < r2 {
		bounds.W = widget.W
		bounds.H = widget.W / r1
		bounds.Y = (widget.H / 2) - (bounds.H / 2)
	} else if r1 > r2 {
		bounds.W = widget.H * r1
		bounds.H = widget.H
		bounds.X = (widget.W / 2) - (bounds.W / 2)
	} else {
		bounds.W = widget.W
		bounds.H = widget.H
	}
	return
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:15,代码来源:image.go


示例3: PreferredSize

func (self *MarginBox) PreferredSize(constraints geom.Size) geom.Size {
	margin := self.Margin()

	if self.content == nil {
		return margin.Size()
	}

	if constraints.W >= 0 {
		constraints.W = math.Max(0, constraints.W-margin.Width())
	}

	if constraints.H >= 0 {
		constraints.H = math.Max(0, constraints.H-margin.Height())
	}

	return margin.GrowSize(self.content.PreferredSize(constraints))
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:17,代码来源:margin.go


示例4: PreferredSize

func (self HorizontalLayout) PreferredSize(constraints geom.Size, widgets ...Widget) (size geom.Size) {
	n := len(widgets)

	if n == 0 {
		return
	}

	constraints.W /= float64(n)

	for _, w := range widgets {
		s := w.PreferredSize(constraints)
		size.W = math.Max(s.W, size.W)
		size.H = math.Max(s.H, size.H)
	}

	size.W = (size.W * float64(n)) + (self.Spacing * float64(n-1))
	return
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:18,代码来源:layout.go


示例5: run

func (self *window) run() {
	var glctx gl.Context
	var frame geom.Size
	var scale float64

	defer close(self.events)

	for v := range self.app.Events() {
		switch e := v.(type) {
		default:
			// This is none of the events that we know the mobile package should send,
			// probably a custom event from the application so we simply forward it.
			self.events <- v

		case paint.Event:
			if glctx != nil {
				// Always clear the content before redrawing so we don't leak left overs
				// of the video buffer.
				glctx.ClearColor(0, 0, 0, 1)
				glctx.Clear(gl.COLOR_BUFFER_BIT)
				gc := newGraphicContext(self.app, glctx)

				self.events <- event.Redraw{
					GC:       gc,
					Clip:     geom.Rect{W: frame.W, H: frame.H},
					External: e.External,
				}

				gc.join.Wait()
			}

		case size.Event:
			w := float64(e.WidthPt)
			h := float64(e.HeightPt)
			d := float64(e.PixelsPerPt)

			if w != frame.W || h != frame.H || d != scale {
				frame.W = w
				frame.H = h
				scale = d

				self.events <- event.ChangeScreen{
					Bounds: geom.Rect{W: frame.W, H: frame.H},
					Scale:  scale,
				}

				self.events <- event.Move{}

				self.events <- event.Resize{
					Size: frame,
				}
			}

		case lifecycle.Event:
			if e.To == lifecycle.StageDead {
				self.events <- event.Close{}
				return
			}

			switch e.Crosses(lifecycle.StageVisible) {
			case lifecycle.CrossOn:
				// The app doesn't send a paint event when it starts so we force
				// it here to trigger the first drawing of the newly created
				// window.
				glctx = e.DrawContext.(gl.Context)
				self.app.Send(paint.Event{External: true})
				self.events <- event.Focus{Focused: true}

			case lifecycle.CrossOff:
				glctx = nil
				self.events <- event.Focus{Focused: false}
			}
		}
	}

	// Unsure under which condition the events channel could get closed before a
	// lifecycle event indicating the app is going away but just in case we send
	// a close event before returning.
	self.events <- event.Close{}
}
开发者ID:achille-roussel,项目名称:go-vu,代码行数:80,代码来源:mobile.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gcstats.GcStats类代码示例发布时间:2022-05-24
下一篇:
Golang geom.Rect类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap