Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/IGUIObject.cpp
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | |||||
void IGUIObject::UpdateCachedSize() | void IGUIObject::UpdateCachedSize() | ||||
{ | { | ||||
bool absolute; | bool absolute; | ||||
GUI<bool>::GetSetting(this, "absolute", absolute); | GUI<bool>::GetSetting(this, "absolute", absolute); | ||||
float aspectratio = 0.f; | float aspectratio = 0.f; | ||||
GUI<float>::GetSetting(this, "aspectratio", aspectratio); | GUI<float>::GetSetting(this, "aspectratio", aspectratio); | ||||
CClientArea* ca; | const CClientArea& ca = GUI<CClientArea>::GetSetting(this, "size"); | ||||
GUI<CClientArea>::GetSettingPointer(this, "size", ca); | |||||
// If absolute="false" and the object has got a parent, | // If absolute="false" and the object has got a parent, | ||||
// use its cached size instead of the screen. Notice | // use its cached size instead of the screen. Notice | ||||
// it must have just been cached for it to work. | // it must have just been cached for it to work. | ||||
if (absolute == false && m_pParent && !IsRootObject()) | if (absolute == false && m_pParent && !IsRootObject()) | ||||
m_CachedActualSize = ca->GetClientArea(m_pParent->m_CachedActualSize); | m_CachedActualSize = ca.GetClientArea(m_pParent->m_CachedActualSize); | ||||
else | else | ||||
m_CachedActualSize = ca->GetClientArea(CRect(0.f, 0.f, g_xres / g_GuiScale, g_yres / g_GuiScale)); | m_CachedActualSize = ca.GetClientArea(CRect(0.f, 0.f, g_xres / g_GuiScale, g_yres / g_GuiScale)); | ||||
// In a few cases, GUI objects have to resize to fill the screen | // In a few cases, GUI objects have to resize to fill the screen | ||||
// but maintain a constant aspect ratio. | // but maintain a constant aspect ratio. | ||||
// Adjust the size to be the max possible, centered in the original size: | // Adjust the size to be the max possible, centered in the original size: | ||||
if (aspectratio) | if (aspectratio) | ||||
{ | { | ||||
if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()*aspectratio) | if (m_CachedActualSize.GetWidth() > m_CachedActualSize.GetHeight()*aspectratio) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator