summaryrefslogtreecommitdiff
path: root/src/build_vehicle_gui.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-26 20:55:04 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-26 20:55:04 +0000
commitc99eb9e4564b0c39356b469dfc2e1038c74da853 (patch)
tree1cd56469593a22050ca5d32236023544801b40a3 /src/build_vehicle_gui.cpp
parentd3990083d3ff15dfa94d8723421911dc270875bd (diff)
downloadopenttd-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/build_vehicle_gui.cpp')
-rw-r--r--src/build_vehicle_gui.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 50655df53..d524b0770 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -958,23 +958,6 @@ void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, u
}
}
-static void ExpandPurchaseInfoWidget(Window *w, int expand_by)
-{
- Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
-
- SetWindowDirty(w);
- wi->bottom += expand_by;
-
- for (uint i = BUILD_VEHICLE_WIDGET_BUILD; i < BUILD_VEHICLE_WIDGET_END; i++) {
- wi = &w->widget[i];
- wi->top += expand_by;
- wi->bottom += expand_by;
- }
-
- w->height += expand_by;
- SetWindowDirty(w);
-}
-
static void DrawBuildVehicleWindow(Window *w)
{
const buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -996,7 +979,11 @@ static void DrawBuildVehicleWindow(Window *w)
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
- if (text_end > wi->bottom) ExpandPurchaseInfoWidget(w, text_end - wi->bottom);
+ if (text_end > wi->bottom) {
+ SetWindowDirty(w);
+ ResizeWindowForWidget(w, BUILD_VEHICLE_WIDGET_PANEL, 0, text_end - wi->bottom);
+ SetWindowDirty(w);
+ }
}
DrawSortButtonState(w, BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, bv->descending_sort_order ? SBS_DOWN : SBS_UP);