Added provisions for giving Table columns custom titles. Will now implement.

This commit is contained in:
Pietro Gagliardi 2015-02-21 14:57:21 -05:00
parent d855f5df3f
commit 23e6739dfa
2 changed files with 11 additions and 2 deletions

View File

@ -18,7 +18,8 @@ import (
// Tables are read-only by default, except for checkboxes, which are user-settable. // Tables are read-only by default, except for checkboxes, which are user-settable.
// //
// Tables have headers on top of all columns. // Tables have headers on top of all columns.
// Currently the name of the header is the same as the name of the field. // By default, the name of the header is the same as the name of the field.
// If the struct field has a tag "uicolumn", its value is used as the header string instead.
// //
// Tables maintain their own storage behind a sync.RWMutex-compatible sync.Locker; use Table.Lock()/Table.Unlock() to make changes and Table.RLock()/Table.RUnlock() to merely read values. // Tables maintain their own storage behind a sync.RWMutex-compatible sync.Locker; use Table.Lock()/Table.Unlock() to make changes and Table.RLock()/Table.RUnlock() to merely read values.
type Table interface { type Table interface {

View File

@ -38,6 +38,12 @@ func newSimpleGrid(n int, c ...Control) SimpleGrid {
return g return g
} }
type colnametest struct {
IncorrectColumnName string `uicolumn:"Correct Column Name"`
IncorrectColumnName2 string `uicolumn:"正解なコラムネーム"` // thanks GlitterBerri in irc.badnik.net/#zelda
AlreadyCorrect string
}
type dtype struct { type dtype struct {
Name string Name string
Address string Address string
@ -183,7 +189,9 @@ func (tw *testwin) make(done chan struct{}) {
tw.roenter.OnChanged(func() { tw.roenter.OnChanged(func() {
tw.roro.SetText(tw.roenter.Text()) tw.roro.SetText(tw.roenter.Text())
}) })
tw.t.Append("Read-Only", newVerticalStack(tw.roenter, tw.roro)) s := newVerticalStack(tw.roenter, tw.roro, NewTable(reflect.TypeOf(colnametest{})))
s.SetStretchy(2)
tw.t.Append("Read-Only", s)
tw.icons = readIcons() // repainter uses these tw.icons = readIcons() // repainter uses these
tw.repainter = newRepainter(15) tw.repainter = newRepainter(15)
tw.t.Append("Repaint", tw.repainter.grid) tw.t.Append("Repaint", tw.repainter.grid)