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

Method setVScrollBar

gui/table.go:1438–1471  ·  view source on GitHub ↗

setVScrollBar sets the visibility state of the vertical scrollbar

(state bool)

Source from the content-addressed store, hash-verified

1436
1437// setVScrollBar sets the visibility state of the vertical scrollbar
1438func (t *Table) setVScrollBar(state bool) {
1439
1440 // Visible
1441 if state {
1442 var scrollWidth float32 = 20
1443 // Creates scroll bar if necessary
1444 if t.vscroll == nil {
1445 t.vscroll = NewVScrollBar(0, 0)
1446 t.vscroll.SetBorders(0, 0, 0, 1)
1447 t.vscroll.Subscribe(OnChange, t.onVScrollBar)
1448 t.Panel.Add(t.vscroll)
1449 }
1450 // Sets the scroll bar size and positions
1451 py, height := t.rowsHeight()
1452 t.vscroll.SetSize(scrollWidth, height)
1453 t.vscroll.SetPositionX(t.ContentWidth() - scrollWidth)
1454 t.vscroll.SetPositionY(py)
1455 t.vscroll.recalc()
1456 t.vscroll.SetVisible(true)
1457 if !t.scrollBarEvent {
1458 maxFirst := t.calcMaxFirst()
1459 t.vscroll.SetValue(float32(t.firstRow) / float32(maxFirst))
1460 } else {
1461 t.scrollBarEvent = false
1462 }
1463 // scroll bar must be on top of all table rows
1464 t.SetTopChild(t.vscroll)
1465 // Not visible
1466 } else {
1467 if t.vscroll != nil {
1468 t.vscroll.SetVisible(false)
1469 }
1470 }
1471}
1472
1473// onVScrollBar is called when a vertical scroll bar event is received
1474func (t *Table) onVScrollBar(evname string, ev interface{}) {

Callers 1

recalcMethod · 0.95

Calls 14

rowsHeightMethod · 0.95
calcMaxFirstMethod · 0.95
NewVScrollBarFunction · 0.85
SetBordersMethod · 0.80
ContentWidthMethod · 0.80
SetTopChildMethod · 0.80
SubscribeMethod · 0.65
SetPositionXMethod · 0.65
SetPositionYMethod · 0.65
SetVisibleMethod · 0.65
AddMethod · 0.45
SetSizeMethod · 0.45

Tested by

no test coverage detected