| 275 | static Point _vp_move_offs; |
| 276 | |
| 277 | static void DoSetViewportPosition(Window::IteratorToFront it, int left, int top, int width, int height) |
| 278 | { |
| 279 | for (; !it.IsEnd(); ++it) { |
| 280 | const Window *w = *it; |
| 281 | if (left + width > w->left && |
| 282 | w->left + w->width > left && |
| 283 | top + height > w->top && |
| 284 | w->top + w->height > top) { |
| 285 | |
| 286 | if (left < w->left) { |
| 287 | DoSetViewportPosition(it, left, top, w->left - left, height); |
| 288 | DoSetViewportPosition(it, left + (w->left - left), top, width - (w->left - left), height); |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | if (left + width > w->left + w->width) { |
| 293 | DoSetViewportPosition(it, left, top, (w->left + w->width - left), height); |
| 294 | DoSetViewportPosition(it, left + (w->left + w->width - left), top, width - (w->left + w->width - left), height); |
| 295 | return; |
| 296 | } |
| 297 | |
| 298 | if (top < w->top) { |
| 299 | DoSetViewportPosition(it, left, top, width, (w->top - top)); |
| 300 | DoSetViewportPosition(it, left, top + (w->top - top), width, height - (w->top - top)); |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | if (top + height > w->top + w->height) { |
| 305 | DoSetViewportPosition(it, left, top, width, (w->top + w->height - top)); |
| 306 | DoSetViewportPosition(it, left, top + (w->top + w->height - top), width, height - (w->top + w->height - top)); |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | return; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | { |
| 315 | int xo = _vp_move_offs.x; |
| 316 | int yo = _vp_move_offs.y; |
| 317 | |
| 318 | if (abs(xo) >= width || abs(yo) >= height) { |
| 319 | /* fully_outside */ |
| 320 | RedrawScreenRect(left, top, left + width, top + height); |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | GfxScroll(left, top, width, height, xo, yo); |
| 325 | |
| 326 | if (xo > 0) { |
| 327 | RedrawScreenRect(left, top, xo + left, top + height); |
| 328 | left += xo; |
| 329 | width -= xo; |
| 330 | } else if (xo < 0) { |
| 331 | RedrawScreenRect(left + width + xo, top, left + width, top + height); |
| 332 | width += xo; |
| 333 | } |
| 334 |
no test coverage detected