MCPcopy Create free account
hub / github.com/cogentcore/core / cacheVisibleFields

Method cacheVisibleFields

core/table.go:158–189  ·  view source on GitHub ↗

cacheVisibleFields caches the visible struct fields.

()

Source from the content-addressed store, hash-verified

156
157// cacheVisibleFields caches the visible struct fields.
158func (tb *Table) cacheVisibleFields() {
159 tb.visibleFields = make([]reflect.StructField, 0)
160 shouldShow := func(field reflect.StructField) bool {
161 tvtag := field.Tag.Get("table")
162 switch {
163 case tvtag == "+":
164 return true
165 case tvtag == "-":
166 return false
167 case tvtag == "-select" && tb.IsReadOnly():
168 return false
169 case tvtag == "-edit" && !tb.IsReadOnly():
170 return false
171 default:
172 return field.Tag.Get("display") != "-"
173 }
174 }
175
176 reflectx.WalkFields(tb.elementValue,
177 func(parent reflect.Value, field reflect.StructField, value reflect.Value) bool {
178 return shouldShow(field)
179 },
180 func(parent reflect.Value, parentField *reflect.StructField, field reflect.StructField, value reflect.Value) {
181 if parentField != nil {
182 field.Index = append(parentField.Index, field.Index...)
183 }
184 tb.visibleFields = append(tb.visibleFields, field)
185 })
186 tb.numVisibleFields = len(tb.visibleFields)
187 tb.headerWidths = make([]int, tb.numVisibleFields)
188 tb.colMaxWidths = make([]int, tb.numVisibleFields)
189}
190
191func (tb *Table) UpdateMaxWidths() {
192 if tb.SliceSize == 0 {

Callers 1

SetSliceMethod · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 2

WalkFieldsFunction · 0.92
IsReadOnlyMethod · 0.45

Tested by

no test coverage detected