Skip to content

Commit 4724dec

Browse files
committed
debugui: change the ID for windows to use callers
1 parent a4d5362 commit 4724dec

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

container.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,22 @@ func (c *Context) currentContainer() *container {
6868
}
6969

7070
func (c *Context) Window(title string, rect image.Rectangle, f func(layout ContainerLayout)) {
71+
pc := caller()
72+
id := c.idFromCaller(pc)
7173
c.wrapError(func() error {
72-
if err := c.window(title, rect, 0, f); err != nil {
74+
if err := c.window(title, rect, 0, id, f); err != nil {
7375
return err
7476
}
7577
return nil
7678
})
7779
}
7880

79-
func (c *Context) window(title string, bounds image.Rectangle, opt option, f func(layout ContainerLayout)) (err error) {
80-
id := c.idFromGlobalString(title)
81-
c.idScopeFromGlobalString(title, func() {
81+
func (c *Context) window(title string, bounds image.Rectangle, opt option, id controlID, f func(layout ContainerLayout)) error {
82+
var err error
83+
c.idScopeFromID(id, func() {
8284
err = c.doWindow(title, bounds, opt, id, f)
8385
})
84-
return
86+
return err
8587
}
8688

8789
func (c *Context) doWindow(title string, bounds image.Rectangle, opt option, id controlID, f func(layout ContainerLayout)) (err error) {
@@ -263,9 +265,10 @@ func (c *Context) ClosePopup(name string) {
263265
}
264266

265267
func (c *Context) Popup(name string, f func(layout ContainerLayout)) {
268+
id := c.idFromGlobalString(name)
266269
c.wrapError(func() error {
267270
opt := optionPopup | optionAutoSize | optionNoResize | optionNoScroll | optionNoTitle | optionClosed
268-
if err := c.window(name, image.Rectangle{}, opt, f); err != nil {
271+
if err := c.window(name, image.Rectangle{}, opt, id, f); err != nil {
269272
return err
270273
}
271274
return nil

id.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ func (c *Context) idScopeFromID(id controlID, f func()) {
4040
f()
4141
}
4242

43-
func (c *Context) idScopeFromGlobalString(name string, f func()) {
44-
c.idStack = append(c.idStack, controlID(fmt.Sprintf("string:%q", name)))
45-
defer func() {
46-
c.idStack = slices.Delete(c.idStack, len(c.idStack)-1, len(c.idStack))
47-
}()
48-
f()
49-
}
50-
5143
func (c *Context) idScopeToControlID() controlID {
5244
var newID controlID
5345
for _, id := range c.idStack {

0 commit comments

Comments
 (0)