music_lib_list_page_list_item.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 MusicLibListPageListItem struct {
  21. UI.InfoPageListItem
  22. Active bool
  23. Value string
  24. MyType int
  25. Path string
  26. }
  27. func NewMusicLibListPageListItem() *MusicLibListPageListItem {
  28. p := &MusicLibListPageListItem{}
  29. p.Height = UI.DefaultInfoPageListItemHeight
  30. p.ReadOnly = false
  31. p.Labels = make(map[string]UI.LabelInterface)
  32. p.Icons = make(map[string]UI.IconItemInterface)
  33. p.Fonts = make(map[string]*ttf.Font)
  34. p.MyType = UI.ICON_TYPES["EXE"]
  35. return p
  36. }
  37. func (self *MusicLibListPageListItem) Init(text string) {
  38. l := UI.NewLabel()
  39. l.PosX = 10
  40. l.SetCanvasHWND(self.Parent.GetCanvasHWND())
  41. l.Init(text, self.Fonts["normal"], nil)
  42. self.Labels["Text"] = l
  43. }
  44. func (self *MusicLibListPageListItem) Draw() {
  45. x, _ := self.Labels["Text"].Coord()
  46. w, h := self.Labels["Text"].Size()
  47. self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
  48. if self.MyType == UI.ICON_TYPES["DIR"] && self.Path != "[..]" {
  49. sys_icon := self.Parent.(*MusicLibListPage).Icons["sys"]
  50. sys_icon.SetIconIndex(0)
  51. _,h := sys_icon.Size()
  52. sys_icon.NewCoord(self.Width - 12,self.PosY+ (self.Height - h)/2+h/2)
  53. sys_icon.Draw()
  54. }
  55. if self.MyType == UI.ICON_TYPES["FILE"] {
  56. sys_icon := self.Parent.(*MusicLibListPage).Icons["sys"]
  57. sys_icon.SetIconIndex(1)
  58. _,h := sys_icon.Size()
  59. sys_icon.NewCoord(self.Width-12,self.PosY+ (self.Height - h)/2+h/2)
  60. sys_icon.Draw()
  61. }
  62. /*
  63. if self.Active == true {
  64. self.Parent.(*MusicLibListPage).Icons["sys"].NewCoord(self.Parent.(*MusicLibListPage).Width-30, self.PosY+5)
  65. self.Parent.(*MusicLibListPage).Icons["sys"].Draw()
  66. }
  67. */
  68. self.Labels["Text"].SetBold(self.Active)
  69. self.Labels["Text"].Draw()
  70. if _, ok := self.Labels["Small"]; ok {
  71. x, _ = self.Labels["Small"].Coord()
  72. w, h = self.Labels["Small"].Size()
  73. self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
  74. self.Labels["Small"].Draw()
  75. }
  76. canvas_ := self.Parent.GetCanvasHWND()
  77. draw.Line(canvas_, &color.Color{169, 169, 169, 255},
  78. self.PosX, self.PosY+self.Height-1,
  79. self.PosX+self.Width, self.PosY+self.Height-1, 1)
  80. }