aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/imageviewer/browser.go6
-rw-r--r--examples/imageviewer/button.go6
-rw-r--r--examples/imageviewer/splits.go40
-rw-r--r--examples/imageviewer/viewer.go6
-rw-r--r--win/win.go22
5 files changed, 40 insertions, 40 deletions
diff --git a/examples/imageviewer/browser.go b/examples/imageviewer/browser.go
index e3df54e..a5fb461 100644
--- a/examples/imageviewer/browser.go
+++ b/examples/imageviewer/browser.go
@@ -112,13 +112,13 @@ func Browser(env gui.Env, theme *Theme, dir string, cd <-chan string, view chan<
}
var (
- minX, minY, maxX, maxY int
+ x0, y0, x1, y1 int
x, y int
)
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &maxX, &maxY):
- r = image.Rect(minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &y1):
+ r = image.Rect(x0, y0, x1, y1)
env.Draw() <- redraw(r, selected, position, lineHeight, namesImage)
case e.Matches("mo/down/%d/%d", &x, &y):
diff --git a/examples/imageviewer/button.go b/examples/imageviewer/button.go
index e012a08..8d448e4 100644
--- a/examples/imageviewer/button.go
+++ b/examples/imageviewer/button.go
@@ -34,11 +34,11 @@ func Button(env gui.Env, theme *Theme, text string, action func()) {
)
for e := range env.Events() {
- var x, y, minX, minY, maxX, maxY int
+ var x, y, x0, y0, x1, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &maxX, &maxY):
- r = image.Rect(minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &y1):
+ r = image.Rect(x0, y0, x1, y1)
env.Draw() <- redraw(r, over, pressed)
case e.Matches("mo/down/%d/%d/left", &x, &y):
diff --git a/examples/imageviewer/splits.go b/examples/imageviewer/splits.go
index 041a770..871a3a5 100644
--- a/examples/imageviewer/splits.go
+++ b/examples/imageviewer/splits.go
@@ -15,15 +15,15 @@ type envPair struct {
func (ep *envPair) Events() <-chan gui.Event { return ep.events }
func (ep *envPair) Draw() chan<- func(draw.Image) image.Rectangle { return ep.draw }
-func FixedLeft(env gui.Env, maxX int) gui.Env {
+func FixedLeft(env gui.Env, x1 int) gui.Env {
out, in := gui.MakeEventsChan()
go func() {
for e := range env.Events() {
- var minX, minY, dummy, maxY int
+ var x0, y0, dummy, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &dummy, &maxY):
- in <- gui.Eventf("resize/%d/%d/%d/%d", minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &dummy, &y1):
+ in <- gui.Eventf("resize/%d/%d/%d/%d", x0, y0, x1, y1)
default:
in <- e
}
@@ -34,15 +34,15 @@ func FixedLeft(env gui.Env, maxX int) gui.Env {
return &envPair{out, env.Draw()}
}
-func FixedRight(env gui.Env, minX int) gui.Env {
+func FixedRight(env gui.Env, x0 int) gui.Env {
out, in := gui.MakeEventsChan()
go func() {
for e := range env.Events() {
- var dummy, minY, maxX, maxY int
+ var dummy, y0, x1, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &dummy, &minY, &maxX, &maxY):
- in <- gui.Eventf("resize/%d/%d/%d/%d", minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &dummy, &y0, &x1, &y1):
+ in <- gui.Eventf("resize/%d/%d/%d/%d", x0, y0, x1, y1)
default:
in <- e
}
@@ -53,15 +53,15 @@ func FixedRight(env gui.Env, minX int) gui.Env {
return &envPair{out, env.Draw()}
}
-func FixedTop(env gui.Env, maxY int) gui.Env {
+func FixedTop(env gui.Env, y1 int) gui.Env {
out, in := gui.MakeEventsChan()
go func() {
for e := range env.Events() {
- var minX, minY, maxX, dummy int
+ var x0, y0, x1, dummy int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &maxX, &dummy):
- in <- gui.Eventf("resize/%d/%d/%d/%d", minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &dummy):
+ in <- gui.Eventf("resize/%d/%d/%d/%d", x0, y0, x1, y1)
default:
in <- e
}
@@ -72,15 +72,15 @@ func FixedTop(env gui.Env, maxY int) gui.Env {
return &envPair{out, env.Draw()}
}
-func FixedBottom(env gui.Env, minY int) gui.Env {
+func FixedBottom(env gui.Env, y0 int) gui.Env {
out, in := gui.MakeEventsChan()
go func() {
for e := range env.Events() {
- var minX, dummy, maxX, maxY int
+ var x0, dummy, x1, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &dummy, &maxX, &maxY):
- in <- gui.Eventf("resize/%d/%d/%d/%d", minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &dummy, &x1, &y1):
+ in <- gui.Eventf("resize/%d/%d/%d/%d", x0, y0, x1, y1)
default:
in <- e
}
@@ -96,11 +96,11 @@ func EvenHorizontal(env gui.Env, minI, maxI, n int) gui.Env {
go func() {
for e := range env.Events() {
- var minX, minY, maxX, maxY int
+ var x0, y0, x1, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &maxX, &maxY):
- minX, maxX := minX+(maxX-minX)*minI/n, minX+(maxX-minX)*maxI/n
- in <- gui.Eventf("resize/%d/%d/%d/%d", minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &y1):
+ x0, x1 := x0+(x1-x0)*minI/n, x0+(x1-x0)*maxI/n
+ in <- gui.Eventf("resize/%d/%d/%d/%d", x0, y0, x1, y1)
default:
in <- e
}
diff --git a/examples/imageviewer/viewer.go b/examples/imageviewer/viewer.go
index e783d78..e7eb7c6 100644
--- a/examples/imageviewer/viewer.go
+++ b/examples/imageviewer/viewer.go
@@ -54,10 +54,10 @@ func Viewer(env gui.Env, theme *Theme, view <-chan string) {
return
}
- var minX, minY, maxX, maxY int
+ var x0, y0, x1, y1 int
switch {
- case e.Matches("resize/%d/%d/%d/%d", &minX, &minY, &maxX, &maxY):
- r = image.Rect(minX, minY, maxX, maxY)
+ case e.Matches("resize/%d/%d/%d/%d", &x0, &y0, &x1, &y1):
+ r = image.Rect(x0, y0, x1, y1)
env.Draw() <- redraw(r, img)
}
}
diff --git a/win/win.go b/win/win.go
index 0a9b8c4..69bc5c1 100644
--- a/win/win.go
+++ b/win/win.go
@@ -131,18 +131,18 @@ func makeGLFWWin(o *options) (*glfw.Window, error) {
// Here are all kinds of events that a window can produce, along with descriptions.
// Things enclosed in <> are values that are filled in.
//
-// resize/<w>/<h> Window resized to w x h.
-// wi/close Window close button pressed.
-// mo/move/<x>/<y> Mouse moved to (x, y).
-// mo/down/<x>/<y>/<button> A mouse button pressed on (x, y).
-// mo/up/<x>/<y>/<button> A mouse button released on (x, y).
-// mo/scroll/<x>/<y> Mouse scrolled by (x, y).
-// kb/type/<code> A unicode character typed on the keyboard.
-// kb/down/<key> A key on the keyboard pressed.
-// kb/up/<key> A key on the keyboard released.
-// kb/repeat/<key> A key on the keyboard repeated (happens when held).
+// resize/<x0>/<y0>/<x1>/<y1> Window resized to (x0, y0, x1, y1).
+// wi/close Window close button pressed.
+// mo/move/<x>/<y> Mouse moved to (x, y).
+// mo/down/<x>/<y>/<button> A mouse button pressed on (x, y).
+// mo/up/<x>/<y>/<button> A mouse button released on (x, y).
+// mo/scroll/<x>/<y> Mouse scrolled by (x, y).
+// kb/type/<code> A unicode character typed on the keyboard.
+// kb/down/<key> A key on the keyboard pressed.
+// kb/up/<key> A key on the keyboard released.
+// kb/repeat/<key> A key on the keyboard repeated (happens when held).
//
-// <w>, <h>, <x>, <y>, and <code> are numbers (%d).
+// <x0>, <y0>, <x1>, <y1>, <w>, <h>, <x>, <y>, and <code> are numbers (%d).
// <button> is one of:
// left right middle
// <key> is one of: