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

Method makeColumns

plot/plotcore/ploteditor.go:485–563  ·  view source on GitHub ↗

makeColumns makes the Plans for columns

(p *tree.Plan)

Source from the content-addressed store, hash-verified

483
484// makeColumns makes the Plans for columns
485func (pl *PlotEditor) makeColumns(p *tree.Plan) {
486 pl.columnsListUpdate()
487 tree.Add(p, func(w *core.Frame) {
488 tree.AddChild(w, func(w *core.Button) {
489 w.SetText("Clear").SetIcon(icons.ClearAll).SetType(core.ButtonAction)
490 w.SetTooltip("Turn all columns off")
491 w.OnClick(func(e events.Event) {
492 pl.setAllColumns(false)
493 })
494 })
495 tree.AddChild(w, func(w *core.Button) {
496 w.SetText("Search").SetIcon(icons.Search).SetType(core.ButtonAction)
497 w.SetTooltip("Select columns by column name")
498 w.OnClick(func(e events.Event) {
499 core.CallFunc(pl, pl.setColumnsByName)
500 })
501 })
502 })
503 tree.Add(p, func(w *core.Separator) {})
504 for _, cp := range pl.Columns {
505 tree.AddAt(p, cp.Column, func(w *core.Frame) {
506 w.Styler(func(s *styles.Style) {
507 s.CenterAll()
508 })
509 tree.AddChild(w, func(w *core.Switch) {
510 w.SetType(core.SwitchCheckbox).SetTooltip("Turn this column on or off")
511 w.OnChange(func(e events.Event) {
512 cp.On = w.IsChecked()
513 pl.UpdatePlot()
514 })
515 w.Updater(func() {
516 xaxis := cp.Column == pl.Options.XAxis || cp.Column == pl.Options.Legend
517 w.SetState(xaxis, states.Disabled, states.Indeterminate)
518 if xaxis {
519 cp.On = false
520 } else {
521 w.SetChecked(cp.On)
522 }
523 })
524 })
525 tree.AddChild(w, func(w *core.Button) {
526 w.SetText(cp.Column).SetType(core.ButtonAction).SetTooltip("Edit column options including setting it as the x-axis or legend")
527 w.OnClick(func(e events.Event) {
528 update := func() {
529 if core.TheApp.Platform().IsMobile() {
530 pl.Update()
531 return
532 }
533 // we must be async on multi-window platforms since
534 // it is coming from a separate window
535 pl.AsyncLock()
536 pl.Update()
537 pl.AsyncUnlock()
538 }
539 d := core.NewBody().AddTitle("Column options")
540 core.NewForm(d).SetStruct(cp).
541 OnChange(func(e events.Event) {
542 update()

Callers

nothing calls this directly

Calls 15

columnsListUpdateMethod · 0.95
setAllColumnsMethod · 0.95
UpdatePlotMethod · 0.95
AddFunction · 0.92
AddChildFunction · 0.92
CallFuncFunction · 0.92
AddAtFunction · 0.92
NewBodyFunction · 0.92
NewFormFunction · 0.92
SetTooltipMethod · 0.80
StylerMethod · 0.80
CenterAllMethod · 0.80

Tested by

no test coverage detected