summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/scroll_engine.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/firmware/scroll_engine.c b/firmware/scroll_engine.c
index 200695b5d6..9607c90448 100644
--- a/firmware/scroll_engine.c
+++ b/firmware/scroll_engine.c
@@ -84,6 +84,18 @@ void lcd_stop_scroll(void)
84 lcd_scroll_info.lines = 0; 84 lcd_scroll_info.lines = 0;
85} 85}
86 86
87/* returns true if the 'line' in 'lines_vp' would scroll into 'othervp' */
88static bool line_overlaps_viewport(struct viewport *lines_vp, int line,
89 struct viewport *othervp)
90{
91 int y = (font_get(lines_vp->font)->height*line) + lines_vp->y;
92 if (y < othervp->y || y > othervp->y + othervp->height)
93 return false;
94 else if ((lines_vp->x + lines_vp->width < othervp->x) ||
95 (othervp->x + othervp->width < lines_vp->x))
96 return false;
97 return true;
98}
87/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */ 99/* Stop scrolling line y in the specified viewport, or all lines if y < 0 */
88void lcd_scroll_stop_line(struct viewport* current_vp, int y) 100void lcd_scroll_stop_line(struct viewport* current_vp, int y)
89{ 101{
@@ -91,8 +103,11 @@ void lcd_scroll_stop_line(struct viewport* current_vp, int y)
91 103
92 while (i < lcd_scroll_info.lines) 104 while (i < lcd_scroll_info.lines)
93 { 105 {
94 if ((lcd_scroll_info.scroll[i].vp == current_vp) && 106 if (((lcd_scroll_info.scroll[i].vp == current_vp) &&
95 ((y < 0) || (lcd_scroll_info.scroll[i].y == y))) 107 ((y < 0) || (lcd_scroll_info.scroll[i].y == y))) ||
108 ((lcd_scroll_info.scroll[i].vp != current_vp) &&
109 line_overlaps_viewport(lcd_scroll_info.scroll[i].vp,
110 lcd_scroll_info.scroll[i].y, current_vp)))
96 { 111 {
97 /* If i is not the last active line in the array, then move 112 /* If i is not the last active line in the array, then move
98 the last item to position i */ 113 the last item to position i */
@@ -102,8 +117,10 @@ void lcd_scroll_stop_line(struct viewport* current_vp, int y)
102 } 117 }
103 lcd_scroll_info.lines--; 118 lcd_scroll_info.lines--;
104 119
105 /* A line can only appear once, so we're done. */ 120 /* A line can only appear once, so we're done,
106 return ; 121 * unless we are clearing the whole viewport */
122 if (y >= 0)
123 return ;
107 } 124 }
108 else 125 else
109 { 126 {
@@ -165,8 +182,11 @@ void lcd_remote_scroll_stop_line(struct viewport* current_vp, int y)
165 182
166 while (i < lcd_remote_scroll_info.lines) 183 while (i < lcd_remote_scroll_info.lines)
167 { 184 {
168 if ((lcd_remote_scroll_info.scroll[i].vp == current_vp) && 185 if (((lcd_remote_scroll_info.scroll[i].vp == current_vp) &&
169 ((y < 0) || (lcd_remote_scroll_info.scroll[i].y == y))) 186 ((y < 0) || (lcd_remote_scroll_info.scroll[i].y == y))) ||
187 (((lcd_remote_scroll_info.scroll[i].vp != current_vp) &&
188 line_overlaps_viewport(lcd_scroll_info.scroll[i].vp,
189 lcd_scroll_info.scroll[i].y, current_vp))))
170 { 190 {
171 /* If i is not the last active line in the array, then move 191 /* If i is not the last active line in the array, then move
172 the last item to position i */ 192 the last item to position i */
@@ -176,8 +196,10 @@ void lcd_remote_scroll_stop_line(struct viewport* current_vp, int y)
176 } 196 }
177 lcd_remote_scroll_info.lines--; 197 lcd_remote_scroll_info.lines--;
178 198
179 /* A line can only appear once, so we're done. */ 199 /* A line can only appear once, so we're done,
180 return ; 200 * unless we are clearing the whole viewport */
201 if (y >= 0)
202 return ;
181 } 203 }
182 else 204 else
183 { 205 {