1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/time_nl.h"
29 #include "nel/misc/rgba.h"
36 /** class for progress bar controls
37 * \author David Fleury
38 * \author Nevrax France
41 class CProgressBar
: public CControl
, public CPen
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
);
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
);
56 * get the range value of the progress control
57 * \return uint32 the range value
59 inline uint32
getRange() const { return _Range
; }
63 * \param uint32 step the new step value
64 * \return uint32 the old step value
66 uint32
setStep( uint32 step
);
70 * \param uint32 step the new step value
71 * \return uint32 the old step value
73 inline uint32
getStep() const { return _StepInc
; }
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
);
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
; }
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
)
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
;
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
; }
176 void init(uint32 range
);
180 /// the current 'position'
183 /// the range of the bar (always start at 0)
186 /// the step increment
189 /// temporary position, used when smooth filling the control, only for internal use
192 // textures and colors
193 /// background texture
194 uint _BackgroundTexture
;
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
206 /// the smooth mode (smooth transition beetween two positions true = ON) (default = false)
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 */