(p *tree.Plan)
| 215 | } |
| 216 | |
| 217 | func (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 |
| 261 | func (tb *Table) SliceHeader() *core.Frame { |
no test coverage detected