Finished the Area.Repaint() test and fixed found bugs. There's some weird issue left in GTK+ Areas...

This commit is contained in:
Pietro Gagliardi 2014-08-21 18:23:51 -04:00
parent 4e2315e757
commit 8feaa1c439
3 changed files with 71 additions and 3 deletions

View File

@ -75,7 +75,8 @@ func (a *area) Repaint(r image.Rectangle) {
if r.Empty() {
return
}
C.gtk_widget_queue_draw_area(a._widget, C.gint(r.Min.X), C.gint(r.Max.Y), C.gint(r.Dx()), C.gint(r.Dy()))
println(a._widget, C.gint(r.Min.X), C.gint(r.Min.Y), C.gint(r.Dx()), C.gint(r.Dy()))
C.gtk_widget_queue_draw_area(a._widget, C.gint(r.Min.X), C.gint(r.Min.Y), C.gint(r.Dx()), C.gint(r.Dy()))
}
func (a *area) RepaintAll() {

View File

@ -17,9 +17,7 @@ Tab
// After Delete(), the effect of accessing the Control of the deleted tab or any of its children is undefned. [TODO reword?]
investigate close buttons (especially for LikeTab)
Area
Repaint(rect image.Rectangle)
keyboard scrolling
GTK+ port: our_area_focus_callback() has something to do with it
OpenTextFieldAt() and OpenTextAreaAt() to allow editing of text from within Areas
Tree
Mac OS X: make sure newScrollView() has the correct parameters for Table and Tree (and that Area has the appropriate ones from both + its own no border)

View File

@ -4,6 +4,9 @@ package ui
import (
"image"
"image/color"
"image/draw"
"strconv"
)
type repainter struct {
@ -16,6 +19,11 @@ type repainter struct {
repaint Button
all Button
stack Stack
xv int
yv int
wv int
hv int
}
func newRepainter(times int) *repainter {
@ -23,11 +31,17 @@ func newRepainter(times int) *repainter {
r.img = tileImage(times)
r.area = NewArea(r.img.Rect.Dx(), r.img.Rect.Dy(), r)
r.x = NewTextField()
r.x.OnChanged(r.setx)
r.y = NewTextField()
r.y.OnChanged(r.sety)
r.width = NewTextField()
r.width.OnChanged(r.setwidth)
r.height = NewTextField()
r.height.OnChanged(r.setheight)
r.repaint = NewButton("Rect")
r.repaint.OnClicked(r.dorect)
r.all = NewButton("All")
r.all.OnClicked(r.doall)
r.stack = NewHorizontalStack(r.x, r.y, r.width, r.height, r.repaint, r.all)
r.stack.SetStretchy(0)
r.stack.SetStretchy(1)
@ -44,3 +58,58 @@ func (r *repainter) Paint(rect image.Rectangle) *image.RGBA {
func (r *repainter) Mouse(me MouseEvent) {}
func (r *repainter) Key(ke KeyEvent) bool { return false }
func (r *repainter) setx() {
i, err := strconv.Atoi(r.x.Text())
if err != nil {
r.x.Invalid(err.Error())
return
}
r.x.Invalid("")
r.xv = i
}
func (r *repainter) sety() {
i, err := strconv.Atoi(r.y.Text())
if err != nil {
r.y.Invalid(err.Error())
return
}
r.y.Invalid("")
r.yv = i
}
func (r *repainter) setwidth() {
i, err := strconv.Atoi(r.width.Text())
if err != nil {
r.width.Invalid(err.Error())
return
}
r.width.Invalid("")
r.wv = i
}
func (r *repainter) setheight() {
i, err := strconv.Atoi(r.height.Text())
if err != nil {
r.height.Invalid(err.Error())
return
}
r.height.Invalid("")
r.hv = i
}
func (r *repainter) alter(rect image.Rectangle, c color.Color) {
draw.Draw(r.img, rect, &image.Uniform{c}, image.ZP, draw.Over)
}
func (r *repainter) dorect() {
rect := image.Rect(r.xv, r.yv, r.xv + r.wv, r.yv + r.hv)
r.alter(rect, color.RGBA{255, 0, 255, 128})
r.area.Repaint(rect)
}
func (r *repainter) doall() {
r.alter(r.img.Rect, color.RGBA{255, 255, 0, 128})
r.area.RepaintAll()
}