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/>.
28 #include "nel/misc/types_nl.h"
29 #include "nel/misc/debug.h"
31 #include "nel/3d/u_texture.h"
41 using NL3D::UTextureFile
;
51 * Class to manage the rosace component.
52 * \author Guillaume PUZIN
53 * \author Nevrax France
56 class CRosaceComponent
59 /// Callback function for the interface controls.
60 typedef void (*TFunc
) (void);
63 /// Position X of the component (between 0-1).
65 /// Position Y of the component (between 0-1).
67 /// Width of the component (between 0-1).
69 /// Height of the component (between 0-1).
71 /// Callback function associated.
73 /// Texture used to display the component.
74 UTextureFile
*_Texture
;
79 /// Display the component.
80 void display(bool selected
);
81 /// Execute the callback associated to the component.
83 /// Set the texture for the component.
84 void texture(const string
&filename
);
85 /// Return true if the position (x,y) is inside the rosace.
86 bool inside(float x
, float y
);
87 /// Set the callback function.
88 inline void callback(TFunc func
) {_Callback
= func
;}
89 /// Set the component position.
90 inline void setPos(float x
, float y
) {_X
= x
; _Y
= y
;}
91 /// Get the component position.
92 inline void getPos(float &x
, float &y
) { x
= _X
; y
= _Y
;}
97 * Class to manage the rosace page.
98 * \author Guillaume PUZIN
99 * \author Nevrax France
112 NbRosaceMode
// Not really a mode.
116 typedef vector
<CRosaceComponent
> TComponents
;
117 vector
<CRosaceComponent
> _Components
;
126 /// Component Width (between 0-1)
128 /// Component Height (between 0-1)
130 /// Component Width (in Pixel)
132 /// Component Height (in Pixel)
137 /// Select the component under the position (x,y) or unselect all if nothing at this position.
138 void cursorMode(float x
, float y
);
139 /// Select a component according to the angle generated by position (x,y) and screen center.
140 void cursorAngleMode(float x
, float y
);
142 void relativeMode(float x
, float y
);
144 void directMode(float x
, float y
);
149 CRosacePage(sint nb
);
150 /// Return the number of components in the page.
151 inline uint
size() const {return (uint
)_Components
.size();}
152 /// Display all the components in the page.
154 /// Execute the callback associated to the selected component.
156 /// Select the next valide component.
158 /// Select the previous valide component.
160 /// Generate the rosace (all components).
163 void update(float x
, float y
, TMode mode
);
164 /// Return if the current selected component is valide.
165 inline bool valide() {return (_Selected
>=0 && _Selected
<(sint
)size());}
167 void select(double ang
);
170 * Operator to access to the selected component.
171 * \param comp Number of the component to access.
172 * \warning Those functions do not test if the parameter is out of range !
175 CRosaceComponent
&operator [] (const uint
&comp
)
177 nlassert(comp
<size());
178 return _Components
[comp
];
181 const CRosaceComponent
&operator [] (const uint
&comp
) const
183 nlassert(comp
<size());
184 return _Components
[comp
];
191 * Class to manage the rosace context.
192 * \author Guillaume PUZIN
193 * \author Nevrax France
199 typedef vector
<CRosacePage
> TPages
;
200 vector
<CRosacePage
> _Pages
;
208 CRosaceContext(sint nb
);
209 /// Return the number of pages in the context.
210 inline uint
size() const {return (uint
)_Pages
.size();}
211 /// Display all the pages in the context.
213 /// Execute the callback associated to the selected component in the selected page.
216 void add(const CRosacePage
&page
);
217 /// Update the context.
218 void update(float x
, float y
, CRosacePage::TMode mode
);
219 /// Return if the current selected page is valide.
220 inline bool valide() {return (_Selected
>=0 && _Selected
<(sint
)size());}
221 /// Select the next valide page.
223 /// Select the previous valide page.
227 * Operator to access to the selected page.
228 * \param page Number of the page to access.
229 * \warning Those functions do not test if the parameter is out of range !
232 CRosacePage
&operator [] (const uint
&page
)
234 nlassert(page
<size());
238 const CRosacePage
&operator [] (const uint
&page
) const
240 nlassert(page
<size());
248 * Class to manage the rosace.
249 * \author Guillaume PUZIN
250 * \author Nevrax France
256 /// Contexts in the rosace.
257 typedef map
<string
, CRosaceContext
> TContexts
;
259 /// Mode to manage the rosace.
260 CRosacePage::TMode _Mode
;
265 /// Initialize the rosace.
274 /// Add a page. ("" is not valide name).
275 void add(const string
&name
, const CRosaceContext
&context
);
276 /// Is the current context valide.
278 /// Select a context.
279 void select(const string
&name
) {_Selected
= name
;}
281 void mode(CRosacePage::TMode mode
) {_Mode
= mode
;}
283 /// Display the rosace.
285 /// Update the rosace.
286 void update(float x
, float y
);
287 /// Execute the callback function corresponding to the selected component.
289 /// Swap to next rosace page.
294 #endif // CL_ROSACE_H
296 /* End of rosace.h */