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 27 namespace osgfxbrowser { 28 29 struct Rect { 30 float x0, y0, x1, y1; RectRect31 Rect() {} RectRect32 Rect(float x0_, float y0_, float x1_, float y1_): x0(x0_), y0(y0_), x1(x1_), y1(y1_) {} widthRect33 inline float width() const { return x1 - x0; } heightRect34 inline float height() const { return y0 - y1; } 35 }; 36 37 class Frame: public osg::Geode { 38 public: 39 Frame(); 40 Frame(const Frame ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY); 41 42 META_Node(osgfxbrowser, Frame); 43 getCaption()44 inline const std::string &getCaption() const { return caption_; } setCaption(const std::string & caption)45 inline void setCaption(const std::string &caption) { caption_ = caption; } 46 getBackgroundColor()47 inline const osg::Vec4 &getBackgroundColor() const { return bgcolor_; } setBackgroundColor(const osg::Vec4 & bgcolor)48 inline void setBackgroundColor(const osg::Vec4 &bgcolor) { bgcolor_ = bgcolor; } 49 getRect()50 inline const Rect &getRect() const { return rect_; } setRect(const Rect & 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 57 protected: ~Frame()58 virtual ~Frame() {} operator()59 Frame &operator()(const Frame &) { return *this; } 60 rebuild_client_area(const Rect &)61 virtual void rebuild_client_area(const Rect & /*client_rect*/) {} 62 63 private: 64 osg::Vec4 bgcolor_; 65 Rect rect_; 66 std::string caption_; 67 }; 68 69 } 70 71 #endif 72