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

Method MakeRow

core/list.go:588–625  ·  view source on GitHub ↗
(p *tree.Plan, i int)

Source from the content-addressed store, hash-verified

586}
587
588func (lb *ListBase) MakeRow(p *tree.Plan, i int) {
589 svi := lb.This.(Lister)
590 si, vi, invis := svi.SliceIndex(i)
591 itxt := strconv.Itoa(i)
592 val := lb.sliceElementValue(vi)
593
594 if lb.ShowIndexes {
595 lb.MakeGridIndex(p, i, si, itxt, invis)
596 }
597
598 valnm := fmt.Sprintf("value-%s-%s", itxt, reflectx.ShortTypeName(lb.elementValue.Type()))
599 tree.AddNew(p, valnm, func() Value {
600 return NewValue(val.Addr().Interface(), "")
601 }, func(w Value) {
602 wb := w.AsWidget()
603 lb.MakeValue(w, i)
604 if !lb.IsReadOnly() {
605 wb.OnChange(func(e events.Event) {
606 lb.SendChange(e)
607 })
608 }
609 wb.Updater(func() {
610 wb := w.AsWidget()
611 _, vi, invis := svi.SliceIndex(i)
612 val := lb.sliceElementValue(vi)
613 Bind(val.Addr().Interface(), w)
614 wb.SetReadOnly(lb.IsReadOnly())
615 wb.SetState(invis, states.Invisible)
616 if lb.This.(Lister).HasStyler() {
617 w.Style()
618 }
619 if invis {
620 wb.SetSelected(false)
621 }
622 })
623 })
624
625}
626
627func (lb *ListBase) MakeGridIndex(p *tree.Plan, i, si int, itxt string, invis bool) {
628 ls := lb.This.(Lister)

Callers

nothing calls this directly

Calls 15

sliceElementValueMethod · 0.95
MakeGridIndexMethod · 0.95
MakeValueMethod · 0.95
ShortTypeNameFunction · 0.92
AddNewFunction · 0.92
NewValueFunction · 0.85
BindFunction · 0.85
SendChangeMethod · 0.80
UpdaterMethod · 0.80
SliceIndexMethod · 0.65
TypeMethod · 0.65
AsWidgetMethod · 0.65

Tested by

no test coverage detected