I happen to come across a problem with update method of ListViewPort. I have a listBox, and if 2 rows are displayed completely and the third row isn't displayed completely the current code would delete the components of the third row and re-create them since they are partially visible.
In void updateContents();
const int numNeeded = 2 + getMaximumVisibleHeight() / rowHeight;
Both getMaximumVisibleHeight() and rowHeight are integers and their division will return integer. So if two and half rows are visible, this code would assume calculate it to 2 rows and the third row will be deleted and again created.
If you change the code to this
const int numNeeded = std::ceil( ( 2 + getMaximumVisibleHeight() ) /(float) rowHeight);
it would not delete a row if it’s partially visible.
Secondly shouldn’t there be a bracket since division has higher priority hence “getMaximumVisibleHeight()/rowHeight” would be done first and then 2 will be added.( I am assuming that 2 there is 2 pixel and not row rows)