Changeset - r21814:76dbe7ca0bbf
[Not reviewed]
master
0 12 0
peter1138 - 10 years ago 2014-10-05 11:20:02
peter1138@openttd.org
(svn r26960) -Codechange: Draw sort button symbols as sprites, and pad sort buttons with non-static width.
12 files changed with 29 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -259,7 +259,7 @@ public:
 
		switch (widget) {
 
			case WID_RV_SORT_ASCENDING_DESCENDING: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/bridge_gui.cpp
Show inline comments
 
@@ -168,7 +168,7 @@ public:
 
		switch (widget) {
 
			case WID_BBS_DROPDOWN_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1391,7 +1391,7 @@ struct BuildVehicleWindow : Window {
 

	
 
			case WID_BV_SORT_ASCENDING_DESCENDING: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/fios_gui.cpp
Show inline comments
 
@@ -483,7 +483,7 @@ public:
 
			case WID_SL_SORT_BYNAME:
 
			case WID_SL_SORT_BYDATE: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/group_gui.cpp
Show inline comments
 
@@ -384,7 +384,7 @@ public:
 

	
 
			case WID_GL_SORT_BY_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/industry_gui.cpp
Show inline comments
 
@@ -1283,7 +1283,7 @@ public:
 
		switch (widget) {
 
			case WID_ID_DROPDOWN_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/network/network_gui.cpp
Show inline comments
 
@@ -523,11 +523,11 @@ public:
 
				break;
 

	
 
			case WID_NG_NAME:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
 
				break;
 

	
 
			case WID_NG_CLIENTS:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
 
				SetDParamMaxValue(0, MAX_CLIENTS);
 
				SetDParamMaxValue(1, MAX_CLIENTS);
 
				SetDParamMaxValue(2, MAX_COMPANIES);
 
@@ -536,7 +536,7 @@ public:
 
				break;
 

	
 
			case WID_NG_MAPSIZE:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
 
				SetDParamMaxValue(0, MAX_MAP_SIZE);
 
				SetDParamMaxValue(1, MAX_MAP_SIZE);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
 
@@ -544,7 +544,7 @@ public:
 

	
 
			case WID_NG_DATE:
 
			case WID_NG_YEARS:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
 
				SetDParamMaxValue(0, 5);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
 
				break;
src/station_gui.cpp
Show inline comments
 
@@ -339,7 +339,7 @@ public:
 
		switch (widget) {
 
			case WID_STL_SORTBY: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/town_gui.cpp
Show inline comments
 
@@ -797,7 +797,7 @@ public:
 
		switch (widget) {
 
			case WID_TD_SORT_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/vehicle_gui.cpp
Show inline comments
 
@@ -1486,7 +1486,7 @@ public:
 

	
 
			case WID_VL_SORT_ORDER: {
 
				Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
 
				d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
 
				d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
src/widget.cpp
Show inline comments
 
@@ -26,9 +26,6 @@
 

	
 
#include "safeguards.h"
 

	
 
static const char *UPARROW   = "\xEE\x8A\xA0"; ///< String containing an upwards pointing arrow.
 
static const char *DOWNARROW = "\xEE\x8A\xAA"; ///< String containing a downwards pointing arrow.
 

	
 
/**
 
 * Compute the vertical position of the draggable part of scrollbar
 
 * @param sb     Scrollbar list data
 
@@ -644,11 +641,22 @@ void Window::DrawSortButtonState(int wid
 
	assert(this->nested_array != NULL);
 
	const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(widget);
 

	
 
	/* Sort button uses the same sprites as vertical scrollbar */
 
	Dimension dim = NWidgetScrollbar::GetVerticalDimension();
 
	int offset = this->IsWidgetLowered(widget) ? 1 : 0;
 
	int base = offset + nwid->pos_x + (_current_text_dir == TD_LTR ? nwid->current_x - WD_SORTBUTTON_ARROW_WIDTH : 0);
 
	int top = nwid->pos_y;
 

	
 
	DrawString(base, base + WD_SORTBUTTON_ARROW_WIDTH, top + 1 + offset, state == SBS_DOWN ? DOWNARROW : UPARROW, TC_BLACK, SA_HOR_CENTER);
 
	int x = offset + nwid->pos_x + (_current_text_dir == TD_LTR ? nwid->current_x - dim.width : 0);
 
	int y = offset + nwid->pos_y + (nwid->current_y - dim.height) / 2;
 

	
 
	DrawSprite(state == SBS_DOWN ? SPR_ARROW_DOWN : SPR_ARROW_UP, PAL_NONE, x, y);
 
}
 

	
 
/**
 
 * Get width of up/down arrow of sort button state.
 
 * @return Width of space required by sort button arrow.
 
 */
 
int Window::SortButtonWidth()
 
{
 
	return NWidgetScrollbar::GetVerticalDimension().width + 1;
 
}
 

	
 

	
src/window_gui.h
Show inline comments
 
@@ -136,8 +136,6 @@ enum WidgetDrawDistances {
 
	WD_DROPDOWNTEXT_TOP    = 1,  ///< Top offset of the dropdown widget string.
 
	WD_DROPDOWNTEXT_BOTTOM = 1,  ///< Bottom offset of the dropdown widget string.
 

	
 
	WD_SORTBUTTON_ARROW_WIDTH = 11, ///< Width of up/down arrow of sort button state.
 

	
 
	WD_PAR_VSEP_NORMAL = 2,      ///< Normal amount of vertical space between two paragraphs of text.
 
	WD_PAR_VSEP_WIDE   = 8,      ///< Large amount of vertical space between two paragraphs of text.
 
};
 
@@ -509,6 +507,7 @@ public:
 
	void DrawWidgets() const;
 
	void DrawViewport() const;
 
	void DrawSortButtonState(int widget, SortButtonState state) const;
 
	static int SortButtonWidth();
 

	
 
	void DeleteChildWindows(WindowClass wc = WC_INVALID) const;
 

	
0 comments (0 inline, 0 general)