diff --git a/src/gui/help_menu.cpp b/src/gui/help_menu.cpp index 83bb7e565..2638e8656 100644 --- a/src/gui/help_menu.cpp +++ b/src/gui/help_menu.cpp @@ -79,7 +79,7 @@ HelpMenu::HelpMenu() //----------------------------------------------------------------------------- HelpMenu::~HelpMenu() { - widget_manager->reset() ; + widget_manager->reset(); if (m_box != NULL && m_silver_coin != NULL && m_gold_coin != NULL && m_banana != NULL ) diff --git a/src/widget.cpp b/src/widget.cpp index a06140349..644ef45dd 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -161,8 +161,8 @@ void Widget::update(const float DELTA) // left; positive values move to the right and negative // values to the left. - float left, right, bottom, top; - font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, &bottom, &top); + float left, right; + font_gui->getBBox(m_text.c_str(), m_text_size, false, &left, &right, NULL, NULL); int text_width = (int)(right - left + 0.99); const int Y_LIMIT = lines * m_text_size + m_height; diff --git a/src/widget_manager.cpp b/src/widget_manager.cpp index d68391d1e..5c307a154 100644 --- a/src/widget_manager.cpp +++ b/src/widget_manager.cpp @@ -63,9 +63,11 @@ bool WidgetManager::add_wgt WidgetID new_id; new_id.token = TOKEN; + //There is no reason to make a token-less widget active, so if the token //WGT_NONE, the widget is forced to be inactive, preventing bugs. new_id.active = TOKEN != WGT_NONE ? m_default_active : false; + new_id.min_width = MIN_WIDTH; new_id.min_height = MIN_HEIGHT; @@ -198,6 +200,8 @@ void WidgetManager::reset() m_elems.clear(); restore_default_states(); + + m_selected_wgt_token = WGT_NONE; } //----------------------------------------------------------------------------- @@ -535,10 +539,11 @@ bool WidgetManager::layout(const WidgetArea POSITION) } } - //Always select the first active widget by default + //Select the first active widget by default + m_selected_wgt_token = WGT_NONE; for( int i = 0; i < NUM_WIDGETS; ++i ) { - if( m_widgets[i].active) + if( m_widgets[i].active ) { m_selected_wgt_token = m_widgets[i].token; break; @@ -950,31 +955,6 @@ void WidgetManager::hide_wgt_text( const int TOKEN ) else std::cerr << "WARNING: tried to toggle the text of an unnamed widget with token " << TOKEN << '\n'; }*/ -//----------------------------------------------------------------------------- -/* -void WidgetManager::set_wgt_text_x_alignment( const int TOKEN, const Font::FontAlignType ALIGN ) -{ - const int ID = find_id(TOKEN); - if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_x_alignment = ALIGN; - else - { - std::cerr << "WARNING: tried to set the X alignment of text of " << - "an unnamed widget with token " << TOKEN << '\n'; - } -} -*/ -//----------------------------------------------------------------------------- -/*void WidgetManager::set_wgt_text_y_alignment( const int TOKEN, const Font::FontAlignType ALIGN ) -{ - const int ID = find_id(TOKEN); - if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_y_alignment = ALIGN; - else - { - std::cerr << "WARNING: tried to set the Y alignment of text of " << - "an unnamed widget with token " << TOKEN << '\n'; - } -}*/ - //----------------------------------------------------------------------------- void WidgetManager::enable_wgt_scroll( const int TOKEN ) { @@ -1284,7 +1264,6 @@ int WidgetManager::find_left_widget(const int START_WGT) const return closest_wgt; } -//FIXME: find_right_widget() doesn't works properly yet /** find_right_widget() returns the closest widget to the right of START_WGT */ int WidgetManager::find_right_widget(const int START_WGT) const @@ -1333,7 +1312,6 @@ int WidgetManager::find_right_widget(const int START_WGT) const return closest_wgt; } -//FIXME: fix find_left_widget and find_right_widget. /** find_top_widget() returns the closest widget on top of START_WGT. * Remember that for the widget manager, the value 0 in the y-axis is in * the bottom of the screen.