mirror of https://github.com/OpenTTD/OpenTTD
(svn r16837) -Codechange: Collect largest used index while constructing nested widget tree.
parent
f085d7775b
commit
92206f2d18
|
@ -86,7 +86,13 @@ struct GraphLegendWindow : Window {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static NWidgetBase *MakeNWidgetCompanyLines()
|
/**
|
||||||
|
* Construct a vertical list of buttons, one for each company.
|
||||||
|
* @param biggest_index Storage for collecting the biggest index used in the returned tree.
|
||||||
|
* @return Panel with company buttons.
|
||||||
|
* @postcond \c *biggest_index contains the largest used index in the tree.
|
||||||
|
*/
|
||||||
|
static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetVertical *vert = new NWidgetVertical();
|
NWidgetVertical *vert = new NWidgetVertical();
|
||||||
|
|
||||||
|
@ -97,6 +103,7 @@ static NWidgetBase *MakeNWidgetCompanyLines()
|
||||||
panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION);
|
panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION);
|
||||||
vert->Add(panel);
|
vert->Add(panel);
|
||||||
}
|
}
|
||||||
|
*biggest_index = GLW_LAST_COMPANY;
|
||||||
return vert;
|
return vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,8 +1202,12 @@ struct PerformanceRatingDetailWindow : Window {
|
||||||
|
|
||||||
CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
|
CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
|
||||||
|
|
||||||
/** Make a vertical list of panels for outputting score details. */
|
/** Make a vertical list of panels for outputting score details.
|
||||||
static NWidgetBase *MakePerformanceDetailPanels()
|
* @param biggest_index Storage for collecting the biggest index used in the returned tree.
|
||||||
|
* @return Panel with performance details.
|
||||||
|
* @postcond \c *biggest_index contains the largest used index in the tree.
|
||||||
|
*/
|
||||||
|
static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
|
||||||
{
|
{
|
||||||
const StringID performance_tips[] = {
|
const StringID performance_tips[] = {
|
||||||
STR_PERFORMANCE_DETAIL_VEHICLES_TIP,
|
STR_PERFORMANCE_DETAIL_VEHICLES_TIP,
|
||||||
|
@ -1221,11 +1232,17 @@ static NWidgetBase *MakePerformanceDetailPanels()
|
||||||
panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]);
|
panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]);
|
||||||
vert->Add(panel);
|
vert->Add(panel);
|
||||||
}
|
}
|
||||||
|
*biggest_index = PRW_SCORE_LAST;
|
||||||
return vert;
|
return vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make a number of rows with button-like graphics, for enabling/disabling each company. */
|
/**
|
||||||
static NWidgetBase *MakeCompanyButtonRows()
|
* Make a number of rows with button-like graphics, for enabling/disabling each company.
|
||||||
|
* @param biggest_index Storage for collecting the biggest index used in the returned tree.
|
||||||
|
* @return Panel with rows of company buttons.
|
||||||
|
* @postcond \c *biggest_index contains the largest used index in the tree.
|
||||||
|
*/
|
||||||
|
static NWidgetBase *MakeCompanyButtonRows(int *biggest_index)
|
||||||
{
|
{
|
||||||
static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
|
static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
|
||||||
NWidgetVertical *vert = NULL; // Storage for all rows.
|
NWidgetVertical *vert = NULL; // Storage for all rows.
|
||||||
|
@ -1252,6 +1269,7 @@ static NWidgetBase *MakeCompanyButtonRows()
|
||||||
hor->Add(panel);
|
hor->Add(panel);
|
||||||
hor_length++;
|
hor_length++;
|
||||||
}
|
}
|
||||||
|
*biggest_index = PRW_COMPANY_LAST;
|
||||||
if (vert == NULL) return hor; // All buttons fit in a single row.
|
if (vert == NULL) return hor; // All buttons fit in a single row.
|
||||||
|
|
||||||
if (hor_length > 0 && hor_length < MAX_LENGTH) {
|
if (hor_length > 0 && hor_length < MAX_LENGTH) {
|
||||||
|
|
|
@ -1081,7 +1081,13 @@ NEWS_SETTINGS_LINE(28, NT_GENERAL),
|
||||||
{ WIDGETS_END},
|
{ WIDGETS_END},
|
||||||
};
|
};
|
||||||
|
|
||||||
static NWidgetBase *MakeNewsSettingLines()
|
/**
|
||||||
|
* Make nested widget tree for the news settings.
|
||||||
|
* @param biggest_index Storage for collecting the biggest index used in the returned tree.
|
||||||
|
* @return Panel with rows of news settings.
|
||||||
|
* @postcond \c *biggest_index contains the largest used index in the tree.
|
||||||
|
*/
|
||||||
|
static NWidgetBase *MakeNewsSettingLines(int *biggest_index)
|
||||||
{
|
{
|
||||||
const int NEWS_SETTING_HEIGHT = 12; // Height of one line.
|
const int NEWS_SETTING_HEIGHT = 12; // Height of one line.
|
||||||
NWidgetVertical *vert = new NWidgetVertical;
|
NWidgetVertical *vert = new NWidgetVertical;
|
||||||
|
@ -1110,6 +1116,7 @@ static NWidgetBase *MakeNewsSettingLines()
|
||||||
|
|
||||||
vert->Add(hor);
|
vert->Add(hor);
|
||||||
}
|
}
|
||||||
|
*biggest_index = widnum - 1;
|
||||||
return vert;
|
return vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
/** @file osk_gui.cpp The On Screen Keyboard GUI */
|
/** @file osk_gui.cpp The On Screen Keyboard GUI */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "core/math_func.hpp"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -336,9 +337,10 @@ static const int INTER_KEY_SPACE = 2; // Number of pixels between two keys.
|
||||||
* @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget.
|
* @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget.
|
||||||
* @param widnum Widget number of the key.
|
* @param widnum Widget number of the key.
|
||||||
* @param widdata Data value of the key widget.
|
* @param widdata Data value of the key widget.
|
||||||
|
* @param biggest_index Collected biggest widget index so far.
|
||||||
* @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows.
|
* @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows.
|
||||||
*/
|
*/
|
||||||
static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType widtype, int widnum, uint16 widdata)
|
static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index)
|
||||||
{
|
{
|
||||||
int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1);
|
int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1);
|
||||||
|
|
||||||
|
@ -355,84 +357,86 @@ static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType
|
||||||
leaf->SetMinimalSize(key_width, height);
|
leaf->SetMinimalSize(key_width, height);
|
||||||
hor->Add(leaf);
|
hor->Add(leaf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*biggest_index = max(*biggest_index, widnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the top row keys (cancel, ok, backspace). */
|
/** Construct the top row keys (cancel, ok, backspace). */
|
||||||
static NWidgetBase *MakeTopKeys()
|
static NWidgetBase *MakeTopKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 12;
|
int key_height = 12;
|
||||||
|
|
||||||
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, OSK_WIDGET_CANCEL, STR_QUERY_CANCEL);
|
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, OSK_WIDGET_CANCEL, STR_QUERY_CANCEL, biggest_index);
|
||||||
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, OSK_WIDGET_OK, STR_QUERY_OK);
|
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, OSK_WIDGET_OK, STR_QUERY_OK, biggest_index);
|
||||||
AddKey(hor, key_height, 2 * 2, WWT_PUSHIMGBTN, OSK_WIDGET_BACKSPACE, SPR_OSK_BACKSPACE);
|
AddKey(hor, key_height, 2 * 2, WWT_PUSHIMGBTN, OSK_WIDGET_BACKSPACE, SPR_OSK_BACKSPACE, biggest_index);
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the row containing the digit keys. */
|
/** Construct the row containing the digit keys. */
|
||||||
static NWidgetBase *MakeNumberKeys()
|
static NWidgetBase *MakeNumberKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 16;
|
int key_height = 16;
|
||||||
|
|
||||||
for (int widnum = OSK_WIDGET_NUMBERS_FIRST; widnum <= OSK_WIDGET_NUMBERS_LAST; widnum++) {
|
for (int widnum = OSK_WIDGET_NUMBERS_FIRST; widnum <= OSK_WIDGET_NUMBERS_LAST; widnum++) {
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0);
|
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index);
|
||||||
}
|
}
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the qwerty row keys. */
|
/** Construct the qwerty row keys. */
|
||||||
static NWidgetBase *MakeQwertyKeys()
|
static NWidgetBase *MakeQwertyKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 16;
|
int key_height = 16;
|
||||||
|
|
||||||
AddKey(hor, key_height, 3, WWT_PUSHIMGBTN, OSK_WIDGET_SPECIAL, SPR_OSK_SPECIAL);
|
AddKey(hor, key_height, 3, WWT_PUSHIMGBTN, OSK_WIDGET_SPECIAL, SPR_OSK_SPECIAL, biggest_index);
|
||||||
for (int widnum = OSK_WIDGET_QWERTY_FIRST; widnum <= OSK_WIDGET_QWERTY_LAST; widnum++) {
|
for (int widnum = OSK_WIDGET_QWERTY_FIRST; widnum <= OSK_WIDGET_QWERTY_LAST; widnum++) {
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0);
|
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index);
|
||||||
}
|
}
|
||||||
AddKey(hor, key_height, 1, NWID_SPACER, 0, 0);
|
AddKey(hor, key_height, 1, NWID_SPACER, 0, 0, biggest_index);
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the asdfg row keys. */
|
/** Construct the asdfg row keys. */
|
||||||
static NWidgetBase *MakeAsdfgKeys()
|
static NWidgetBase *MakeAsdfgKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 16;
|
int key_height = 16;
|
||||||
|
|
||||||
AddKey(hor, key_height, 4, WWT_IMGBTN, OSK_WIDGET_CAPS, SPR_OSK_CAPS);
|
AddKey(hor, key_height, 4, WWT_IMGBTN, OSK_WIDGET_CAPS, SPR_OSK_CAPS, biggest_index);
|
||||||
for (int widnum = OSK_WIDGET_ASDFG_FIRST; widnum <= OSK_WIDGET_ASDFG_LAST; widnum++) {
|
for (int widnum = OSK_WIDGET_ASDFG_FIRST; widnum <= OSK_WIDGET_ASDFG_LAST; widnum++) {
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0);
|
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index);
|
||||||
}
|
}
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the zxcvb row keys. */
|
/** Construct the zxcvb row keys. */
|
||||||
static NWidgetBase *MakeZxcvbKeys()
|
static NWidgetBase *MakeZxcvbKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 16;
|
int key_height = 16;
|
||||||
|
|
||||||
AddKey(hor, key_height, 3, WWT_IMGBTN, OSK_WIDGET_SHIFT, SPR_OSK_SHIFT);
|
AddKey(hor, key_height, 3, WWT_IMGBTN, OSK_WIDGET_SHIFT, SPR_OSK_SHIFT, biggest_index);
|
||||||
for (int widnum = OSK_WIDGET_ZXCVB_FIRST; widnum <= OSK_WIDGET_ZXCVB_LAST; widnum++) {
|
for (int widnum = OSK_WIDGET_ZXCVB_FIRST; widnum <= OSK_WIDGET_ZXCVB_LAST; widnum++) {
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0);
|
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index);
|
||||||
}
|
}
|
||||||
AddKey(hor, key_height, 1, NWID_SPACER, 0, 0);
|
AddKey(hor, key_height, 1, NWID_SPACER, 0, 0, biggest_index);
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct the spacebar row keys. */
|
/** Construct the spacebar row keys. */
|
||||||
static NWidgetBase *MakeSpacebarKeys()
|
static NWidgetBase *MakeSpacebarKeys(int *biggest_index)
|
||||||
{
|
{
|
||||||
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
NWidgetHorizontal *hor = new NWidgetHorizontal;
|
||||||
int key_height = 16;
|
int key_height = 16;
|
||||||
|
|
||||||
AddKey(hor, key_height, 8, NWID_SPACER, 0, 0);
|
AddKey(hor, key_height, 8, NWID_SPACER, 0, 0, biggest_index);
|
||||||
AddKey(hor, key_height, 13, WWT_PUSHTXTBTN, OSK_WIDGET_SPACE, STR_EMPTY);
|
AddKey(hor, key_height, 13, WWT_PUSHTXTBTN, OSK_WIDGET_SPACE, STR_EMPTY, biggest_index);
|
||||||
AddKey(hor, key_height, 3, NWID_SPACER, 0, 0);
|
AddKey(hor, key_height, 3, NWID_SPACER, 0, 0, biggest_index);
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHIMGBTN, OSK_WIDGET_LEFT, SPR_OSK_LEFT);
|
AddKey(hor, key_height, 2, WWT_PUSHIMGBTN, OSK_WIDGET_LEFT, SPR_OSK_LEFT, biggest_index);
|
||||||
AddKey(hor, key_height, 2, WWT_PUSHIMGBTN, OSK_WIDGET_RIGHT, SPR_OSK_RIGHT);
|
AddKey(hor, key_height, 2, WWT_PUSHIMGBTN, OSK_WIDGET_RIGHT, SPR_OSK_RIGHT, biggest_index);
|
||||||
return hor;
|
return hor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2255,9 +2255,11 @@ bool CompareWidgetArrays(const Widget *orig, const Widget *gen, bool report)
|
||||||
* @param count Length of the \a parts array.
|
* @param count Length of the \a parts array.
|
||||||
* @param dest Address of pointer to use for returning the composed widget.
|
* @param dest Address of pointer to use for returning the composed widget.
|
||||||
* @param fill_dest Fill the composed widget with child widgets.
|
* @param fill_dest Fill the composed widget with child widgets.
|
||||||
|
* @param biggest_index Pointer to biggest nested widget index in the tree encountered so far.
|
||||||
* @return Number of widget part elements used to compose the widget.
|
* @return Number of widget part elements used to compose the widget.
|
||||||
|
* @precond \c biggest_index != NULL.
|
||||||
*/
|
*/
|
||||||
static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest, bool *fill_dest)
|
static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest, bool *fill_dest, int *biggest_index)
|
||||||
{
|
{
|
||||||
int num_used = 0;
|
int num_used = 0;
|
||||||
|
|
||||||
|
@ -2288,6 +2290,7 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
||||||
case WWT_FRAME:
|
case WWT_FRAME:
|
||||||
if (*dest != NULL) return num_used;
|
if (*dest != NULL) return num_used;
|
||||||
*dest = new NWidgetBackground(parts->type, parts->u.widget.colour, parts->u.widget.index);
|
*dest = new NWidgetBackground(parts->type, parts->u.widget.colour, parts->u.widget.index);
|
||||||
|
*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
|
||||||
*fill_dest = true;
|
*fill_dest = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2297,11 +2300,15 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
||||||
*fill_dest = true;
|
*fill_dest = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPT_FUNCTION:
|
case WPT_FUNCTION: {
|
||||||
if (*dest != NULL) return num_used;
|
if (*dest != NULL) return num_used;
|
||||||
*dest = parts->u.func_ptr();
|
/* Ensure proper functioning even when the called code simply writes its largest index. */
|
||||||
|
int biggest = -1;
|
||||||
|
*dest = parts->u.func_ptr(&biggest);
|
||||||
|
*biggest_index = max(*biggest_index, biggest);
|
||||||
*fill_dest = false;
|
*fill_dest = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case NWID_SELECTION:
|
case NWID_SELECTION:
|
||||||
case NWID_LAYERED:
|
case NWID_LAYERED:
|
||||||
|
@ -2391,6 +2398,7 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
||||||
if (*dest != NULL) return num_used;
|
if (*dest != NULL) return num_used;
|
||||||
assert((parts->type & WWT_MASK) < NWID_HORIZONTAL);
|
assert((parts->type & WWT_MASK) < NWID_HORIZONTAL);
|
||||||
*dest = new NWidgetLeaf(parts->type, parts->u.widget.colour, parts->u.widget.index, 0x0, STR_NULL);
|
*dest = new NWidgetLeaf(parts->type, parts->u.widget.colour, parts->u.widget.index, 0x0, STR_NULL);
|
||||||
|
*biggest_index = max(*biggest_index, (int)parts->u.widget.index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
num_used++;
|
num_used++;
|
||||||
|
@ -2405,9 +2413,11 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
||||||
* @param parts Array with parts of the nested widgets.
|
* @param parts Array with parts of the nested widgets.
|
||||||
* @param count Length of the \a parts array.
|
* @param count Length of the \a parts array.
|
||||||
* @param parent Container to use for storing the child widgets.
|
* @param parent Container to use for storing the child widgets.
|
||||||
|
* @param biggest_index Pointer to biggest nested widget index in the tree.
|
||||||
* @return Number of widget part elements used to fill the container.
|
* @return Number of widget part elements used to fill the container.
|
||||||
|
* @postcond \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
|
||||||
*/
|
*/
|
||||||
static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *parent)
|
static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *parent, int *biggest_index)
|
||||||
{
|
{
|
||||||
/* Given parent must be either a #NWidgetContainer or a #NWidgetBackground object. */
|
/* Given parent must be either a #NWidgetContainer or a #NWidgetBackground object. */
|
||||||
NWidgetContainer *nwid_cont = dynamic_cast<NWidgetContainer *>(parent);
|
NWidgetContainer *nwid_cont = dynamic_cast<NWidgetContainer *>(parent);
|
||||||
|
@ -2418,7 +2428,7 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *pare
|
||||||
while (true) {
|
while (true) {
|
||||||
NWidgetBase *sub_widget = NULL;
|
NWidgetBase *sub_widget = NULL;
|
||||||
bool fill_sub = false;
|
bool fill_sub = false;
|
||||||
int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub);
|
int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
|
||||||
parts += num_used;
|
parts += num_used;
|
||||||
total_used += num_used;
|
total_used += num_used;
|
||||||
|
|
||||||
|
@ -2433,7 +2443,7 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *pare
|
||||||
WidgetType tp = sub_widget->type;
|
WidgetType tp = sub_widget->type;
|
||||||
if (fill_sub && (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL
|
if (fill_sub && (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL
|
||||||
|| tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION || tp == NWID_LAYERED)) {
|
|| tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION || tp == NWID_LAYERED)) {
|
||||||
int num_used = MakeWidgetTree(parts, count - total_used, sub_widget);
|
int num_used = MakeWidgetTree(parts, count - total_used, sub_widget, biggest_index);
|
||||||
parts += num_used;
|
parts += num_used;
|
||||||
total_used += num_used;
|
total_used += num_used;
|
||||||
}
|
}
|
||||||
|
@ -2455,8 +2465,9 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *pare
|
||||||
*/
|
*/
|
||||||
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count)
|
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count)
|
||||||
{
|
{
|
||||||
|
int biggest_index = -1;
|
||||||
NWidgetContainer *cont = new NWidgetVertical();
|
NWidgetContainer *cont = new NWidgetVertical();
|
||||||
MakeWidgetTree(parts, count, cont);
|
MakeWidgetTree(parts, count, cont, &biggest_index);
|
||||||
return cont;
|
return cont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -561,8 +561,12 @@ struct NWidgetPartPIP {
|
||||||
uint8 pre, inter, post; ///< Amount of space before/between/after child widgets.
|
uint8 pre, inter, post; ///< Amount of space before/between/after child widgets.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Pointer to function returning a nested widget. */
|
/** Pointer to function returning a nested widget.
|
||||||
typedef NWidgetBase *NWidgetFunctionType();
|
* @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget.
|
||||||
|
* @return Nested widget (tree).
|
||||||
|
* @postcond \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.
|
/** Partial widget specification to allow NWidgets to be written nested.
|
||||||
* @ingroup NestedWidgetParts */
|
* @ingroup NestedWidgetParts */
|
||||||
|
|
Loading…
Reference in New Issue