()
| 4052 | } |
| 4053 | |
| 4054 | func (ds *DraggableSpace) Draw() { |
| 4055 | |
| 4056 | if ds.Max == 0 { |
| 4057 | return |
| 4058 | } |
| 4059 | |
| 4060 | current := ds.Current |
| 4061 | if current > ds.Max { |
| 4062 | current = ds.Max |
| 4063 | } |
| 4064 | if current < ds.Min { |
| 4065 | current = ds.Min |
| 4066 | } |
| 4067 | |
| 4068 | stepWidth := ds.Rect.W / float32(ds.Max-ds.Min) |
| 4069 | dragHandlePoint := Vector{ds.Rect.X + (stepWidth * float32(current)), ds.Rect.Y + ds.Rect.H} |
| 4070 | cursorPos := globals.Mouse.WorldPosition() |
| 4071 | lmb := globals.Mouse.Button(sdl.BUTTON_LEFT) |
| 4072 | |
| 4073 | // if cursorPos.Inside(ds.Rect) && globals.Mouse.WorldPosition().Distance(dragHandlePoint) < 16 { |
| 4074 | |
| 4075 | // For now, we will just check to see if the mouse is close enough to grab the point |
| 4076 | if globals.Mouse.WorldPosition().Distance(dragHandlePoint) < 8 { |
| 4077 | |
| 4078 | globals.Mouse.SetCursor(CursorHand) |
| 4079 | |
| 4080 | if lmb.Pressed() { |
| 4081 | lmb.Consume() |
| 4082 | ds.Dragging = true |
| 4083 | } |
| 4084 | |
| 4085 | } |
| 4086 | |
| 4087 | if lmb.Released() { |
| 4088 | ds.Dragging = false |
| 4089 | } |
| 4090 | |
| 4091 | if ds.Dragging { |
| 4092 | |
| 4093 | globals.Mouse.SetCursor(CursorHandGrab) |
| 4094 | |
| 4095 | ds.NewCurrent = int(math.Round(float64((cursorPos.X - ds.Rect.X) / stepWidth))) |
| 4096 | |
| 4097 | if ds.NewCurrent != ds.Current { |
| 4098 | PlayUISound(UISoundTypeType) |
| 4099 | } |
| 4100 | |
| 4101 | if ds.NewCurrent < ds.Min { |
| 4102 | ds.NewCurrent = ds.Min |
| 4103 | } |
| 4104 | |
| 4105 | if ds.NewCurrent > ds.Max { |
| 4106 | ds.NewCurrent = ds.Max |
| 4107 | } |
| 4108 | |
| 4109 | } |
| 4110 | |
| 4111 | dragHandlePoint = globals.Project.Camera.TranslatePoint(dragHandlePoint) |
nothing calls this directly
no test coverage detected