OGRE  1.9
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 "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 
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.
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
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:70
Positions & sizes are in absolute pixels.