This commit is contained in:
cuu 2023-01-17 23:33:46 +00:00
parent 0e62938403
commit 529f1d1b83
3 changed files with 91 additions and 11 deletions

View File

@ -221,9 +221,13 @@ func (self *MusicLibListPage) Click() {
}
if cur_li.MyType == UI.ICON_TYPES["FILE"] {
//addfile(cur_li.Path)
//PlayListPage.SyncList()
//print("add" , cur_li._Path)
conn := self.Parent.MpdClient
conn.Add(cur_li.Path)
self.Parent.SyncList()
//addfile(cur_li.Path)
//PlayListPage.SyncList()
//print("add" , cur_li._Path)
}
self.Screen.Draw()

View File

@ -93,6 +93,59 @@ func (self *MusicPlayerPage) SetLabels() {
}
func (self *MusicPlayerPage) SyncList() {
conn := self.MpdClient
start_x := 0
start_y := 0
if conn == nil {
return
}
self.MyList = nil
play_list,_ := conn.PlaylistInfo(-1,-1)
for i,v := range play_list {
li := NewMusicPlayPageListItem()
li.Parent = self
li.PosX = start_x
li.PosY = start_y + UI.DefaultInfoPageListItemHeight * i
li.Width = UI.Width
li.Fonts["normal"] = self.ListFontObj
if val,ok:=v["Title"]; ok {
li.Init(val)
if val2,ok2 := v["file"]; ok2 {
li.Path = val2
}
}else {
if val2,ok2 := v["file"]; ok2 {
li.Init(filepath.Base(val2))
li.Path = val2
}else{
li.Init("NoName")
}
}
li.Labels["Text"].PosX = 7
self.MyList = append(self.MyList, li)
}
self.SyncPlaying()
}
func (self *MusicPlayerPage) SyncPlaying() {
conn := self.MpdClient
for i,_ := range self.MyList {
self.MyList[i].(*MusicPlayPageListItem).Active = false
self.MyList[i].(*MusicPlayPageListItem).PlayingProcess = 0
}
}
func (self *MusicPlayerPage) Init() {
if self.Screen == nil {
panic("No Screen")

View File

@ -27,6 +27,8 @@ type MusicPlayPageListItem struct {
Value string
MyType int
Path string
PlayingProcess int
}
func NewMusicPlayPageListItem() *MusicPlayPageListItem {
@ -47,15 +49,30 @@ func (self *MusicPlayPageListItem) Draw() {
w, h := self.Labels["Text"].Size()
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
if self.Active == true {
self.Parent.(*MusicPlayerPage).Icons["sys"].NewCoord(self.Parent.(*MusicPlayerPage).Width-30, self.PosY+5)
self.Parent.(*MusicPlayerPage).Icons["sys"].Draw()
}
if self.MyType == UI.ICON_TYPES["DIR"] && self.Path != "[..]" {
sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"]
sys_icon.IconIndex = 0.
sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - sys_icon.Height)/2 + sys_icon.Height /2)
sys_icon.Draw()
}
if self.MyType == UI.ICON_TYPES["FILE"] {
sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"]
sys_icon.IconIndex = 1
sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - sys_icon.Height)/2 + sys_icon.Height /2)
sys_icon.Draw()
}
self.Labels["Text"].Active = self.Active
self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
self.Labels["Text"].SetBold(self.Active)
self.Labels["Text"].Draw()
/*
if _, ok := self.Labels["Small"]; ok {
x, _ = self.Labels["Small"].Coord()
w, h = self.Labels["Small"].Size()
@ -64,10 +81,16 @@ func (self *MusicPlayPageListItem) Draw() {
self.Labels["Small"].Draw()
}
canvas_ := self.Parent.GetCanvasHWND()
draw.Line(canvas_, &color.Color{169, 169, 169, 255},
*/
canvas_ := self.Parent.GetCanvasHWND()
draw.Line(canvas_, UI.MySkinManager.GiveColor("Line"),
self.PosX, self.PosY+self.Height-1,
self.PosX+self.Width, self.PosY+self.Height-1, 1)
if self.PlayingProcess > 0 {
seek_posx := int(self.Width * self.PlayingProcess/100.0)
draw.Line(canvas_, UI.MySkinManager.GiveColor("Active"),
self.PosX, self.PosY+self.Height-2,
self.PosX+seek_posx, self.PosY+self.Height-2, 2)
}
}