MCPcopy
hub / github.com/g3n/engine / InsertAt

Method InsertAt

gui/itemscroller.go:90–116  ·  view source on GitHub ↗

InsertAt inserts an item at the specified position

(pos int, item IPanel)

Source from the content-addressed store, hash-verified

88
89// InsertAt inserts an item at the specified position
90func (s *ItemScroller) InsertAt(pos int, item IPanel) {
91
92 // Validates position
93 if pos < 0 || pos > len(s.items) {
94 panic("ItemScroller.InsertAt(): Invalid position")
95 }
96 item.GetPanel().SetVisible(false)
97
98 // Insert item in the items array
99 s.items = append(s.items, nil)
100 copy(s.items[pos+1:], s.items[pos:])
101 s.items[pos] = item
102
103 // Insert item in the scroller
104 s.Panel.Add(item)
105 s.autoSize()
106 s.recalc()
107
108 // Scroll bar should be on the foreground,
109 // in relation of all the other child panels.
110 if s.vscroll != nil {
111 s.Panel.SetTopChild(s.vscroll)
112 }
113 if s.hscroll != nil {
114 s.Panel.SetTopChild(s.hscroll)
115 }
116}
117
118// RemoveAt removes item from the specified position
119func (s *ItemScroller) RemoveAt(pos int) IPanel {

Callers 1

AddMethod · 0.95

Calls 6

autoSizeMethod · 0.95
recalcMethod · 0.95
SetTopChildMethod · 0.80
SetVisibleMethod · 0.65
GetPanelMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected