List can now add multiple entries at once, and clear all of them
This commit is contained in:
parent
f37101eb9e
commit
faf5ebb283
@ -244,13 +244,16 @@ func (element *List) CountEntries () (count int) {
|
|||||||
return len(element.entries)
|
return len(element.entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append adds an entry to the end of the list.
|
// Append adds one or more entries to the end of the list.
|
||||||
func (element *List) Append (entry ListEntry) {
|
func (element *List) Append (entries ...ListEntry) {
|
||||||
// append
|
// append
|
||||||
entry = element.resizeEntryToFit(entry)
|
for index, entry := range entries {
|
||||||
entry.SetTheme(element.theme.Theme)
|
entry = element.resizeEntryToFit(entry)
|
||||||
entry.SetConfig(element.config)
|
entry.SetTheme(element.theme.Theme)
|
||||||
element.entries = append(element.entries, entry)
|
entry.SetConfig(element.config)
|
||||||
|
entries[index] = entry
|
||||||
|
}
|
||||||
|
element.entries = append(element.entries, entries...)
|
||||||
|
|
||||||
// recalculate, redraw, notify
|
// recalculate, redraw, notify
|
||||||
element.updateMinimumSize()
|
element.updateMinimumSize()
|
||||||
@ -313,6 +316,19 @@ func (element *List) Remove (index int) {
|
|||||||
element.scrollBoundsChange()
|
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
|
// Replace replaces the entry at the specified index with another. If the index
|
||||||
// is out of bounds, it panics.
|
// is out of bounds, it panics.
|
||||||
func (element *List) Replace (index int, entry ListEntry) {
|
func (element *List) Replace (index int, entry ListEntry) {
|
||||||
|
Reference in New Issue
Block a user