Changeset - r25214:ac90bf6da654
[Not reviewed]
master
0 6 0
Peter Nelson - 3 years ago 2021-04-19 11:12:07
peter1138@openttd.org
Codechange: Add internal widget alignment property, along with widget part.
6 files changed with 142 insertions and 55 deletions:
0 comments (0 inline, 0 general)
src/gfx_func.h
Show inline comments
 
@@ -82,42 +82,24 @@ void UpdateGUIZoom();
 
void UndrawMouseCursor();
 

	
 
/** Size of the buffer used for drawing strings. */
 
static const int DRAW_STRING_BUFFER = 2048;
 

	
 
void RedrawScreenRect(int left, int top, int right, int bottom);
 
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
 

	
 
Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
 
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
 
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
 

	
 
/** How to align the to-be drawn text. */
 
enum StringAlignment {
 
	SA_LEFT        = 0 << 0, ///< Left align the text.
 
	SA_HOR_CENTER  = 1 << 0, ///< Horizontally center the text.
 
	SA_RIGHT       = 2 << 0, ///< Right align the text (must be a single bit).
 
	SA_HOR_MASK    = 3 << 0, ///< Mask for horizontal alignment.
 

	
 
	SA_TOP         = 0 << 2, ///< Top align the text.
 
	SA_VERT_CENTER = 1 << 2, ///< Vertically center the text.
 
	SA_BOTTOM      = 2 << 2, ///< Bottom align the text.
 
	SA_VERT_MASK   = 3 << 2, ///< Mask for vertical alignment.
 

	
 
	SA_CENTER      = SA_HOR_CENTER | SA_VERT_CENTER, ///< Center both horizontally and vertically.
 

	
 
	SA_FORCE       = 1 << 4, ///< Force the alignment, i.e. don't swap for RTL languages.
 
};
 
DECLARE_ENUM_AS_BIT_SET(StringAlignment)
 

	
 
int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 

	
 
void DrawCharCentered(WChar c, int x, int y, TextColour colour);
 

	
 
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
 
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
 
void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 

	
src/gfx_type.h
Show inline comments
 
@@ -314,13 +314,31 @@ struct Palette {
 
	Colour palette[256]; ///< Current palette. Entry 0 has to be always fully transparent!
 
	int first_dirty;     ///< The first dirty element.
 
	int count_dirty;     ///< The number of dirty elements.
 
};
 

	
 
/** Modes for 8bpp support */
 
enum Support8bpp {
 
	S8BPP_NONE = 0, ///< No support for 8bpp by OS or hardware, force 32bpp blitters.
 
	S8BPP_SYSTEM,   ///< No 8bpp support by hardware, do not try to use 8bpp video modes or hardware palettes.
 
	S8BPP_HARDWARE, ///< Full 8bpp support by OS and hardware.
 
};
 

	
 
	/** How to align the to-be drawn text. */
 
enum StringAlignment {
 
	SA_LEFT        = 0 << 0, ///< Left align the text.
 
	SA_HOR_CENTER  = 1 << 0, ///< Horizontally center the text.
 
	SA_RIGHT       = 2 << 0, ///< Right align the text (must be a single bit).
 
	SA_HOR_MASK    = 3 << 0, ///< Mask for horizontal alignment.
 

	
 
	SA_TOP         = 0 << 2, ///< Top align the text.
 
	SA_VERT_CENTER = 1 << 2, ///< Vertically center the text.
 
	SA_BOTTOM      = 2 << 2, ///< Bottom align the text.
 
	SA_VERT_MASK   = 3 << 2, ///< Mask for vertical alignment.
 

	
 
	SA_CENTER      = SA_HOR_CENTER | SA_VERT_CENTER, ///< Center both horizontally and vertically.
 

	
 
	SA_FORCE       = 1 << 4, ///< Force the alignment, i.e. don't swap for RTL languages.
 
};
 
DECLARE_ENUM_AS_BIT_SET(StringAlignment)
 

	
 
#endif /* GFX_TYPE_H */
src/news_gui.cpp
Show inline comments
 
