(svn r11918) -Codechange: Draw engine lists at widget positions instead of fixed pixel positions
authorpeter1138
Fri, 18 Jan 2008 18:18:39 +0000
changeset 8848 96987946673f
parent 8847 98ccd8072daf
child 8849 0e1357f6b480
(svn r11918) -Codechange: Draw engine lists at widget positions instead of fixed pixel positions
src/autoreplace_gui.cpp
src/build_vehicle_gui.cpp
--- a/src/autoreplace_gui.cpp	Fri Jan 18 14:48:57 2008 +0000
+++ b/src/autoreplace_gui.cpp	Fri Jan 18 18:18:39 2008 +0000
@@ -334,13 +334,13 @@
 
 			/* Draw the lists */
 			for(byte i = 0; i < 2; i++) {
-				uint16 x        = i == 0 ? 2 : 230; // at what X offset
+				uint widget     = (i == 0) ? RVW_WIDGET_LEFT_MATRIX : RVW_WIDGET_RIGHT_MATRIX;
 				EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
 				EngineID start  = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
 				EngineID end    = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
 
 				/* Do the actual drawing */
-				DrawEngineList((VehicleType)w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0, selected_group);
+				DrawEngineList((VehicleType)w->window_number, w->widget[widget].left + 2, w->widget[widget].top + 1, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0, selected_group);
 
 				/* Also draw the details if an engine is selected */
 				if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
--- a/src/build_vehicle_gui.cpp	Fri Jan 18 14:48:57 2008 +0000
+++ b/src/build_vehicle_gui.cpp	Fri Jan 18 18:18:39 2008 +0000
@@ -986,7 +986,7 @@
 
 	DrawWindowWidgets(w);
 
-	DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
+	DrawEngineList(bv->vehicle_type, w->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, w->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
 
 	if (bv->sel_engine != INVALID_ENGINE) {
 		const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
@@ -1011,7 +1011,7 @@
 			break;
 
 		case BUILD_VEHICLE_WIDGET_LIST: {
-			uint i = (e->we.click.pt.y - 26) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos;
+			uint i = (e->we.click.pt.y - w->widget[BUILD_VEHICLE_WIDGET_LIST].top) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos;
 			uint num_items = EngList_Count(&bv->eng_list);
 			bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE;
 			SetWindowDirty(w);