Changeset - r21990:cedbcf015b65
[Not reviewed]
master
0 6 0
frosch - 10 years ago 2015-02-13 21:13:45
frosch@openttd.org
(svn r27146) -Fix: Make statusbar and chat-entry window use the same width as the toolbar. Otherwise they lack a size definition.
6 files changed with 34 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -18,12 +18,13 @@
 
#include "../blitter/factory.hpp"
 
#include "../console_func.h"
 
#include "../video/video_driver.hpp"
 
#include "../querystring_gui.h"
 
#include "../town.h"
 
#include "../window_func.h"
 
#include "../toolbar_gui.h"
 
#include "../core/geometry_func.hpp"
 
#include "network.h"
 
#include "network_client.h"
 
#include "network_base.h"
 

	
 
#include "../widgets/network_chat_widget.h"
 
@@ -318,12 +319,17 @@ struct NetworkChatWindow : public Window
 

	
 
	~NetworkChatWindow()
 
	{
 
		InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
 
	}
 

	
 
	virtual void FindWindowPlacementAndResize(int def_width, int def_height)
 
	{
 
		Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
 
	}
 

	
 
	/**
 
	 * Find the next item of the list of things that can be auto-completed.
 
	 * @param item The current indexed item to return. This function can, and most
 
	 *     likely will, alter item, to skip empty items in the arrays.
 
	 * @return Returns the char that matched to the index.
 
	 */
 
@@ -533,13 +539,13 @@ static const NWidgetPart _nested_chat_wi
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
/** The description of the chat window. */
 
static WindowDesc _chat_window_desc(
 
	WDP_MANUAL, NULL, 640, 14, // x, y, width, height
 
	WDP_MANUAL, NULL, 0, 0,
 
	WC_SEND_NETWORK_MSG, WC_NONE,
 
	0,
 
	_nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
 
);
 

	
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -21,12 +21,13 @@
 
#include "news_gui.h"
 
#include "company_gui.h"
 
#include "window_gui.h"
 
#include "saveload/saveload.h"
 
#include "window_func.h"
 
#include "statusbar_gui.h"
 
#include "toolbar_gui.h"
 
#include "core/geometry_func.hpp"
 

	
 
#include "widgets/statusbar_widget.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
@@ -98,12 +99,17 @@ struct StatusBarWindow : Window {
 
	virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
 
	{
 
		Point pt = { 0, _screen.height - sm_height };
 
		return pt;
 
	}
 

	
 
	virtual void FindWindowPlacementAndResize(int def_width, int def_height)
 
	{
 
		Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		Dimension d;
 
		switch (widget) {
 
			case WID_S_LEFT:
 
				SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR);
 
@@ -235,13 +241,13 @@ static const NWidgetPart _nested_main_st
 
		NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0),
 
		NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_RIGHT), SetMinimalSize(140, 12),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _main_status_desc(
 
	WDP_MANUAL, NULL, 640, 12,
 
	WDP_MANUAL, NULL, 0, 0,
 
	WC_STATUS_BAR, WC_NONE,
 
	WDF_NO_FOCUS,
 
	_nested_main_status_widgets, lengthof(_nested_main_status_widgets)
 
);
 

	
 
/**
src/toolbar_gui.cpp
Show inline comments
 
@@ -43,22 +43,26 @@
 
#include "hotkeys.h"
 
#include "engine_base.h"
 
#include "highscore.h"
 
#include "game/game.hpp"
 
#include "goal_base.h"
 
#include "story_base.h"
 
#include "toolbar_gui.h"
 

	
 
#include "widgets/toolbar_widget.h"
 

	
 
#include "network/network.h"
 
#include "network/network_gui.h"
 
#include "network/network_func.h"
 

	
 
#include "safeguards.h"
 

	
 

	
 
/** Width of the toolbar, shared by statusbar. */
 
uint _toolbar_width = 0;
 

	
 
RailType _last_built_railtype;
 
RoadType _last_built_roadtype;
 

	
 
static ScreenshotType _confirmed_screenshot_type; ///< Screenshot type the current query is about to confirm.
 

	
 
/** Toobar modes */
 