@@ -413,25 +413,25 @@ struct NewsWindow : Window {
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_N_DATE) SetDParam(0, this->ni->date);
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_N_CAPTION:
 
				DrawCaption(r, COLOUR_LIGHT_BLUE, this->owner, STR_NEWS_MESSAGE_CAPTION);
 
				DrawCaption(r, COLOUR_LIGHT_BLUE, this->owner, STR_NEWS_MESSAGE_CAPTION, SA_HOR_CENTER);
 
				break;
 

	
 
			case WID_N_PANEL:
 
				this->DrawNewsBorder(r);
 
				break;
 

	
 
			case WID_N_MESSAGE:
 
				CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
 
				DrawStringMultiLine(r.left, r.right, r.top, r.bottom, this->ni->string_id, TC_FROMSTRING, SA_CENTER);
 
				break;
 

	
 
			case WID_N_MGR_FACE: {
src/widget.cpp
Show inline comments
 
@@ -16,24 +16,51 @@
 
#include "transparency.h"
 
#include "core/geometry_func.hpp"
 
#include "settings_type.h"
 
#include "querystring_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "table/string_colours.h"
 

	
 
#include "safeguards.h"
 

	
 
/**
 
 * Calculate x and y coordinates for an aligned object within a window.
 
 * @param r     Rectangle of the widget to be drawn in.
 
 * @param d     Dimension of the object to be drawn.
 
 * @param align Alignment of the object.
 
 * @return A point containing the position at which to draw.
 
 */
 
static inline Point GetAlignedPosition(const Rect &r, const Dimension &d, StringAlignment align)
 
{
 
	Point p;
 
	/* In case we have a RTL language we swap the alignment. */
 
	if (!(align & SA_FORCE) && _current_text_dir == TD_RTL && (align & SA_HOR_MASK) != SA_HOR_CENTER) align ^= SA_RIGHT;
 
	switch (align & SA_HOR_MASK) {
 
		case SA_LEFT:       p.x = r.left; break;
 
		case SA_HOR_CENTER: p.x = CenterBounds(r.left, r.right, d.width); break;
 
		case SA_RIGHT:      p.x = r.right - d.width; break;
 
		default: NOT_REACHED();
 
	}
 
	switch (align & SA_VERT_MASK) {
 
		case SA_TOP:         p.y = r.top; break;
 
		case SA_VERT_CENTER: p.y = CenterBounds(r.top, r.bottom, d.height); break;
 
		case SA_BOTTOM:      p.y = r.bottom - d.height; break;
 
		default: NOT_REACHED();
 
	}
 
	return p;
 
}
 

	
 
/**
 
 * Compute the vertical position of the draggable part of scrollbar
 
 * @param sb     Scrollbar list data
 
 * @param top    Top position of the scrollbar (top position of the up-button)
 
 * @param bottom Bottom position of the scrollbar (bottom position of the down-button)
 
 * @param horizontal Whether the scrollbar is horizontal or not
 
 * @return A Point, with x containing the top coordinate of the draggable part, and
 
 *                       y containing the bottom coordinate of the draggable part
 
 */
 
static Point HandleScrollbarHittest(const Scrollbar *sb, int top, int bottom, bool horizontal)
 
{
 
	/* Base for reversion */
 
	int rev_base = top + bottom;
 
@@ -203,74 +230,79 @@ void DrawFrameRect(int left, int top, in
 
			GfxFillRect(left + WD_BEVEL_LEFT, top + WD_BEVEL_TOP, right - WD_BEVEL_RIGHT, bottom - WD_BEVEL_BOTTOM, interior);
 
		}
 
	}
 
}
 

	
 
/**
 
 * Draw an image button.
 
 * @param r       Rectangle of the button.
 
 * @param type    Widget type (#WWT_IMGBTN or #WWT_IMGBTN_2).
 
 * @param colour  Colour of the button.
 
 * @param clicked Button is lowered.
 
 * @param img     Sprite to draw.
 
 * @param align   Alignment of the sprite.
 
 */
 
static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colour, bool clicked, SpriteID img)
 
static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colour, bool clicked, SpriteID img, StringAlignment align)
 
{
 
	assert(img != 0);
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
 

	
 
	if ((type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; // Show different image when clicked for #WWT_IMGBTN_2.
 
	Dimension d = GetSpriteSize(img);
 
	DrawSprite(img, PAL_NONE, CenterBounds(r.left, r.right, d.width) + clicked, CenterBounds(r.top, r.bottom, d.height) + clicked);
 
	Point p = GetAlignedPosition(r, d, align);
 
	DrawSprite(img, PAL_NONE, p.x + clicked, p.y + clicked);
 
}
 

	
 
/**
 
 * Draw the label-part of a widget.
 
 * @param r       Rectangle of the label background.
 
 * @param type    Widget type (#WWT_TEXTBTN, #WWT_TEXTBTN_2, or #WWT_LABEL).
 
 * @param clicked Label is rendered lowered.
 
 * @param str     Text to draw.
 
 * @param align   Alignment of the text.
 
 */
 
static inline void DrawLabel(const Rect &r, WidgetType type, bool clicked, StringID str)
 
static inline void DrawLabel(const Rect &r, WidgetType type, bool clicked, StringID str, StringAlignment align)
 
{
 
	if (str == STR_NULL) return;
 
	if ((type & WWT_MASK) == WWT_TEXTBTN_2 && clicked) str++;
 
	Dimension d = GetStringBoundingBox(str);
 
	int offset = std::max(0, ((int)(r.bottom - r.top + 1) - (int)d.height) / 2); // Offset for rendering the text vertically centered
 
	DrawString(r.left + clicked, r.right + clicked, r.top + offset + clicked, str, TC_FROMSTRING, SA_HOR_CENTER);
 
	Point p = GetAlignedPosition(r, d, align);
 
	DrawString(r.left + clicked, r.right + clicked, p.y + clicked, str, TC_FROMSTRING, align);
 
}
 

	
 
/**
 
 * Draw text.
 
 * @param r      Rectangle of the background.
 
 * @param colour Colour of the text.
 
 * @param str    Text to draw.
 
 * @param align  Alignment of the text.
 
 */
 
static inline void DrawText(const Rect &r, TextColour colour, StringID str)
 
static inline void DrawText(const Rect &r, TextColour colour, StringID str, StringAlignment align)
 
{
 
	Dimension d = GetStringBoundingBox(str);
 
	int offset = std::max(0, ((int)(r.bottom - r.top + 1) - (int)d.height) / 2); // Offset for rendering the text vertically centered
 
	if (str != STR_NULL) DrawString(r.left, r.right, r.top + offset, str, colour);
 
	Point p = GetAlignedPosition(r, d, align);
 
	if (str != STR_NULL) DrawString(r.left, r.right, p.y, str, colour, align);
 
}
 

	
 
/**
 
 * Draw an inset widget.
 
 * @param r      Rectangle of the background.
 
 * @param colour Colour of the inset.
 
 * @param str    Text to draw.
 
 * @param align  Alignment of the text.
 
 */
 
static inline void DrawInset(const Rect &r, Colours colour, StringID str)
 
static inline void DrawInset(const Rect &r, Colours colour, StringID str, StringAlignment align)
 
{
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_LOWERED | FR_DARKENED);
 
	if (str != STR_NULL) DrawString(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + WD_INSET_TOP, str);
 
	if (str != STR_NULL) DrawString(r.left + WD_INSET_LEFT, r.right - WD_INSET_RIGHT, r.top + WD_INSET_TOP, str, TC_FROMSTRING, align);
 
}
 

	
 
/**
 
 * Draw a matrix widget.
 
 * @param r       Rectangle of the matrix background.
 
 * @param colour  Colour of the background.
 
 * @param clicked Matrix is rendered lowered.
 
 * @param data    Data of the widget, number of rows and columns of the widget.
 
 * @param resize_x Matrix resize unit size.
 
 * @param resize_y Matrix resize unit size.
 
 */
 
static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16 data, uint resize_x, uint resize_y)
 
