maxFirst returns the maximum position of the first visible item
()
| 507 | |
| 508 | // maxFirst returns the maximum position of the first visible item |
| 509 | func (s *ItemScroller) maxFirst() int { |
| 510 | |
| 511 | // Vertical scroller |
| 512 | if s.vert { |
| 513 | var height float32 |
| 514 | pos := len(s.items) - 1 |
| 515 | if pos < 0 { |
| 516 | return 0 |
| 517 | } |
| 518 | for { |
| 519 | item := s.items[pos] |
| 520 | height += item.GetPanel().Height() |
| 521 | if height > s.Height() { |
| 522 | break |
| 523 | } |
| 524 | pos-- |
| 525 | if pos < 0 { |
| 526 | break |
| 527 | } |
| 528 | } |
| 529 | return pos + 1 |
| 530 | } |
| 531 | |
| 532 | // Horizontal scroller |
| 533 | var width float32 |
| 534 | pos := len(s.items) - 1 |
| 535 | if pos < 0 { |
| 536 | return 0 |
| 537 | } |
| 538 | for { |
| 539 | item := s.items[pos] |
| 540 | width += item.GetPanel().Width() |
| 541 | if width > s.Width() { |
| 542 | break |
| 543 | } |
| 544 | pos-- |
| 545 | if pos < 0 { |
| 546 | break |
| 547 | } |
| 548 | } |
| 549 | return pos + 1 |
| 550 | } |
| 551 | |
| 552 | // setVScrollBar sets the visibility state of the vertical scrollbar |
| 553 | func (s *ItemScroller) setVScrollBar(state bool) { |
no test coverage detected