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

Method recalc

gui/table.go:1310–1354  ·  view source on GitHub ↗

recalc calculates the visibility, positions and sizes of all row cells. should be called in the following situations: - the table is resized - row is added, inserted or removed - column alignment and expansion changed - column visibility is changed - horizontal or vertical scroll position changed

()

Source from the content-addressed store, hash-verified

1308// - column visibility is changed
1309// - horizontal or vertical scroll position changed
1310func (t *Table) recalc() {
1311
1312 // Get available row height for rows
1313 starty, theight := t.rowsHeight()
1314
1315 // Determines if it is necessary to show the scrollbar or not.
1316 scroll := false
1317 py := starty
1318 for ri := 0; ri < len(t.rows); ri++ {
1319 trow := t.rows[ri]
1320 py += trow.height
1321 if py > starty+theight {
1322 scroll = true
1323 break
1324 }
1325 }
1326 t.setVScrollBar(scroll)
1327 // Recalculates the header
1328 t.recalcHeader()
1329
1330 // Sets the position and sizes of all cells of the visible rows
1331 py = starty
1332 for ri := 0; ri < len(t.rows); ri++ {
1333 trow := t.rows[ri]
1334 // If row is before first row or its y coordinate is greater the table height,
1335 // sets it invisible
1336 if ri < t.firstRow || py > starty+theight {
1337 trow.SetVisible(false)
1338 continue
1339 }
1340 t.recalcRow(ri)
1341 // Set row y position and visible
1342 trow.SetPosition(0, py)
1343 trow.SetVisible(true)
1344 t.updateRowStyle(ri)
1345 // Set the last completely visible row index
1346 if py+trow.Height() <= starty+theight {
1347 t.lastRow = ri
1348 }
1349 //log.Error("ri:%v py:%v theight:%v", ri, py, theight)
1350 py += trow.height
1351 }
1352 // Status panel must be on top of all the row panels
1353 t.SetTopChild(&t.statusPanel)
1354}
1355
1356// recalcRow recalculates the positions and sizes of all cells of the specified row
1357// Should be called when the row is created and column visibility or order is changed.

Callers 15

SetStylesMethod · 0.95
ShowHeaderMethod · 0.95
ShowColumnMethod · 0.95
ShowAllColumnsMethod · 0.95
SetRowsMethod · 0.95
SetRowMethod · 0.95
SetCellMethod · 0.95
SetColOrderMethod · 0.95
SetColExpandMethod · 0.95
InsertRowMethod · 0.95
RemoveRowMethod · 0.95
ClearMethod · 0.95

Calls 9

rowsHeightMethod · 0.95
setVScrollBarMethod · 0.95
recalcHeaderMethod · 0.95
recalcRowMethod · 0.95
updateRowStyleMethod · 0.95
SetTopChildMethod · 0.80
SetVisibleMethod · 0.65
SetPositionMethod · 0.65
HeightMethod · 0.65

Tested by

no test coverage detected