root/OpenSceneGraph/trunk/examples/osgfxbrowser/Frame.h @ 6941

Revision 6941, 2.3 kB (checked in by robert, 7 years ago)

From Martin Lavery and Robert Osfield, Updated examples to use a variation of the MIT License

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*-
2*
3*  OpenSceneGraph example, osgfxbrowser.
4*
5*  Permission is hereby granted, free of charge, to any person obtaining a copy
6*  of this software and associated documentation files (the "Software"), to deal
7*  in the Software without restriction, including without limitation the rights
8*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*  copies of the Software, and to permit persons to whom the Software is
10*  furnished to do so, subject to the following conditions:
11*
12*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18*  THE SOFTWARE.
19*/
20
21#ifndef FRAME_H_
22#define FRAME_H_
23
24#include <osg/Geode>
25#include <osg/Geometry>
26
27namespace osgfxbrowser {
28
29struct Rect {
30        float x0, y0, x1, y1;
31        Rect() {}
32        Rect(float x0_, float y0_, float x1_, float y1_): x0(x0_), y0(y0_), x1(x1_), y1(y1_) {}
33        inline float width() const { return x1 - x0; }
34        inline float height() const { return y0 - y1; }
35};
36
37class Frame: public osg::Geode {
38public:
39        Frame();
40        Frame(const Frame &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
41
42        META_Node(osgfxbrowser, Frame);
43
44        inline const std::string &getCaption() const              { return caption_; }
45        inline void setCaption(const std::string &caption)        { caption_ = caption; }
46
47        inline const osg::Vec4 &getBackgroundColor() const        { return bgcolor_; }
48        inline void setBackgroundColor(const osg::Vec4 &bgcolor)  { bgcolor_ = bgcolor; }
49
50        inline const Rect &getRect() const                { return rect_; }
51        inline void setRect(const Rect &rect)             { rect_ = rect; }
52
53        static osg::Geometry *build_quad(const Rect &rect, const osg::Vec4 &color, bool shadow = true, float z = 0);
54
55        virtual void rebuild();
56
57protected:
58        virtual ~Frame() {}
59        Frame &operator()(const Frame &) { return *this; }     
60
61        virtual void rebuild_client_area(const Rect & /*client_rect*/) {}
62
63private:
64        osg::Vec4 bgcolor_;
65        Rect rect_;
66        std::string caption_;
67};
68
69}
70
71#endif
Note: See TracBrowser for help on using the browser.