SuperTuxKart
progress_bar_widget.hpp
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 {
35  class ProgressBarWidget : public Widget
36  {
39  virtual int getWidthNeededAroundLabel() const { return 35; }
40 
43  virtual int getHeightNeededAroundLabel() const { return 4; }
44 
46  void setLabel(const irr::core::stringw label);
47  float m_value;
48  bool m_show_label;
49 
52  float m_previous_value;
53 
54  public:
55 
56  LEAK_CHECK()
57  ProgressBarWidget(bool show_label = true);
58  virtual ~ProgressBarWidget();
59 
61  void setValue(float value);
62 
64  void moveValue(float value);
65 
66  virtual void update(float delta);
67 
68  void add();
69 
70  // --------------------------------------------------------------------
72  float getValue() {return m_value; };
73  // --------------------------------------------------------------------
76  void showLabel(bool show_label) { m_show_label = show_label; }
77 
78  };
79 }
80 
81 #endif
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
float m_target_value
Values for animation.
Definition: progress_bar_widget.hpp:51
virtual int getWidthNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: progress_bar_widget.hpp:39
virtual void update(float delta)
Override in children to possibly receive updates (you may need to register to them first)
Definition: progress_bar_widget.cpp:101
void add()
Create and add the irrLicht widget(s) associated with this object.
Definition: progress_bar_widget.cpp:50
void moveValue(float value)
Change the value of the widget smooth, it must be a percent.
Definition: progress_bar_widget.cpp:88
virtual int getHeightNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: progress_bar_widget.hpp:43
void showLabel(bool show_label)
Sets if the current fraction is shown as a percentage value in the progress bar.
Definition: progress_bar_widget.hpp:76
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:138
float getValue()
Get the current value of the widget.
Definition: progress_bar_widget.hpp:72
A progress bar widget.
Definition: progress_bar_widget.hpp:35
void setLabel(const irr::core::stringw label)
Change the label on the widget.
Definition: progress_bar_widget.cpp:119
void setValue(float value)
Change the value of the widget, it must be a percent.
Definition: progress_bar_widget.cpp:74