mirror of https://github.com/OpenTTD/OpenTTD
(svn r25988) [1.3] -Backport from trunk:
- Fix: Center the edit sign window like all query windows (r25918) - Fix: Initialization of default objects swapped cost and dates (r25868) - Fix: Use the actual sprite dimensions for sizing the dropdown arrow of dropdown widgets (r25864) - Fix: If the child widgets of a NWidgetHorizontal container do not fill the complete container, align them according to text direction [FS#5686] (r25862, r25729)release/1.3
parent
04fc4595cf
commit
dff569beb6
|
@ -52,7 +52,10 @@ enum ObjectClassID {
|
||||||
/** Allow incrementing of ObjectClassID variables */
|
/** Allow incrementing of ObjectClassID variables */
|
||||||
DECLARE_POSTFIX_INCREMENT(ObjectClassID)
|
DECLARE_POSTFIX_INCREMENT(ObjectClassID)
|
||||||
|
|
||||||
/** An object that isn't use for transport, industries or houses. */
|
/** An object that isn't use for transport, industries or houses.
|
||||||
|
* @note If you change this struct, adopt the initialization of
|
||||||
|
* default objects in table/object_land.h
|
||||||
|
*/
|
||||||
struct ObjectSpec {
|
struct ObjectSpec {
|
||||||
/* 2 because of the "normal" and "buy" sprite stacks. */
|
/* 2 because of the "normal" and "buy" sprite stacks. */
|
||||||
GRFFilePropsBase<2> grf_prop; ///< Properties related the the grf file
|
GRFFilePropsBase<2> grf_prop; ///< Properties related the the grf file
|
||||||
|
|
|
@ -417,11 +417,10 @@ struct GameOptionsWindow : Window {
|
||||||
if (list != NULL) {
|
if (list != NULL) {
|
||||||
/* Find the biggest item for the default size. */
|
/* Find the biggest item for the default size. */
|
||||||
for (DropDownList::iterator it = list->begin(); it != list->end(); it++) {
|
for (DropDownList::iterator it = list->begin(); it != list->end(); it++) {
|
||||||
static const Dimension extra = {WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM};
|
|
||||||
Dimension string_dim;
|
Dimension string_dim;
|
||||||
int width = (*it)->Width();
|
int width = (*it)->Width();
|
||||||
string_dim.width = width + extra.width;
|
string_dim.width = width + padding.width;
|
||||||
string_dim.height = (*it)->Height(width) + extra.height;
|
string_dim.height = (*it)->Height(width) + padding.height;
|
||||||
*size = maxdim(*size, string_dim);
|
*size = maxdim(*size, string_dim);
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ static const NWidgetPart _nested_query_sign_edit_widgets[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _query_sign_edit_desc(
|
static const WindowDesc _query_sign_edit_desc(
|
||||||
WDP_AUTO, 0, 0,
|
WDP_CENTER, 0, 0,
|
||||||
WC_QUERY_STRING, WC_NONE,
|
WC_QUERY_STRING, WC_NONE,
|
||||||
WDF_CONSTRUCTION,
|
WDF_CONSTRUCTION,
|
||||||
_nested_query_sign_edit_widgets, lengthof(_nested_query_sign_edit_widgets)
|
_nested_query_sign_edit_widgets, lengthof(_nested_query_sign_edit_widgets)
|
||||||
|
|
|
@ -123,7 +123,7 @@ static const DrawTileSprites _object_hq[] = {
|
||||||
|
|
||||||
#undef TILE_SPRITE_LINE
|
#undef TILE_SPRITE_LINE
|
||||||
|
|
||||||
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, flags) { GRFFilePropsBase<2>(), INVALID_OBJECT_CLASS, name, 0xF, size, 0, 0, build_cost_multiplier, clear_cost_multiplier, flags, {0, 0, 0, 0}, 0, height, 1, true }
|
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, flags) { GRFFilePropsBase<2>(), INVALID_OBJECT_CLASS, name, 0xF, size, build_cost_multiplier, clear_cost_multiplier, 0, 0, flags, {0, 0, 0, 0}, 0, height, 1, true }
|
||||||
|
|
||||||
/** Specification of the original object structures. */
|
/** Specification of the original object structures. */
|
||||||
extern const ObjectSpec _original_objects[] = {
|
extern const ObjectSpec _original_objects[] = {
|
||||||
|
|
|
@ -541,16 +541,18 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke
|
||||||
{
|
{
|
||||||
int text_offset = max(0, ((int)(r.bottom - r.top + 1) - FONT_HEIGHT_NORMAL) / 2); // Offset for rendering the text vertically centered
|
int text_offset = 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;
|
||||||
|
|
||||||
if (_current_text_dir == TD_LTR) {
|
if (_current_text_dir == TD_LTR) {
|
||||||
DrawFrameRect(r.left, r.top, r.right - 12, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
||||||
DrawFrameRect(r.right - 11, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
|
DrawFrameRect(r.right + 1 - dd_width, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
|
||||||
DrawString(r.right - (clicked_dropdown ? 10 : 11), r.right, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
|
DrawString(r.right - dd_width + (clicked_dropdown ? 2 : 1), r.right, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
|
||||||
if (str != STR_NULL) DrawString(r.left + 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 + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - dd_width - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK);
|
||||||
} else {
|
} else {
|
||||||
DrawFrameRect(r.left + 12, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
|
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 + 11, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
|
DrawFrameRect(r.left, r.top, r.left + dd_width - 1, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
|
||||||
DrawString(r.left + clicked_dropdown, r.left + 11, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
|
DrawString(r.left + (clicked_dropdown ? 2 : 1), r.left + dd_width, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
|
||||||
if (str != STR_NULL) DrawString(r.left + WD_DROPDOWNTEXT_RIGHT + clicked_button, r.right - WD_DROPDOWNTEXT_LEFT + 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,17 +1223,18 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui
|
||||||
assert(num_changing_childs == 0);
|
assert(num_changing_childs == 0);
|
||||||
|
|
||||||
/* Third loop: Compute position and call the child. */
|
/* Third loop: Compute position and call the child. */
|
||||||
uint position = 0; // Place to put next child relative to origin of the container.
|
uint position = rtl ? this->current_x : 0; // Place to put next child relative to origin of the container.
|
||||||
NWidgetBase *child_wid = rtl ? this->tail : this->head;
|
NWidgetBase *child_wid = this->head;
|
||||||
while (child_wid != NULL) {
|
while (child_wid != NULL) {
|
||||||
uint child_width = child_wid->current_x;
|
uint child_width = child_wid->current_x;
|
||||||
uint child_x = x + position + (rtl ? child_wid->padding_right : child_wid->padding_left);
|
uint child_x = x + (rtl ? position - child_width - child_wid->padding_left : position + child_wid->padding_left);
|
||||||
uint child_y = y + child_wid->padding_top;
|
uint child_y = y + child_wid->padding_top;
|
||||||
|
|
||||||
child_wid->AssignSizePosition(sizing, child_x, child_y, child_width, child_wid->current_y, rtl);
|
child_wid->AssignSizePosition(sizing, child_x, child_y, child_width, child_wid->current_y, rtl);
|
||||||
position += child_width + child_wid->padding_right + child_wid->padding_left;
|
uint padded_child_width = child_width + child_wid->padding_right + child_wid->padding_left;
|
||||||
|
position = rtl ? position - padded_child_width : position + padded_child_width;
|
||||||
|
|
||||||
child_wid = rtl ? child_wid->prev : child_wid->next;
|
child_wid = child_wid->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2039,6 +2042,7 @@ Dimension NWidgetScrollbar::horizontal_dimension = {0, 0};
|
||||||
stickybox_dimension.width = stickybox_dimension.height = 0;
|
stickybox_dimension.width = stickybox_dimension.height = 0;
|
||||||
resizebox_dimension.width = resizebox_dimension.height = 0;
|
resizebox_dimension.width = resizebox_dimension.height = 0;
|
||||||
closebox_dimension.width = closebox_dimension.height = 0;
|
closebox_dimension.width = closebox_dimension.height = 0;
|
||||||
|
dropdown_dimension.width = dropdown_dimension.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dimension NWidgetLeaf::shadebox_dimension = {0, 0};
|
Dimension NWidgetLeaf::shadebox_dimension = {0, 0};
|
||||||
|
@ -2046,6 +2050,7 @@ Dimension NWidgetLeaf::debugbox_dimension = {0, 0};
|
||||||
Dimension NWidgetLeaf::stickybox_dimension = {0, 0};
|
Dimension NWidgetLeaf::stickybox_dimension = {0, 0};
|
||||||
Dimension NWidgetLeaf::resizebox_dimension = {0, 0};
|
Dimension NWidgetLeaf::resizebox_dimension = {0, 0};
|
||||||
Dimension NWidgetLeaf::closebox_dimension = {0, 0};
|
Dimension NWidgetLeaf::closebox_dimension = {0, 0};
|
||||||
|
Dimension NWidgetLeaf::dropdown_dimension = {0, 0};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested leaf widget.
|
* Nested leaf widget.
|
||||||
|
@ -2286,8 +2291,14 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array)
|
||||||
case WWT_DROPDOWN:
|
case WWT_DROPDOWN:
|
||||||
case NWID_BUTTON_DROPDOWN:
|
case NWID_BUTTON_DROPDOWN:
|
||||||
case NWID_PUSHBUTTON_DROPDOWN: {
|
case NWID_PUSHBUTTON_DROPDOWN: {
|
||||||
static const Dimension extra = {WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM};
|
static Dimension extra = {WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM};
|
||||||
padding = &extra;
|
padding = &extra;
|
||||||
|
if (NWidgetLeaf::dropdown_dimension.width == 0) {
|
||||||
|
NWidgetLeaf::dropdown_dimension = GetSpriteSize(SPR_ARROW_DOWN);
|
||||||
|
NWidgetLeaf::dropdown_dimension.width += WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT;
|
||||||
|
NWidgetLeaf::dropdown_dimension.height += WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM;
|
||||||
|
extra.width = WD_DROPDOWNTEXT_LEFT + WD_DROPDOWNTEXT_RIGHT + NWidgetLeaf::dropdown_dimension.width;
|
||||||
|
}
|
||||||
if (this->index >= 0) w->SetStringParameters(this->index);
|
if (this->index >= 0) w->SetStringParameters(this->index);
|
||||||
Dimension d2 = GetStringBoundingBox(this->widget_data);
|
Dimension d2 = GetStringBoundingBox(this->widget_data);
|
||||||
d2.width += extra.width;
|
d2.width += extra.width;
|
||||||
|
|
|
@ -775,6 +775,8 @@ public:
|
||||||
bool ButtonHit(const Point &pt);
|
bool ButtonHit(const Point &pt);
|
||||||
|
|
||||||
static void InvalidateDimensionCache();
|
static void InvalidateDimensionCache();
|
||||||
|
|
||||||
|
static Dimension dropdown_dimension; ///< Cached size of a dropdown widget.
|
||||||
private:
|
private:
|
||||||
static Dimension shadebox_dimension; ///< Cached size of a shadebox widget.
|
static Dimension shadebox_dimension; ///< Cached size of a shadebox widget.
|
||||||
static Dimension debugbox_dimension; ///< Cached size of a debugbox widget.
|
static Dimension debugbox_dimension; ///< Cached size of a debugbox widget.
|
||||||
|
|
|
@ -131,7 +131,7 @@ enum WidgetDrawDistances {
|
||||||
/* Dropdown widget. */
|
/* Dropdown widget. */
|
||||||
WD_DROPDOWN_HEIGHT = 12, ///< Height of a drop down widget.
|
WD_DROPDOWN_HEIGHT = 12, ///< Height of a drop down widget.
|
||||||
WD_DROPDOWNTEXT_LEFT = 2, ///< Left offset of the dropdown widget string.
|
WD_DROPDOWNTEXT_LEFT = 2, ///< Left offset of the dropdown widget string.
|
||||||
WD_DROPDOWNTEXT_RIGHT = 14, ///< Right 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_TOP = 1, ///< Top offset of the dropdown widget string.
|
||||||
WD_DROPDOWNTEXT_BOTTOM = 1, ///< Bottom offset of the dropdown widget string.
|
WD_DROPDOWNTEXT_BOTTOM = 1, ///< Bottom offset of the dropdown widget string.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue