OgreOverlayElement.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __OverlayElement_H__
#define __OverlayElement_H__
#include "OgreOverlayPrerequisites.h"
#include "OgreString.h"
#include "OgreRenderable.h"
#include "OgreUTFString.h"
#include "OgreStringInterface.h"
#include "OgreOverlayElementCommands.h"
#include "OgreColourValue.h"
namespace Ogre {
#if OGRE_UNICODE_SUPPORT
typedef UTFString DisplayString;
# define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter()
#else
typedef String DisplayString;
# define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it
#endif
enum GuiMetricsMode
{
GMM_RELATIVE,
GMM_PIXELS,
GMM_RELATIVE_ASPECT_ADJUSTED
};
enum GuiHorizontalAlignment
{
GHA_LEFT,
GHA_CENTER,
GHA_RIGHT
};
enum GuiVerticalAlignment
{
GVA_TOP,
GVA_CENTER,
GVA_BOTTOM
};
class _OgreOverlayExport OverlayElement : public StringInterface, public Renderable, public OverlayAlloc
{
public:
protected:
// Command object for setting / getting parameters
static OverlayElementCommands::CmdLeft msLeftCmd;
static OverlayElementCommands::CmdTop msTopCmd;
static OverlayElementCommands::CmdWidth msWidthCmd;
static OverlayElementCommands::CmdHeight msHeightCmd;
static OverlayElementCommands::CmdMaterial msMaterialCmd;
static OverlayElementCommands::CmdCaption msCaptionCmd;
static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd;
static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd;
static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd;
static OverlayElementCommands::CmdVisible msVisibleCmd;
String mName;
bool mVisible;
bool mCloneable;
Real mLeft;
Real mTop;
Real mWidth;
Real mHeight;
String mMaterialName;
MaterialPtr mMaterial;
DisplayString mCaption;
ColourValue mColour;
RealRect mClippingRegion;
GuiMetricsMode mMetricsMode;
GuiHorizontalAlignment mHorzAlign;
GuiVerticalAlignment mVertAlign;
// metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
Real mPixelTop;
Real mPixelLeft;
Real mPixelWidth;
Real mPixelHeight;
Real mPixelScaleX;
Real mPixelScaleY;
OverlayContainer* mParent;
Overlay* mOverlay;
// Derived positions from parent
Real mDerivedLeft;
Real mDerivedTop;
bool mDerivedOutOfDate;
bool mGeomPositionsOutOfDate;
bool mGeomUVsOutOfDate;
ushort mZOrder;
Matrix4 mXForm;
bool mEnabled;
bool mInitialised;
OverlayElement* mSourceTemplate ;
virtual void updatePositionGeometry(void) = 0;
virtual void updateTextureGeometry(void) = 0;
virtual void addBaseParameters(void);
public:
OverlayElement(const String& name);
virtual ~OverlayElement();
virtual void initialise(void) = 0;
const String& getName(void) const;
virtual void show(void);
virtual void hide(void);
bool isVisible(void) const;
bool isEnabled() const;
virtual void setEnabled(bool b);
void setDimensions(Real width, Real height);
void setPosition(Real left, Real top);
void setWidth(Real width);
Real getWidth(void) const;
void setHeight(Real height);
Real getHeight(void) const;
void setLeft(Real left);
Real getLeft(void) const;
void setTop(Real Top);
Real getTop(void) const;
Real _getLeft(void) const { return mLeft; }
Real _getTop(void) const { return mTop; }
Real _getWidth(void) const { return mWidth; }
Real _getHeight(void) const { return mHeight; }
void _setLeft(Real left);
void _setTop(Real top);
void _setWidth(Real width);
void _setHeight(Real height);
void _setPosition(Real left, Real top);
void _setDimensions(Real width, Real height);
virtual const String& getMaterialName(void) const;
virtual void setMaterialName(const String& matName);
// --- Renderable Overrides ---
const MaterialPtr& getMaterial(void) const;
// NB getRenderOperation not implemented, still abstract here
void getWorldTransforms(Matrix4* xform) const;
virtual void _positionsOutOfDate(void);
virtual void _update(void);
virtual void _updateFromParent(void);
virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
virtual Real _getDerivedLeft(void);
virtual Real _getDerivedTop(void);
virtual Real _getRelativeWidth(void);
virtual Real _getRelativeHeight(void);
virtual void _getClippingRegion(RealRect &clippingRegion);
virtual ushort _notifyZOrder(ushort newZOrder);
virtual void _notifyWorldTransforms(const Matrix4& xform);
virtual void _notifyViewport();
virtual void _updateRenderQueue(RenderQueue* queue);
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
virtual const String& getTypeName(void) const = 0;
virtual void setCaption(const DisplayString& text);
virtual const DisplayString& getCaption(void) const;
virtual void setColour(const ColourValue& col);
virtual const ColourValue& getColour(void) const;
virtual void setMetricsMode(GuiMetricsMode gmm);
virtual GuiMetricsMode getMetricsMode(void) const;
virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
virtual void setVerticalAlignment(GuiVerticalAlignment gva);
virtual GuiVerticalAlignment getVerticalAlignment(void) const;
virtual bool contains(Real x, Real y) const;
virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent
inline virtual bool isContainer() const
{ return false; }
inline virtual bool isKeyEnabled() const
{ return false; }
inline virtual bool isCloneable() const
{ return mCloneable; }
inline virtual void setCloneable(bool c)
{ mCloneable = c; }
OverlayContainer* getParent() ;
void _setParent(OverlayContainer* parent) { mParent = parent; }
inline ushort getZOrder() const
{ return mZOrder; }
Real getSquaredViewDepth(const Camera* cam) const
{
(void)cam;
return 10000.0f - (Real)getZOrder();
}
const LightList& getLights(void) const
{
// Overlayelements should not be lit by the scene, this will not get called
static LightList ll;
return ll;
}
virtual void copyFromTemplate(OverlayElement* templateOverlay);
virtual OverlayElement* clone(const String& instanceName);
const OverlayElement* getSourceTemplate () const {
return mSourceTemplate ;
}
};
}
#endif
Ogre::OverlayElement::mTop
Real mTop
Definition: OgreOverlayElement.h:130
Ogre::OverlayElement::isCloneable
virtual bool isCloneable() const
Definition: OgreOverlayElement.h:450
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::OverlayElement::mMaterial
MaterialPtr mMaterial
Definition: OgreOverlayElement.h:134
Ogre::OverlayElement::mPixelTop
Real mPixelTop
Definition: OgreOverlayElement.h:144
Ogre::OverlayElement::mGeomPositionsOutOfDate
bool mGeomPositionsOutOfDate
Flag indicating if the vertex positions need recalculating.
Definition: OgreOverlayElement.h:162
Ogre::GMM_RELATIVE
&#39;left&#39;, &#39;top&#39;, &#39;height&#39; and &#39;width&#39; are parametrics from 0.0 to 1.0
Definition: OgreOverlayElement.h:61
Ogre::OverlayElement::mColour
ColourValue mColour
Definition: OgreOverlayElement.h:136
Ogre::OverlayElement::mClippingRegion
RealRect mClippingRegion
Definition: OgreOverlayElement.h:137
OgreRenderable.h
Ogre::GuiMetricsMode
GuiMetricsMode
Enum describing how the position / size of an element is to be recorded.
Definition: OgreOverlayElement.h:58
Ogre::OverlayElement::mVisible
bool mVisible
Definition: OgreOverlayElement.h:127
Ogre::OverlayElement::mDerivedLeft
Real mDerivedLeft
Definition: OgreOverlayElement.h:157
Ogre::OverlayElementCommands::CmdVisible
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:108
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
OgreString.h
Ogre::TRect< Real >
Ogre::OverlayElement::msTopCmd
static OverlayElementCommands::CmdTop msTopCmd
Definition: OgreOverlayElement.h:115
Ogre::GMM_PIXELS
Positions & sizes are in absolute pixels.
Definition: OgreOverlayElement.h:63
_OgreOverlayExport
#define _OgreOverlayExport
Definition: OgreOverlayPrerequisites.h:58
Ogre::OverlayElement::mLeft
Real mLeft
Definition: OgreOverlayElement.h:129
Ogre::OverlayElement::mZOrder
ushort mZOrder
Zorder for when sending to render queue.
Definition: OgreOverlayElement.h:168
Ogre::OverlayElement::getLights
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable. ...
Definition: OgreOverlayElement.h:476
Ogre::GuiHorizontalAlignment
GuiHorizontalAlignment
Enum describing where &#39;0&#39; is in relation to the parent in the horizontal dimension.
Definition: OgreOverlayElement.h:71
Ogre::OverlayElement::setCloneable
virtual void setCloneable(bool c)
Definition: OgreOverlayElement.h:453
Ogre::OverlayElement::getSourceTemplate
const OverlayElement * getSourceTemplate() const
Returns the SourceTemplate for this element.
Definition: OgreOverlayElement.h:487
Ogre::OverlayElement::_getTop
Real _getTop(void) const
Gets the top of this element in relation to the screen (where 0 = far left, 1.0 = far right) ...
Definition: OgreOverlayElement.h:258
Ogre::OverlayElement::msCaptionCmd
static OverlayElementCommands::CmdCaption msCaptionCmd
Definition: OgreOverlayElement.h:119
Ogre::OverlayElement::_getHeight
Real _getHeight(void) const
Gets the height of this element in relation to the screen (where 1.0 = screen height) ...
Definition: OgreOverlayElement.h:262
Ogre::OverlayElement::msWidthCmd
static OverlayElementCommands::CmdWidth msWidthCmd
Definition: OgreOverlayElement.h:116
Ogre::OverlayElementCommands::CmdWidth
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:59
Ogre::OverlayElement::msVerticalAlignCmd
static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd
Definition: OgreOverlayElement.h:122
Ogre::OverlayElement::mPixelHeight
Real mPixelHeight
Definition: OgreOverlayElement.h:147
Ogre::OverlayElement::mPixelLeft
Real mPixelLeft
Definition: OgreOverlayElement.h:145
Ogre::OverlayElement::mHeight
Real mHeight
Definition: OgreOverlayElement.h:132
Ogre::OverlayElement::getZOrder
ushort getZOrder() const
Returns the zOrder of the element.
Definition: OgreOverlayElement.h:465
Ogre::OverlayElementCommands::CmdMetricsMode
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:87
Ogre::GVA_BOTTOM
Definition: OgreOverlayElement.h:84
Ogre::OverlayElement::msHeightCmd
static OverlayElementCommands::CmdHeight msHeightCmd
Definition: OgreOverlayElement.h:117
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::OverlayElement::mInitialised
bool mInitialised
Is element initialised?
Definition: OgreOverlayElement.h:177
Ogre::OverlayElement::msMetricsModeCmd
static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd
Definition: OgreOverlayElement.h:120
Ogre::OverlayElement::mParent
OverlayContainer * mParent
Parent pointer.
Definition: OgreOverlayElement.h:152
Ogre::OverlayElement::mName
String mName
Definition: OgreOverlayElement.h:126
Ogre::OverlayElement::msVisibleCmd
static OverlayElementCommands::CmdVisible msVisibleCmd
Definition: OgreOverlayElement.h:123
Ogre::OverlayElementCommands::CmdVerticalAlign
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:101
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::OverlayElement::mSourceTemplate
OverlayElement * mSourceTemplate
Used to see if this element is created from a Template.
Definition: OgreOverlayElement.h:180
Ogre::OverlayElement::getSquaredViewDepth
Real getSquaredViewDepth(const Camera *cam) const
Overridden from Renderable.
Definition: OgreOverlayElement.h:469
Ogre::OverlayElement::mPixelScaleY
Real mPixelScaleY
Definition: OgreOverlayElement.h:149
Ogre::OverlayElement::mPixelWidth
Real mPixelWidth
Definition: OgreOverlayElement.h:146
Ogre::StringInterface
Class defining the common interface which classes can use to present a reflection-style, self-defining parameter set to callers.
Definition: OgreStringInterface.h:163
Ogre::GHA_RIGHT
Definition: OgreOverlayElement.h:75
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
OgreOverlayPrerequisites.h
Ogre::OverlayElement::msMaterialCmd
static OverlayElementCommands::CmdMaterial msMaterialCmd
Definition: OgreOverlayElement.h:118
Ogre::OverlayElement::mVertAlign
GuiVerticalAlignment mVertAlign
Definition: OgreOverlayElement.h:141
Ogre::OverlayElement::isContainer
virtual bool isContainer() const
returns false as this class is not a container type
Definition: OgreOverlayElement.h:444
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::OverlayElement::mHorzAlign
GuiHorizontalAlignment mHorzAlign
Definition: OgreOverlayElement.h:140
Ogre::OverlayElementCommands::CmdHorizontalAlign
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:94
Ogre::GMM_RELATIVE_ASPECT_ADJUSTED
Positions & sizes are in virtual pixels.
Definition: OgreOverlayElement.h:65
Ogre::OverlayElement::mXForm
Matrix4 mXForm
World transforms.
Definition: OgreOverlayElement.h:171
Ogre::OverlayElement::mOverlay
Overlay * mOverlay
Overlay attached to.
Definition: OgreOverlayElement.h:154
OgreOverlayElementCommands.h
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::DisplayString
String DisplayString
Definition: OgreOverlayElement.h:53
Ogre::GuiVerticalAlignment
GuiVerticalAlignment
Enum describing where &#39;0&#39; is in relation to the parent in the vertical dimension. ...
Definition: OgreOverlayElement.h:80
Ogre::OverlayElement::_setParent
void _setParent(OverlayContainer *parent)
Definition: OgreOverlayElement.h:460
Ogre::OverlayElement::mGeomUVsOutOfDate
bool mGeomUVsOutOfDate
Flag indicating if the vertex uvs need recalculating.
Definition: OgreOverlayElement.h:164
Ogre::OverlayElement::_getLeft
Real _getLeft(void) const
Gets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right) ...
Definition: OgreOverlayElement.h:256
Ogre::SharedPtr< Material >
Ogre::GHA_LEFT
Definition: OgreOverlayElement.h:73
Ogre::OverlayElement::_getWidth
Real _getWidth(void) const
Gets the width of this element in relation to the screen (where 1.0 = screen width) ...
Definition: OgreOverlayElement.h:260
Ogre::OverlayElement::mDerivedTop
Real mDerivedTop
Definition: OgreOverlayElement.h:158
OgreColourValue.h
Ogre::OverlayElement::isKeyEnabled
virtual bool isKeyEnabled() const
Definition: OgreOverlayElement.h:447
Ogre::OverlayElement::msLeftCmd
static OverlayElementCommands::CmdLeft msLeftCmd
Definition: OgreOverlayElement.h:114
Ogre::GVA_CENTER
Definition: OgreOverlayElement.h:83
Ogre::OverlayElement::mCaption
DisplayString mCaption
Definition: OgreOverlayElement.h:135
Ogre::OverlayElement
Abstract definition of a 2D element to be displayed in an Overlay.
Definition: OgreOverlayElement.h:108
Ogre::OverlayElement::mCloneable
bool mCloneable
Definition: OgreOverlayElement.h:128
Ogre::OverlayElement::mMaterialName
String mMaterialName
Definition: OgreOverlayElement.h:133
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::OverlayContainer
A 2D element which contains other OverlayElement instances.
Definition: OgreOverlayContainer.h:56
Ogre::OverlayElementCommands::CmdHeight
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:66
Ogre::OverlayElement::mMetricsMode
GuiMetricsMode mMetricsMode
Definition: OgreOverlayElement.h:139
Ogre::OverlayElement::mDerivedOutOfDate
bool mDerivedOutOfDate
Definition: OgreOverlayElement.h:159
Ogre::OverlayElement::msHorizontalAlignCmd
static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd
Definition: OgreOverlayElement.h:121
Ogre::GVA_TOP
Definition: OgreOverlayElement.h:82
Ogre::Overlay
Represents a layer which is rendered on top of the &#39;normal&#39; scene contents.
Definition: OgreOverlay.h:70
Ogre::OverlayElementCommands::CmdLeft
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:45
Ogre::OverlayElement::mWidth
Real mWidth
Definition: OgreOverlayElement.h:131
OgreStringInterface.h
Ogre::OverlayElementCommands::CmdTop
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:52
Ogre::OverlayElement::mPixelScaleX
Real mPixelScaleX
Definition: OgreOverlayElement.h:148
Ogre::OverlayElementCommands::CmdCaption
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:80
Ogre::OverlayElementCommands::CmdMaterial
Command object for OverlayElement - see ParamCommand.
Definition: OgreOverlayElementCommands.h:73
Ogre::GHA_CENTER
Definition: OgreOverlayElement.h:74
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::OverlayElement::mEnabled
bool mEnabled
Is element enabled?
Definition: OgreOverlayElement.h:174

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.