From 2399f91f62f3768c2ab74db85e709d0869e36eb2 Mon Sep 17 00:00:00 2001 From: alberth Date: Tue, 21 Jul 2009 22:25:21 +0000 Subject: [PATCH] (svn r16906) -Fix (r12939): Child windows of build toolbars were placed inconsistently. --- src/airport_gui.cpp | 4 ++-- src/bridge_gui.cpp | 4 ++-- src/dock_gui.cpp | 10 +++++----- src/rail_gui.cpp | 16 ++++++++-------- src/road_gui.cpp | 12 ++++++------ src/window.cpp | 4 ++-- src/window_gui.h | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index a8d6577367..18162a785d 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -126,7 +126,7 @@ struct BuildAirToolbarWindow : Window { { this->RaiseButtons(); - DeleteWindowById(WC_BUILD_STATION, 0); + DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR); DeleteWindowById(WC_SELECT_STATION, 0); } }; @@ -202,7 +202,7 @@ enum AirportPickerWidgets { class AirportPickerWindow : public PickerWindowBase { public: - AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent, TRANSPORT_AIR) { this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index acf67083b6..7f0c1a3ebe 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -118,7 +118,7 @@ private: } public: - BuildBridgeWindow(const WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(desc), + BuildBridgeWindow(const WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(desc, GB(br_type, 15, 2)), start_tile(start), end_tile(end), type(br_type), @@ -308,7 +308,7 @@ static const WindowDesc _build_bridge_desc( */ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type) { - DeleteWindowById(WC_BUILD_BRIDGE, 0); + DeleteWindowByClass(WC_BUILD_BRIDGE); /* Data type for the bridge. * Bit 16,15 = transport type, diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 3c4e08905a..f7aed41ed6 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -241,10 +241,10 @@ struct BuildDocksToolbarWindow : Window { { this->RaiseButtons(); - DeleteWindowById(WC_BUILD_STATION, 0); - DeleteWindowById(WC_BUILD_DEPOT, 0); + DeleteWindowById(WC_BUILD_STATION, TRANSPORT_WATER); + DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_WATER); DeleteWindowById(WC_SELECT_STATION, 0); - DeleteWindowById(WC_BUILD_BRIDGE, 0); + DeleteWindowByClass(WC_BUILD_BRIDGE); } virtual void OnPlacePresize(Point pt, TileIndex tile_from) @@ -341,7 +341,7 @@ struct BuildDocksStationWindow : public PickerWindowBase { public: BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) { - this->InitNested(desc); + this->InitNested(desc, TRANSPORT_WATER); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); } @@ -447,7 +447,7 @@ private: public: BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) { - this->InitNested(desc); + this->InitNested(desc, TRANSPORT_WATER); this->LowerWidget(_ship_depot_direction + BDDW_X); UpdateDocksDirection(); } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 82fc959cae..bcb21d63db 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -766,11 +766,11 @@ struct BuildRailToolbarWindow : Window { this->DisableWidget(RTW_REMOVE); this->InvalidateWidget(RTW_REMOVE); - DeleteWindowById(WC_BUILD_SIGNAL, 0); - DeleteWindowById(WC_BUILD_STATION, 0); - DeleteWindowById(WC_BUILD_DEPOT, 0); + DeleteWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL); + DeleteWindowById(WC_BUILD_STATION, TRANSPORT_RAIL); + DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL); DeleteWindowById(WC_SELECT_STATION, 0); - DeleteWindowById(WC_BUILD_BRIDGE, 0); + DeleteWindowByClass(WC_BUILD_BRIDGE); } virtual void OnPlacePresize(Point pt, TileIndex tile) @@ -986,7 +986,7 @@ public: BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(parent) { this->line_height = FONT_HEIGHT_NORMAL + 4; - this->InitNested(desc); + this->InitNested(desc, TRANSPORT_RAIL); this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X); if (_settings_client.gui.station_dragdrop) { @@ -1470,7 +1470,7 @@ private: } public: - BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent, TRANSPORT_RAIL) { this->FindWindowPlacementAndResize(desc); }; @@ -1639,7 +1639,7 @@ enum BuildRailDepotWidgets { }; struct BuildRailDepotWindow : public PickerWindowBase { - BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent, TRANSPORT_RAIL) { this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE); this->FindWindowPlacementAndResize(desc); @@ -1740,7 +1740,7 @@ enum BuildRailWaypointWidgets { }; struct BuildRailWaypointWindow : PickerWindowBase { - BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent, TRANSPORT_RAIL) { this->hscroll.cap = 5; this->hscroll.count = _waypoint_count; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index aa38c4923d..5ce82268c2 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -528,11 +528,11 @@ struct BuildRoadToolbarWindow : Window { this->InvalidateWidget(RTW_REMOVE); this->InvalidateWidget(RTW_ONE_WAY); - DeleteWindowById(WC_BUS_STATION, 0); - DeleteWindowById(WC_TRUCK_STATION, 0); - DeleteWindowById(WC_BUILD_DEPOT, 0); + DeleteWindowById(WC_BUS_STATION, TRANSPORT_ROAD); + DeleteWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD); + DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD); DeleteWindowById(WC_SELECT_STATION, 0); - DeleteWindowById(WC_BUILD_BRIDGE, 0); + DeleteWindowByClass(WC_BUILD_BRIDGE); } virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) @@ -796,7 +796,7 @@ enum BuildRoadDepotWidgets { }; struct BuildRoadDepotWindow : public PickerWindowBase { - BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent, TRANSPORT_ROAD) { this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE); if ( _cur_roadtype == ROADTYPE_TRAM) { @@ -907,7 +907,7 @@ enum BuildRoadStationWidgets { }; struct BuildRoadStationWindow : public PickerWindowBase { - BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent) + BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent, TRANSPORT_ROAD) { /* Trams don't have non-drivethrough stations */ if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) { diff --git a/src/window.cpp b/src/window.cpp index 00e42ff722..60519f3ee5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1198,7 +1198,7 @@ restart: * * By default position a child window at an offset of 10/10 of its parent. * With the exception of WC_BUILD_TOOLBAR (build railway/roads/ship docks/airports) - * and WC_SCEN_LAND_GEN (landscaping). Whose child window has an offset of 0/36 of + * and WC_SCEN_LAND_GEN (landscaping). Whose child window has an offset of 0/toolbar-height of * its parent. So it's exactly under the parent toolbar and no buttons will be covered. * However if it falls too extremely outside window positions, reposition * it to an automatic place. @@ -1226,7 +1226,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int if (pt.x > _screen.width + 10 - default_width) { pt.x = (_screen.width + 10 - default_width) - 20; } - pt.y = w->top + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? 36 : 10); + pt.y = w->top + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? w->height : 10); } else { switch (desc->left) { case WDP_ALIGN_TBR: // Align the right side with the top toolbar diff --git a/src/window_gui.h b/src/window_gui.h index 387dab1f69..3cb1fa9f6d 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -709,7 +709,7 @@ public: class PickerWindowBase : public Window { public: - PickerWindowBase(const WindowDesc *desc, Window *parent) : Window(desc) + PickerWindowBase(const WindowDesc *desc, Window *parent, WindowNumber number = 0) : Window(desc, number) { this->parent = parent; };