mirror of https://github.com/anoshenko/rui.git
Added ReloadListViewItem method to ListView interface
This commit is contained in:
parent
9b9adcab88
commit
655bea09a8
|
|
@ -3,9 +3,10 @@
|
|||
* Removed "style-disabled" property and GetDisabledStyle function
|
||||
* Added GoogleFonts field to AppParams
|
||||
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded, GetBackgroundColorPair,
|
||||
GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair
|
||||
GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair, ReloadListViewItem
|
||||
* Added ClientSession interface
|
||||
* Added ClientSession, Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface
|
||||
* Added ReloadListViewItem method to ListView interface
|
||||
* Removed ClientItem, SetClientItem, RemoveClientItem, and RemoveAllClientItems methods from Session interface
|
||||
* Added DismissWithoutAnimation add SetHotKey methods to Popup interface
|
||||
* Added "outside-color" add "outside-filter" properties to Popup interface
|
||||
|
|
|
|||
38
listView.go
38
listView.go
|
|
@ -121,9 +121,13 @@ const (
|
|||
type ListView interface {
|
||||
View
|
||||
ParentView
|
||||
|
||||
// ReloadListViewData updates ListView content
|
||||
ReloadListViewData()
|
||||
|
||||
// ReloadListViewItem updates the contents of the item at the given index.
|
||||
ReloadListViewItem(index int)
|
||||
|
||||
getItemFrames() []Frame
|
||||
}
|
||||
|
||||
|
|
@ -445,9 +449,8 @@ func (listView *listViewData) getAdapter() ListAdapter {
|
|||
}
|
||||
|
||||
func (listView *listViewData) ReloadListViewData() {
|
||||
itemCount := 0
|
||||
if adapter := listView.getAdapter(); adapter != nil {
|
||||
itemCount = adapter.ListSize()
|
||||
itemCount := adapter.ListSize()
|
||||
|
||||
if itemCount != len(listView.items) {
|
||||
listView.items = make([]View, itemCount)
|
||||
|
|
@ -465,6 +468,25 @@ func (listView *listViewData) ReloadListViewData() {
|
|||
updateInnerHTML(listView.htmlID(), listView.session)
|
||||
}
|
||||
|
||||
func (listView *listViewData) ReloadListViewItem(index int) {
|
||||
adapter := listView.getAdapter()
|
||||
if adapter == nil || index < 0 || index >= adapter.ListSize() || index >= len(listView.items) {
|
||||
return
|
||||
}
|
||||
|
||||
listView.items[index] = adapter.ListItem(index, listView.Session())
|
||||
|
||||
if view := listView.items[index]; view != nil {
|
||||
html := allocStringBuilder()
|
||||
defer freeStringBuilder(html)
|
||||
|
||||
listView.session.callFunc("hideTooltip")
|
||||
|
||||
viewHTML(view, html, "")
|
||||
listView.session.updateInnerHTML(listView.htmlID()+"-"+strconv.Itoa(index), html.String())
|
||||
}
|
||||
}
|
||||
|
||||
func (listView *listViewData) getItemFrames() []Frame {
|
||||
return listView.itemFrame
|
||||
}
|
||||
|
|
@ -1281,6 +1303,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
|
|||
}
|
||||
|
||||
// ReloadListViewData updates ListView content
|
||||
//
|
||||
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
|
||||
func ReloadListViewData(view View, subviewID ...string) {
|
||||
if view = getSubview(view, subviewID); view != nil {
|
||||
|
|
@ -1289,3 +1312,14 @@ func ReloadListViewData(view View, subviewID ...string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ReloadListViewItem updates updates the contents of the ListView item at the given index.
|
||||
//
|
||||
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
|
||||
func ReloadListViewItem(index int, view View, subviewID ...string) {
|
||||
if view = getSubview(view, subviewID); view != nil {
|
||||
if listView, ok := view.(ListView); ok {
|
||||
listView.ReloadListViewItem(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue