gui: avoid high CPU usage while waiting for input

- add a timeout to ev_get
- set timeout to 1 second when idle
- delay timeout for 15 frames to keep animation objects working
- stop kinetic scrolling immediately at end of list

Change-Id: I77138055c464b65b71e296f9c7ef63ea06809bc1
This commit is contained in:
that
2015-02-09 16:53:21 +01:00
committed by Dees Troy
parent 3f15be40aa
commit de72b6d4d8
4 changed files with 28 additions and 15 deletions
+5 -1
View File
@@ -632,8 +632,10 @@ void GUIScrollList::HandleScrolling()
firstDisplayedItem--;
y_offset -= actualItemHeight;
}
if (firstDisplayedItem == 0 && y_offset > 0)
if (firstDisplayedItem == 0 && y_offset > 0) {
y_offset = 0; // user kept dragging downward past the top of the list, so always reset the offset to 0 since we can't scroll any further in this direction
scrollingSpeed = 0; // stop kinetic scrolling
}
// handle dragging upward, scrolling downward
int totalSize = GetItemCount();
@@ -649,9 +651,11 @@ void GUIScrollList::HandleScrolling()
if (bottom_offset != 0 && firstDisplayedItem + lines + 1 >= totalSize && y_offset <= bottom_offset) {
firstDisplayedItem = totalSize - lines - 1;
y_offset = bottom_offset;
scrollingSpeed = 0; // stop kinetic scrolling
} else if (firstDisplayedItem + lines >= totalSize && y_offset < 0) {
firstDisplayedItem = totalSize - lines;
y_offset = 0;
scrollingSpeed = 0; // stop kinetic scrolling
}
}