588 } |
588 } |
589 } |
589 } |
590 } |
590 } |
591 |
591 |
592 /** Resize a widget and shuffle other widgets around to fit. */ |
592 /** Resize a widget and shuffle other widgets around to fit. */ |
593 void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y) |
593 void ResizeWindowForWidget(Window *w, uint widget, int delta_x, int delta_y) |
594 { |
594 { |
595 int right = w->widget[widget].right; |
595 int right = w->widget[widget].right; |
596 int bottom = w->widget[widget].bottom; |
596 int bottom = w->widget[widget].bottom; |
597 |
597 |
598 for (uint i = 0; i < w->widget_count; i++) { |
598 for (uint i = 0; i < w->widget_count; i++) { |
599 if (w->widget[i].left >= right) w->widget[i].left += delta_x; |
599 if (w->widget[i].left >= right && i != widget) w->widget[i].left += delta_x; |
600 if (w->widget[i].right >= right) w->widget[i].right += delta_x; |
600 if (w->widget[i].right >= right) w->widget[i].right += delta_x; |
601 if (w->widget[i].top >= bottom) w->widget[i].top += delta_y; |
601 if (w->widget[i].top >= bottom && i != widget) w->widget[i].top += delta_y; |
602 if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y; |
602 if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y; |
603 } |
603 } |
|
604 |
|
605 /* A hidden widget has bottom == top or right == left, we need to make it |
|
606 * one less to fit in its new gap. */ |
|
607 if (right == w->widget[widget].left) w->widget[widget].right--; |
|
608 if (bottom == w->widget[widget].top) w->widget[widget].bottom--; |
604 |
609 |
605 w->width += delta_x; |
610 w->width += delta_x; |
606 w->height += delta_y; |
611 w->height += delta_y; |
607 w->resize.width += delta_x; |
612 w->resize.width += delta_x; |
608 w->resize.height += delta_y; |
613 w->resize.height += delta_y; |