示例#1
0
func (b *ProgressBar) PaintProgress(c gxui.Canvas, r math.Rect, frac float32) {
	r.Max.X = math.Lerp(r.Min.X, r.Max.X, frac)
	c.DrawRect(r, gxui.CreateBrush(gxui.Gray50))
	c.Push()
	c.AddClip(r)
	c.DrawCanvas(b.chevrons, math.Point{X: b.scroll})
	c.Pop()
}
示例#2
0
文件: scroll_bar.go 项目: langxj/gxui
func (s *ScrollBar) updateBarRect() {
	sf, st := s.ScrollFraction()
	size := s.Size()
	b := size.Rect()
	halfMinLen := s.minBarLength / 2
	if s.orientation.Horizontal() {
		b.Min.X = math.Lerp(0, size.W, sf)
		b.Max.X = math.Lerp(0, size.W, st)
		if b.W() < s.minBarLength {
			c := (b.Min.X + b.Max.X) / 2
			c = math.Clamp(c, b.Min.X+halfMinLen, b.Max.X-halfMinLen)
			b.Min.X, b.Max.X = c-halfMinLen, c+halfMinLen
		}
	} else {
		b.Min.Y = math.Lerp(0, size.H, sf)
		b.Max.Y = math.Lerp(0, size.H, st)
		if b.H() < s.minBarLength {
			c := (b.Min.Y + b.Max.Y) / 2
			c = math.Clamp(c, b.Min.Y+halfMinLen, b.Max.Y-halfMinLen)
			b.Min.Y, b.Max.Y = c-halfMinLen, c+halfMinLen
		}
	}
	s.barRect = b
}
示例#3
0
func (b *ProgressBar) PaintProgress(c gxui.Canvas, r math.Rect, frac float32) {
	r.Max.X = math.Lerp(r.Min.X, r.Max.X, frac)
	c.DrawRect(r, gxui.CreateBrush(gxui.Gray50))
}