OGRE  2.0
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-2014 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 "OgreRenderable.h"
34 #include "OgreUTFString.h"
35 #include "OgreStringInterface.h"
37 #include "OgreColourValue.h"
38 
39 namespace Ogre {
47 #if OGRE_UNICODE_SUPPORT
48  typedef UTFString DisplayString;
49 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter()
50 #else
52 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it
53 #endif
54 
57  {
64  };
65 
70  {
74  };
79  {
83  };
84 
107  {
108  public:
109 
110  protected:
111  // Command object for setting / getting parameters
122 
123 
125  bool mVisible;
136 
140 
141  // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
148 
153 
154  // Derived positions from parent
158 
163 
167 
170 
172  bool mEnabled;
173 
176 
179 
184  virtual void updatePositionGeometry(void) = 0;
189  virtual void updateTextureGeometry(void) = 0;
190 
199  virtual void addBaseParameters(void);
200 
201  public:
203  OverlayElement(const String& name);
204  virtual ~OverlayElement();
205 
207  virtual void initialise(void) = 0;
208 
210  const String& getName(void) const;
211 
212 
214  virtual void show(void);
215 
217  virtual void hide(void);
218 
220  bool isVisible(void) const;
221 
222  bool isEnabled() const;
223  virtual void setEnabled(bool b);
224 
225 
227  void setDimensions(Real width, Real height);
228 
231  void setPosition(Real left, Real top);
232 
234  void setWidth(Real width);
236  Real getWidth(void) const;
237 
239  void setHeight(Real height);
241  Real getHeight(void) const;
242 
244  void setLeft(Real left);
246  Real getLeft(void) const;
247 
249  void setTop(Real Top);
251  Real getTop(void) const;
252 
254  Real _getLeft(void) const { return mLeft; }
256  Real _getTop(void) const { return mTop; }
258  Real _getWidth(void) const { return mWidth; }
260  Real _getHeight(void) const { return mHeight; }
262  void _setLeft(Real left);
264  void _setTop(Real top);
266  void _setWidth(Real width);
268  void _setHeight(Real height);
270  void _setPosition(Real left, Real top);
272  void _setDimensions(Real width, Real height);
273 
275  virtual const String& getMaterialName(void) const;
276 
287  virtual void setMaterialName(const String& matName);
288 
289 
290  // --- Renderable Overrides ---
292  const MaterialPtr& getMaterial(void) const;
293 
294  // NB getRenderOperation not implemented, still abstract here
295 
297  void getWorldTransforms(Matrix4* xform) const;
298 
300  virtual void _positionsOutOfDate(void);
301 
303  virtual void _update(void);
304 
306  virtual void _updateFromParent(void);
307 
309  virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
310 
312  virtual Real _getDerivedLeft(void);
313 
315  virtual Real _getDerivedTop(void);
316 
318  virtual Real _getRelativeWidth(void);
320  virtual Real _getRelativeHeight(void);
321 
322 
324  virtual void _getClippingRegion(RealRect &clippingRegion);
325 
338  virtual ushort _notifyZOrder(ushort newZOrder);
339 
343  virtual void _notifyWorldTransforms(const Matrix4& xform);
344 
348  virtual void _notifyViewport();
349 
351  virtual void _updateRenderQueue(RenderQueue* queue, Camera *camera, const Camera *lodCamera);
352 
354  void visitRenderables(Renderable::Visitor* visitor,
355  bool debugRenderables = false);
356 
358  virtual const String& getTypeName(void) const = 0;
359 
366  virtual void setCaption(const DisplayString& text);
368  virtual const DisplayString& getCaption(void) const;
375  virtual void setColour(const ColourValue& col);
376 
378  virtual const ColourValue& getColour(void) const;
379 
390  virtual void setMetricsMode(GuiMetricsMode gmm);
392  virtual GuiMetricsMode getMetricsMode(void) const;
408  virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
410  virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
426  virtual void setVerticalAlignment(GuiVerticalAlignment gva);
428  virtual GuiVerticalAlignment getVerticalAlignment(void) const;
429 
430 
431 
432 
434  virtual bool contains(Real x, Real y) const;
435 
437  virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent
438 
442  inline virtual bool isContainer() const
443  { return false; }
444 
445  inline virtual bool isKeyEnabled() const
446  { return false; }
447 
448  inline virtual bool isCloneable() const
449  { return mCloneable; }
450 
451  inline virtual void setCloneable(bool c)
452  { mCloneable = c; }
453 
457  OverlayContainer* getParent() ;
458  void _setParent(OverlayContainer* parent) { mParent = parent; }
459 
463  inline ushort getZOrder() const
464  { return mZOrder; }
465 
467  Real getSquaredViewDepth(const Camera* cam) const
468  {
469  (void)cam;
470  return 10000.0f - (Real)getZOrder();
471  }
472 
474  const LightList& getLights(void) const
475  {
476  // Overlayelements should not be lit by the scene, this will not get called
477  static LightList ll;
478  return ll;
479  }
480 
481  virtual void copyFromTemplate(OverlayElement* templateOverlay);
482  virtual OverlayElement* clone(const String& instanceName);
483 
486  return mSourceTemplate ;
487  }
488  };
489 
490 
494 }
495 
496 
497 #endif
498 
Command object for OverlayElement - see ParamCommand.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
Command object for OverlayElement - see ParamCommand.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
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.
Command object for OverlayElement - see ParamCommand.
#define _OgreOverlayExport
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.
bool mInitialised
Is element initialised?
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.
ushort mZOrder
Zorder for when sending to render queue.
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
Returns the SourceTemplate for this element.
static OverlayElementCommands::CmdHeight msHeightCmd
OverlayElement * mSourceTemplate
Used to see if this element is created from a Template.
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
Parent pointer.
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.
Matrix4 mXForm
World transforms.
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.
Overlay * mOverlay
Overlay attached to.
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) ...
String 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
Definition: OgreCommon.h:53
GuiMetricsMode mMetricsMode
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
bool mEnabled
Is element enabled?
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:69
Positions & sizes are in absolute pixels.