#ifndef CANVAS_WINDOW_HXX_
#define CANVAS_WINDOW_HXX_
-#include "property_based_element.hxx"
-#include "rect.hxx"
-#include <Canvas/MouseEvent.hxx>
-
+#include <simgear/canvas/elements/CanvasImage.hxx>
+#include <simgear/canvas/MouseEvent.hxx>
+#include <simgear/props/PropertyBasedElement.hxx>
#include <simgear/props/propertyObject.hxx>
+#include <simgear/misc/CSSBorder.hxx>
+#include <osg/Geode>
#include <osg/Geometry>
namespace canvas
{
class Window:
- public PropertyBasedElement
+ public simgear::canvas::Image
{
public:
- Window(SGPropertyNode* node);
+ static const std::string TYPE_NAME;
+
+ enum Resize
+ {
+ NONE = 0,
+ LEFT = 1,
+ RIGHT = LEFT << 1,
+ TOP = RIGHT << 1,
+ BOTTOM = TOP << 1,
+ INIT = BOTTOM << 1
+ };
+
+ typedef simgear::canvas::Style Style;
+
+ /**
+ * @param node Property node containing settings for this window:
+ * capture-events Disable/Enable event capturing
+ * content-size[0-1] Size of content area (excluding
+ * decoration border)
+ * decoration-border Size of decoration border
+ * resize Enable resize cursor and properties
+ * shadow-inset Inset of shadow image
+ * shadow-radius Radius/outset of shadow image
+ */
+ Window( const simgear::canvas::CanvasWeakPtr& canvas,
+ const SGPropertyNode_ptr& node,
+ const Style& parent_style = Style(),
+ Element* parent = 0 );
virtual ~Window();
virtual void update(double delta_time_sec);
- virtual void valueChanged (SGPropertyNode * node);
+ virtual void valueChanged(SGPropertyNode* node);
+
+ osg::Group* getGroup();
+ const SGVec2<float> getPosition() const;
+ const SGRect<float> getScreenRegion() const;
+
+ void setCanvasContent(simgear::canvas::CanvasPtr canvas);
+ simgear::canvas::CanvasWeakPtr getCanvasContent() const;
- osg::Drawable* getDrawable() { return _geometry; }
- const Rect<int>& getRegion() const { return _region; }
+ simgear::canvas::CanvasPtr getCanvasDecoration();
- void setCanvas(CanvasPtr canvas);
- CanvasWeakPtr getCanvas() const;
+ bool isResizable() const;
+ bool isCapturingEvents() const;
- bool handleMouseEvent(const MouseEvent& event);
+ /**
+ * Moves window on top of all other windows with the same z-index.
+ *
+ * @note If no z-index is set it defaults to 0.
+ */
+ void raise();
+
+ void handleResize( uint8_t mode,
+ const osg::Vec2f& offset = osg::Vec2f() );
protected:
- bool _dirty;
+ enum Attributes
+ {
+ DECORATION = 1
+ };
+
+ uint32_t _attributes_dirty;
+
+ simgear::canvas::CanvasPtr _canvas_decoration;
+ simgear::canvas::CanvasWeakPtr _canvas_content;
+
+ simgear::canvas::ImagePtr _image_content,
+ _image_shadow;
+
+ bool _resizable,
+ _capture_events;
- osg::ref_ptr<osg::Geometry> _geometry;
- osg::ref_ptr<osg::Vec3Array> _vertices;
- osg::ref_ptr<osg::Vec2Array> _tex_coords;
+ simgear::PropertyObject<int> _resize_top,
+ _resize_right,
+ _resize_bottom,
+ _resize_left,
+ _resize_status;
- simgear::PropertyObject<int> _x, _y,
- _width, _height;
- Rect<int> _region;
+ simgear::CSSBorder _decoration_border;
- CanvasWeakPtr _canvas;
+ void parseDecorationBorder(const std::string& str);
+ void updateDecoration();
};
} // namespace canvas