@@ -396,30 +428,31 @@ static inline void DrawHorizontalScrollb
 
	GfxFillRect(r.left + width, r.top + centre + 3, r.right - width, r.top + centre + 3, c2);
 

	
 
	/* draw actual scrollbar */
 
	Point pt = HandleScrollbarHittest(scrollbar, r.left, r.right, true);
 
	DrawFrameRect(pt.x, r.top, pt.y, r.bottom, colour, bar_dragged ? FR_LOWERED : FR_NONE);
 
}
 

	
 
/**
 
 * Draw a frame widget.
 
 * @param r      Rectangle of the frame.
 
 * @param colour Colour of the frame.
 
 * @param str    Text of the frame.
 
 * @param align  Alignment of the text in the frame.
 
 */
 
static inline void DrawFrame(const Rect &r, Colours colour, StringID str)
 
static inline void DrawFrame(const Rect &r, Colours colour, StringID str, StringAlignment align)
 
{
 
	int x2 = r.left; // by default the left side is the left side of the widget
 

	
 
	if (str != STR_NULL) x2 = DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top, str);
 
	if (str != STR_NULL) x2 = DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top, str, TC_FROMSTRING, align);
 

	
 
	int c1 = _colour_gradient[colour][3];
 
	int c2 = _colour_gradient[colour][7];
 

	
 
	/* If the frame has text, adjust the top bar to fit half-way through */
 
	int dy1 = 4;
 
	if (str != STR_NULL) dy1 = FONT_HEIGHT_NORMAL / 2 - 1;
 
	int dy2 = dy1 + 1;
 

	
 
	if (_current_text_dir == TD_LTR) {
 
		/* Line from upper left corner to start of text */
 
		GfxFillRect(r.left, r.top + dy1, r.left + 4, r.top + dy1, c1);
 
@@ -449,58 +482,58 @@ static inline void DrawFrame(const Rect 
 
	GfxFillRect(r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1, c1);
 
	GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2);
 
}
 

	
 
/**
 
 * Draw a shade box.
 
 * @param r       Rectangle of the box.
 
 * @param colour  Colour of the shade box.
 
 * @param clicked Box is lowered.
 
 */
 
static inline void DrawShadeBox(const Rect &r, Colours colour, bool clicked)
 
{
 
	DrawImageButtons(r, WWT_SHADEBOX, colour, clicked, clicked ? SPR_WINDOW_SHADE: SPR_WINDOW_UNSHADE);
 
	DrawImageButtons(r, WWT_SHADEBOX, colour, clicked, clicked ? SPR_WINDOW_SHADE: SPR_WINDOW_UNSHADE, SA_CENTER);
 
}
 

	
 
/**
 
 * Draw a sticky box.
 
 * @param r       Rectangle of the box.
 
 * @param colour  Colour of the sticky box.
 
 * @param clicked Box is lowered.
 
 */
 
static inline void DrawStickyBox(const Rect &r, Colours colour, bool clicked)
 
{
 
	DrawImageButtons(r, WWT_STICKYBOX, colour, clicked, clicked ? SPR_PIN_UP : SPR_PIN_DOWN);
 
	DrawImageButtons(r, WWT_STICKYBOX, colour, clicked, clicked ? SPR_PIN_UP : SPR_PIN_DOWN, SA_CENTER);
 
}
 

	
 
/**
 
 * Draw a defsize box.
 
 * @param r       Rectangle of the box.
 
 * @param colour  Colour of the defsize box.
 
 * @param clicked Box is lowered.
 
 */
 
static inline void DrawDefSizeBox(const Rect &r, Colours colour, bool clicked)
 
{
 
	DrawImageButtons(r, WWT_DEFSIZEBOX, colour, clicked, SPR_WINDOW_DEFSIZE);
 
	DrawImageButtons(r, WWT_DEFSIZEBOX, colour, clicked, SPR_WINDOW_DEFSIZE, SA_CENTER);
 
}
 

	
 
