summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-23 20:54:11 -0400
committerPietro Gagliardi <[email protected]>2014-03-23 20:54:11 -0400
commita41f58286646057d1c022e260662944efd7b85ce (patch)
treed675fabc592c366821ad143439fcc5aece4d7a48 /test
parent0cc13633cb99b59a605296591c81732c11ba06f8 (diff)
Added Area resizing. Everything mostly works, but not making things smaller...
Diffstat (limited to 'test')
-rw-r--r--test/main.go24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/main.go b/test/main.go
index b2d6a6d..a2d683e 100644
--- a/test/main.go
+++ b/test/main.go
@@ -10,6 +10,7 @@ import (
_ "image/png"
"bytes"
"time"
+ "strconv"
. "github.com/andlabs/ui"
)
@@ -158,13 +159,25 @@ func areaTest() {
img := image.NewNRGBA(ximg.Bounds())
draw.Draw(img, img.Rect, ximg, image.ZP, draw.Over)
w := NewWindow("Area Test", 100, 100)
- a := NewArea(&areaHandler{
+ a := NewArea(320, 240, &areaHandler{
img: img,
})
timedisp := NewLabel("")
timechan := time.Tick(time.Second)
+ widthbox := NewLineEdit("320")
+ heightbox := NewLineEdit("240")
+ resize := NewButton("Resize")
+ sizeStack := NewHorizontalStack(widthbox, heightbox, resize)
+ sizeStack.SetStretchy(0)
+ sizeStack.SetStretchy(1)
+ sizeStack.SetStretchy(2)
+ sizeStack = NewHorizontalStack(sizeStack, Space(), Space())
+ sizeStack.SetStretchy(0)
+ sizeStack.SetStretchy(1)
+ sizeStack.SetStretchy(2)
layout := NewVerticalStack(a,
- NewHorizontalStack(timedisp))
+ NewHorizontalStack(timedisp),
+ sizeStack)
layout.SetStretchy(0)
err = w.Open(layout)
if err != nil {
@@ -176,6 +189,13 @@ func areaTest() {
return
case t := <-timechan:
timedisp.SetText(t.String())
+ case <-resize.Clicked:
+ width, err := strconv.Atoi(widthbox.Text())
+ if err != nil { println(err); continue }
+ height, err := strconv.Atoi(heightbox.Text())
+ if err != nil { println(err); continue }
+println(width, height)
+ a.SetSize(width, height)
}
}
}