slider.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package UI
  2. import (
  3. //"fmt"
  4. //"math"
  5. //"sync"
  6. "github.com/veandco/go-sdl2/sdl"
  7. //"github.com/cuu/gogame/surface"
  8. //"github.com/cuu/gogame/draw"
  9. //"github.com/cuu/gogame/rect"
  10. //"github.com/cuu/gogame/font"
  11. "github.com/cuu/gogame/event"
  12. //"github.com/cuu/gogame/transform"
  13. //"github.com/clockworkpi/LauncherGoDev/sysgo/easings"
  14. )
  15. type SliderInterface interface {
  16. WidgetInterface
  17. Init()
  18. SetValue()
  19. SetRange(m1, m2 int)
  20. SetCanvasHWND(canvas *sdl.Surface)
  21. KeyDown(ev *event.Event)
  22. Draw()
  23. }
  24. type Slider struct {
  25. Widget
  26. Value int
  27. CanvasHWND *sdl.Surface
  28. Range [2]int
  29. }
  30. func NewSlider() *Slider {
  31. p := &Slider{}
  32. p.Range = [2]int{0, 255}
  33. p.Value = 0
  34. return p
  35. }
  36. func (self *Slider) Init() {
  37. self.Value = 0
  38. }
  39. func (self *Slider) SetValue(v int) {
  40. self.Value = v
  41. }
  42. func (self *Slider) SetRange(m1, m2 int) {
  43. if m1 >= m2 {
  44. return
  45. }
  46. self.Range[0] = m1
  47. self.Range[1] = m2
  48. }
  49. func (self *Slider) SetCanvasHWND(canvas *sdl.Surface) {
  50. self.CanvasHWND = canvas
  51. }
  52. func (self *Slider) KeyDown(ev *event.Event) {
  53. }
  54. func (self *Slider) Draw() {
  55. }