mirror of https://github.com/OpenTTD/OpenTTD
(svn r13977) -Codechange: Let ResizeWindowForWidget() handle hidden (zero height or zero width) widgets.
parent
b92c4cfc92
commit
92b63e38f0
|
@ -590,18 +590,23 @@ void ResizeButtons(Window *w, byte left, byte right)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resize a widget and shuffle other widgets around to fit. */
|
/** Resize a widget and shuffle other widgets around to fit. */
|
||||||
void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y)
|
void ResizeWindowForWidget(Window *w, uint widget, int delta_x, int delta_y)
|
||||||
{
|
{
|
||||||
int right = w->widget[widget].right;
|
int right = w->widget[widget].right;
|
||||||
int bottom = w->widget[widget].bottom;
|
int bottom = w->widget[widget].bottom;
|
||||||
|
|
||||||
for (uint i = 0; i < w->widget_count; i++) {
|
for (uint i = 0; i < w->widget_count; i++) {
|
||||||
if (w->widget[i].left >= right) w->widget[i].left += delta_x;
|
if (w->widget[i].left >= right && i != widget) w->widget[i].left += delta_x;
|
||||||
if (w->widget[i].right >= right) w->widget[i].right += delta_x;
|
if (w->widget[i].right >= right) w->widget[i].right += delta_x;
|
||||||
if (w->widget[i].top >= bottom) w->widget[i].top += delta_y;
|
if (w->widget[i].top >= bottom && i != widget) w->widget[i].top += delta_y;
|
||||||
if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y;
|
if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A hidden widget has bottom == top or right == left, we need to make it
|
||||||
|
* one less to fit in its new gap. */
|
||||||
|
if (right == w->widget[widget].left) w->widget[widget].right--;
|
||||||
|
if (bottom == w->widget[widget].top) w->widget[widget].bottom--;
|
||||||
|
|
||||||
w->width += delta_x;
|
w->width += delta_x;
|
||||||
w->height += delta_y;
|
w->height += delta_y;
|
||||||
w->resize.width += delta_x;
|
w->resize.width += delta_x;
|
||||||
|
|
|
@ -573,7 +573,7 @@ void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y);
|
||||||
|
|
||||||
void ResizeButtons(Window *w, byte left, byte right);
|
void ResizeButtons(Window *w, byte left, byte right);
|
||||||
|
|
||||||
void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y);
|
void ResizeWindowForWidget(Window *w, uint widget, int delta_x, int delta_y);
|
||||||
|
|
||||||
void SetVScrollCount(Window *w, int num);
|
void SetVScrollCount(Window *w, int num);
|
||||||
void SetVScroll2Count(Window *w, int num);
|
void SetVScroll2Count(Window *w, int num);
|
||||||
|
|
Loading…
Reference in New Issue