music_player_page_list_item.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. }
  27. func NewMusicPlayPageListItem() *MusicPlayPageListItem {
  28. p := &MusicPlayPageListItem{}
  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 *MusicPlayPageListItem) Draw() {
  38. x, _ := self.Labels["Text"].Coord()
  39. w, h := self.Labels["Text"].Size()
  40. self.Labels["Text"].NewCoord(x, self.PosY+(self.Height-h)/2)
  41. if self.Active == true {
  42. self.Parent.(*MusicPlayerPage).Icons["sys"].NewCoord(self.Parent.(*MusicPlayerPage).Width-30, self.PosY+5)
  43. self.Parent.(*MusicPlayerPage).Icons["sys"].Draw()
  44. }
  45. self.Labels["Text"].SetBold(self.Active)
  46. self.Labels["Text"].Draw()
  47. if _, ok := self.Labels["Small"]; ok {
  48. x, _ = self.Labels["Small"].Coord()
  49. w, h = self.Labels["Small"].Size()
  50. self.Labels["Small"].NewCoord(self.Width-w-10, self.PosY+(self.Height-h)/2)
  51. self.Labels["Small"].Draw()
  52. }
  53. canvas_ := self.Parent.GetCanvasHWND()
  54. draw.Line(canvas_, &color.Color{169, 169, 169, 255},
  55. self.PosX, self.PosY+self.Height-1,
  56. self.PosX+self.Width, self.PosY+self.Height-1, 1)
  57. }