()
| 3493 | } |
| 3494 | |
| 3495 | func (s *Scrollbar) Draw() { |
| 3496 | |
| 3497 | s.MouseClose = false |
| 3498 | |
| 3499 | if s.Rect.W < 0 || s.Rect.H < 0 { |
| 3500 | return |
| 3501 | } |
| 3502 | |
| 3503 | mousePos := globals.Mouse.Position() |
| 3504 | if s.WorldSpace { |
| 3505 | mousePos = globals.Mouse.WorldPosition() |
| 3506 | } |
| 3507 | |
| 3508 | s.MouseClose = mousePos.DistanceToRect(s.Rect) <= 16 |
| 3509 | |
| 3510 | if s.DrawOnlyWhenMouseIsClose && !s.MouseClose { |
| 3511 | return |
| 3512 | } |
| 3513 | |
| 3514 | sr := *s.Rect |
| 3515 | rect := &sr |
| 3516 | if s.WorldSpace { |
| 3517 | rect = globals.Project.Camera.TranslateRect(rect) |
| 3518 | } |
| 3519 | |
| 3520 | //Outline |
| 3521 | FillRect(rect.X+2, rect.Y+2, rect.W-4, rect.H-4, getThemeColor(GUIFontColor)) |
| 3522 | |
| 3523 | //Inside |
| 3524 | FillRect(rect.X+4, rect.Y+(s.Rect.H-rect.H)/2+4, rect.W-8, rect.H-8, getThemeColor(GUIMenuColor)) |
| 3525 | |
| 3526 | headRect := *rect |
| 3527 | |
| 3528 | if s.Vertical() { |
| 3529 | |
| 3530 | // head |
| 3531 | scroll := s.Rect.H*s.Value - (12 * s.Value) |
| 3532 | headRect.X = rect.X + 4 |
| 3533 | headRect.Y = rect.Y + 4 + scroll |
| 3534 | headRect.W = rect.W - 8 |
| 3535 | headRect.H = 4 |
| 3536 | FillRect(headRect.X, headRect.Y, headRect.W, headRect.H, getThemeColor(GUIFontColor)) |
| 3537 | |
| 3538 | } else { |
| 3539 | |
| 3540 | // head |
| 3541 | scroll := s.Rect.W*s.Value - (12 * s.Value) |
| 3542 | |
| 3543 | headRect.X = rect.X + 4 + scroll |
| 3544 | headRect.Y = rect.Y + 4 |
| 3545 | headRect.W = 4 |
| 3546 | headRect.H = rect.H - 8 |
| 3547 | |
| 3548 | FillRect(headRect.X, headRect.Y, headRect.W, headRect.H, getThemeColor(GUIFontColor)) |
| 3549 | |
| 3550 | } |
| 3551 | |
| 3552 | s.Highlighter.Draw() |
nothing calls this directly
no test coverage detected