OgreOverlayElement.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __OverlayElement_H__
30 #define __OverlayElement_H__
31 
33 #include "OgreString.h"
34 #include "OgreRenderable.h"
35 #include "OgreUTFString.h"
36 #include "OgreStringInterface.h"
38 
39 #include "OgreColourValue.h"
40 
41 namespace Ogre {
49 #if OGRE_UNICODE_SUPPORT
50  typedef UTFString DisplayString;
51 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter()
52 #else
54 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it
55 #endif
56 
59  {
66  };
67 
72  {
76  };
81  {
85  };
86 
109  {
110  public:
111 
112  protected:
113  // Command object for setting / getting parameters
124 
125 
127  bool mVisible;
138 
142 
143  // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
150 
155 
156  // Derived positions from parent
160 
165 
169 
172 
174  bool mEnabled;
175 
178 
181 
186  virtual void updatePositionGeometry(void) = 0;
191  virtual void updateTextureGeometry(void) = 0;
192 
201  virtual void addBaseParameters(void);
202 
203  public:
205  OverlayElement(const String& name);
206  virtual ~OverlayElement();
207 
209  virtual void initialise(void) = 0;
210 
212  const String& getName(void) const;
213 
214 
216  virtual void show(void);
217 
219  virtual void hide(void);
220 
222  bool isVisible(void) const;
223 
224  bool isEnabled() const;
225  virtual void setEnabled(bool b);
226 
227 
229  void setDimensions(Real width, Real height);
230 
233  void setPosition(Real left, Real top);
234 
236  void setWidth(Real width);
238  Real getWidth(void) const;
239 
241  void setHeight(Real height);
243  Real getHeight(void) const;
244 
246  void setLeft(Real left);
248  Real getLeft(void) const;
249 
251  void setTop(Real Top);
253  Real getTop(void) const;
254 
256  Real _getLeft(void) const { return mLeft; }
258  Real _getTop(void) const { return mTop; }
260  Real _getWidth(void) const { return mWidth; }
262  Real _getHeight(void) const { return mHeight; }
264  void _setLeft(Real left);
266  void _setTop(Real top);
268  void _setWidth(Real width);
270  void _setHeight(Real height);
272  void _setPosition(Real left, Real top);
274  void _setDimensions(Real width, Real height);
275 
277  virtual const String& getMaterialName(void) const;
278 
289  virtual void setMaterialName(const String& matName);
290 
291 
292  // --- Renderable Overrides ---
294  const MaterialPtr& getMaterial(void) const;
295 
296  // NB getRenderOperation not implemented, still abstract here
297 
299  void getWorldTransforms(Matrix4* xform) const;
300 
302  virtual void _positionsOutOfDate(void);
303 
305  virtual void _update(void);
306 
308  virtual void _updateFromParent(void);
309 
311  virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
312 
314  virtual Real _getDerivedLeft(void);
315 
317  virtual Real _getDerivedTop(void);
318 
320  virtual Real _getRelativeWidth(void);
322  virtual Real _getRelativeHeight(void);
323 
324 
326  virtual void _getClippingRegion(RealRect &clippingRegion);
327 
340  virtual ushort _notifyZOrder(ushort newZOrder);
341 
345  virtual void _notifyWorldTransforms(const Matrix4& xform);
346 
350  virtual void _notifyViewport();
351 
353  virtual void _updateRenderQueue(RenderQueue* queue);
354 
356  void visitRenderables(Renderable::Visitor* visitor,
357  bool debugRenderables = false);
358 
360  virtual const String& getTypeName(void) const = 0;
361 
368  virtual void setCaption(const DisplayString& text);
370  virtual const DisplayString& getCaption(void) const;
377  virtual void setColour(const ColourValue& col);
378 
380  virtual const ColourValue& getColour(void) const;
381 
392  virtual void setMetricsMode(GuiMetricsMode gmm);
394  virtual GuiMetricsMode getMetricsMode(void) const;
410  virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
412  virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
428  virtual void setVerticalAlignment(GuiVerticalAlignment gva);
430  virtual GuiVerticalAlignment getVerticalAlignment(void) const;
431 
432 
433 
434 
436  virtual bool contains(Real x, Real y) const;
437 
439  virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent
440 
444  inline virtual bool isContainer() const
445  { return false; }
446 
447  inline virtual bool isKeyEnabled() const
448  { return false; }
449 
450  inline virtual bool isCloneable() const
451  { return mCloneable; }
452 
453  inline virtual void setCloneable(bool c)
454  { mCloneable = c; }
455 
459  OverlayContainer* getParent() ;
460  void _setParent(OverlayContainer* parent) { mParent = parent; }
461 
465  inline ushort getZOrder() const
466  { return mZOrder; }
467 
469  Real getSquaredViewDepth(const Camera* cam) const
470  {
471  (void)cam;
472  return 10000.0f - (Real)getZOrder();
473  }
474 
476  const LightList& getLights(void) const
477  {
478  // Overlayelements should not be lit by the scene, this will not get called
479  static LightList ll;
480  return ll;
481  }
482 
483  virtual void copyFromTemplate(OverlayElement* templateOverlay);
484  virtual OverlayElement* clone(const String& instanceName);
485 
488  return mSourceTemplate ;
489  }
490  };
491 
492 
496 }
497 
498 
499 #endif
500 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:43