/**
 
 * Draw a NewGRF debug box.
 
 * @param r       Rectangle of the box.
 
 * @param colour  Colour of the debug box.
 
 * @param clicked Box is lowered.
 
 */
 
static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked)
 
{
 
	DrawImageButtons(r, WWT_DEBUGBOX, colour, clicked, SPR_WINDOW_DEBUG);
 
	DrawImageButtons(r, WWT_DEBUGBOX, colour, clicked, SPR_WINDOW_DEBUG, SA_CENTER);
 
}
 

	
 
/**
 
 * Draw a resize box.
 
 * @param r       Rectangle of the box.
 
 * @param colour  Colour of the resize box.
 
 * @param at_left Resize box is at left-side of the window,
 
 * @param clicked Box is lowered.
 
 */
 
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked)
 
{
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
 
@@ -525,84 +558,87 @@ static inline void DrawCloseBox(const Re
 
	if (colour != COLOUR_WHITE) DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
 
	Dimension d = GetSpriteSize(SPR_CLOSEBOX);
 
	int s = UnScaleGUI(1); /* Offset to account for shadow of SPR_CLOSEBOX */
 
	DrawSprite(SPR_CLOSEBOX, (colour != COLOUR_WHITE ? TC_BLACK : TC_SILVER) | (1 << PALETTE_TEXT_RECOLOUR), CenterBounds(r.left, r.right, d.width - s), CenterBounds(r.top, r.bottom, d.height - s));
 
}
 

	
 
/**
 
 * Draw a caption bar.
 
 * @param r      Rectangle of the bar.
 
 * @param colour Colour of the window.
 
 * @param owner  'Owner' of the window.
 
 * @param str    Text to draw in the bar.
 
 * @param align  Alignment of the text.
 
 */
 
void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str)
 
void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str, StringAlignment align)
 
{
 
	bool company_owned = owner < MAX_COMPANIES;
 

	
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_BORDERONLY);
 
	DrawFrameRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, colour, company_owned ? FR_LOWERED | FR_DARKENED | FR_BORDERONLY : FR_LOWERED | FR_DARKENED);
 

	
 
	if (company_owned) {
 
		GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[owner]][4]);
 
	}
 

	
 
	if (str != STR_NULL) {
 
		Dimension d = GetStringBoundingBox(str);
 
		int offset = std::max(0, ((int)(r.bottom - r.top + 1) - (int)d.height) / 2); // Offset for rendering the text vertically centered
 
		DrawString(r.left + WD_CAPTIONTEXT_LEFT, r.right - WD_CAPTIONTEXT_RIGHT, r.top + offset, str, TC_FROMSTRING, SA_HOR_CENTER);
 
		Point p = GetAlignedPosition(r, d, align);
 
		DrawString(r.left + WD_CAPTIONTEXT_LEFT, r.right - WD_CAPTIONTEXT_RIGHT, p.y, str, TC_FROMSTRING, align);
 
	}
 
}
 

	
 
/**
 
 * Draw a button with a dropdown (#WWT_DROPDOWN and #NWID_BUTTON_DROPDOWN).
 
 * @param r                Rectangle containing the widget.
 
 * @param colour           Background colour of the widget.
 
 * @param clicked_button   The button-part is lowered.
 
 * @param clicked_dropdown The drop-down part is lowered.
 
 * @param str              Text of the button.
 
 * @param align            Alignment of the text within the dropdown.
 
 *
 
 * @note Magic constants are also used in #NWidgetLeaf::ButtonHit.
 
 */
 
static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, StringID str)
 
static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, StringID str, StringAlignment align)
 
