MCPcopy
hub / github.com/g3n/engine / maxFirst

Method maxFirst

gui/itemscroller.go:509–550  ·  view source on GitHub ↗

maxFirst returns the maximum position of the first visible item

()

Source from the content-addressed store, hash-verified

507
508// maxFirst returns the maximum position of the first visible item
509func (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
553func (s *ItemScroller) setVScrollBar(state bool) {

Callers 5

SetFirstMethod · 0.95
ScrollDownMethod · 0.95
vRecalcMethod · 0.95
hRecalcMethod · 0.95
onScrollBarEventMethod · 0.95

Calls 3

HeightMethod · 0.65
GetPanelMethod · 0.65
WidthMethod · 0.65

Tested by

no test coverage detected