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 | c5b749f9837effff08f766e9405b5175cefb4306 (patch) | |
tree | 1cd56469593a22050ca5d32236023544801b40a3 /src/build_vehicle_gui.cpp | |
parent | 2ff76007b0d91b30c78bdc20d352b3eeea3b8c43 (diff) | |
download | openttd-c5b749f9837effff08f766e9405b5175cefb4306.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.cpp | 23 |
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); |