{
 
	int text_offset = std::max(0, ((int)(r.bottom - r.top + 1) - FONT_HEIGHT_NORMAL) / 2); // Offset for rendering the text vertically centered
 

	
 
	int dd_width  = NWidgetLeaf::dropdown_dimension.width;
 
	int dd_height = NWidgetLeaf::dropdown_dimension.height;
 
	int image_offset = std::max(0, ((int)(r.bottom - r.top + 1) - dd_height) / 2);
 

	
 
	if (_current_text_dir == TD_LTR) {
 
		DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
		DrawFrameRect(r.right + 1 - dd_width, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 
		DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.right - (dd_width - 2) + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
		if (str != STR_NULL) DrawString(r.left + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - dd_width - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK);
 
		if (str != STR_NULL) DrawString(r.left + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - dd_width - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK, align);
 
	} else {
 
		DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
		DrawFrameRect(r.left, r.top, r.left + dd_width - 1, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 
		DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
		if (str != STR_NULL) DrawString(r.left + dd_width + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK);
 
		if (str != STR_NULL) DrawString(r.left + dd_width + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK, align);
 
	}
 
}
 

	
 
/**
 
 * Draw a dropdown #WWT_DROPDOWN widget.
 
 * @param r       Rectangle containing the widget.
 
 * @param colour  Background colour of the widget.
 
 * @param clicked The widget is lowered.
 
 * @param str     Text of the button.
 
 * @param align   Alignment of the text.
 
 */
 
static inline void DrawDropdown(const Rect &r, Colours colour, bool clicked, StringID str)
 
static inline void DrawDropdown(const Rect &r, Colours colour, bool clicked, StringID str, StringAlignment align)
 
{
 
	DrawButtonDropdown(r, colour, false, clicked, str);
 
	DrawButtonDropdown(r, colour, false, clicked, str, align);
 
}
 

	
 
/**
 
 * Paint all widgets of a window.
 
 */
 
void Window::DrawWidgets() const
 
{
 
	this->nested_root->Draw(this);
 

	
 
	if (this->flags & WF_WHITE_BORDER) {
 
		DrawFrameRect(0, 0, this->width - 1, this->height - 1, COLOUR_WHITE, FR_BORDERONLY);
 
	}
 
@@ -863,24 +899,25 @@ void NWidgetResizeBase::AssignSizePositi
 
 * @param fill_x      Default horizontal filling.
 
 * @param fill_y      Default vertical filling.
 
 * @param widget_data Data component of the widget. @see Widget::data
 
 * @param tool_tip    Tool tip of the widget. @see Widget::tooltips
 
 */
 
NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y)
 
{
 
	this->colour = colour;
 
	this->index = -1;
 
	this->widget_data = widget_data;
 
	this->tool_tip = tool_tip;
 
	this->scrollbar_index = -1;
 
	this->align = SA_CENTER;
 
}
 

	
 
/**
 
 * Set index of the nested widget in the widget array.
 
 * @param index Index to use.
 
 */
 
void NWidgetCore::SetIndex(int index)
 
{
 
	assert(index >= 0);
 
	this->index = index;
 
}
 

	
 
@@ -895,24 +932,33 @@ void NWidgetCore::SetDataTip(uint32 widg
 
	this->tool_tip = tool_tip;
 
}
 

	
 
/**
 
 * Set the tool tip of the nested widget.
 
 * @param tool_tip Tool tip string to use.
 
 */
 
void NWidgetCore::SetToolTip(StringID tool_tip)
 
{
 
	this->tool_tip = tool_tip;
 
}
 

	
 
/**
 
 * Set the text/image alignment of the nested widget.
 
 * @param align Alignment to use.
 
 */
 
void NWidgetCore::SetAlignment(StringAlignment align)
 
{
 
	this->align = align;
 
}
 

	
 
void NWidgetCore::FillNestedArray(NWidgetBase **array, uint length)
 
{
 
	if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this;
 
}
 

	
 
NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y)
 
{
 
	return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : nullptr;
 
}
 

	
 
/**
 
 * Constructor container baseclass.
 
@@ -1716,24 +1762,25 @@ void NWidgetMatrix::GetScrollOffsets(int
 
 * @param tp     Type of parent widget.
 
 * @param colour Colour of the parent widget.
 
 * @param index  Index in the widget array used by the window system.
 
 * @param child  Child container widget (if supplied). If not supplied, a
 
 *               vertical container will be inserted while adding the first
 
 *               child widget.
 
 */
 
NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL)
 
{
 
	assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME);
 
	if (index >= 0) this->SetIndex(index);
 
	this->child = child;
 
	this->SetAlignment(SA_TOP | SA_LEFT);
 
}
 

	
 
NWidgetBackground::~NWidgetBackground()
 
{
 
	if (this->child != nullptr) delete this->child;
 
}
 

	
 
