Improved the SETTING_BUTTON_HEIGHT macro

This commit is contained in:
Sergii Pylypenko
2021-12-01 00:40:20 +02:00
parent 3330660c5e
commit 7b4be1c39c
5 changed files with 8 additions and 20 deletions

View File

@@ -376,7 +376,7 @@ struct AISettingsWindow : public Window {
int y = r.top;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
int text_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
const ScriptConfigItem &config_item = **it;
int current_value = config->GetSetting((config_item).name);
@@ -418,7 +418,7 @@ struct AISettingsWindow : public Window {
}
}
DrawString(text_left, text_right, Center(y, this->line_height), str, colour);
DrawString(text_left, text_right, y + text_y_offset, str, colour);
y += this->line_height;
}
}

View File

@@ -1525,8 +1525,6 @@ void ScreenSizeChanged()
/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
_cursor.visible = false;
CheckWindowMinSizings();
}
void UndrawMouseCursor()

View File

@@ -13,6 +13,12 @@
#include "gfx_type.h"
#include "widgets/dropdown_type.h"
/** Width of setting buttons */
#define SETTING_BUTTON_WIDTH (GetMinButtonSize() * 2)
/** Height of setting buttons */
#define SETTING_BUTTON_HEIGHT (GetMinButtonSize())
extern int SETTING_BUTTON_WIDTH; ///< Width of setting buttons
extern int SETTING_BUTTON_HEIGHT; ///< Height of setting buttons

View File

@@ -1921,21 +1921,6 @@ Window *FindWindowFromPt(int x, int y)
return nullptr;
}
int SETTING_BUTTON_WIDTH = 20;
int SETTING_BUTTON_HEIGHT = 10;
/**
* Set button size of settings. If automatic sizing is also enabled, it also sets
* the sizing of buttons, scrollbars and font size (recommend restart).
* @todo Check if it can be moved to another file, so we do not need to include error, string and fontcache headers.
* @todo Fix magic numbers 16/18/20/30/32
*/
void CheckWindowMinSizings()
{
SETTING_BUTTON_HEIGHT = GetMinButtonSize();
SETTING_BUTTON_WIDTH = 2 * SETTING_BUTTON_HEIGHT;
}
/**
* (re)initialize the windowing system
*/

View File

@@ -27,7 +27,6 @@ int PositionNetworkChatWindow(Window *w);
int GetMainViewTop();
int GetMainViewBottom();
void CheckWindowMinSizings();
void InitWindowSystem();
void UnInitWindowSystem();
void ResetWindowSystem();