diff options
-rw-r--r-- | src/terraform_gui.cpp | 17 | ||||
-rw-r--r-- | src/transparency_gui.cpp | 9 | ||||
-rw-r--r-- | src/window.cpp | 16 | ||||
-rw-r--r-- | src/window_gui.h | 2 |
4 files changed, 37 insertions, 7 deletions
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index c869a2bef..fb9b09b2a 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -31,6 +31,7 @@ #include "tree_map.h" #include "landscape_type.h" #include "tilehighlight_func.h" +#include "strings_func.h" #include "table/sprites.h" #include "table/strings.h" @@ -288,6 +289,13 @@ struct TerraformToolbarWindow : Window { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } + virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + { + Point pt = GetToolbarAlignedWindowPosition(sm_width); + pt.y += sm_height; + return pt; + } + virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) { if (pt.x != -1) { @@ -337,7 +345,7 @@ static const NWidgetPart _nested_terraform_widgets[] = { }; static const WindowDesc _terraform_desc( - WDP_ALIGN_TBR, 22 + 36, 158, 36, + WDP_MANUAL, WDP_MANUAL, 158, 36, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, _nested_terraform_widgets, lengthof(_nested_terraform_widgets) @@ -354,15 +362,14 @@ Window *ShowTerraformToolbar(Window *link) w = FindWindowById(WC_SCEN_LAND_GEN, 0); if (w == NULL) return NULL; } else { - w->top = 22; + w->top -= w->height; w->SetDirty(); } /* Align the terraform toolbar under the main toolbar and put the linked - * toolbar to left of it - */ + * toolbar to left/right of it */ + link->left = w->left + (_dynlang.text_dir == TD_RTL ? w->width : -link->width); link->top = w->top; - link->left = w->left - link->width; link->SetDirty(); return w; diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 1195c4f95..6233817c8 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -117,6 +117,13 @@ public: } } + virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + { + Point pt = GetToolbarAlignedWindowPosition(sm_width); + pt.y += 2 * (sm_height - this->GetWidget<NWidgetBase>(TTW_WIDGET_BUTTONS)->current_y); + return pt; + } + virtual void OnInvalidateData(int data) { for (uint i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) { @@ -149,7 +156,7 @@ static const NWidgetPart _nested_transparency_widgets[] = { }; static const WindowDesc _transparency_desc( - WDP_ALIGN_TBR, 94, 219, 49, + WDP_MANUAL, WDP_MANUAL, 219, 49, WC_TRANSPARENCY_TOOLBAR, WC_NONE, 0, _nested_transparency_widgets, lengthof(_nested_transparency_widgets) diff --git a/src/window.cpp b/src/window.cpp index a5a057cfc..28f6fddf5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1052,6 +1052,20 @@ restart: } /** + * Computer the position of the top-left corner of a window to be opened right + * under the toolbar. + * @param window_width the width of the window to get the position for + * @return Coordinate of the top-left corner of the new window. + */ +Point GetToolbarAlignedWindowPosition(int window_width) +{ + const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + assert(w != NULL); + Point pt = { _dynlang.text_dir == TD_RTL ? w->left : (w->left + w->width) - window_width, w->top + w->height }; + return pt; +} + +/** * Compute the position of the top-left corner of a new window that is opened. * * By default position a child window at an offset of 10/10 of its parent. @@ -1071,7 +1085,7 @@ restart: static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) { Point pt; - Window *w; + const Window *w; int16 default_width = max(desc->default_width, sm_width); int16 default_height = max(desc->default_height, sm_height); diff --git a/src/window_gui.h b/src/window_gui.h index 01b49b23c..5eb2bf4ef 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -166,6 +166,8 @@ enum WindowDefaultPosition { WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar }; +Point GetToolbarAlignedWindowPosition(int window_width); + /** * Scrollbar data structure */ |