Fixed: Update text widget parent size when interface scale changes

--HG--
branch : experimental-ui-scaling
This commit is contained in:
Nimetu 2016-06-07 17:27:00 +03:00
parent 34fa04644e
commit 2cb71e654a
2 changed files with 12 additions and 3 deletions

View file

@ -614,6 +614,7 @@ namespace NLGUI
uint32 _ScreenH; uint32 _ScreenH;
uint32 _ScreenW; uint32 _ScreenW;
float _InterfaceScale;
std::vector< CInterfaceAnim* > activeAnims; std::vector< CInterfaceAnim* > activeAnims;

View file

@ -1850,9 +1850,10 @@ namespace NLGUI
class InvalidateTextVisitor : public CInterfaceElementVisitor class InvalidateTextVisitor : public CInterfaceElementVisitor
{ {
public: public:
InvalidateTextVisitor( bool reset ) InvalidateTextVisitor( bool reset, bool invalidate )
{ {
this->reset = reset; this->reset = reset;
this->invalidate = invalidate;
} }
void visitGroup( CInterfaceGroup *group ) void visitGroup( CInterfaceGroup *group )
@ -1865,13 +1866,17 @@ namespace NLGUI
{ {
if( reset ) if( reset )
vt->resetTextIndex(); vt->resetTextIndex();
vt->updateTextContext(); if( invalidate )
vt->invalidateContent();
else
vt->updateTextContext();
} }
} }
} }
private: private:
bool reset; bool reset;
bool invalidate;
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -1884,6 +1889,8 @@ namespace NLGUI
CViewRenderer::getInstance()->checkNewScreenSize (); CViewRenderer::getInstance()->checkNewScreenSize ();
CViewRenderer::getInstance()->getScreenSize (w, h); CViewRenderer::getInstance()->getScreenSize (w, h);
bool scaleChanged = _InterfaceScale != CViewRenderer::getInstance()->getInterfaceScale();
// Update ui:* (limit the master containers to the height of the screen) // Update ui:* (limit the master containers to the height of the screen)
for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++) for (nMasterGroup = 0; nMasterGroup < _MasterGroups.size(); nMasterGroup++)
{ {
@ -1902,7 +1909,7 @@ namespace NLGUI
{ {
SMasterGroup &rMG = _MasterGroups[nMasterGroup]; SMasterGroup &rMG = _MasterGroups[nMasterGroup];
InvalidateTextVisitor inv( false ); InvalidateTextVisitor inv( false, scaleChanged );
rMG.Group->visitGroupAndChildren( &inv ); rMG.Group->visitGroupAndChildren( &inv );
rMG.Group->invalidateCoords (); rMG.Group->invalidateCoords ();
@ -3725,6 +3732,7 @@ namespace NLGUI
inGame = false; inGame = false;
setScreenWH(0, 0); setScreenWH(0, 0);
_InterfaceScale = 1.0f;
_GroupSelection = false; _GroupSelection = false;
multiSelection = false; multiSelection = false;