00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 00029 #ifndef __OverlayElement_H__ 00030 #define __OverlayElement_H__ 00031 00032 #include "OgreOverlayPrerequisites.h" 00033 #include "OgreString.h" 00034 #include "OgreRenderable.h" 00035 #include "OgreUTFString.h" 00036 #include "OgreStringInterface.h" 00037 #include "OgreOverlayElementCommands.h" 00038 00039 #include "OgreColourValue.h" 00040 00041 namespace Ogre { 00049 #if OGRE_UNICODE_SUPPORT 00050 typedef UTFString DisplayString; 00051 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter() 00052 #else 00053 typedef String DisplayString; 00054 # define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it 00055 #endif 00056 00058 enum GuiMetricsMode 00059 { 00061 GMM_RELATIVE, 00063 GMM_PIXELS, 00065 GMM_RELATIVE_ASPECT_ADJUSTED 00066 }; 00067 00071 enum GuiHorizontalAlignment 00072 { 00073 GHA_LEFT, 00074 GHA_CENTER, 00075 GHA_RIGHT 00076 }; 00080 enum GuiVerticalAlignment 00081 { 00082 GVA_TOP, 00083 GVA_CENTER, 00084 GVA_BOTTOM 00085 }; 00086 00108 class _OgreOverlayExport OverlayElement : public StringInterface, public Renderable, public OverlayAlloc 00109 { 00110 public: 00111 00112 protected: 00113 // Command object for setting / getting parameters 00114 static OverlayElementCommands::CmdLeft msLeftCmd; 00115 static OverlayElementCommands::CmdTop msTopCmd; 00116 static OverlayElementCommands::CmdWidth msWidthCmd; 00117 static OverlayElementCommands::CmdHeight msHeightCmd; 00118 static OverlayElementCommands::CmdMaterial msMaterialCmd; 00119 static OverlayElementCommands::CmdCaption msCaptionCmd; 00120 static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd; 00121 static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd; 00122 static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd; 00123 static OverlayElementCommands::CmdVisible msVisibleCmd; 00124 00125 00126 String mName; 00127 bool mVisible; 00128 bool mCloneable; 00129 Real mLeft; 00130 Real mTop; 00131 Real mWidth; 00132 Real mHeight; 00133 String mMaterialName; 00134 MaterialPtr mMaterial; 00135 DisplayString mCaption; 00136 ColourValue mColour; 00137 RealRect mClippingRegion; 00138 00139 GuiMetricsMode mMetricsMode; 00140 GuiHorizontalAlignment mHorzAlign; 00141 GuiVerticalAlignment mVertAlign; 00142 00143 // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode. 00144 Real mPixelTop; 00145 Real mPixelLeft; 00146 Real mPixelWidth; 00147 Real mPixelHeight; 00148 Real mPixelScaleX; 00149 Real mPixelScaleY; 00150 00152 OverlayContainer* mParent; 00154 Overlay* mOverlay; 00155 00156 // Derived positions from parent 00157 Real mDerivedLeft; 00158 Real mDerivedTop; 00159 bool mDerivedOutOfDate; 00160 00162 bool mGeomPositionsOutOfDate; 00164 bool mGeomUVsOutOfDate; 00165 00168 ushort mZOrder; 00169 00171 Matrix4 mXForm; 00172 00174 bool mEnabled; 00175 00177 bool mInitialised; 00178 00180 OverlayElement* mSourceTemplate ; 00181 00186 virtual void updatePositionGeometry(void) = 0; 00191 virtual void updateTextureGeometry(void) = 0; 00192 00201 virtual void addBaseParameters(void); 00202 00203 public: 00205 OverlayElement(const String& name); 00206 virtual ~OverlayElement(); 00207 00209 virtual void initialise(void) = 0; 00210 00212 const String& getName(void) const; 00213 00214 00216 virtual void show(void); 00217 00219 virtual void hide(void); 00220 00222 bool isVisible(void) const; 00223 00224 bool isEnabled() const; 00225 virtual void setEnabled(bool b); 00226 00227 00229 void setDimensions(Real width, Real height); 00230 00233 void setPosition(Real left, Real top); 00234 00236 void setWidth(Real width); 00238 Real getWidth(void) const; 00239 00241 void setHeight(Real height); 00243 Real getHeight(void) const; 00244 00246 void setLeft(Real left); 00248 Real getLeft(void) const; 00249 00251 void setTop(Real Top); 00253 Real getTop(void) const; 00254 00256 Real _getLeft(void) const { return mLeft; } 00258 Real _getTop(void) const { return mTop; } 00260 Real _getWidth(void) const { return mWidth; } 00262 Real _getHeight(void) const { return mHeight; } 00264 void _setLeft(Real left); 00266 void _setTop(Real top); 00268 void _setWidth(Real width); 00270 void _setHeight(Real height); 00272 void _setPosition(Real left, Real top); 00274 void _setDimensions(Real width, Real height); 00275 00277 virtual const String& getMaterialName(void) const; 00278 00289 virtual void setMaterialName(const String& matName); 00290 00291 00292 // --- Renderable Overrides --- 00294 const MaterialPtr& getMaterial(void) const; 00295 00296 // NB getRenderOperation not implemented, still abstract here 00297 00299 void getWorldTransforms(Matrix4* xform) const; 00300 00302 virtual void _positionsOutOfDate(void); 00303 00305 virtual void _update(void); 00306 00308 virtual void _updateFromParent(void); 00309 00311 virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay); 00312 00314 virtual Real _getDerivedLeft(void); 00315 00317 virtual Real _getDerivedTop(void); 00318 00320 virtual Real _getRelativeWidth(void); 00322 virtual Real _getRelativeHeight(void); 00323 00324 00326 virtual void _getClippingRegion(RealRect &clippingRegion); 00327 00340 virtual ushort _notifyZOrder(ushort newZOrder); 00341 00345 virtual void _notifyWorldTransforms(const Matrix4& xform); 00346 00350 virtual void _notifyViewport(); 00351 00353 virtual void _updateRenderQueue(RenderQueue* queue); 00354 00356 void visitRenderables(Renderable::Visitor* visitor, 00357 bool debugRenderables = false); 00358 00360 virtual const String& getTypeName(void) const = 0; 00361 00368 virtual void setCaption(const DisplayString& text); 00370 virtual const DisplayString& getCaption(void) const; 00377 virtual void setColour(const ColourValue& col); 00378 00380 virtual const ColourValue& getColour(void) const; 00381 00392 virtual void setMetricsMode(GuiMetricsMode gmm); 00394 virtual GuiMetricsMode getMetricsMode(void) const; 00410 virtual void setHorizontalAlignment(GuiHorizontalAlignment gha); 00412 virtual GuiHorizontalAlignment getHorizontalAlignment(void) const; 00428 virtual void setVerticalAlignment(GuiVerticalAlignment gva); 00430 virtual GuiVerticalAlignment getVerticalAlignment(void) const; 00431 00432 00433 00434 00436 virtual bool contains(Real x, Real y) const; 00437 00439 virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent 00440 00444 inline virtual bool isContainer() const 00445 { return false; } 00446 00447 inline virtual bool isKeyEnabled() const 00448 { return false; } 00449 00450 inline virtual bool isCloneable() const 00451 { return mCloneable; } 00452 00453 inline virtual void setCloneable(bool c) 00454 { mCloneable = c; } 00455 00459 OverlayContainer* getParent() ; 00460 void _setParent(OverlayContainer* parent) { mParent = parent; } 00461 00465 inline ushort getZOrder() const 00466 { return mZOrder; } 00467 00469 Real getSquaredViewDepth(const Camera* cam) const 00470 { 00471 (void)cam; 00472 return 10000.0f - (Real)getZOrder(); 00473 } 00474 00476 const LightList& getLights(void) const 00477 { 00478 // Overlayelements should not be lit by the scene, this will not get called 00479 static LightList ll; 00480 return ll; 00481 } 00482 00483 virtual void copyFromTemplate(OverlayElement* templateOverlay); 00484 virtual OverlayElement* clone(const String& instanceName); 00485 00487 const OverlayElement* getSourceTemplate () const { 00488 return mSourceTemplate ; 00489 } 00490 }; 00491 00492 00496 } 00497 00498 00499 #endif 00500
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:44