InsertAt inserts an item at the specified position
(pos int, item IPanel)
| 88 | |
| 89 | // InsertAt inserts an item at the specified position |
| 90 | func (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 |
| 119 | func (s *ItemScroller) RemoveAt(pos int) IPanel { |
no test coverage detected