source: OGRE/trunk/ogrenew/OgreMain/src/OgreOverlayElement.cpp @ 657

Revision 657, 26.6 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1
2/*
3-----------------------------------------------------------------------------
4This source file is part of OGRE
5    (Object-oriented Graphics Rendering Engine)
6For the latest info, see http://www.ogre3d.org/
7
8Copyright (c) 2000-2005 The OGRE Team
9Also see acknowledgements in Readme.html
10
11This program is free software you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/copyleft/lesser.txt.
24-----------------------------------------------------------------------------
25*/
26#include "OgreStableHeaders.h"
27
28#include "OgreRoot.h"
29#include "OgreRenderSystem.h"
30#include "OgreOverlayElement.h"
31#include "OgreMaterialManager.h"
32#include "OgreOverlay.h"
33#include "OgreOverlayContainer.h"
34#include "OgreOverlayManager.h"
35#include "OgreException.h"
36#include "OgreRenderQueue.h"
37
38namespace Ogre {
39
40
41    //---------------------------------------------------------------------
42    // Define static members
43    OverlayElementCommands::CmdLeft OverlayElement::msLeftCmd;
44    OverlayElementCommands::CmdTop OverlayElement::msTopCmd;
45    OverlayElementCommands::CmdWidth OverlayElement::msWidthCmd;
46    OverlayElementCommands::CmdHeight OverlayElement::msHeightCmd;
47    OverlayElementCommands::CmdMaterial OverlayElement::msMaterialCmd;
48    OverlayElementCommands::CmdCaption OverlayElement::msCaptionCmd;
49    OverlayElementCommands::CmdMetricsMode OverlayElement::msMetricsModeCmd;
50    OverlayElementCommands::CmdHorizontalAlign OverlayElement::msHorizontalAlignCmd;
51    OverlayElementCommands::CmdVerticalAlign OverlayElement::msVerticalAlignCmd;
52    OverlayElementCommands::CmdVisible OverlayElement::msVisibleCmd;
53    //---------------------------------------------------------------------
54    OverlayElement::OverlayElement(const String& name)
55      : mName(name)
56      , mVisible(true)
57      , mCloneable(true)
58      , mLeft(0.0f)
59      , mTop(0.0f)
60      , mWidth(1.0f)
61      , mHeight(1.0f)
62      , mMetricsMode(GMM_RELATIVE)
63      , mHorzAlign(GHA_LEFT)
64      , mVertAlign(GVA_TOP)
65      , mPixelTop(0.0)
66      , mPixelLeft(0.0)
67      , mPixelWidth(1.0)
68      , mPixelHeight(1.0)
69      , mPixelScaleX(1.0)
70      , mPixelScaleY(1.0)
71      , mParent(0)
72      , mOverlay(0)
73      , mDerivedOutOfDate(true)
74      , mGeomPositionsOutOfDate(true)
75      , mGeomUVsOutOfDate(true)
76      , mZOrder(0)
77      , mEnabled(true)
78      , mInitialised(false)
79      , mSourceTemplate(0)
80    {
81                // default overlays to preserve their own detail level
82                mRenderDetailOverrideable = false;
83    }
84    //---------------------------------------------------------------------
85    OverlayElement::~OverlayElement()
86    {
87    }
88    //---------------------------------------------------------------------
89    const String& OverlayElement::getName(void) const
90    {
91        return mName;
92    }
93    //---------------------------------------------------------------------
94    void OverlayElement::show(void)
95    {
96        mVisible = true;
97    }
98    //---------------------------------------------------------------------
99    void OverlayElement::hide(void)
100    {
101        mVisible = false;
102    }
103    //---------------------------------------------------------------------
104    bool OverlayElement::isVisible(void) const
105    {
106        return mVisible;
107    }
108    //---------------------------------------------------------------------
109    void OverlayElement::setDimensions(Real width, Real height)
110    {
111        if (mMetricsMode != GMM_RELATIVE)
112        {
113            mPixelWidth = width;
114            mPixelHeight = height;
115        }
116        else
117        {
118            mWidth = width;
119            mHeight = height;
120        }
121        mDerivedOutOfDate = true;
122        _positionsOutOfDate();
123    }
124    //---------------------------------------------------------------------
125    void OverlayElement::setPosition(Real left, Real top)
126    {
127        if (mMetricsMode != GMM_RELATIVE)
128        {
129            mPixelLeft = left;
130            mPixelTop = top;
131        }
132        else
133        {
134            mLeft = left;
135            mTop = top;
136        }
137        mDerivedOutOfDate = true;
138        _positionsOutOfDate();
139
140    }
141    //---------------------------------------------------------------------
142    void OverlayElement::setWidth(Real width)
143    {
144        if (mMetricsMode != GMM_RELATIVE)
145        {
146            mPixelWidth = width;
147        }
148        else
149        {
150            mWidth = width;
151        }
152        mDerivedOutOfDate = true;
153        _positionsOutOfDate();
154    }
155    //---------------------------------------------------------------------
156    Real OverlayElement::getWidth(void) const
157    {
158        if (mMetricsMode != GMM_RELATIVE)
159        {
160                        return mPixelWidth;
161                }
162                else
163                {
164                return mWidth;
165                }
166    }
167    //---------------------------------------------------------------------
168    void OverlayElement::setHeight(Real height)
169    {
170        if (mMetricsMode != GMM_RELATIVE)
171        {
172            mPixelHeight = height;
173        }
174        else
175        {
176            mHeight = height;
177        }
178        mDerivedOutOfDate = true;
179        _positionsOutOfDate();
180    }
181    //---------------------------------------------------------------------
182    Real OverlayElement::getHeight(void) const
183    {
184        if (mMetricsMode != GMM_RELATIVE)
185        {
186                        return mPixelHeight;
187                }
188                else
189                {
190                        return mHeight;
191                }
192    }
193    //---------------------------------------------------------------------
194    void OverlayElement::setLeft(Real left)
195    {
196        if (mMetricsMode != GMM_RELATIVE)
197        {
198            mPixelLeft = left;
199        }
200        else
201        {
202            mLeft = left;
203        }
204        mDerivedOutOfDate = true;
205        _positionsOutOfDate();
206    }
207    //---------------------------------------------------------------------
208    Real OverlayElement::getLeft(void) const
209    {
210        if (mMetricsMode != GMM_RELATIVE)
211        {
212                        return mPixelLeft;
213                }
214                else
215                {
216                return mLeft;
217                }
218    }
219    //---------------------------------------------------------------------
220    void OverlayElement::setTop(Real top)
221    {
222        if (mMetricsMode != GMM_RELATIVE)
223        {
224            mPixelTop = top;
225        }
226        else
227        {
228            mTop = top;
229        }
230
231        mDerivedOutOfDate = true;
232        _positionsOutOfDate();
233    }
234    //---------------------------------------------------------------------
235    Real OverlayElement::getTop(void) const
236    {
237        if (mMetricsMode != GMM_RELATIVE)
238        {
239                        return mPixelTop;
240                }
241                else
242                {
243                return mTop;
244                }
245    }
246    //---------------------------------------------------------------------
247    void OverlayElement::_setLeft(Real left)
248    {
249        mLeft = left;
250        mPixelLeft = left / mPixelScaleX;
251
252        mDerivedOutOfDate = true;
253        _positionsOutOfDate();
254    }
255    //---------------------------------------------------------------------
256    void OverlayElement::_setTop(Real top)
257    {
258        mTop = top;
259        mPixelTop = top / mPixelScaleY;
260
261        mDerivedOutOfDate = true;
262        _positionsOutOfDate();
263    }
264    //---------------------------------------------------------------------
265    void OverlayElement::_setWidth(Real width)
266    {
267        mWidth = width;
268        mPixelWidth = width / mPixelScaleX;
269
270        mDerivedOutOfDate = true;
271        _positionsOutOfDate();
272    }
273    //---------------------------------------------------------------------
274    void OverlayElement::_setHeight(Real height)
275    {
276        mHeight = height;
277        mPixelHeight = height / mPixelScaleY;
278
279        mDerivedOutOfDate = true;
280        _positionsOutOfDate();
281    }
282    //---------------------------------------------------------------------
283    void OverlayElement::_setPosition(Real left, Real top)
284    {
285        mLeft = left;
286        mTop  = top;
287        mPixelLeft = left / mPixelScaleX;
288        mPixelTop  = top / mPixelScaleY;
289
290        mDerivedOutOfDate = true;
291        _positionsOutOfDate();
292    }
293    //---------------------------------------------------------------------
294    void OverlayElement::_setDimensions(Real width, Real height)
295    {
296        mWidth  = width;
297        mHeight = height;
298        mPixelWidth  = width / mPixelScaleX;
299        mPixelHeight = height / mPixelScaleY;
300
301        mDerivedOutOfDate = true;
302        _positionsOutOfDate();
303    }
304    //---------------------------------------------------------------------
305    const String& OverlayElement::getMaterialName(void) const
306    {
307        return mMaterialName;
308
309    }
310    //---------------------------------------------------------------------
311    void OverlayElement::setMaterialName(const String& matName)
312    {
313        mMaterialName = matName;
314        mpMaterial = MaterialManager::getSingleton().getByName(matName);
315                if (mpMaterial.isNull())
316                        OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + matName,
317                                "OverlayElement::setMaterialName" );
318        mpMaterial->load();
319        // Set some prerequisites to be sure
320        mpMaterial->setLightingEnabled(false);
321        mpMaterial->setDepthCheckEnabled(false);
322
323    }
324    //---------------------------------------------------------------------
325    const MaterialPtr& OverlayElement::getMaterial(void) const
326    {
327        return mpMaterial;
328    }
329    //---------------------------------------------------------------------
330    void OverlayElement::getWorldTransforms(Matrix4* xform) const
331    {
332        mOverlay->_getWorldTransforms(xform);
333    }
334    //-----------------------------------------------------------------------
335    const Quaternion& OverlayElement::getWorldOrientation(void) const
336    {
337        return mOverlay->getWorldOrientation();
338    }
339    //-----------------------------------------------------------------------
340    const Vector3& OverlayElement::getWorldPosition(void) const
341    {
342        return mOverlay->getWorldPosition();
343    }
344    //---------------------------------------------------------------------
345    bool OverlayElement::useIdentityProjection(void) const
346    {
347        return true;
348    }
349    //---------------------------------------------------------------------
350    bool OverlayElement::useIdentityView(void) const
351    {
352        return true;
353    }
354
355    //---------------------------------------------------------------------
356        void OverlayElement::_positionsOutOfDate(void)
357        {
358                mGeomPositionsOutOfDate = true;
359        }
360
361    //---------------------------------------------------------------------
362    void OverlayElement::_update(void)
363    {
364        // Check size if pixel-based
365        switch (mMetricsMode)
366        {
367        case GMM_PIXELS :
368            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
369            {
370                Real vpWidth, vpHeight;
371                OverlayManager& oMgr = OverlayManager::getSingleton();
372                vpWidth = (Real) (oMgr.getViewportWidth());
373                vpHeight = (Real) (oMgr.getViewportHeight());
374
375                mPixelScaleX = 1.0 / vpWidth;
376                mPixelScaleY = 1.0 / vpHeight;
377
378                mLeft = mPixelLeft * mPixelScaleX;
379                mTop = mPixelTop * mPixelScaleY;
380                mWidth = mPixelWidth * mPixelScaleX;
381                mHeight = mPixelHeight * mPixelScaleY;
382            }
383            break;
384
385        case GMM_RELATIVE_ASPECT_ADJUSTED :
386            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
387            {
388                Real vpWidth, vpHeight;
389                OverlayManager& oMgr = OverlayManager::getSingleton();
390                vpWidth = (Real) (oMgr.getViewportWidth());
391                vpHeight = (Real) (oMgr.getViewportHeight());
392
393                mPixelScaleX = 1.0 / (10000.0 * (vpWidth / vpHeight));
394                mPixelScaleY = 1.0 /  10000.0;
395
396                mLeft = mPixelLeft * mPixelScaleX;
397                mTop = mPixelTop * mPixelScaleY;
398                mWidth = mPixelWidth * mPixelScaleX;
399                mHeight = mPixelHeight * mPixelScaleY;
400            }
401            break;
402        default:
403            break;
404        }
405
406        _updateFromParent();
407        // NB container subclasses will update children too
408
409        // Tell self to update own position geometry
410        if (mGeomPositionsOutOfDate && mInitialised)
411        {
412            updatePositionGeometry();
413            mGeomPositionsOutOfDate = false;
414        }
415                // Tell self to update own texture geometry
416                if (mGeomUVsOutOfDate && mInitialised)
417                {
418                        updateTextureGeometry();
419                        mGeomUVsOutOfDate = false;
420                }
421    }
422    //---------------------------------------------------------------------
423    void OverlayElement::_updateFromParent(void)
424    {
425        Real parentLeft, parentTop, parentBottom, parentRight;
426
427        if (mParent)
428        {
429            parentLeft = mParent->_getDerivedLeft();
430            parentTop = mParent->_getDerivedTop();
431            if (mHorzAlign == GHA_CENTER || mHorzAlign == GHA_RIGHT)
432            {
433                parentRight = parentLeft + mParent->getWidth();
434            }
435            if (mVertAlign == GVA_CENTER || mVertAlign == GVA_BOTTOM)
436            {
437                parentBottom = parentTop + mParent->getHeight();
438            }
439
440        }
441        else
442        {
443            RenderSystem* rSys = Root::getSingleton().getRenderSystem();
444            OverlayManager& oMgr = OverlayManager::getSingleton();
445
446            // Calculate offsets required for mapping texel origins to pixel origins in the
447            // current rendersystem
448            Real hOffset = rSys->getHorizontalTexelOffset() / oMgr.getViewportWidth();
449            Real vOffset = rSys->getVerticalTexelOffset() / oMgr.getViewportHeight();
450
451            parentLeft = 0.0f + hOffset;
452            parentTop = 0.0f + vOffset;
453            parentRight = 1.0f + hOffset;
454            parentBottom = 1.0f + vOffset;
455        }
456
457        // Sort out position based on alignment
458        // NB all we do is derived the origin, we don't automatically sort out the position
459        // This is more flexible than forcing absolute right & middle
460        switch(mHorzAlign)
461        {
462        case GHA_CENTER:
463            mDerivedLeft = ((parentLeft + parentRight) * 0.5f) + mLeft;
464            break;
465        case GHA_LEFT:
466            mDerivedLeft = parentLeft + mLeft;
467            break;
468        case GHA_RIGHT:
469            mDerivedLeft = parentRight + mLeft;
470            break;
471        };
472        switch(mVertAlign)
473        {
474        case GVA_CENTER:
475            mDerivedTop = ((parentTop + parentBottom) * 0.5f) + mTop;
476            break;
477        case GVA_TOP:
478            mDerivedTop = parentTop + mTop;
479            break;
480        case GVA_BOTTOM:
481            mDerivedTop = parentBottom + mTop;
482            break;
483        };
484
485        mDerivedOutOfDate = false;
486
487        if (mParent != 0)
488        {
489            Rectangle parent;
490            Rectangle child;
491
492            mParent->_getClippingRegion(parent);
493
494            child.left   = mDerivedLeft;
495            child.top    = mDerivedTop;
496            child.right  = mDerivedLeft + mWidth;
497            child.bottom = mDerivedTop + mHeight;
498
499            mClippingRegion = intersect(parent, child);
500        }
501        else
502        {
503            mClippingRegion.left   = mDerivedLeft;
504            mClippingRegion.top    = mDerivedTop;
505            mClippingRegion.right  = mDerivedLeft + mWidth;
506            mClippingRegion.bottom = mDerivedTop + mHeight;
507        }
508    }
509    //---------------------------------------------------------------------
510    void OverlayElement::_notifyParent(OverlayContainer* parent, Overlay* overlay)
511    {
512        mParent = parent;
513        mOverlay = overlay;
514
515                if (mOverlay && mOverlay->isInitialised() && !mInitialised)
516                {
517                        initialise();
518                }
519
520        mDerivedOutOfDate = true;
521    }
522    //---------------------------------------------------------------------
523    Real OverlayElement::_getDerivedLeft(void)
524    {
525        if (mDerivedOutOfDate)
526        {
527            _updateFromParent();
528        }
529        return mDerivedLeft;
530    }
531    //---------------------------------------------------------------------
532    Real OverlayElement::_getDerivedTop(void)
533    {
534        if (mDerivedOutOfDate)
535        {
536            _updateFromParent();
537        }
538        return mDerivedTop;
539    }
540    //---------------------------------------------------------------------   
541    void OverlayElement::_getClippingRegion(Rectangle &clippingRegion)
542    {
543        if (mDerivedOutOfDate)
544        {
545            _updateFromParent();
546        }
547        clippingRegion = mClippingRegion;
548    }
549    //---------------------------------------------------------------------
550    void OverlayElement::_notifyZOrder(ushort newZOrder)
551    {
552        mZOrder = newZOrder;
553    }
554
555    //---------------------------------------------------------------------
556    void OverlayElement::_notifyWorldTransforms(const Matrix4& xform)
557    {
558        mXForm = xform;
559    }
560
561    //---------------------------------------------------------------------
562    void OverlayElement::_notifyViewport()
563    {
564        switch (mMetricsMode)
565        {
566        case GMM_PIXELS :
567            {
568                Real vpWidth, vpHeight;
569                OverlayManager& oMgr = OverlayManager::getSingleton();
570                vpWidth = (Real) (oMgr.getViewportWidth());
571                vpHeight = (Real) (oMgr.getViewportHeight());
572
573                mPixelScaleX = 1.0 / vpWidth;
574                mPixelScaleY = 1.0 / vpHeight;
575            }
576            break;
577
578        case GMM_RELATIVE_ASPECT_ADJUSTED :
579            {
580                Real vpWidth, vpHeight;
581                OverlayManager& oMgr = OverlayManager::getSingleton();
582                vpWidth = (Real) (oMgr.getViewportWidth());
583                vpHeight = (Real) (oMgr.getViewportHeight());
584
585                mPixelScaleX = 1.0 / (10000.0 * (vpWidth / vpHeight));
586                mPixelScaleY = 1.0 /  10000.0;
587            }
588            break;
589
590        case GMM_RELATIVE :
591            mPixelScaleX = 1.0;
592            mPixelScaleY = 1.0;
593            mPixelLeft = mLeft;
594            mPixelTop = mTop;
595            mPixelWidth = mWidth;
596            mPixelHeight = mHeight;
597            break;
598        }
599
600        mLeft = mPixelLeft * mPixelScaleX;
601        mTop = mPixelTop * mPixelScaleY;
602        mWidth = mPixelWidth * mPixelScaleX;
603        mHeight = mPixelHeight * mPixelScaleY;
604
605        mGeomPositionsOutOfDate = true;
606    }
607
608    //---------------------------------------------------------------------
609    void OverlayElement::_updateRenderQueue(RenderQueue* queue)
610    {
611        if (mVisible)
612        {
613            queue->addRenderable(this, RENDER_QUEUE_OVERLAY, mZOrder);
614        }
615     
616    }
617    //-----------------------------------------------------------------------
618    void OverlayElement::addBaseParameters(void)   
619    {
620        ParamDictionary* dict = getParamDictionary();
621
622        dict->addParameter(ParameterDef("left",
623            "The position of the left border of the gui element."
624            , PT_REAL),
625            &msLeftCmd);
626        dict->addParameter(ParameterDef("top",
627            "The position of the top border of the gui element."
628            , PT_REAL),
629            &msTopCmd);
630        dict->addParameter(ParameterDef("width",
631            "The width of the element."
632            , PT_REAL),
633            &msWidthCmd);
634        dict->addParameter(ParameterDef("height",
635            "The height of the element."
636            , PT_REAL),
637            &msHeightCmd);
638        dict->addParameter(ParameterDef("material",
639            "The name of the material to use."
640            , PT_STRING),
641            &msMaterialCmd);
642        dict->addParameter(ParameterDef("caption",
643            "The element caption, if supported."
644            , PT_STRING),
645            &msCaptionCmd);
646        dict->addParameter(ParameterDef("metrics_mode",
647            "The type of metrics to use, either 'relative' to the screen, 'pixels' or 'relative_aspect_adjusted'."
648            , PT_STRING),
649            &msMetricsModeCmd);
650        dict->addParameter(ParameterDef("horz_align",
651            "The horizontal alignment, 'left', 'right' or 'center'."
652            , PT_STRING),
653            &msHorizontalAlignCmd);
654        dict->addParameter(ParameterDef("vert_align",
655            "The vertical alignment, 'top', 'bottom' or 'center'."
656            , PT_STRING),
657            &msVerticalAlignCmd);
658        dict->addParameter(ParameterDef("visible",
659            "Initial visibility of element, either 'true' or 'false' (default true)."
660            , PT_STRING),
661            &msVisibleCmd);
662    }
663    //-----------------------------------------------------------------------
664    void OverlayElement::setCaption( const String& caption )
665    {
666        mCaption = caption;
667        _positionsOutOfDate();
668    }
669    //-----------------------------------------------------------------------
670    const String& OverlayElement::getCaption() const
671    {
672        return mCaption;
673    }
674    //-----------------------------------------------------------------------
675    void OverlayElement::setColour(const ColourValue& col)
676    {
677        mColour = col;
678    }
679    //-----------------------------------------------------------------------
680    const ColourValue& OverlayElement::getColour(void) const
681    {
682        return mColour;
683    }
684    //-----------------------------------------------------------------------
685    void OverlayElement::setMetricsMode(GuiMetricsMode gmm)
686    {
687        switch (gmm)
688        {
689        case GMM_PIXELS :
690            {
691                Real vpWidth, vpHeight;
692                OverlayManager& oMgr = OverlayManager::getSingleton();
693                vpWidth = (Real) (oMgr.getViewportWidth());
694                vpHeight = (Real) (oMgr.getViewportHeight());
695
696                mPixelScaleX = 1.0 / vpWidth;
697                mPixelScaleY = 1.0 / vpHeight;
698
699                if (mMetricsMode == GMM_RELATIVE)
700                {
701                    mPixelLeft = mLeft;
702                    mPixelTop = mTop;
703                    mPixelWidth = mWidth;
704                    mPixelHeight = mHeight;
705                }
706            }
707            break;
708
709        case GMM_RELATIVE_ASPECT_ADJUSTED :
710            {
711                Real vpWidth, vpHeight;
712                OverlayManager& oMgr = OverlayManager::getSingleton();
713                vpWidth = (Real) (oMgr.getViewportWidth());
714                vpHeight = (Real) (oMgr.getViewportHeight());
715
716                mPixelScaleX = 1.0 / (10000.0 * (vpWidth / vpHeight));
717                mPixelScaleY = 1.0 /  10000.0;
718
719                if (mMetricsMode == GMM_RELATIVE)
720                {
721                    mPixelLeft = mLeft;
722                    mPixelTop = mTop;
723                    mPixelWidth = mWidth;
724                    mPixelHeight = mHeight;
725                }
726            }
727            break;
728
729        case GMM_RELATIVE :
730            mPixelScaleX = 1.0;
731            mPixelScaleY = 1.0;
732            mPixelLeft = mLeft;
733            mPixelTop = mTop;
734            mPixelWidth = mWidth;
735            mPixelHeight = mHeight;
736            break;
737        }
738
739        mLeft = mPixelLeft * mPixelScaleX;
740        mTop = mPixelTop * mPixelScaleY;
741        mWidth = mPixelWidth * mPixelScaleX;
742        mHeight = mPixelHeight * mPixelScaleY;
743
744        mMetricsMode = gmm;
745        mDerivedOutOfDate = true;
746        _positionsOutOfDate();
747    }
748    //-----------------------------------------------------------------------
749    GuiMetricsMode OverlayElement::getMetricsMode(void) const
750    {
751        return mMetricsMode;
752    }
753    //-----------------------------------------------------------------------
754    void OverlayElement::setHorizontalAlignment(GuiHorizontalAlignment gha)
755    {
756        mHorzAlign = gha;
757        _positionsOutOfDate();
758    }
759    //-----------------------------------------------------------------------
760    GuiHorizontalAlignment OverlayElement::getHorizontalAlignment(void) const
761    {
762        return mHorzAlign;
763    }
764    //-----------------------------------------------------------------------
765    void OverlayElement::setVerticalAlignment(GuiVerticalAlignment gva)
766    {
767        mVertAlign = gva;
768        _positionsOutOfDate();
769    }
770    //-----------------------------------------------------------------------
771    GuiVerticalAlignment OverlayElement::getVerticalAlignment(void) const
772    {
773        return mVertAlign;
774    }
775    //-----------------------------------------------------------------------
776
777
778    //-----------------------------------------------------------------------
779        bool OverlayElement::contains(Real x, Real y) const
780        {
781        return mClippingRegion.inside(x, y);
782        }
783
784    //-----------------------------------------------------------------------
785        OverlayElement* OverlayElement::findElementAt(Real x, Real y)           // relative to parent
786        {
787                OverlayElement* ret = NULL;
788                if (contains(x , y ))
789                {
790                        ret = this;
791                }
792                return ret;
793        }
794
795    //-----------------------------------------------------------------------
796        OverlayContainer* OverlayElement::getParent()
797        {
798                return mParent;         
799        }
800
801    void OverlayElement::copyFromTemplate(OverlayElement* templateOverlay)
802        {
803                templateOverlay->copyParametersTo(this);
804    mSourceTemplate = templateOverlay ;
805                return;
806        }
807
808    OverlayElement* OverlayElement::clone(const String& instanceName)
809    {
810        OverlayElement* newElement;
811
812        newElement = OverlayManager::getSingleton().createOverlayElement(
813                        getTypeName(), instanceName + "/" + mName);
814        copyParametersTo(newElement);
815
816        return newElement;
817    }
818
819    //-----------------------------------------------------------------------
820        bool OverlayElement::isEnabled() const
821        {
822                return mEnabled;
823        }
824
825    //-----------------------------------------------------------------------
826        void OverlayElement::setEnabled(bool b)
827        {
828                mEnabled = b;
829        }
830
831
832}
833
Note: See TracBrowser for help on using the repository browser.