summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-10-24 13:58:18 +0000
committeralberth <alberth@openttd.org>2009-10-24 13:58:18 +0000
commitc3992ab7b69461189f217be73136997cd097ee62 (patch)
tree3f1fe36516122b2a23654a9b8b8699173474aabf /src
parentef5dc588ded9a044c8f05ad4195207444f21be17 (diff)
downloadopenttd-c3992ab7b69461189f217be73136997cd097ee62.tar.xz
(svn r17852) -Codechange: Use viewport nested widget in the view-vehicle window.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_gui.cpp25
-rw-r--r--src/vehicle_gui.h3
2 files changed, 15 insertions, 13 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 4b6a12617..c69dfc944 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1533,7 +1533,9 @@ static const NWidgetPart _nested_vehicle_view_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_GREY, VVW_WIDGET_PANEL),
- NWidget(WWT_INSET, COLOUR_GREY, VVW_WIDGET_VIEWPORT), SetPadding(2, 2, 2, 2), SetMinimalSize(228, 86), SetResize(1, 1), EndContainer(),
+ NWidget(WWT_INSET, COLOUR_GREY, VVW_WIDGET_INSET), SetPadding(2, 2, 2, 2),
+ NWidget(NWID_VIEWPORT, INVALID_COLOUR, VVW_WIDGET_VIEWPORT), SetMinimalSize(226, 84), SetResize(1, 1), SetPadding(1, 1, 1, 1),
+ EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, VVW_WIDGET_CENTER_MAIN_VIEH), SetMinimalSize(18, 18), SetFill(true, true), SetDataTip(SPR_CENTRE_VIEW_VEHICLE, 0x0 /* filled later */),
@@ -1595,8 +1597,6 @@ static const ZoomLevel _vehicle_view_zoom_levels[] = {
};
/* Constants for geometry of vehicle view viewport */
-static const int VV_VIEWPORT_X = 3;
-static const int VV_VIEWPORT_Y = 17;
static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
@@ -1719,9 +1719,7 @@ public:
}
this->FinishInitNested(desc, window_number);
this->owner = v->owner;
- InitializeWindowViewport(this, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
- (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT,
- this->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
+ this->GetWidget<NWidgetViewport>(VVW_WIDGET_VIEWPORT)->InitializeViewport(this, this->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
this->GetWidget<NWidgetCore>(VVW_WIDGET_START_STOP_VEH)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATE_START_STOP_TOOLTIP + v->type;
this->GetWidget<NWidgetCore>(VVW_WIDGET_CENTER_MAIN_VIEH)->tool_tip = STR_VEHICLE_VIEW_TRAIN_LOCATION_TOOLTIP + v->type;
@@ -1749,6 +1747,11 @@ public:
size->height = 0;
size->width = 0;
} break;
+
+ case VVW_WIDGET_VIEWPORT:
+ size->width = VV_INITIAL_VIEWPORT_WIDTH;
+ size->height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
+ break;
}
}
@@ -1768,8 +1771,6 @@ public:
}
this->DrawWidgets();
-
- this->DrawViewport();
}
virtual void SetStringParameters(int widget) const
@@ -1921,10 +1922,10 @@ public:
virtual void OnResize(Point delta)
{
- this->viewport->width += delta.x;
- this->viewport->height += delta.y;
- this->viewport->virtual_width += delta.x;
- this->viewport->virtual_height += delta.y;
+ if (this->viewport != NULL) {
+ NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(VVW_WIDGET_VIEWPORT);
+ nvp->UpdateViewportCoordinates(this);
+ }
}
virtual void OnTick()
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 889b18281..75705ec59 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -28,7 +28,8 @@ enum VehicleViewWindowWidgets {
VVW_WIDGET_CAPTION,
VVW_WIDGET_STICKY,
VVW_WIDGET_PANEL,
- VVW_WIDGET_VIEWPORT,
+ VVW_WIDGET_INSET,
+ VVW_WIDGET_VIEWPORT, ///< Viewport widget.
VVW_WIDGET_START_STOP_VEH,
VVW_WIDGET_CENTER_MAIN_VIEH,
VVW_WIDGET_GOTO_DEPOT,