music_player_page_list_item.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package MusicPlayer
  2. import (
  3. //"fmt"
  4. //"io/ioutil"
  5. //"path/filepath"
  6. "github.com/veandco/go-sdl2/ttf"
  7. //"runtime"
  8. //"strconv"
  9. //"strings"
  10. //"github.com/mitchellh/go-homedir"
  11. //"github.com/clockworkpi/LauncherGoDev/sysgo"
  12. "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
  13. //"github.com/cuu/gogame/color"
  14. "github.com/cuu/gogame/draw"
  15. //"github.com/cuu/gogame/event"
  16. //"github.com/cuu/gogame/rect"
  17. //"github.com/cuu/gogame/surface"
  18. //"github.com/cuu/gogame/time"
  19. )
  20. type MusicPlayPageListItem struct {
  21. UI.InfoPageListItem
  22. Active bool
  23. Value string
  24. MyType int
  25. Path string
  26. State string
  27. PlayingProcess int
  28. }
  29. func NewMusicPlayPageListItem() *MusicPlayPageListItem {
  30. p := &MusicPlayPageListItem{}
  31. p.Height = UI.DefaultInfoPageListItemHeight
  32. p.ReadOnly = false
  33. p.Labels = make(map[string]UI.LabelInterface)
  34. p.Icons = make(map[string]UI.IconItemInterface)
  35. p.Fonts = make(map[string]*ttf.Font)
  36. p.MyType = UI.ICON_TYPES["EXE"]
  37. return p
  38. }
  39. func (self *MusicPlayPageListItem) Init(text string) {
  40. l := UI.NewLabel()
  41. l.PosX = 10
  42. l.SetCanvasHWND(self.Parent.GetCanvasHWND())
  43. l.Init(text, self.Fonts["normal"], nil)
  44. self.Labels["Text"] = l
  45. }
  46. func (self *MusicPlayPageListItem) Draw() {
  47. x, _ := self.Labels["Text"].Coord()
  48. _, h := self.Labels["Text"].Size()
  49. self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
  50. if self.MyType == UI.ICON_TYPES["DIR"] && self.Path != "[..]" {
  51. sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"]
  52. _,h := sys_icon.Size()
  53. sys_icon.SetIconIndex(0)
  54. sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - h)/2 + h/2)
  55. sys_icon.Draw()
  56. }
  57. if self.MyType == UI.ICON_TYPES["FILE"] {
  58. sys_icon := self.Parent.(*MusicPlayerPage).Icons["sys"]
  59. _,h := sys_icon.Size()
  60. sys_icon.SetIconIndex(1)
  61. sys_icon.NewCoord(self.PosX+12,self.PosY + ( self.Height - h)/2 + h /2)
  62. sys_icon.Draw()
  63. }
  64. self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
  65. self.Labels["Text"].SetBold(self.Active)
  66. self.Labels["Text"].Draw()
  67. /*
  68. if _, ok := self.Labels["Small"]; ok {
  69. x, _ = self.Labels["Small"].Coord()
  70. w, h = self.Labels["Small"].Size()
  71. self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
  72. self.Labels["Small"].Draw()
  73. }
  74. */
  75. canvas_ := self.Parent.GetCanvasHWND()
  76. draw.Line(canvas_, UI.MySkinManager.GiveColor("Line"),
  77. self.PosX, self.PosY+self.Height-1,
  78. self.PosX+self.Width, self.PosY+self.Height-1, 1)
  79. if self.PlayingProcess > 0 {
  80. seek_posx := int(self.Width * self.PlayingProcess/100.0)
  81. draw.Line(canvas_, UI.MySkinManager.GiveColor("Active"),
  82. self.PosX, self.PosY+self.Height-2,
  83. self.PosX+seek_posx, self.PosY+self.Height-2, 2)
  84. }
  85. }