/**
 
 * Add a child to the parent.
 
 * @param nwid Nested widget to add to the background widget.
 
 *
 
 * Unless a child container has been given in the constructor, a parent behaves as a vertical container.
 
@@ -1849,30 +1896,30 @@ void NWidgetBackground::Draw(const Windo
 

	
 
	const DrawPixelInfo *dpi = _cur_dpi;
 
	if (dpi->left > r.right || dpi->left + dpi->width <= r.left || dpi->top > r.bottom || dpi->top + dpi->height <= r.top) return;
 

	
 
	switch (this->type) {
 
		case WWT_PANEL:
 
			assert(this->widget_data == 0);
 
			DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, this->IsLowered() ? FR_LOWERED : FR_NONE);
 
			break;
 

	
 
		case WWT_FRAME:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawFrame(r, this->colour, this->widget_data);
 
			DrawFrame(r, this->colour, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_INSET:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawInset(r, this->colour, this->widget_data);
 
			DrawInset(r, this->colour, this->widget_data, this->align);
 
			break;
 

	
 
		default:
 
			NOT_REACHED();
 
	}
 

	
 
	if (this->index >= 0) w->DrawWidget(r, this->index);
 
	if (this->child != nullptr) this->child->Draw(w);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
 
	}
 
@@ -2183,33 +2230,37 @@ Dimension NWidgetLeaf::dropdown_dimensio
 
NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip)
 
{
 
	assert(index >= 0 || tp == WWT_LABEL || tp == WWT_TEXT || tp == WWT_CAPTION || tp == WWT_RESIZEBOX || tp == WWT_SHADEBOX || tp == WWT_DEFSIZEBOX || tp == WWT_DEBUGBOX || tp == WWT_STICKYBOX || tp == WWT_CLOSEBOX);
 
	if (index >= 0) this->SetIndex(index);
 
	this->min_x = 0;
 
	this->min_y = 0;
 
	this->SetResize(0, 0);
 

	
 
	switch (tp) {
 
		case WWT_EMPTY:
 
			break;
 

	
 
		case WWT_TEXT:
 
			this->SetFill(0, 0);
 
			this->SetAlignment(SA_LEFT | SA_VERT_CENTER);
 
			break;
 

	
 
		case WWT_PUSHBTN:
 
		case WWT_IMGBTN:
 
		case WWT_PUSHIMGBTN:
 
		case WWT_IMGBTN_2:
 
		case WWT_TEXTBTN:
 
		case WWT_PUSHTXTBTN:
 
		case WWT_TEXTBTN_2:
 
		case WWT_LABEL:
 
		case WWT_TEXT:
 
		case WWT_MATRIX:
 
		case NWID_BUTTON_DROPDOWN:
 
		case NWID_PUSHBUTTON_DROPDOWN:
 
		case WWT_ARROWBTN:
 
		case WWT_PUSHARROWBTN:
 
			this->SetFill(0, 0);
 
			break;
 

	
 
		case WWT_EDITBOX:
 
			this->SetFill(0, 0);
 
			break;
 

	
 
@@ -2250,24 +2301,25 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, 
 
			this->SetDataTip(STR_NULL, STR_TOOLTIP_RESIZE);
 
			break;
 

	
 
		case WWT_CLOSEBOX:
 
			this->SetFill(0, 0);
 
			this->SetMinimalSize(WD_CLOSEBOX_WIDTH, WD_CAPTION_HEIGHT);
 
			this->SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW);
 
			break;
 

	
 
		case WWT_DROPDOWN:
 
			this->SetFill(0, 0);
 
			this->min_y = WD_DROPDOWN_HEIGHT;
 
			this->SetAlignment(SA_TOP | SA_LEFT);
 
			break;
 

	
 
		default:
 
			NOT_REACHED();
 
	}
 
}
 

	
 
void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array)
 
{
 
	if (this->index >= 0 && init_array) { // Fill w->nested_array[]
 
		assert(w->nested_array_size > (uint)this->index);
 
		w->nested_array[this->index] = this;
 
@@ -2484,72 +2536,72 @@ void NWidgetLeaf::Draw(const Window *w)
 
	switch (this->type) {
 
		case WWT_EMPTY:
 
			break;
 

	
 
		case WWT_PUSHBTN:
 
			assert(this->widget_data == 0);
 
			DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FR_LOWERED : FR_NONE);
 
			break;
 

	
 
		case WWT_IMGBTN:
 
		case WWT_PUSHIMGBTN:
 
		case WWT_IMGBTN_2:
 
			DrawImageButtons(r, this->type, this->colour, clicked, this->widget_data);
 
			DrawImageButtons(r, this->type, this->colour, clicked, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_TEXTBTN:
 
		case WWT_PUSHTXTBTN:
 
		case WWT_TEXTBTN_2:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawFrameRect(r.left, r.top, r.right, r.bottom, this->colour, (clicked) ? FR_LOWERED : FR_NONE);
 
			DrawLabel(r, this->type, clicked, this->widget_data);
 
			DrawLabel(r, this->type, clicked, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_ARROWBTN:
 
		case WWT_PUSHARROWBTN: {
 
			SpriteID sprite;
 
			switch (this->widget_data) {
 
				case AWV_DECREASE: sprite = _current_text_dir != TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_INCREASE: sprite = _current_text_dir == TD_RTL ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT; break;
 
				case AWV_LEFT:     sprite = SPR_ARROW_LEFT;  break;
 
				case AWV_RIGHT:    sprite = SPR_ARROW_RIGHT; break;
 
				default: NOT_REACHED();
 
			}
 
			DrawImageButtons(r, WWT_PUSHIMGBTN, this->colour, clicked, sprite);
 
			DrawImageButtons(r, WWT_PUSHIMGBTN, this->colour, clicked, sprite, this->align);
 
			break;
 
		}
 

	
 
		case WWT_LABEL:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawLabel(r, this->type, clicked, this->widget_data);
 
			DrawLabel(r, this->type, clicked, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_TEXT:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawText(r, (TextColour)this->colour, this->widget_data);
 
			DrawText(r, (TextColour)this->colour, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_MATRIX:
 
			DrawMatrix(r, this->colour, clicked, this->widget_data, this->resize_x, this->resize_y);
 
			break;
 

	
 
		case WWT_EDITBOX: {
 
			const QueryString *query = w->GetQueryString(this->index);
 
			if (query != nullptr) query->DrawEditBox(w, this->index);
 
			break;
 
		}
 

	
 
		case WWT_CAPTION:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawCaption(r, this->colour, w->owner, this->widget_data);
 
			DrawCaption(r, this->colour, w->owner, this->widget_data, this->align);
 
			break;
 

	
 
		case WWT_SHADEBOX:
 
			assert(this->widget_data == 0);
 
			DrawShadeBox(r, this->colour, w->IsShaded());
 
			break;
 

	
 
		case WWT_DEBUGBOX:
 
			DrawDebugBox(r, this->colour, clicked);
 
			break;
 

	
 
		case WWT_STICKYBOX:
 
@@ -2564,31 +2616,31 @@ void NWidgetLeaf::Draw(const Window *w)
 

	
 
		case WWT_RESIZEBOX:
 
			assert(this->widget_data == 0);
 
			DrawResizeBox(r, this->colour, this->pos_x < (w->width / 2), !!(w->flags & WF_SIZING));
 
			break;
 

	
 
		case WWT_CLOSEBOX:
 
			DrawCloseBox(r, this->colour);
 
			break;
 

	
 
		case WWT_DROPDOWN:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawDropdown(r, this->colour, clicked, this->widget_data);
 
			DrawDropdown(r, this->colour, clicked, this->widget_data, this->align);
 
			break;
 

	
 
		case NWID_BUTTON_DROPDOWN:
 
		case NWID_PUSHBUTTON_DROPDOWN:
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			DrawButtonDropdown(r, this->colour, clicked, (this->disp_flags & ND_DROPDOWN_ACTIVE) != 0, this->widget_data);
 
			DrawButtonDropdown(r, this->colour, clicked, (this->disp_flags & ND_DROPDOWN_ACTIVE) != 0, this->widget_data, this->align);
 
			break;
 

	
 
		default:
 
			NOT_REACHED();
 
	}
 
	if (this->index >= 0) w->DrawWidget(r, this->index);
 

	
 
	if (this->IsDisabled()) {
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, _colour_gradient[this->colour & 0xF][2], FILLRECT_CHECKER);
 
	}
 

	
 
	_cur_dpi = old_dpi;
 
@@ -2709,24 +2761,32 @@ static int MakeNWidget(const NWidgetPart
 
				break;
 
			}
 

	
 
			case WPT_MINTEXTLINES: {
 
				NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
 
				if (nwrb != nullptr) {
 
					assert(parts->u.text_lines.size >= FS_BEGIN && parts->u.text_lines.size < FS_END);
 
					nwrb->SetMinimalTextLines(parts->u.text_lines.lines, parts->u.text_lines.spacing, parts->u.text_lines.size);
 
				}
 
				break;
 
			}
 

	
 
			case WPT_ALIGNMENT: {
 
				NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
 
				if (nwc != nullptr) {
 
					nwc->SetAlignment(parts->u.align.align);
 
				}
 
				break;
 
			}
 

	
 
			case WPT_FILL: {
 
				NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
 
				if (nwrb != nullptr) nwrb->SetFill(parts->u.xy.x, parts->u.xy.y);
 
				break;
 
			}
 

	
 
			case WPT_DATATIP: {
 
				NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
 
				if (nwc != nullptr) {
 
					nwc->widget_data = parts->u.data_tip.data;
 
					nwc->tool_tip = parts->u.data_tip.tooltip;
 
				}
src/widget_type.h
Show inline comments
 
@@ -80,24 +80,25 @@ enum WidgetType {
 
	NWID_BUTTON_DROPDOWN, ///< Button with a drop-down.
 
	NWID_HSCROLLBAR,      ///< Horizontal scrollbar
 
	NWID_VSCROLLBAR,      ///< Vertical scrollbar
 

	
 
	/* Nested widget part types. */
 
	WPT_RESIZE,       ///< Widget part for specifying resizing.
 
	WPT_MINSIZE,      ///< Widget part for specifying minimal size.
 
	WPT_MINTEXTLINES, ///< Widget part for specifying minimal number of lines of text.
 
	WPT_FILL,         ///< Widget part for specifying fill.
 
	WPT_DATATIP,      ///< Widget part for specifying data and tooltip.
 
	WPT_PADDING,      ///< Widget part for specifying a padding.
 
	WPT_PIPSPACE,     ///< Widget part for specifying pre/inter/post space for containers.
 
	WPT_ALIGNMENT,    ///< Widget part for specifying text/image alignment.
 
	WPT_ENDCONTAINER, ///< Widget part to denote end of a container.
 
	WPT_FUNCTION,     ///< Widget part for calling a user function.
 
	WPT_SCROLLBAR,    ///< Widget part for attaching a scrollbar.
 

	
 
	/* Pushable window widget types. */
 
	WWT_MASK = 0x7F,
 

	
 
	WWB_PUSHBUTTON    = 1 << 7,
 

	
 
	WWT_PUSHBTN       = WWT_PANEL    | WWB_PUSHBUTTON,    ///< Normal push-button (no toggle button) with custom drawing
 
	WWT_PUSHTXTBTN    = WWT_TEXTBTN  | WWB_PUSHBUTTON,    ///< Normal push-button (no toggle button) with text caption
 
	WWT_PUSHIMGBTN    = WWT_IMGBTN   | WWB_PUSHBUTTON,    ///< Normal push-button (no toggle button) with image caption
 
