1 // SuperTuxKart - a fun racing game with go-kart 2 // Copyright (C) 2009-2015 Marianne Gagnon 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 3 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 19 20 #ifndef HEADER_PROGRESS_BAR_HPP 21 #define HEADER_PROGRESS_BAR_HPP 22 23 #include <irrString.h> 24 25 #include "guiengine/widget.hpp" 26 #include "utils/leak_check.hpp" 27 #include "utils/ptr_vector.hpp" 28 29 namespace GUIEngine 30 { 31 /** 32 * \brief A progress bar widget. 33 * \ingroup widgetsgroup 34 */ 35 class ProgressBarWidget : public Widget 36 { 37 /** When inferring widget size from its label length, this method will be called to 38 * if/how much space must be added to the raw label's size for the widget to be large enough */ getWidthNeededAroundLabel() const39 virtual int getWidthNeededAroundLabel() const { return 35; } 40 41 /** When inferring widget size from its label length, this method will be called to 42 * if/how much space must be added to the raw label's size for the widget to be large enough */ getHeightNeededAroundLabel() const43 virtual int getHeightNeededAroundLabel() const { return 4; } 44 45 /** Change the label on the widget */ 46 void setLabel(const irr::core::stringw label); 47 float m_value; 48 bool m_show_label; 49 50 /** Values for animation */ 51 float m_target_value; 52 float m_previous_value; 53 54 public: 55 56 LEAK_CHECK() 57 ProgressBarWidget(bool show_label = true); 58 virtual ~ProgressBarWidget(); 59 60 /** Change the value of the widget, it must be a percent. */ 61 void setValue(float value); 62 63 /** Change the value of the widget smooth, it must be a percent. */ 64 void moveValue(float value); 65 66 virtual void update(float delta); 67 68 void add(); 69 70 // -------------------------------------------------------------------- 71 /** Get the current value of the widget. */ getValue()72 float getValue() {return m_value; }; 73 // -------------------------------------------------------------------- 74 /** Sets if the current fraction is shown as a percentage value 75 * in the progress bar. */ showLabel(bool show_label)76 void showLabel(bool show_label) { m_show_label = show_label; } 77 78 }; 79 } 80 81 #endif 82