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

Method UpdateMaxWidths

core/table.go:191–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189}
190
191func (tb *Table) UpdateMaxWidths() {
192 if tb.SliceSize == 0 {
193 return
194 }
195 for fli := 0; fli < tb.numVisibleFields; fli++ {
196 field := tb.visibleFields[fli]
197 tb.colMaxWidths[fli] = 0
198 val := tb.sliceElementValue(0)
199 fval := val.FieldByIndex(field.Index)
200 _, isicon := fval.Interface().(icons.Icon)
201 isString := fval.Type().Kind() == reflect.String
202 if !isString || isicon {
203 continue
204 }
205 mxw := 0
206 for rw := 0; rw < tb.SliceSize; rw++ {
207 val := tb.sliceElementValue(rw)
208 str := reflectx.ToString(val.FieldByIndex(field.Index).Interface())
209 mxw = max(mxw, len(str))
210 }
211 tb.colMaxWidths[fli] = mxw
212 }
213}
214
215func (tb *Table) makeHeader(p *tree.Plan) {
216 tree.AddAt(p, "header", func(w *Frame) {

Callers

nothing calls this directly

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 5

ToStringFunction · 0.92
sliceElementValueMethod · 0.80
FieldByIndexMethod · 0.80
KindMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected