Removed less used sizing types

This commit is contained in:
Sergii Pylypenko
2021-05-07 22:38:44 +03:00
parent e80df6ae8e
commit 1efdce0358
5 changed files with 13 additions and 25 deletions

View File

@@ -1235,7 +1235,7 @@ struct QueryWindow : public Window {
{
if (widget != WID_Q_TEXT) return;
size->width = GetMinSizing(NWST_WINDOW_LENGTH, size->width);
size->width = std::max(GetMinSizing(NWST_BUTTON) * 8, size->width);
Dimension d = GetStringMultiLineBoundingBox(this->message, *size);
d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;

View File

@@ -362,7 +362,7 @@ struct NewsWindow : Window {
break;
case WID_N_MESSAGE:
size->width = GetMinSizing(NWST_WINDOW_LENGTH, size->width);
size->width = std::max(GetMinSizing(NWST_BUTTON) * 8, size->width);
CopyInDParam(0, this->ni->params, lengthof(this->ni->params));
str = this->ni->string_id;
break;

View File

@@ -228,8 +228,7 @@ static const int INTER_KEY_SPACE = 2; // Number of pixels between two keys.
*/
static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index)
{
int min_half_key = std::max<int>(GetMinSizing(NWST_BUTTON), HALF_KEY_WIDTH);
int key_width = min_half_key + (INTER_KEY_SPACE + min_half_key) * (num_half - 1);
int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1);
if (widtype == NWID_SPACER) {
if (!hor->IsEmpty()) key_width += INTER_KEY_SPACE;
@@ -252,7 +251,7 @@ static void AddKey(NWidgetHorizontal *hor, int height, int num_half, WidgetType
static NWidgetBase *MakeTopKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontal();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 2);
int key_height = FONT_HEIGHT_NORMAL + 2;
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL, biggest_index);
AddKey(hor, key_height, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK, biggest_index);
@@ -264,7 +263,7 @@ static NWidgetBase *MakeTopKeys(int *biggest_index)
static NWidgetBase *MakeNumberKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 6);
int key_height = FONT_HEIGHT_NORMAL + 6;
for (int widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) {
AddKey(hor, key_height, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index);
@@ -276,7 +275,7 @@ static NWidgetBase *MakeNumberKeys(int *biggest_index)
static NWidgetBase *MakeQwertyKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 6);
int key_height = FONT_HEIGHT_NORMAL + 6;
AddKey(hor, key_height, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL, biggest_index);
for (int widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) {
@@ -290,7 +289,7 @@ static NWidgetBase *MakeQwertyKeys(int *biggest_index)
static NWidgetBase *MakeAsdfgKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 6);
int key_height = FONT_HEIGHT_NORMAL + 6;
AddKey(hor, key_height, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS, biggest_index);
for (int widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) {
@@ -303,7 +302,7 @@ static NWidgetBase *MakeAsdfgKeys(int *biggest_index)
static NWidgetBase *MakeZxcvbKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontalLTR();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 6);
int key_height = FONT_HEIGHT_NORMAL + 6;
AddKey(hor, key_height, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT, biggest_index);
for (int widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) {
@@ -317,7 +316,7 @@ static NWidgetBase *MakeZxcvbKeys(int *biggest_index)
static NWidgetBase *MakeSpacebarKeys(int *biggest_index)
{
NWidgetHorizontal *hor = new NWidgetHorizontal();
int key_height = GetMinSizing(NWST_KEYBOARD, FONT_HEIGHT_NORMAL + 6);
int key_height = FONT_HEIGHT_NORMAL + 6;
AddKey(hor, key_height, 8, NWID_SPACER, 0, 0, biggest_index);
AddKey(hor, key_height, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY, biggest_index);
@@ -329,7 +328,7 @@ static NWidgetBase *MakeSpacebarKeys(int *biggest_index)
static const NWidgetPart _nested_osk_widgets[] = {
NWidget(WWT_CAPTION, COLOUR_GREY, WID_OSK_CAPTION), SetSizingType(NWST_BUTTON), SetDataTip(STR_WHITE_STRING, STR_NULL),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_OSK_CAPTION), SetDataTip(STR_WHITE_STRING, STR_NULL),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_OSK_TEXT), SetMinimalSize(252, 12), SetPadding(2, 2, 2, 2),
EndContainer(),

View File

@@ -845,7 +845,6 @@ void NWidgetResizeBase::SetMinimalSize(uint min_x, uint min_y)
uint min_size = 0;
switch (this->sizing_type) {
case NWST_NONE:
case NWST_OVERRIDE:
min_size = 0;
break;
case NWST_BUTTON:
@@ -2411,7 +2410,7 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data,
this->SetMinimalSize(8, 8);
break;
default:
this->sizing_type = NWST_OVERRIDE;
this->sizing_type = NWST_NONE;
}
}
@@ -2510,7 +2509,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array)
this->type == WWT_DEFSIZEBOX || this->type == WWT_CLOSEBOX || this->type == WWT_DEBUGBOX)) {
static const Dimension extra = {0, 0};
padding = &extra;
this->sizing_type = NWST_OVERRIDE;
this->sizing_type = NWST_NONE;
size = extra;
fill = extra;
resize = extra;
@@ -3245,17 +3244,10 @@ uint GetMinSizing(NWidSizingType type, uint min_1)
uint min_sizing;
switch (type) {
case NWST_NONE:
case NWST_OVERRIDE:
return min_1;
case NWST_BUTTON:
min_sizing = _settings_client.gui.min_button;
break;
case NWST_KEYBOARD:
min_sizing = 2 * _settings_client.gui.min_button;
break;
case NWST_WINDOW_LENGTH:
min_sizing = 8 * _settings_client.gui.min_button;
break;
default: NOT_REACHED();
}
min_sizing = RescaleFrom854x480(min_sizing);

View File

@@ -40,12 +40,9 @@ enum ArrowWidgetValues {
/** Values for different minimal sizing of widgets. */
enum NWidSizingType {
NWST_NONE, ///< No sizing type is yet defined.
NWST_NONE, ///< No automatic minimal sizing.
NWST_BUTTON, ///< Size will be set at least _settings_client.gui.min_button.
NWST_KEYBOARD, ///< Size for keyboard keys.
NWST_WINDOW_LENGTH, ///< Width for command errors, message windows and statusbar middle part.
NWST_VIEWPORT, ///< Sizing type for viewports.
NWST_OVERRIDE, ///< Avoid widgets to use automatic minimal sizing.
NWST_END
};