mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-13 08:28:51 +01:00
...
This commit is contained in:
parent
fa855f9ca8
commit
598a93d684
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/muka/go-bluetooth/bluez/profile"
|
"github.com/muka/go-bluetooth/bluez/profile"
|
||||||
|
|
||||||
|
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||||
)
|
)
|
||||||
|
|
||||||
func showDeviceInfo(dev *bleapi.Device) {
|
func showDeviceInfo(dev *bleapi.Device) {
|
||||||
@ -534,7 +535,7 @@ func (self *BluetoothPage) GenNetworkList() {
|
|||||||
start_y := 0
|
start_y := 0
|
||||||
|
|
||||||
|
|
||||||
for i v := range self.Devices {
|
for i v := range self.Devices { // v == bleapi.Device
|
||||||
|
|
||||||
props, err := v.GetProperties()
|
props, err := v.GetProperties()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -551,7 +552,8 @@ func (self *BluetoothPage) GenNetworkList() {
|
|||||||
ni.FontObj = self.ListFontObj
|
ni.FontObj = self.ListFontObj
|
||||||
ni.Path = v.Path
|
ni.Path = v.Path
|
||||||
ni.Props = props
|
ni.Props = props
|
||||||
|
ni.Parent = self
|
||||||
|
ni.Device = &v
|
||||||
if props.Name != "" {
|
if props.Name != "" {
|
||||||
ni.Init(props.Name)
|
ni.Init(props.Name)
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@ -2,8 +2,9 @@ package Bluetooth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
||||||
|
bleapi "github.com/muka/go-bluetooth/api"
|
||||||
"github.com/muka/go-bluetooth/bluez/profile"
|
"github.com/muka/go-bluetooth/bluez/profile"
|
||||||
|
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||||
)
|
)
|
||||||
var NetItemDefaultHeight = 30
|
var NetItemDefaultHeight = 30
|
||||||
|
|
||||||
@ -67,9 +68,10 @@ type NetItem struct {
|
|||||||
FontObj *ttf.Font
|
FontObj *ttf.Font
|
||||||
RSSI int // 0
|
RSSI int // 0
|
||||||
MacAddr string //
|
MacAddr string //
|
||||||
|
Parent *BluetoothPage
|
||||||
Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26
|
Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26
|
||||||
Props *profile.Device1Properties
|
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)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user