OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
32 #include "OgrePrerequisites.h"
33 #include "OgreString.h"
34 #include "OgreRenderable.h"
35 #include "OgreUTFString.h"
36 #include "OgreStringInterface.h"
38 
39 #include "OgreColourValue.h"
40 #include "OgreRectangle.h"
41 
42 namespace Ogre {
50 #if OGRE_UNICODE_SUPPORT
51  typedef UTFString DisplayString;
52 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter()
53 #else
54  typedef String DisplayString;
55 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it
56 #endif
57 
60  {
67  };
68 
73  {
77  };
82  {
86  };
87 
110  {
111  public:
112 
113  protected:
114  // Command object for setting / getting parameters
125 
126 
128  bool mVisible;
139 
143 
144  // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
151 
152  // Parent pointer
154  // Overlay attached to
156 
157  // Derived positions from parent
161 
166 
167  // Zorder for when sending to render queue
168  // Derived from parent
170 
171  // world transforms
173 
174  // is element enabled
175  bool mEnabled;
176 
177  // is element initialised
179 
180  // Used to see if this element is created from a Template
182 
187  virtual void updatePositionGeometry(void) = 0;
192  virtual void updateTextureGeometry(void) = 0;
193 
202  virtual void addBaseParameters(void);
203 
204  public:
206  OverlayElement(const String& name);
207  virtual ~OverlayElement();
208 
210  virtual void initialise(void) = 0;
211 
213  const String& getName(void) const;
214 
215 
217  virtual void show(void);
218 
220  virtual void hide(void);
221 
223  bool isVisible(void) const;
224 
225  bool isEnabled() const;
226  virtual void setEnabled(bool b);
227 
228 
230  void setDimensions(Real width, Real height);
231 
234  void setPosition(Real left, Real top);
235 
237  void setWidth(Real width);
239  Real getWidth(void) const;
240 
242  void setHeight(Real height);
244  Real getHeight(void) const;
245 
247  void setLeft(Real left);
249  Real getLeft(void) const;
250 
252  void setTop(Real Top);
254  Real getTop(void) const;
255 
257  Real _getLeft(void) const { return mLeft; }
259  Real _getTop(void) const { return mTop; }
261  Real _getWidth(void) const { return mWidth; }
263  Real _getHeight(void) const { return mHeight; }
265  void _setLeft(Real left);
267  void _setTop(Real top);
269  void _setWidth(Real width);
271  void _setHeight(Real height);
273  void _setPosition(Real left, Real top);
275  void _setDimensions(Real width, Real height);
276 
278  virtual const String& getMaterialName(void) const;
279 
290  virtual void setMaterialName(const String& matName);
291 
292 
293  // --- Renderable Overrides ---
295  const MaterialPtr& getMaterial(void) const;
296 
297  // NB getRenderOperation not implemented, still abstract here
298 
300  void getWorldTransforms(Matrix4* xform) const;
301 
303  virtual void _positionsOutOfDate(void);
304 
306  virtual void _update(void);
307 
309  virtual void _updateFromParent(void);
310 
312  virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
313 
315  virtual Real _getDerivedLeft(void);
316 
318  virtual Real _getDerivedTop(void);
319 
321  virtual Real _getRelativeWidth(void);
323  virtual Real _getRelativeHeight(void);
324 
325 
327  virtual void _getClippingRegion(Rectangle &clippingRegion);
328 
341  virtual ushort _notifyZOrder(ushort newZOrder);
342 
346  virtual void _notifyWorldTransforms(const Matrix4& xform);
347 
351  virtual void _notifyViewport();
352 
354  virtual void _updateRenderQueue(RenderQueue* queue);
355 
357  void visitRenderables(Renderable::Visitor* visitor,
358  bool debugRenderables = false);
359 
361  virtual const String& getTypeName(void) const = 0;
362 
369  virtual void setCaption(const DisplayString& text);
371  virtual const DisplayString& getCaption(void) const;
378  virtual void setColour(const ColourValue& col);
379 
381  virtual const ColourValue& getColour(void) const;
382 
393  virtual void setMetricsMode(GuiMetricsMode gmm);
395  virtual GuiMetricsMode getMetricsMode(void) const;
411  virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
413  virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
429  virtual void setVerticalAlignment(GuiVerticalAlignment gva);
431  virtual GuiVerticalAlignment getVerticalAlignment(void) const;
432 
433 
434 
435 
437  virtual bool contains(Real x, Real y) const;
438 
440  virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent
441 
445  inline virtual bool isContainer() const
446  { return false; }
447 
448  inline virtual bool isKeyEnabled() const
449  { return false; }
450 
451  inline virtual bool isCloneable() const
452  { return mCloneable; }
453 
454  inline virtual void setCloneable(bool c)
455  { mCloneable = c; }
456 
460  OverlayContainer* getParent() ;
461  void _setParent(OverlayContainer* parent) { mParent = parent; }
462 
466  inline ushort getZOrder() const
467  { return mZOrder; }
468 
470  Real getSquaredViewDepth(const Camera* cam) const
471  {
472  (void)cam;
473  return 10000.0f - (Real)getZOrder();
474  }
475 
477  const LightList& getLights(void) const
478  {
479  // Overlayelements should not be lit by the scene, this will not get called
480  static LightList ll;
481  return ll;
482  }
483 
484  virtual void copyFromTemplate(OverlayElement* templateOverlay);
485  virtual OverlayElement* clone(const String& instanceName);
486 
487  // Returns the SourceTemplate for this element
489  return mSourceTemplate ;
490  }
491  };
492 
493 
497 }
498 
499 
500 #endif
501 
Command object for OverlayElement - see ParamCommand.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Command object for OverlayElement - see ParamCommand.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Real _getHeight(void) const
Gets the height of this element in relation to the screen (where 1.0 = screen height) ...
float Real
Software floating point type.
bool mGeomPositionsOutOfDate
Flag indicating if the vertex positions need recalculating.
#define _OgreExport
Definition: OgrePlatform.h:233
Command object for OverlayElement - see ParamCommand.
Class representing colour.
Real _getTop(void) const
Gets the top of this element in relation to the screen (where 0 = far left, 1.0 = far right) ...
static OverlayElementCommands::CmdTop msTopCmd
static OverlayElementCommands::CmdWidth msWidthCmd
Positions & sizes are in virtual pixels.
static OverlayElementCommands::CmdCaption msCaptionCmd
Real getSquaredViewDepth(const Camera *cam) const
Overridden from Renderable.
A 2D element which contains other OverlayElement instances.
ushort getZOrder() const
Returns the zOrder of the element.
GuiMetricsMode
Enum describing how the position / size of an element is to be recorded.
Abstract class defining the interface all renderable objects must implement.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
virtual void setCloneable(bool c)
virtual bool isKeyEnabled() const
Class defining the common interface which classes can use to present a reflection-style, self-defining parameter set to callers.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable. ...
static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd
static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd
static OverlayElementCommands::CmdVisible msVisibleCmd
const OverlayElement * getSourceTemplate() const
static OverlayElementCommands::CmdHeight msHeightCmd
OverlayElement * mSourceTemplate
Command object for OverlayElement - see ParamCommand.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
static OverlayElementCommands::CmdMaterial msMaterialCmd
OverlayContainer * mParent
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Command object for OverlayElement - see ParamCommand.
bool mGeomUVsOutOfDate
Flag indicating if the vertex uvs need recalculating.
Command object for OverlayElement - see ParamCommand.
static OverlayElementCommands::CmdLeft msLeftCmd
unsigned short ushort
GuiHorizontalAlignment mHorzAlign
Abstract definition of a 2D element to be displayed in an Overlay.
static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd
virtual bool isContainer() const
returns false as this class is not a container type
Real _getWidth(void) const
Gets the width of this element in relation to the screen (where 1.0 = screen width) ...
UTFString DisplayString
GuiVerticalAlignment mVertAlign
Class to manage the scene object rendering queue.
void _setParent(OverlayContainer *parent)
Command object for OverlayElement - see ParamCommand.
virtual bool isCloneable() const
_StringBase String
GuiMetricsMode mMetricsMode
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
GuiVerticalAlignment
Enum describing where '0' is in relation to the parent in the vertical dimension. ...
GuiHorizontalAlignment
Enum describing where '0' is in relation to the parent in the horizontal dimension.
'left', 'top', 'height' and 'width' are parametrics from 0.0 to 1.0
Real _getLeft(void) const
Gets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right) ...
Represents a layer which is rendered on top of the 'normal' scene contents.
Definition: OgreOverlay.h:70
Positions & sizes are in absolute pixels.