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

Method setSplitIndex

core/splits.go:502–533  ·  view source on GitHub ↗

setSplitIndex sets given proportional "Splits" space to given value. Splits are indexed first by Tiles (major splits) and then within tiles, where TileSplit has 2 and the Long cases, have the long element first followed by the two smaller ones. Calls updateSplits after to ensure renormalization and

(idx int, val float32)

Source from the content-addressed store, hash-verified

500// Calls updateSplits after to ensure renormalization and
501// NeedsLayout to ensure layout is updated.
502func (sl *Splits) setSplitIndex(idx int, val float32) {
503 nt := len(sl.Tiles)
504 if nt == 0 {
505 return
506 }
507 if idx < nt {
508 sl.TileSplits[idx] = val
509 return
510 }
511 ci := nt
512 for i, t := range sl.Tiles {
513 tn := tileNumElements[t]
514 ri := idx - ci
515 if ri < 0 {
516 break
517 }
518 switch t {
519 case TileSpan:
520 case TileSplit:
521 if ri < 2 {
522 sl.SubSplits[i][ri] = val
523 }
524 case TileFirstLong, TileSecondLong:
525 if ri < 3 {
526 sl.SubSplits[i][ri] = val
527 }
528 }
529 ci += tn
530 }
531 sl.updateSplits()
532 sl.NeedsLayout()
533}
534
535// collapseSplit collapses the splitter region(s) at given index(es),
536// by setting splits value to 0.

Callers 1

collapseSplitMethod · 0.95

Calls 2

updateSplitsMethod · 0.95
NeedsLayoutMethod · 0.45

Tested by

no test coverage detected