Files
LinuxPA/prtapAdap.go
T
Belac Darkstorm f2621afdda Initial Upload
Has basic functionality, still need to work on some stuff though
2016-08-31 08:39:58 -05:00

55 lines
966 B
Go

package main
import (
"github.com/nelsam/gxui"
"github.com/nelsam/gxui/math"
)
type prtapAdap struct {
gxui.AdapterBase
apps []prtap
}
func (p *prtapAdap) SetApps(apps []prtap) {
p.apps = apps
p.DataChanged(false)
}
func (p *prtapAdap) Count() int {
return len(p.apps)
}
func (p *prtapAdap) Create(th gxui.Theme, index int) gxui.Control {
box := th.CreateLinearLayout()
box.SetDirection(gxui.LeftToRight)
// pic := th.CreateImage()
// dr.CreateTexture()
//add image support
lbl := th.CreateLabel()
lbl.SetText(p.apps[index].name)
// box.AddChild(pic)
box.AddChild(lbl)
return box
}
func (p *prtapAdap) ItemAt(index int) gxui.AdapterItem {
return p.apps[index]
}
func (p *prtapAdap) ItemIndex(item gxui.AdapterItem) int {
it, ok := item.(prtap)
if !ok {
return -1
}
for i, v := range p.apps {
if v == it {
return i
}
}
return -1
}
func (p *prtapAdap) Size(gxui.Theme) math.Size {
return math.Size{W: math.MaxSize.W, H: 20}
}