diff options
author | peter1138 <peter1138@openttd.org> | 2008-01-26 20:55:04 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-01-26 20:55:04 +0000 |
commit | c99eb9e4564b0c39356b469dfc2e1038c74da853 (patch) | |
tree | 1cd56469593a22050ca5d32236023544801b40a3 /src/widget.cpp | |
parent | d3990083d3ff15dfa94d8723421911dc270875bd (diff) | |
download | openttd-c99eb9e4564b0c39356b469dfc2e1038c74da853.tar.xz |
(svn r11988) -Codechange: Add a generic way of changing a widget's size and adjust the widgets around it to suit.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r-- | src/widget.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp index 3bd140ea1..d505f9f0b 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -583,6 +583,24 @@ void ResizeButtons(Window *w, byte left, byte right) } } +void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y) +{ + int right = w->widget[widget].right; + int bottom = w->widget[widget].bottom; + + 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].right >= right) w->widget[i].right += delta_x; + if (w->widget[i].top >= bottom) w->widget[i].top += delta_y; + if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y; + } + + w->width += delta_x; + w->height += delta_y; + w->resize.width += delta_x; + w->resize.height += delta_y; +} + /** Draw a sort button's up or down arrow symbol. * @param w Window of widget * @param widget Sort button widget |