Skip to content

Commit 5fcc5a3

Browse files
committed
debugui: add bounds argument to GridCell
1 parent 2cba96c commit 5fcc5a3

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

control.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (c *Context) control(id controlID, opt option, f func(bounds image.Rectangl
136136
// Text creates a text label.
137137
func (c *Context) Text(text string) {
138138
c.wrapError(func() error {
139-
if err := c.gridCell(func() error {
139+
if err := c.gridCell(func(bounds image.Rectangle) error {
140140
var endIdx, p int
141141
c.SetGridLayout([]int{-1}, []int{lineHeight()})
142142
for endIdx < len(text) {

example/ui.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (g *Game) testWindow(ctx *debugui.Context) {
6868
})
6969
ctx.Header("Tree and Text", true, func() {
7070
ctx.SetGridLayout([]int{-1, -1}, nil)
71-
ctx.GridCell(func() {
71+
ctx.GridCell(func(bounds image.Rectangle) {
7272
ctx.TreeNode("Test 1", func() {
7373
ctx.TreeNode("Test 1a", func() {
7474
ctx.Text("Hello")
@@ -111,7 +111,7 @@ func (g *Game) testWindow(ctx *debugui.Context) {
111111
})
112112
ctx.Header("Color", true, func() {
113113
ctx.SetGridLayout([]int{-3, -1}, []int{54})
114-
ctx.GridCell(func() {
114+
ctx.GridCell(func(bounds image.Rectangle) {
115115
ctx.SetGridLayout([]int{-1, -3}, nil)
116116
ctx.Text("Red:")
117117
ctx.Slider(&g.bg[0], 0, 255, 1)
@@ -167,7 +167,7 @@ func (g *Game) logWindow(ctx *debugui.Context) {
167167
g.logUpdated = false
168168
}
169169
})
170-
ctx.GridCell(func() {
170+
ctx.GridCell(func(bounds image.Rectangle) {
171171
var submit bool
172172
ctx.SetGridLayout([]int{-3, -1}, nil)
173173
if ctx.TextField(&g.logSubmitBuf) {

layout.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ func (c *Context) popLayout() error {
8383
return err
8484
}
8585

86-
func (c *Context) GridCell(f func()) {
86+
func (c *Context) GridCell(f func(bounds image.Rectangle)) {
8787
c.wrapError(func() error {
88-
if err := c.gridCell(func() error {
89-
f()
88+
if err := c.gridCell(func(bounds image.Rectangle) error {
89+
f(bounds)
9090
return nil
9191
}); err != nil {
9292
return err
@@ -95,7 +95,7 @@ func (c *Context) GridCell(f func()) {
9595
})
9696
}
9797

98-
func (c *Context) gridCell(f func() error) error {
98+
func (c *Context) gridCell(f func(bounds image.Rectangle) error) error {
9999
_, err := c.control(emptyControlID, 0, func(bounds image.Rectangle, wasFocused bool) (res bool, err error) {
100100
if err := c.pushLayout(bounds, image.Pt(0, 0), false); err != nil {
101101
return false, err
@@ -105,7 +105,7 @@ func (c *Context) gridCell(f func() error) error {
105105
err = err2
106106
}
107107
}()
108-
if err := f(); err != nil {
108+
if err := f(bounds); err != nil {
109109
return false, err
110110
}
111111
b := &c.layoutStack[len(c.layoutStack)-1]

0 commit comments

Comments
 (0)