bluetooth alpha

This commit is contained in:
cuu
2018-12-18 19:14:00 +08:00
parent 78522c4b46
commit f4e4ff3921
6 changed files with 106 additions and 50 deletions

View File

@@ -250,6 +250,8 @@ func (self *FavListPage) ScrollUp() {
if y < 0 {
for i,_ := range self.MyList{
x,y = self.MyList[i].Coord()
_, h = self.MyList[i].Size()
self.MyList[i].NewCoord(x, y + h)
}
@@ -273,6 +275,8 @@ func (self *FavListPage) ScrollDown(){
_,h := cur_li.Size()
if y + h > self.Height {
for i,_ := range self.MyList{
x,y = self.MyList[i].Coord()
_, h = self.MyList[i].Size()
self.MyList[i].NewCoord(x,y-h)
}
self.Scrolled -=1

View File

@@ -227,6 +227,7 @@ func (self *EmulatorListItem) Draw() {
x,y := self.Labels["Text"].Coord()
_,h := self.Labels["Text"].Size()
if self.Path != "[..]" {
self.Labels["Text"].NewCoord(23,y)

View File

@@ -74,7 +74,7 @@ func (self *RomListPage) GeneratePathList(path string) ([]map[string]string,erro
if UI.IsDirectory(path) == false {
return nil,errors.New("Path is not a folder")
}
dirmap := make(map[string]string)
var ret []map[string]string
file_paths,err := filepath.Glob(path+"/*")//sorted
@@ -82,8 +82,9 @@ func (self *RomListPage) GeneratePathList(path string) ([]map[string]string,erro
fmt.Println(err)
return ret,err
}
for _,v := range file_paths {
dirmap := make(map[string]string)
if UI.IsDirectory(v) && self.EmulatorConfig.FILETYPE == "dir" { // like DOSBOX
gameshell_bat := self.EmulatorConfig.EXT[0]
if UI.GetGid(v) == FavGID { // skip fav roms
@@ -139,7 +140,7 @@ func (self *RomListPage) GeneratePathList(path string) ([]map[string]string,erro
func (self *RomListPage) SyncList( path string ) {
alist,err := self.GeneratePathList(path)
//fmt.Println(alist)
if err != nil {
fmt.Println(err)
return
@@ -191,7 +192,6 @@ func (self *RomListPage) SyncList( path string ) {
}
li.Init(init_val)
self.MyList = append(self.MyList,li)
}
}
@@ -276,6 +276,8 @@ func (self *RomListPage) ScrollUp() {
_,h := cur_li.Size()
if y < 0 {
for i,_ := range self.MyList{
x,y = self.MyList[i].Coord()
_, h = self.MyList[i].Size()
self.MyList[i].NewCoord(x,y + h)
}
@@ -300,6 +302,8 @@ func (self *RomListPage) ScrollDown(){
if y+ h > self.Height {
for i,_ := range self.MyList{
x,y = self.MyList[i].Coord()
_, h = self.MyList[i].Size()
self.MyList[i].NewCoord(x,y - h)
}
self.Scrolled -=1
@@ -538,28 +542,20 @@ func (self *RomListPage) Draw() {
}else{
_,h := self.Ps.Size()
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
self.Ps.NewSize(self.Width - 10,h)
self.Ps.Draw()
for _,v := range self.MyList {
_,y := v.Coord()
if y > self.Height + self.Height/2 {
if y > (self.Height + self.Height/2) {
break
}
if y < 0 {
continue
}
v.Draw()
}
self.Scroller.UpdateSize( len(self.MyList)*HierListItemDefaultHeight, self.PsIndex*HierListItemDefaultHeight)
self.Scroller.Draw()
}else {
self.Ps.NewSize(self.Width,h)
self.Ps.Draw()

View File

@@ -291,6 +291,25 @@ func (self *TitleBar) SetBatteryStat( bat int) {
}
func (self *TitleBar) CheckBluetooth() {
out := System("hcitool dev | grep hci0 |cut -f3")
if len(out) < 17 {
fmt.Println("Titlebar CheckBluetooth: no bluetooth",out)
self.Icons["bluetooth"].SetIconIndex(2)
return
}else {
out = System("sudo rfkill list | grep hci0 -A 2 | grep yes")
if len(out) > 10 {
self.Icons["bluetooth"].SetIconIndex(1)
return
}
}
self.Icons["bluetooth"].SetIconIndex(0)
}
func (self *TitleBar) Init(main_screen *MainScreen) {
start_x := 0
@@ -346,6 +365,16 @@ func (self *TitleBar) Init(main_screen *MainScreen) {
self.SyncSoundVolume()
bluetooth := NewTitleBarIconItem()
bluetooth.MyType = ICON_TYPES["STAT"]
bluetooth.Parent = self
bluetooth.ImageName = self.icon_base_path+"bluetooth.png"
bluetooth.Adjust(start_x+self.IconWidth+self.IconWidth+8,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2,self.IconWidth,self.IconHeight,0)
self.Icons["bluetooth"] = bluetooth
self.CheckBluetooth()
round_corners := NewTitleBarIconItem()
round_corners.IconWidth = 10
round_corners.IconHeight = 10
@@ -410,6 +439,8 @@ func (self *TitleBar) Draw(title string) {
surface.Blit(self.CanvasHWND, time_text_surf, draw.MidRect(Width-time_text_w/2-self.ROffset, time_text_h/2+(self.BarHeight-time_text_h)/2, time_text_w,time_text_h,Width,Height),nil)
start_x := Width - time_text_w - self.ROffset - self.IconWidth*3 // close to the time_text
self.Icons["bluetooth"].NewCoord(start_x - self.IconWidth,self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
self.Icons["sound"].NewCoord( start_x, self.IconHeight/2+ (self.BarHeight-self.IconHeight)/2)
self.Icons["battery"].NewCoord(start_x+self.IconWidth+self.IconWidth+8, self.IconHeight/2+(self.BarHeight-self.IconHeight)/2)
@@ -435,7 +466,8 @@ func (self *TitleBar) Draw(title string) {
self.Icons["sound"].Draw()
self.Icons["battery"].Draw()
self.Icons["bluetooth"].Draw()
draw.Line(self.CanvasHWND,self.SkinManager.GiveColor("Line"), 0,self.BarHeight,self.Width,self.BarHeight, self.BorderWidth)