diff --git a/elements/basic/list.go b/elements/basic/list.go index e8801bd..704f1f0 100644 --- a/elements/basic/list.go +++ b/elements/basic/list.go @@ -244,13 +244,16 @@ func (element *List) CountEntries () (count int) { return len(element.entries) } -// Append adds an entry to the end of the list. -func (element *List) Append (entry ListEntry) { +// Append adds one or more entries to the end of the list. +func (element *List) Append (entries ...ListEntry) { // append - entry = element.resizeEntryToFit(entry) - entry.SetTheme(element.theme.Theme) - entry.SetConfig(element.config) - element.entries = append(element.entries, entry) + for index, entry := range entries { + entry = element.resizeEntryToFit(entry) + entry.SetTheme(element.theme.Theme) + entry.SetConfig(element.config) + entries[index] = entry + } + element.entries = append(element.entries, entries...) // recalculate, redraw, notify element.updateMinimumSize() @@ -313,6 +316,19 @@ func (element *List) Remove (index int) { element.scrollBoundsChange() } +// Clear removes all entries from the list. +func (element *List) Clear () { + element.entries = nil + + // recalculate, redraw, notify + element.updateMinimumSize() + if element.core.HasImage() { + element.draw() + element.core.DamageAll() + } + element.scrollBoundsChange() +} + // Replace replaces the entry at the specified index with another. If the index // is out of bounds, it panics. func (element *List) Replace (index int, entry ListEntry) {