@@ -1347,13 +1351,13 @@ public:
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			child_wid->current_y = this->smallest_y;
 
			if (!this->IsButton(child_wid->type)) {
 
				child_wid->current_x = child_wid->smallest_x;
 
			}
 
		}
 
		w->window_desc->default_width = nbuttons * this->smallest_x;
 
		_toolbar_width = nbuttons * this->smallest_x;
 
	}
 

	
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
 
	{
 
		assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 

	
 
@@ -1523,13 +1527,13 @@ class NWidgetScenarioToolbarContainer : 
 
		uint i = 0;
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue;
 

	
 
			assert(i < lengthof(this->panel_widths));
 
			this->panel_widths[i++] = child_wid->current_x;
 
			w->window_desc->default_width += child_wid->current_x;
 
			_toolbar_width += child_wid->current_x;
 
		}
 
	}
 

	
 
	/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
 
	{
 
		static const byte arrange_all[] = {
 
@@ -1663,12 +1667,17 @@ struct MainToolbarWindow : Window {
 
		this->SetWidgetDisabledState(WID_TN_PAUSE, _networking && !_network_server); // if not server, disable pause button
 
		this->SetWidgetDisabledState(WID_TN_FAST_FORWARD, _networking); // if networking, disable fast-forward button
 
		PositionMainToolbar(this);
 
		DoZoomInOutWindow(ZOOM_NONE, this);
 
	}
 

	
 
	virtual void FindWindowPlacementAndResize(int def_width, int def_height)
 
	{
 
		Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* If spectator, disable all construction buttons
 
		 * ie : Build road, rail, ships, airports and landscaping
 
		 * Since enabled state is the default, just disable when needed */
 
		this->SetWidgetsDisabledState(_local_company == COMPANY_SPECTATOR, WID_TN_RAILS, WID_TN_ROADS, WID_TN_WATER, WID_TN_AIR, WID_TN_LANDSCAPE, WIDGET_LIST_END);
 
@@ -1897,13 +1906,13 @@ static NWidgetBase *MakeMainToolbar(int 
 

	
 
static const NWidgetPart _nested_toolbar_normal_widgets[] = {
 
	NWidgetFunction(MakeMainToolbar),
 
};
 

	
 
static WindowDesc _toolb_normal_desc(
 
	WDP_MANUAL, NULL, 640, 22,
 
	WDP_MANUAL, NULL, 0, 0,
 
	WC_MAIN_TOOLBAR, WC_NONE,
 
	WDF_NO_FOCUS,
 
	_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
 
	&MainToolbarWindow::hotkeys
 
);
 

	
 
@@ -2208,13 +2217,13 @@ static NWidgetBase *MakeScenarioToolbar(
 

	
 
static const NWidgetPart _nested_toolb_scen_widgets[] = {
 
	NWidgetFunction(MakeScenarioToolbar),
 
};
 

	
 
static WindowDesc _toolb_scen_desc(
 
	WDP_MANUAL, NULL, 640, 22,
 
	WDP_MANUAL, NULL, 0, 0,
 
	WC_MAIN_TOOLBAR, WC_NONE,
 
	WDF_NO_FOCUS,
 
	_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
 
	&ScenarioEditorToolbarWindow::hotkeys
 
);
 

	
src/toolbar_gui.h
Show inline comments
 
@@ -13,7 +13,9 @@
 
#define TOOLBAR_GUI_H
 

	
 
void AllocateToolbar();
 
void ToggleBoundingBoxes();
 
void ToggleDirtyBlocks();
 

	
 
extern uint _toolbar_width;
 

	
 
#endif /* TOOLBAR_GUI_H */
src/window.cpp
Show inline comments
 
@@ -3385,32 +3385,33 @@ void RelocateAllWindows(int neww, int ne
 
			case WC_MAIN_WINDOW:
 
			case WC_BOOTSTRAP:
 
				ResizeWindow(w, neww, newh);
 
				continue;
 

	
 
			case WC_MAIN_TOOLBAR:
 
				ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
 
				ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
 

	
 
				top = w->top;
 
				left = PositionMainToolbar(w); // changes toolbar orientation
 
				break;
 

	
 
			case WC_NEWS_WINDOW:
 
				top = newh - w->height;
 
				left = PositionNewsMessage(w);
 
				break;
 

	
 
			case WC_STATUS_BAR:
 
				ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
 
				ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
 

	
 
				top = newh - w->height;
 
				left = PositionStatusbar(w);
 
				break;
 

	
 
			case WC_SEND_NETWORK_MSG:
 
				ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0, false);
 
				ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
 

	
 
				top = newh - w->height - FindWindowById(WC_STATUS_BAR, 0)->height;
 
				left = PositionNetworkChatWindow(w);
 
				break;
 

	
 
			case WC_CONSOLE:
 
				IConsoleResize(w);
src/window_gui.h
Show inline comments
 
@@ -268,13 +268,13 @@ struct QueryString;
 
 * Data structure for an opened window
 
 */
 
struct Window : ZeroedMemoryAllocator {
 
protected:
 
	void InitializeData(WindowNumber window_number);
 
	void InitializePositionSize(int x, int y, int min_width, int min_height);
 
	void FindWindowPlacementAndResize(int def_width, int def_height);
 
	virtual void FindWindowPlacementAndResize(int def_width, int def_height);
 

	
 
	SmallVector<int, 4> scheduled_invalidation_data;  ///< Data of scheduled OnInvalidateData() calls.
 

	
 
public:
 
	Window(WindowDesc *desc);
 

	
0 comments (0 inline, 0 general)