add Steve Hill's scroller synchronization patch

This commit is contained in:
marschap
2006-09-20 15:40:27 +00:00
parent 5e80cfa503
commit f1c194513c
2 changed files with 141 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
Multiple scrollers on the same screen are not synchronised with eachother
- some may be scrolling in the opposite direction to others. I find
that this makes the display look messy and harder to read.
The patch in syncscrollers.patch addresses this problem by ensuring the scrollers
are all going in the same direction. All scrollers on the screen now wait
once they reach the end of their travel until the longer scrollers catch
up.
At the moment this has not been done as an autoconf option - I'm not sure
what the consensus is on whether this sort of thing should be optional or
not?
Steve Hill <steve@nexusuk.org>
+127
View File
@@ -0,0 +1,127 @@
Index: server/render.c
===================================================================
--- server/render.c (revision 78)
+++ server/render.c (revision 79)
@@ -176,6 +176,7 @@
int length, speed;
int str_length = BUFSIZE-1;
int reset = 1;
+ int max_scroller_len = 0;
debug( RPT_DEBUG, "%s( list=%p, fscroll='%c', left=%d, top=%d, "
"right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%d )",
@@ -202,6 +203,27 @@
/* TODO: Frames don't scroll horizontally yet! */
}
+ /* loop through the widgets before starting to render to pull out data we need before starting */
+ LL_Rewind (list);
+ do {
+ Widget *w = (Widget *) LL_Get(list);
+ if (!w)
+ break;
+
+ switch (w->type) {
+ case WID_SCROLLER:
+ /* length is really direction(!) */
+ if (w->length == 'h') {
+ length = strlen(w->text) + 1;
+ if (max_scroller_len < length)
+ max_scroller_len = length;
+ }
+ break;
+ default:
+ break;
+ }
+ } while (LL_Next(list) == 0);
+
/* reset widget list */
LL_Rewind (list);
@@ -343,13 +365,9 @@
/* it fits within the box, just render it */
drivers_string (w->left, w->top, w->text);
} else {
- int necessaryTimeUnits = 0;
-
if (w->speed > 0) {
- necessaryTimeUnits = length * w->speed;
offset = (timer % (length * w->speed)) / w->speed;
} else if (w->speed < 0) {
- necessaryTimeUnits = length / (w->speed * -1);
offset = (timer % (length / (w->speed * -1))) * w->speed * -1;
} else {
offset = 0;
@@ -380,28 +398,39 @@
drivers_string (w->left, w->top, w->text);
} else {
int effLength = length - screen_width;
- int necessaryTimeUnits = 0;
+ int maxeffLength = max_scroller_len - screen_width;
+ int waitlen = maxeffLength - effLength;
if (w->speed > 0) {
- necessaryTimeUnits = effLength * w->speed;
- if (((timer / (effLength * w->speed)) % 2) == 0) {
+ if (((timer / (maxeffLength * w->speed)) % 2) == 0) {
/*wiggle one way*/
- offset = (timer % (effLength * w->speed))
+ offset = (timer % (maxeffLength * w->speed))
/ w->speed;
+ if (offset >= effLength)
+ offset = effLength - 1;
} else {
/*wiggle the other*/
- offset = (((timer % (effLength * w->speed))
- - (effLength * w->speed) + 1)
+ offset = (((timer % (maxeffLength * w->speed))
+ - (maxeffLength * w->speed) + 1)
/ w->speed) * -1;
+ if (offset <= waitlen)
+ offset = 0;
+ else
+ offset -= waitlen;
}
} else if (w->speed < 0) {
- necessaryTimeUnits = effLength / (w->speed * -1);
- if (((timer / (effLength / (w->speed * -1))) % 2) == 0) {
- offset = (timer % (effLength / (w->speed * -1)))
+ if (((timer / (maxeffLength / (w->speed * -1))) % 2) == 0) {
+ offset = (timer % (maxeffLength / (w->speed * -1)))
* w->speed * -1;
+ if (offset >= effLength)
+ offset = effLength - 1;
} else {
- offset = (((timer % (effLength / (w->speed * -1)))
- * w->speed * -1) - effLength + 1) * -1;
+ offset = (((timer % (maxeffLength / (w->speed * -1)))
+ * w->speed * -1) - maxeffLength + 1) * -1;
+ if (offset <= waitlen)
+ offset = 0;
+ else
+ offset -= waitlen;
}
} else {
offset = 0;
@@ -440,13 +469,11 @@
drivers_string (w->left, w->top + i, str);
}
} else {
- int necessaryTimeUnits = 0;
int effLines = lines_required - available_lines + 1;
int begin = 0;
/*debug(RPT_DEBUG, "length: %d sw: %d lines req: %d avail lines: %d effLines: %d ",length,screen_width,lines_required,available_lines,effLines);*/
if (w->speed > 0) {
- necessaryTimeUnits = effLines * w->speed;
if (((timer / (effLines * w->speed)) % 2) == 0) {
/*debug(RPT_DEBUG, "up ");*/
begin = (timer % (effLines * w->speed))
@@ -458,7 +485,6 @@
* -1;
}
} else if (w->speed < 0) {
- necessaryTimeUnits = effLines / (w->speed * -1);
if (((timer / (effLines / (w->speed * -1))) % 2) == 0) {
begin = (timer % (effLines / (w->speed * -1)))
* w->speed * -1;