OgreOverlayElement.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
41namespace 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
59 {
66 };
67
72 {
76 };
81 {
85 };
86
109 {
110 public:
111
112 protected:
113 // Command object for setting / getting parameters
124
125
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
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);
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);
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
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
394 virtual GuiMetricsMode getMetricsMode(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
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
#define _OgreOverlayExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A viewpoint from which the scene will be rendered.
Definition OgreCamera.h:87
Class representing colour.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition OgreMatrix4.h:79
A 2D element which contains other OverlayElement instances.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Command object for OverlayElement - see ParamCommand.
Abstract definition of a 2D element to be displayed in an Overlay.
static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd
void _setPosition(Real left, Real top)
Sets the left and top of this element in relation to the screen (where 1.0 = screen width)
const OverlayElement * getSourceTemplate() const
Returns the SourceTemplate for this element.
static OverlayElementCommands::CmdTop msTopCmd
virtual bool isCloneable() const
GuiVerticalAlignment mVertAlign
bool mEnabled
Is element enabled?
virtual OverlayElement * clone(const String &instanceName)
virtual Real _getDerivedTop(void)
Gets the 'top' position as derived from own left and that of parents.
Real getWidth(void) const
Gets the width of this element in relation to the screen (where 1.0 = screen width)
virtual void setEnabled(bool b)
static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd
virtual const String & getTypeName(void) const =0
Gets the type name of the element.
void _setTop(Real top)
Sets the top of this element in relation to the screen (where 1.0 = screen width)
void setPosition(Real left, Real top)
Sets the position of the top-left corner of the element, relative to the screen size (1....
virtual void updateTextureGeometry(void)=0
Internal method which is triggered when the UVs of the element get updated, meaning the element shoul...
Real getHeight(void) const
Gets the height of this element in relation to the screen (where 1.0 = screen height)
virtual GuiMetricsMode getMetricsMode(void) const
Retrieves the current settings of how the element metrics are interpreted.
virtual void _updateRenderQueue(RenderQueue *queue)
Internal method to put the contents onto the render queue.
static OverlayElementCommands::CmdCaption msCaptionCmd
virtual void setColour(const ColourValue &col)
Sets the colour on elements that support it.
const MaterialPtr & getMaterial(void) const
See Renderable.
virtual void _notifyParent(OverlayContainer *parent, Overlay *overlay)
Internal method for notifying the GUI element of it's parent and ultimate overlay.
virtual void _positionsOutOfDate(void)
Tell the object to recalculate.
virtual void hide(void)
Hides this element if it was visible.
static OverlayElementCommands::CmdVisible msVisibleCmd
virtual void setHorizontalAlignment(GuiHorizontalAlignment gha)
Sets the horizontal origin for this element.
OverlayContainer * mParent
Parent pointer.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
void setTop(Real Top)
Sets the top of this element in relation to the screen (where 0 = top, 1.0 = bottom)
void setDimensions(Real width, Real height)
Sets the dimensions of this element in relation to the screen (1.0 = screen width/height).
virtual const ColourValue & getColour(void) const
Gets the colour for this element.
void setWidth(Real width)
Sets the width of this element in relation to the screen (where 1.0 = screen width)
virtual void setCloneable(bool c)
void _setLeft(Real left)
Sets the left of this element in relation to the screen (where 1.0 = screen width)
virtual void initialise(void)=0
Initialise gui element.
bool isVisible(void) const
Returns whether or not the element is visible.
void _setWidth(Real width)
Sets the width of this element in relation to the screen (where 1.0 = screen width)
virtual void _notifyViewport()
Internal method to notify the element when the viewport of parent overlay has changed.
static OverlayElementCommands::CmdMaterial msMaterialCmd
OverlayElement * mSourceTemplate
Used to see if this element is created from a Template.
Real _getWidth(void) const
Gets the width of this element in relation to the screen (where 1.0 = screen width)
virtual ushort _notifyZOrder(ushort newZOrder)
Internal method to notify the element when Z-order of parent overlay has changed.
bool mGeomPositionsOutOfDate
Flag indicating if the vertex positions need recalculating.
void _setDimensions(Real width, Real height)
Sets the width and height of this element in relation to the screen (where 1.0 = screen width)
Real _getTop(void) const
Gets the top of this element in relation to the screen (where 0 = far left, 1.0 = far right)
Matrix4 mXForm
World transforms.
virtual bool isKeyEnabled() const
ushort mZOrder
Zorder for when sending to render queue.
virtual ~OverlayElement()
static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd
virtual const String & getMaterialName(void) const
Gets the name of the material this element uses.
bool isEnabled() const
virtual void show(void)
Shows this element if it was hidden.
void setHeight(Real height)
Sets the height of this element in relation to the screen (where 1.0 = screen height)
static OverlayElementCommands::CmdWidth msWidthCmd
void _setParent(OverlayContainer *parent)
virtual void _getClippingRegion(RealRect &clippingRegion)
Gets the clipping region of the element.
virtual void _updateFromParent(void)
Updates this elements transform based on it's parent.
bool mInitialised
Is element initialised?
virtual Real _getRelativeHeight(void)
Gets the 'height' as derived from own height and metrics mode.
virtual bool contains(Real x, Real y) const
Returns true if xy is within the constraints of the component.
void getWorldTransforms(Matrix4 *xform) const
See Renderable.
virtual void setMetricsMode(GuiMetricsMode gmm)
Tells this element how to interpret the position and dimension values it is given.
static OverlayElementCommands::CmdLeft msLeftCmd
Real getLeft(void) const
Gets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right)
virtual void updatePositionGeometry(void)=0
Internal method which is triggered when the positions of the element get updated, meaning the element...
virtual OverlayElement * findElementAt(Real x, Real y)
Returns true if xy is within the constraints of the component.
virtual Real _getDerivedLeft(void)
Gets the 'left' position as derived from own left and that of parents.
virtual void setCaption(const DisplayString &text)
Sets the caption on elements that support it.
virtual GuiVerticalAlignment getVerticalAlignment(void) const
Gets the vertical alignment for this element.
virtual void _update(void)
Internal method to update the element based on transforms applied.
Real _getHeight(void) const
Gets the height of this element in relation to the screen (where 1.0 = screen height)
bool mGeomUVsOutOfDate
Flag indicating if the vertex uvs need recalculating.
virtual void copyFromTemplate(OverlayElement *templateOverlay)
OverlayContainer * getParent()
Returns the parent container.
ushort getZOrder() const
Returns the zOrder of the element.
virtual Real _getRelativeWidth(void)
Gets the 'width' as derived from own width and metrics mode.
virtual void setVerticalAlignment(GuiVerticalAlignment gva)
Sets the vertical origin for this element.
Real getSquaredViewDepth(const Camera *cam) const
Overridden from Renderable.
virtual GuiHorizontalAlignment getHorizontalAlignment(void) const
Gets the horizontal alignment for this element.
OverlayElement(const String &name)
Constructor: do not call direct, use OverlayManager::createElement.
virtual void setMaterialName(const String &matName)
Sets the name of the material this element will use.
const String & getName(void) const
Gets the name of this overlay.
void setLeft(Real left)
Sets the left of this element in relation to the screen (where 0 = far left, 1.0 = far right)
Real getTop(void) const
Gets the top of this element in relation to the screen (where 0 = top, 1.0 = bottom)
virtual void addBaseParameters(void)
Internal method for setting up the basic parameter definitions for a subclass.
virtual void _notifyWorldTransforms(const Matrix4 &xform)
Internal method to notify the element when it's world transform of parent overlay has changed.
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
GuiHorizontalAlignment mHorzAlign
Overlay * mOverlay
Overlay attached to.
virtual const DisplayString & getCaption(void) const
Gets the caption for this element.
static OverlayElementCommands::CmdHeight msHeightCmd
void _setHeight(Real height)
Sets the height of this element in relation to the screen (where 1.0 = screen width)
virtual bool isContainer() const
returns false as this class is not a container type
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:71
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Abstract class defining the interface all renderable objects must implement.
Class defining the common interface which classes can use to present a reflection-style,...
String DisplayString
GuiHorizontalAlignment
Enum describing where '0' is in relation to the parent in the horizontal dimension.
GuiMetricsMode
Enum describing how the position / size of an element is to be recorded.
GuiVerticalAlignment
Enum describing where '0' is in relation to the parent in the vertical dimension.
@ GMM_PIXELS
Positions & sizes are in absolute pixels.
@ GMM_RELATIVE_ASPECT_ADJUSTED
Positions & sizes are in virtual pixels.
@ GMM_RELATIVE
'left', 'top', 'height' and 'width' are parametrics from 0.0 to 1.0
float Real
Software floating point type.
_StringBase String
unsigned short ushort

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