mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Make better use of std::clamp
This commit is contained in:
parent
b6d2c57de2
commit
7a0c13fcf8
38 changed files with 80 additions and 103 deletions
|
@ -31,15 +31,11 @@ namespace Gui
|
|||
}
|
||||
|
||||
private:
|
||||
static int clamp(const int& value, const int& lowBound, const int& highBound)
|
||||
{
|
||||
return std::min(std::max(lowBound, value), highBound);
|
||||
}
|
||||
|
||||
std::string getFontSize()
|
||||
{
|
||||
// Note: we can not use the FontLoader here, so there is a code duplication a bit.
|
||||
static const std::string fontSize = std::to_string(clamp(Settings::Manager::getInt("font size", "GUI"), 12, 20));
|
||||
static const std::string fontSize = std::to_string(std::clamp(Settings::Manager::getInt("font size", "GUI"), 12, 20));
|
||||
return fontSize;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Gui
|
|||
try
|
||||
{
|
||||
mValue = std::stoi(newCaption);
|
||||
int capped = std::min(mMaxValue, std::max(mValue, mMinValue));
|
||||
int capped = std::clamp(mValue, mMinValue, mMaxValue);
|
||||
if (capped != mValue)
|
||||
{
|
||||
mValue = capped;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue