diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 39031436f..38b9ceb67 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -1232,12 +1232,12 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, / (w->getMax() - w->getMin()); - const core::recti dest_area(widget->m_x + handle_size, - widget->m_y, - widget->m_x + handle_size + + const core::recti dest_area(rect.UpperLeftCorner.X + handle_size, + rect.UpperLeftCorner.Y, + rect.UpperLeftCorner.X + handle_size + (int)((widget->m_w - 2*handle_size)*value), - widget->m_y + widget->m_h); + rect.UpperLeftCorner.Y + widget->m_h); const ITexture* texture = SkinConfig::m_render_params["gaugefill::neutral"].getImage(); diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index e551f7a2c..7763e8b86 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -41,9 +41,10 @@ SpinnerWidget::SpinnerWidget(const bool gauge) : Widget(WTYPE_SPINNER) m_gauge = gauge; m_listener = NULL; - + m_graphical = false; m_check_inside_me = true; //FIXME: not sure this is necessary m_supports_multiplayer = true; + m_value = -1; m_min = 0; m_max = 999; @@ -89,7 +90,10 @@ void SpinnerWidget::add() } } - m_value = (m_min + m_max)/2; + if (m_value == -1) + { + m_value = (m_min + m_max)/2; + } // create sub-widgets if they don't already exist if (m_children.size() == 0) @@ -164,6 +168,12 @@ void SpinnerWidget::add() label->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); label->setTabStop(false); label->setNotClipped(true); + + + if (m_labels.size() > 0) + { + label->setText(m_labels[m_value].c_str() ); + } } @@ -332,18 +342,19 @@ void SpinnerWidget::setValue(const int new_value) std::string imagefile = StringUtils::insertValues(icon.str(), m_value); ((IGUIImage*)(m_children[1].m_element))->setImage(irr_driver->getTexture(imagefile)); } - else if (m_labels.size() > 0) + else if (m_labels.size() > 0 && m_children.size() > 0) { assert(new_value >= 0); assert(new_value < (int)m_labels.size()); + m_children[1].m_element->setText(m_labels[new_value].c_str() ); } - else if (m_text.size() > 0) + else if (m_text.size() > 0 && m_children.size() > 0) { stringw text = StringUtils::insertValues(m_text.c_str(), m_value); m_children[1].m_element->setText( text.c_str() ); } - else + else if (m_children.size() > 0) { m_children[1].m_element->setText( stringw(m_value).c_str() ); } @@ -409,3 +420,10 @@ void SpinnerWidget::setDeactivated() setValue( getValue() ); // Update the display } +// ----------------------------------------------------------------------------- + +void SpinnerWidget::setCustomText(const core::stringw& text) +{ + m_children[1].m_element->setText(text.c_str()); +} + diff --git a/src/guiengine/widgets/spinner_widget.hpp b/src/guiengine/widgets/spinner_widget.hpp index c99bb0242..a6f087288 100644 --- a/src/guiengine/widgets/spinner_widget.hpp +++ b/src/guiengine/widgets/spinner_widget.hpp @@ -158,6 +158,9 @@ namespace GUIEngine /** Override method from base class Widget */ virtual void setDeactivated(); + + /** Display custom text in spinner */ + void setCustomText(const core::stringw& text); }; }