Codechange: use iterators instead of 'subranges' when iterating from a specific window.
Using iterators makes it easier to include or exclude the start window in the iteration.
This commit is contained in:
@@ -266,35 +266,36 @@ void InitializeWindowViewport(Window *w, int x, int y,
|
||||
|
||||
static Point _vp_move_offs;
|
||||
|
||||
static void DoSetViewportPosition(const Window *w, int left, int top, int width, int height)
|
||||
static void DoSetViewportPosition(Window::IteratorToFront it, int left, int top, int width, int height)
|
||||
{
|
||||
for (const Window *w : Window::IterateFromBack(w)) {
|
||||
for (; !it.IsEnd(); ++it) {
|
||||
const Window *w = *it;
|
||||
if (left + width > w->left &&
|
||||
w->left + w->width > left &&
|
||||
top + height > w->top &&
|
||||
w->top + w->height > top) {
|
||||
|
||||
if (left < w->left) {
|
||||
DoSetViewportPosition(w, left, top, w->left - left, height);
|
||||
DoSetViewportPosition(w, left + (w->left - left), top, width - (w->left - left), height);
|
||||
DoSetViewportPosition(it, left, top, w->left - left, height);
|
||||
DoSetViewportPosition(it, left + (w->left - left), top, width - (w->left - left), height);
|
||||
return;
|
||||
}
|
||||
|
||||
if (left + width > w->left + w->width) {
|
||||
DoSetViewportPosition(w, left, top, (w->left + w->width - left), height);
|
||||
DoSetViewportPosition(w, left + (w->left + w->width - left), top, width - (w->left + w->width - left), height);
|
||||
DoSetViewportPosition(it, left, top, (w->left + w->width - left), height);
|
||||
DoSetViewportPosition(it, left + (w->left + w->width - left), top, width - (w->left + w->width - left), height);
|
||||
return;
|
||||
}
|
||||
|
||||
if (top < w->top) {
|
||||
DoSetViewportPosition(w, left, top, width, (w->top - top));
|
||||
DoSetViewportPosition(w, left, top + (w->top - top), width, height - (w->top - top));
|
||||
DoSetViewportPosition(it, left, top, width, (w->top - top));
|
||||
DoSetViewportPosition(it, left, top + (w->top - top), width, height - (w->top - top));
|
||||
return;
|
||||
}
|
||||
|
||||
if (top + height > w->top + w->height) {
|
||||
DoSetViewportPosition(w, left, top, width, (w->top + w->height - top));
|
||||
DoSetViewportPosition(w, left, top + (w->top + w->height - top), width, height - (w->top + w->height - top));
|
||||
DoSetViewportPosition(it, left, top, width, (w->top + w->height - top));
|
||||
DoSetViewportPosition(it, left, top + (w->top + w->height - top), width, height - (w->top + w->height - top));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +381,11 @@ static void SetViewportPosition(Window *w, int x, int y)
|
||||
i = top + height - _screen.height;
|
||||
if (i >= 0) height -= i;
|
||||
|
||||
if (height > 0) DoSetViewportPosition(w->z_front, left, top, width, height);
|
||||
if (height > 0) {
|
||||
Window::IteratorToFront it(w);
|
||||
++it;
|
||||
DoSetViewportPosition(it, left, top, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user