Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / interfaces_manager / progress_bar.h
blob5c05e0a76516f02f234672fd66261294e7233690
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // 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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef NL_PROGRESS_BAR_H
20 #define NL_PROGRESS_BAR_H
23 /////////////
24 // Include //
25 /////////////
26 // misc
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/time_nl.h"
29 #include "nel/misc/rgba.h"
30 // Client
31 #include "control.h"
32 #include "pen.h"
36 /** class for progress bar controls
37 * \author David Fleury
38 * \author Nevrax France
39 * \date 2001
41 class CProgressBar : public CControl, public CPen
43 public:
45 /// Constructor
46 CProgressBar(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel, uint range);
48 /**
49 * set the range for the control
50 * \param uint32 range the new range
51 * \return uint32 the old range value
53 uint32 setRange( uint32 range);
55 /**
56 * get the range value of the progress control
57 * \return uint32 the range value
59 inline uint32 getRange() const { return _Range; }
61 /**
62 * set the step value
63 * \param uint32 step the new step value
64 * \return uint32 the old step value
66 uint32 setStep( uint32 step);
68 /**
69 * set the step value
70 * \param uint32 step the new step value
71 * \return uint32 the old step value
73 inline uint32 getStep() const { return _StepInc; }
75 /**
76 * set the position of the progress bar (from 0 to range)
77 * \param uint32 pos the new position
78 * \return uint32 the previous position of the progress bar control
80 uint32 setPos( uint32 pos);
82 /**
83 * get the position of the progress bar (from 0 to range)
84 * \return uint32 the position of the progress bar control
86 inline uint32 getPos() const { return _CurrentPos; }
88 /**
89 * Advances the current position for the progress bar control by the specified value
90 * \param uint32 offset the value added to current position
91 * \return uint32 the old position of the progress bar
93 inline uint32 offsetPos( uint32 offset)
95 uint32 old = _CurrentPos;
96 _CurrentPos += offset;
97 if (_CurrentPos > _Range)
98 _CurrentPos = _Range;
99 return old;
103 * Advances the current position for the progress bar control by the step increment
104 * \return uint32 the previous position of the progress bar control
106 inline uint32 stepIt()
108 uint32 old = _CurrentPos;
109 _CurrentPos += _StepInc;
110 if (_CurrentPos > _Range)
111 _CurrentPos = _Range;
112 return old;
117 * set the texture of the background
118 * \param uint texture the new texture for the background
120 void setBackgroundTexture(uint texture) { _BackgroundTexture = texture; }
123 * set the color of the background
124 * \param CRGBA& color the new color for the background
126 void setBackgroundColor(NLMISC::CRGBA &color) { _BackgroundColor = color; }
129 * set the texture of the progress bar
130 * \param uint texture the new texture for the progress bar
132 void setProgressBarTexture(uint texture) { _ProgressBarTexture = texture; }
135 * set the color of the progress bar
136 * \param CRGBA& color the new color for the progress bar
138 void setProgressBarColor(NLMISC::CRGBA &color) { _ProgressBarColor = color; }
140 /// display the control
141 virtual void display();
144 * set the smooth mode of the control
145 * \param bool smooth the smooth mode (true = smooth mode on)
147 void smooth(bool smooth) { _Smooth = smooth; }
150 * get the smooth mode of the control
151 * \return bool the smooth mode (true = smooth mode on)
153 bool smooth() const { return _Smooth; }
156 * set the smooth fill rate in milliseconds
157 * \param uint32 the smooth fill rate in milliseconds
159 void smoothFillRate( uint32 rate) { _SmoothFillRate = rate; }
163 * get the smooth fill rate in milliseconds
164 * \return the smooth fill rate in milliseconds
166 uint32 smoothFillRate() const { return _SmoothFillRate; }
169 * set the text displayed in the control
170 * \param std::string &text the new text
172 inline void setText( const std::string &text) { _Text = text; }
174 private:
175 /// the init method
176 void init(uint32 range);
178 protected:
180 /// the current 'position'
181 uint32 _CurrentPos;
183 /// the range of the bar (always start at 0)
184 uint32 _Range;
186 /// the step increment
187 uint32 _StepInc;
189 /// temporary position, used when smooth filling the control, only for internal use
190 uint32 _TempPos;
192 // textures and colors
193 /// background texture
194 uint _BackgroundTexture;
195 /// background color
196 NLMISC::CRGBA _BackgroundColor;
198 /// progress bar texture
199 uint _ProgressBarTexture;
200 /// progress bar color
201 NLMISC::CRGBA _ProgressBarColor;
203 /// text to display in the control
204 std::string _Text;
206 /// the smooth mode (smooth transition beetween two positions true = ON) (default = false)
207 bool _Smooth;
209 /// if in smooth mode, set the interval in ms (milliseconds) beetween the addition/soustraction of two units to the bar (defualt = 200ms = 5units/second)
210 uint32 _SmoothFillRate;
212 /// last update time for smooth fill
213 mutable NLMISC::TTime _LastUpdateSmooth;
217 #endif // NL_PROGRESS_BAR_H
219 /* End of progress_bar.h */