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

Method MakeHeader

tensor/tensorcore/table.go:217–258  ·  view source on GitHub ↗
(p *tree.Plan)

Source from the content-addressed store, hash-verified

215}
216
217func (tb *Table) MakeHeader(p *tree.Plan) {
218 tree.AddAt(p, "header", func(w *core.Frame) {
219 core.ToolbarStyles(w)
220 w.Styler(func(s *styles.Style) {
221 s.Grow.Set(0, 0)
222 s.Gap.Set(units.Em(0.5)) // matches grid default
223 })
224 w.Maker(func(p *tree.Plan) {
225 if tb.ShowIndexes {
226 tree.AddAt(p, "head-index", func(w *core.Text) { // TODO: is not working
227 w.SetType(core.TextBodyMedium)
228 w.Styler(func(s *styles.Style) {
229 s.Align.Self = styles.Center
230 })
231 w.SetText("Index")
232 })
233 }
234 for fli := 0; fli < tb.NCols; fli++ {
235 field := tb.Table.Table.ColumnNames[fli]
236 tree.AddAt(p, "head-"+field, func(w *core.Button) {
237 w.SetType(core.ButtonMenu)
238 w.SetText(field)
239 w.OnClick(func(e events.Event) {
240 tb.SortSliceAction(fli)
241 })
242 w.Updater(func() {
243 field := tb.Table.Table.ColumnNames[fli]
244 w.SetText(field).SetTooltip(field + " (tap to sort by)")
245 tb.headerWidths[fli] = len(field)
246 if fli == tb.SortIndex {
247 if tb.SortDescending {
248 w.SetIcon(icons.KeyboardArrowDown)
249 } else {
250 w.SetIcon(icons.KeyboardArrowUp)
251 }
252 }
253 })
254 })
255 }
256 })
257 })
258}
259
260// SliceHeader returns the Frame header for slice grid
261func (tb *Table) SliceHeader() *core.Frame {

Callers 1

InitMethod · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 13

SortSliceActionMethod · 0.95
AddAtFunction · 0.92
ToolbarStylesFunction · 0.92
EmFunction · 0.92
StylerMethod · 0.80
MakerMethod · 0.80
UpdaterMethod · 0.80
SetTooltipMethod · 0.80
SetMethod · 0.65
SetIconMethod · 0.65
SetTypeMethod · 0.45
SetTextMethod · 0.45

Tested by

no test coverage detected