#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 simgear::PropertyBasedElement
+ public simgear::canvas::Image
{
public:
+ static const std::string TYPE_NAME;
enum Resize
{
INIT = BOTTOM << 1
};
- Window(SGPropertyNode* node);
+ 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);
osg::Group* getGroup();
- const SGRect<float>& getRegion() const;
+ const SGVec2<float> getPosition() const;
+ const SGRect<float> getScreenRegion() const;
- void setCanvas(simgear::canvas::CanvasPtr canvas);
- simgear::canvas::CanvasWeakPtr getCanvas() const;
+ void setCanvasContent(simgear::canvas::CanvasPtr canvas);
+ simgear::canvas::CanvasWeakPtr getCanvasContent() const;
+
+ simgear::canvas::CanvasPtr getCanvasDecoration();
- bool isVisible() const;
bool isResizable() const;
bool isCapturingEvents() const;
- bool handleMouseEvent(const simgear::canvas::MouseEventPtr& event);
-
- void handleResize(uint8_t mode, const osg::Vec2f& delta = osg::Vec2f());
+ /**
+ * 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 doRaise(SGPropertyNode* node_raise = 0);
+ void handleResize( uint8_t mode,
+ const osg::Vec2f& offset = osg::Vec2f() );
protected:
- simgear::canvas::Image _image;
+ 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;
_resize_left,
_resize_status;
+ simgear::CSSBorder _decoration_border;
+
+ void parseDecorationBorder(const std::string& str);
+ void updateDecoration();
};
} // namespace canvas