Skip to content

Commit 4685c7b

Browse files
committed
debugui: refactoring: remove helpers.go
1 parent e5bbff0 commit 4685c7b

4 files changed

Lines changed: 28 additions & 32 deletions

File tree

container.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,15 @@ func (c *container) toggle(id WidgetID) {
332332
}
333333
c.toggledIDs[id] = struct{}{}
334334
}
335+
336+
func (c *Context) bringToFront(cnt *container) {
337+
c.lastZIndex++
338+
cnt.zIndex = c.lastZIndex
339+
}
340+
341+
func (c *Context) addUsedContainer(id WidgetID) {
342+
if c.usedContainers == nil {
343+
c.usedContainers = map[WidgetID]struct{}{}
344+
}
345+
c.usedContainers[id] = struct{}{}
346+
}

context.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import (
1212
"github.com/hajimehoshi/ebiten/v2"
1313
)
1414

15+
func clamp[T int | float64](x, a, b T) T {
16+
return min(b, max(a, x))
17+
}
18+
1519
type Context struct {
1620
pointing pointing
1721

@@ -44,6 +48,13 @@ type Context struct {
4448
err error
4549
}
4650

51+
func (c *Context) wrapError(f func() error) {
52+
if c.err != nil {
53+
return
54+
}
55+
c.err = f()
56+
}
57+
4758
func (c *Context) update(f func(ctx *Context) error) (err error) {
4859
if c.err != nil {
4960
return c.err

helpers.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

widget.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,8 @@ func (c *Context) isCapturingInput() bool {
176176
func (c *Context) CurrentWidgetID() WidgetID {
177177
return c.currentID
178178
}
179+
180+
func (c *Context) setFocus(id WidgetID) {
181+
c.focus = id
182+
c.keepFocus = true
183+
}

0 commit comments

Comments
 (0)