Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/overlays/OverlayGroup.h @ 11319

Last change on this file since 11319 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.5 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
[1502]4 *
[1505]5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
[1502]22 *   Author:
[1604]23 *      Reto Grieder
[1502]24 *   Co-authors:
[1604]25 *      ...
[1502]26 *
27 */
[1362]28
[1623]29/**
30@file
31@brief Declaration of the OverlayGroup class.
32*/
33
[1601]34#ifndef _OverlayGroup_H__
35#define _OverlayGroup_H__
[1362]36
[1502]37#include "OrxonoxPrereqs.h"
38
[2890]39#include <set>
[3196]40#include "util/Math.h"
41#include "util/OgreForwardRefs.h"
[1588]42#include "core/BaseObject.h"
[1362]43
44namespace orxonox
45{
[1623]46    /**
47    @brief
48        OverlayGroup does almost exactly what it says: It groups OrxonoxOverlays together.
49        You can scroll the entire group by a certain amount. Scale however works differently
50        than expected: Each OrxonoxOverlay scales individually. That's quite useful when you
51        create your HUD with an OverlayGroup and then want to alter its size.
52    */
[1604]53    class _OrxonoxExport OverlayGroup : public BaseObject
[1362]54    {
[1615]55    public:
[9667]56        OverlayGroup(Context* context);
[1623]57        //! Empty destructor.
[2087]58        ~OverlayGroup();
[1567]59
[11071]60        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
[1588]61
[1604]62        static void toggleVisibility(const std::string& name);
[8309]63        static void show(const std::string& name);
[1614]64        static void scaleGroup(const std::string& name, float scale);
[1615]65        static void scrollGroup(const std::string& name, const Vector2& scroll);
[1567]66
[11071]67        inline const std::set<StrongPtr<OrxonoxOverlay>>& getOverlays() const
[2087]68            { return this->hudElements_; }
69
[11071]70        virtual void changedVisibility() override;
[1747]71
[2890]72        void setOwner(BaseObject* owner);
73        inline BaseObject* getOwner() const
[2662]74            { return this->owner_; }
75
[1623]76        //! Scales each OrxonoxOverlay individually by scale.
[1615]77        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
78        void setScale(const Vector2& scale);
[1623]79        //! Returns the current size of the group.
[1615]80        Vector2 getScale() const { return this->scale_; }
[1564]81
[1623]82        //! Scrolls each OrxonoxOverlay individually by scroll.
[1615]83        void scroll(const Vector2& scroll) { this->setScroll(scroll + this->scroll_); }
84        void setScroll(const Vector2& scroll);
[1623]85        //! Returns the current scrolling offset of the group.
[1615]86        Vector2 getScroll() const { return this->scale_; }
87
[1601]88        void addElement(OrxonoxOverlay* element);
[2911]89        bool removeElement(OrxonoxOverlay* element);
[1601]90        OrxonoxOverlay* getElement(unsigned int index);
[1588]91
[2662]92    private:
[11071]93        std::set<StrongPtr<OrxonoxOverlay>> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
[2890]94        Vector2 scale_;                            //!< Current scale (independent of the elements).
95        Vector2 scroll_;                           //!< Current scrolling offset.
96        BaseObject* owner_;                        //!< The owner of this OverlayGroup
[1362]97    };
98}
99
[1601]100#endif /* _OverlayGroup_H__ */
Note: See TracBrowser for help on using the repository browser.