Clarify the purpose of removedOffset

This commit is contained in:
Fingercomp 2025-09-03 18:39:56 +03:00
parent 6a252d86fd
commit 2c77f8cba9
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37

View File

@ -39,10 +39,18 @@ abstract class LogWidget extends Widget {
} }
} }
// when entries are removed from the head, all consecutive entries need to be shifted up.
// doing that for every single removal is **very** inefficient.
// instead, we keep the widgets where they are without shifting, having the offset accumulate, and update their
// positions only once per frame (in `draw`).
private def removedOffset: Float = entries.headOption.map(_.y - EntryMargin).getOrElse(0) private def removedOffset: Float = entries.headOption.map(_.y - EntryMargin).getOrElse(0)
private def applyRemovedOffset(): Unit = { private def applyRemovedOffset(): Unit = {
val offset = removedOffset val offset = removedOffset
if (offset == 0) {
return
}
for (entry <- entries) { for (entry <- entries) {
entry.y -= offset entry.y -= offset