mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Clarify the purpose of removedOffset
This commit is contained in:
parent
6a252d86fd
commit
2c77f8cba9
@ -39,11 +39,19 @@ 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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user