@@ -287,43 +288,45 @@ DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
 

	
 
/**
 
 * Base class for a 'real' widget.
 
 * @ingroup NestedWidgets
 
 */
 
class NWidgetCore : public NWidgetResizeBase {
 
public:
 
	NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip);
 

	
 
	void SetIndex(int index);
 
	void SetDataTip(uint32 widget_data, StringID tool_tip);
 
	void SetToolTip(StringID tool_tip);
 
	void SetAlignment(StringAlignment align);
 

	
 
	inline void SetLowered(bool lowered);
 
	inline bool IsLowered() const;
 
	inline void SetDisabled(bool disabled);
 
	inline bool IsDisabled() const;
 

	
 
	void FillNestedArray(NWidgetBase **array, uint length) override;
 
	NWidgetCore *GetWidgetFromPos(int x, int y) override;
 
	bool IsHighlighted() const override;
 
	TextColour GetHighlightColour() const override;
 
	void SetHighlighted(TextColour highlight_colour) override;
 

	
 
	NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget.
 
	Colours colour;            ///< Colour of this widget.
 
	int index;                 ///< Index of the nested widget in the widget array of the window (\c -1 means 'not used').
 
	uint32 widget_data;        ///< Data of the widget. @see Widget::data
 
	StringID tool_tip;         ///< Tooltip of the widget. @see Widget::tootips
 
	int scrollbar_index;       ///< Index of an attached scrollbar.
 
	TextColour highlight_colour; ///< Colour of highlight.
 
	StringAlignment align;     ///< Alignment of text/image within widget.
 
};
 

	
 
