Skip to content

Commit a9d4278

Browse files
Synchronize changes from 1.6 branch [ci skip]
6217715 Improved settings window with adaptive horizontal size (vertical impl was already in 4159496 by accident), leaving more space for entries in most locales. It will now also not cut off the left side of window, as it did on the smallest resolutions, and the vertical impl exposes previously unseen entries in locale like Arabic, for which a more extensive fix is still needed though.
2 parents f566392 + 6217715 commit a9d4278

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Client/core/CSettings.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ constexpr float kBorderlessSaturationMax = 2.0f;
4444
constexpr float kBorderlessSaturationDefault = 1.0f;
4545

4646
constexpr float kSettingsContentWidth = 680.0f;
47+
constexpr float kSettingsExtendedContentWidth = 820.0f;
4748
constexpr float kSettingsBaseContentHeight = 480.0f;
4849
constexpr float kSettingsExtendedContentHeight = 520.0f;
4950
constexpr float kSettingsWindowFrameHorizontal = 18.0f; // 9px left + 9px right
5051
constexpr float kSettingsWindowFrameVertical = 22.0f; // 20px top + 2px bottom
52+
constexpr float kSettingsBottomButtonAreaHeight = 38.0f;
5153
constexpr float kPostFxCheckboxOffset = 24.0f;
5254

5355
float NormalizeSliderValue(float value, float minValue, float maxValue)
@@ -108,14 +110,24 @@ void CSettings::CreateGUI()
108110

109111
CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
110112

111-
CVector2D contentSize(kSettingsContentWidth, kSettingsBaseContentHeight);
113+
const float fBottomButtonAreaHeight = kSettingsBottomButtonAreaHeight;
114+
CVector2D contentSize(kSettingsContentWidth, kSettingsBaseContentHeight);
115+
const float availableContentWidth = resolution.fX - kSettingsWindowFrameHorizontal;
116+
if (availableContentWidth >= kSettingsContentWidth)
117+
contentSize.fX = std::min(kSettingsExtendedContentWidth, availableContentWidth);
118+
else if (availableContentWidth > 0.0f)
119+
contentSize.fX = availableContentWidth;
120+
112121
const float availableContentHeight = resolution.fY - kSettingsWindowFrameVertical;
113122
if (availableContentHeight >= kSettingsBaseContentHeight)
114123
contentSize.fY = std::min(kSettingsExtendedContentHeight, availableContentHeight);
124+
else if (availableContentHeight > 0.0f)
125+
contentSize.fY = std::max(availableContentHeight, fBottomButtonAreaHeight + 1.0f);
126+
127+
contentSize.fX = std::max(contentSize.fX, 0.0f);
128+
contentSize.fY = std::max(contentSize.fY, fBottomButtonAreaHeight + 1.0f);
115129

116-
float fBottomButtonAreaHeight = 38;
117130
CVector2D tabPanelPosition;
118-
CVector2D tabPanelSize = contentSize - CVector2D(0, fBottomButtonAreaHeight);
119131

120132
// Window size is content size plus window frame edge dims
121133
CVector2D windowSize = contentSize + CVector2D(kSettingsWindowFrameHorizontal, kSettingsWindowFrameVertical);
@@ -143,6 +155,8 @@ void CSettings::CreateGUI()
143155
pFiller->SetZOrderingEnabled(false);
144156
pFiller->SetAlwaysOnTop(true);
145157
pFiller->MoveToBack();
158+
contentSize.fX = std::min(contentSize.fX, resolution.fX);
159+
contentSize.fY = std::min(contentSize.fY, resolution.fY);
146160
pFiller->SetPosition((resolution - contentSize) / 2);
147161
pFiller->SetSize(contentSize);
148162
m_pWindow = pFiller;
@@ -152,6 +166,7 @@ void CSettings::CreateGUI()
152166
// Create the tab panel and necessary tabs
153167
m_pTabs = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow));
154168
m_pTabs->SetPosition(tabPanelPosition);
169+
const CVector2D tabPanelSize = CVector2D(contentSize.fX, std::max(0.0f, contentSize.fY - fBottomButtonAreaHeight));
155170
m_pTabs->SetSize(tabPanelSize);
156171
m_pTabs->SetSelectionHandler(GUI_CALLBACK(&CSettings::OnTabChanged, this));
157172

0 commit comments

Comments
 (0)