(svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -1051,6 +1051,20 @@ restart:
 | 
			
		||||
	return pt;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 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.
 | 
			
		||||
 *
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user