/**
 
 * Highlight the widget or not.
 
 * @param highlight_colour Widget must be highlighted (blink).
 
 */
 
inline void NWidgetCore::SetHighlighted(TextColour highlight_colour)
 
{
 
	this->disp_flags = highlight_colour != TC_INVALID ? SETBITS(this->disp_flags, ND_HIGHLIGHT) : CLRBITS(this->disp_flags, ND_HIGHLIGHT);
 
	this->highlight_colour = highlight_colour;
 
}
 

	
 
@@ -897,44 +900,53 @@ struct NWidgetPartPIP {
 

	
 
/**
 
 * Widget part for storing minimal text line data.
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartTextLines {
 
	uint8 lines;   ///< Number of text lines.
 
	uint8 spacing; ///< Extra spacing around lines.
 
	FontSize size; ///< Font size of text lines.
 
};
 

	
 
/**
 
 * Widget part for setting text/image alignment within a widget.
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartAlignment {
 
	StringAlignment align; ///< Alignment of text/image.
 
};
 

	
 
/**
 
 * Pointer to function returning a nested widget.
 
 * @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget.
 
 * @return Nested widget (tree).
 
 * @post \c *biggest_index must contain the value of the biggest index in the returned tree.
 
 */
 
typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
 

	
 
/**
 
 * Partial widget specification to allow NWidgets to be written nested.
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPart {
 
	WidgetType type;                         ///< Type of the part. @see NWidgetPartType.
 
	union {
 
		Point xy;                        ///< Part with an x/y size.
 
		NWidgetPartDataTip data_tip;     ///< Part with a data/tooltip.
 
		NWidgetPartWidget widget;        ///< Part with a start of a widget.
 
		NWidgetPartPaddings padding;     ///< Part with paddings.
 
		NWidgetPartPIP pip;              ///< Part with pre/inter/post spaces.
 
		NWidgetPartTextLines text_lines; ///< Part with text line data.
 
		NWidgetPartAlignment align;      ///< Part with internal alignment.
 
		NWidgetFunctionType *func_ptr;   ///< Part with a function call.
 
		NWidContainerFlags cont_flags;   ///< Part with container flags.
 
	} u;
 
};
 

	
 
/**
 
 * Widget part function for setting the resize step.
 
 * @param dx Horizontal resize step. 0 means no horizontal resizing.
 
 * @param dy Vertical resize step. 0 means no vertical resizing.
 
 * @ingroup NestedWidgetParts
 
 */
 
static inline NWidgetPart SetResize(int16 dx, int16 dy)
 
@@ -976,24 +988,39 @@ static inline NWidgetPart SetMinimalText
 
{
 
	NWidgetPart part;
 

	
 
	part.type = WPT_MINTEXTLINES;
 
	part.u.text_lines.lines = lines;
 
	part.u.text_lines.spacing = spacing;
 
	part.u.text_lines.size = size;
 

	
 
	return part;
 
}
 

	
 
/**
 
 * Widget part function for setting the alignment of text/images.
 
 * @param align  Alignment of text/image within widget.
 
 * @ingroup NestedWidgetParts
 
 */
 
static inline NWidgetPart SetAlignment(StringAlignment align)
 
{
 
	NWidgetPart part;
 

	
 
	part.type = WPT_ALIGNMENT;
 
	part.u.align.align = align;
 

	
 
	return part;
 
}
 

	
 
/**
 
 * Widget part function for setting filling.
 
 * @param fill_x Horizontal filling step from minimal size.
 
 * @param fill_y Vertical filling step from minimal size.
 
 * @ingroup NestedWidgetParts
 
 */
 
static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
 
{
 
	NWidgetPart part;
 

	
 
	part.type = WPT_FILL;
 
	part.u.xy.x = fill_x;
 
	part.u.xy.y = fill_y;
src/window_gui.h
Show inline comments
 
@@ -131,25 +131,25 @@ enum WidgetDrawDistances {
 
	WD_DROPDOWN_HEIGHT     = 12, ///< Height of a drop down widget.
 
	WD_DROPDOWNTEXT_LEFT   = 2,  ///< Left offset of the dropdown widget string.
 
	WD_DROPDOWNTEXT_RIGHT  = 2,  ///< Right offset of the dropdown widget string.
 
	WD_DROPDOWNTEXT_TOP    = 1,  ///< Top offset of the dropdown widget string.
 
	WD_DROPDOWNTEXT_BOTTOM = 1,  ///< Bottom offset of the dropdown widget string.
 

	
 
	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.
 
};
 

	
 
/* widget.cpp */
 
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
 
void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str);
 
void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str, StringAlignment align);
 

	
 
/* window.cpp */
 
extern Window *_z_front_window;
 
extern Window *_z_back_window;
 
extern Window *_focused_window;
 

	
 

	
 
/** How do we the window to be placed? */
 
enum WindowPosition {
 
	WDP_MANUAL,        ///< Manually align the window (so no automatic location finding)
 
	WDP_AUTO,          ///< Find a place automatically
 
	WDP_CENTER,        ///< Center the window
0 comments (0 inline, 0 general)