Added a function to dynamically resize to text.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1811 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -150,6 +150,7 @@ void RaceOptions::select()
|
||||
m_difficulty = RaceManager::RD_MEDIUM;
|
||||
widget_manager->setWgtText( WTOK_DIFFICULTY, _("Driver") );
|
||||
}
|
||||
widget_manager->resizeWgtToText( WTOK_DIFFICULTY );
|
||||
break;
|
||||
|
||||
case WTOK_DIFFICULTY_DOWN:
|
||||
|
||||
@@ -1989,6 +1989,31 @@ void WidgetManager::setSelectedWgtToken(const int TOKEN)
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void WidgetManager::resizeWgtToText( const int TOKEN )
|
||||
{
|
||||
const int ID = findId(TOKEN);
|
||||
if( ID != WGT_NONE )
|
||||
{
|
||||
m_widgets[ID].widget->resizeToText();
|
||||
|
||||
const int SCREEN_WIDTH = user_config->m_width;
|
||||
const int SCREEN_HEIGHT = user_config->m_height;
|
||||
|
||||
m_widgets[ID].min_width = ( m_widgets[ID].widget->m_width * 100 ) /
|
||||
SCREEN_WIDTH;
|
||||
m_widgets[ID].min_height = ( m_widgets[ID].widget->m_height * 100 ) /
|
||||
SCREEN_HEIGHT;
|
||||
|
||||
layout();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "WARNING: tried to resize the text of an unnamed " <<
|
||||
"widget with token " << TOKEN << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
/** reloadFonts() sets the pointers to the fonts of the guis
|
||||
* to their choosen fonts; it's useful in cases where you
|
||||
* free the font's memory (which makes the pointers invalid),
|
||||
|
||||
@@ -354,6 +354,7 @@ public:
|
||||
void setWgtResizeToText( const int TOKEN, const bool RESIZE );
|
||||
void showWgtText( const int TOKEN );
|
||||
void hideWgtText( const int TOKEN );
|
||||
void resizeWgtToText( const int TOKEN );
|
||||
void reloadFonts();
|
||||
|
||||
//FIXME: change to enableWgtScrolling, since it enables or disables
|
||||
|
||||
Reference in New Issue
Block a user