• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 18141747950

30 Sep 2025 07:51PM UTC coverage: 60.977%. Remained the same
18141747950

push

github

web-flow
Merge pull request #5956 from Jacalz/build-strings-effectively

Remove two unnecessary uses of strings.Join

10 of 12 new or added lines in 2 files covered. (83.33%)

731 existing lines in 30 files now uncovered.

25578 of 41947 relevant lines covered (60.98%)

694.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.43
/internal/overlay_stack.go
1
package internal
2

3
import (
4
        "fyne.io/fyne/v2"
5
        "fyne.io/fyne/v2/internal/app"
6
        "fyne.io/fyne/v2/internal/widget"
7
)
8

9
// OverlayStack allows stacking overlays on top of each other.
10
// Removing an overlay will also remove all overlays above it.
11
type OverlayStack struct {
12
        OnChange      func()
13
        Canvas        fyne.Canvas
14
        focusManagers []*app.FocusManager
15
        overlays      []fyne.CanvasObject
16
}
17

18
// Add puts an overlay on the stack.
19
func (s *OverlayStack) Add(overlay fyne.CanvasObject) {
6✔
20
        if overlay == nil {
6✔
UNCOV
21
                return
×
UNCOV
22
        }
×
23

24
        if s.OnChange != nil {
6✔
UNCOV
25
                defer s.OnChange()
×
UNCOV
26
        }
×
27

28
        s.overlays = append(s.overlays, overlay)
6✔
29

6✔
30
        // TODO this should probably apply to all once #707 is addressed
6✔
31
        if _, ok := overlay.(*widget.OverlayContainer); ok {
6✔
UNCOV
32
                safePos, safeSize := s.Canvas.InteractiveArea()
×
UNCOV
33

×
34
                overlay.Resize(safeSize)
×
35
                overlay.Move(safePos)
×
36
        }
×
37

38
        s.focusManagers = append(s.focusManagers, app.NewFocusManager(overlay))
6✔
39
}
40

41
// List returns all overlays on the stack from bottom to top.
42
func (s *OverlayStack) List() []fyne.CanvasObject {
8✔
43
        return s.overlays
8✔
44
}
8✔
45

46
// ListFocusManagers returns all focus managers on the stack from bottom to top.
47
func (s *OverlayStack) ListFocusManagers() []*app.FocusManager {
12✔
48
        return s.focusManagers
12✔
49
}
12✔
50

51
// Remove deletes an overlay and all overlays above it from the stack.
52
func (s *OverlayStack) Remove(overlay fyne.CanvasObject) {
5✔
53
        if s.OnChange != nil {
5✔
UNCOV
54
                defer s.OnChange()
×
UNCOV
55
        }
×
56

57
        overlayIdx := -1
5✔
58
        for i, o := range s.overlays {
15✔
59
                if o == overlay {
14✔
60
                        overlayIdx = i
4✔
61
                        break
4✔
62
                }
63
        }
64
        if overlayIdx == -1 {
6✔
65
                return
1✔
66
        }
1✔
67
        // set removed elements in backing array to nil to release memory references
68
        for i := overlayIdx; i < len(s.overlays); i++ {
10✔
69
                s.overlays[i] = nil
6✔
70
                s.focusManagers[i] = nil
6✔
71
        }
6✔
72
        s.overlays = s.overlays[:overlayIdx]
4✔
73
        s.focusManagers = s.focusManagers[:overlayIdx]
4✔
74
}
75

76
// Top returns the top-most overlay of the stack.
77
func (s *OverlayStack) Top() fyne.CanvasObject {
8✔
78
        if len(s.overlays) == 0 {
11✔
79
                return nil
3✔
80
        }
3✔
81
        return s.overlays[len(s.overlays)-1]
5✔
82
}
83

84
// TopFocusManager returns the app.FocusManager assigned to the top-most overlay of the stack.
85
func (s *OverlayStack) TopFocusManager() *app.FocusManager {
12✔
86
        if len(s.focusManagers) == 0 {
15✔
87
                return nil
3✔
88
        }
3✔
89

90
        return s.focusManagers[len(s.focusManagers)-1]
9✔
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc