func (sfr *ScrollFrame) Redraw(flush bool, predrawRects *[]image.Rectangle) {
	bgr := sfr.r
	bgr.Max.X = bgr.Min.X + sfr.Width
	draw.Draw(sfr.b, sfr.r.Intersect(bgr), &sfr.Color, sfr.r.Intersect(bgr).Min, draw.Src)
	posr := bgr
	posr.Max.X = posr.Max.X - 1
	posr.Min.Y = sfr.scale(sfr.Fr.Top) + sfr.r.Min.Y
	posz := sfr.scale(len(sfr.Fr.glyphs))
	if posz < 5 {
		posz = 5
	}
	posr.Max.Y = posz + posr.Min.Y
	draw.Draw(sfr.b, sfr.r.Intersect(posr), &sfr.Fr.Colors[0][0], sfr.r.Intersect(posr).Min, draw.Src)
	sfr.Fr.Redraw(false, predrawRects)
	if flush && (sfr.Flush != nil) {
		sfr.Flush(sfr.r)
	}
	if predrawRects != nil {
		*predrawRects = append(*predrawRects, bgr)
	}
}
/*
Redraws frame.
rdir and rpar are optimization parameters for partial redrawing of the frame during scrolling
When rdir > 0, rpar is the number of glyphs that don't need to be redrawn
When rdir < 0, rpar is the first glyph that doesn't need to be redrawn
package textframe
import (
	"fmt"
	"image"
	"image/draw"
	"time"
	"github.com/aarzilli/yacco/util"
	"golang.org/x/mobile/event/mouse"
)
type ScrollFrame struct {
	b     draw.Image       
	r     image.Rectangle  
	Flush func(...image.Rectangle)
	Color image.Uniform  
	Width int            
	Fr    Frame          
	bodyLen int
}
func (sfr *ScrollFrame) Init(margin int) error {
	sfr.Fr.B = sfr.b
	sfr.Fr.R = sfr.r
	sfr.Fr.R.Min.X += sfr.Width
	sfr.Flush = sfr.Flush
	if sfr.Width < 2 {
		return fmt.Errorf("ScrollFrame not wide enough")
	}
	sfr.Fr.debugRedraw = true
	return sfr.Fr.Init(margin)
}
func (sfr *ScrollFrame) Set(top, bodyLen int) {
	sfr.Fr.Top = top
	sfr.bodyLen = bodyLen
}
func (sfr *ScrollFrame) scale(x int) int {
	scrollsz := (sfr.r.Max.Y - sfr.r.Min.Y)
	return int(float32(x) / float32(sfr.bodyLen) * float32(scrollsz))
}
func (sfr *ScrollFrame) SetRects(b draw.Image, r image.Rectangle) {
	sfr.b = b
	sfr.r = r
	sfr.Fr.B = sfr.b
	sfr.Fr.R = sfr.r
	sfr.Fr.R.Min.X += sfr.Width
}