diff --git a/Menu/GameShell/10_Settings/Blueutooth/bluetooth_page.go b/Menu/GameShell/10_Settings/Blueutooth/bluetooth_page.go index 9db5ec7..1995359 100644 --- a/Menu/GameShell/10_Settings/Blueutooth/bluetooth_page.go +++ b/Menu/GameShell/10_Settings/Blueutooth/bluetooth_page.go @@ -10,7 +10,8 @@ import ( bleapi "github.com/muka/go-bluetooth/api" "github.com/muka/go-bluetooth/bluez/profile" - + + "github.com/cuu/LauncherGoDev/sysgo/UI" ) func showDeviceInfo(dev *bleapi.Device) { @@ -534,7 +535,7 @@ func (self *BluetoothPage) GenNetworkList() { start_y := 0 - for i v := range self.Devices { + for i v := range self.Devices { // v == bleapi.Device props, err := v.GetProperties() if err != nil { @@ -551,7 +552,8 @@ func (self *BluetoothPage) GenNetworkList() { ni.FontObj = self.ListFontObj ni.Path = v.Path ni.Props = props - + ni.Parent = self + ni.Device = &v if props.Name != "" { ni.Init(props.Name) }else { diff --git a/Menu/GameShell/10_Settings/Blueutooth/net_item.go b/Menu/GameShell/10_Settings/Blueutooth/net_item.go index 5e490d4..f43492b 100644 --- a/Menu/GameShell/10_Settings/Blueutooth/net_item.go +++ b/Menu/GameShell/10_Settings/Blueutooth/net_item.go @@ -2,8 +2,9 @@ package Bluetooth import ( + bleapi "github.com/muka/go-bluetooth/api" "github.com/muka/go-bluetooth/bluez/profile" - + "github.com/cuu/LauncherGoDev/sysgo/UI" ) var NetItemDefaultHeight = 30 @@ -67,9 +68,10 @@ type NetItem struct { FontObj *ttf.Font RSSI int // 0 MacAddr string // - + Parent *BluetoothPage Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26 Props *profile.Device1Properties + Device *bleapi.Device } @@ -92,8 +94,61 @@ func (self *NetItem) SetActive(act bool) { } -func (self *NetItem) Init(path string ) { +func (self *NetItem) Init( _label string) { + self.MacAddr = self.Props.Address + self.SetActive(self.Props.Connected) + + + name_label := UI.NewLabel() + name_label.PosX = 12 + + name_label.CanvasHWND = self.Parent.CanvasHWND + + mac_addr := self.MacAddr + if len(self.Props.Name) > 3 { + mac_addr = self.Props.Name + } + + self.RSSI = int(self.Props.RSSI) + + name_label.Init(mac_addr,self.FontObj,nil) + + self.Labels["mac_addr"] = name_label + + done_icon := NewNetItemIcon() + done_icon.ImgSurf = UI.MyIconPool.GetImgSurf("done") + done_icon.CanvasHWND = self.Parent.GetCanvasHWND() + done_icon.Parent = self + self.Icons["done"] = done_icon } + +func (self *NetItem) Connect() { + + if self.Device != nil { + self.Device.Connect() + } +} + + +func (self *NetItem) Draw() { + for k,v := range self.Labels { + x,y := v.Coord() + _,h := v.Size() + self.Labels[k].NewCoord(x, self.PosY+(self.Height - h)/2) + self.Labels[k].Draw() + } + + if self.IsActive { + self.Icons["done"].NewCoord(UI.Width-22, self.PosY) + self.Icons["done"].Draw() + } + + draw.Line(self.Parent.CanvasHWND,&color.Color{169,169,169,255}, + self.PosX,self.PosY+self.Height-1, + self.PosX+self.Width,self.PosY+self.Height-1, + 1) + +}