From Stephan Huber and Robert Osfield,
Stephan: "attached you'll find some modifications to the GraphicsWindow-class and their platform-dependant implementations. The problem: setWindowRectangle and setWindowDecoration do not update the traits-object, so, if you call setWindowRectangle on a not-realized-window it will open with another size when realized later. getWindowRectangle reports possible wrong sizes if setWindowRectangle called before. My solution: split the implementation in two parts: GraphicsWindow::setWindowRectangle will update its traits-object and call afterwards the virtual method setWindowRectangleImplementation (which is implemented by the derived platformspecific classess). For setWindowDecoration I am useing a similar mechanism. I hope you'll find the submission useful, the Win32 and X11 changes are not tested but should work." Changes to this made by Robert are call of resized in setWindowRectangle instead of setting of Traits, and use of a bool return type.
This commit is contained in:
@@ -49,13 +49,32 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
|
||||
virtual void checkEvents() {}
|
||||
|
||||
/** Set the window's position and size.*/
|
||||
virtual void setWindowRectangle(int /*x*/, int /*y*/, int /*width*/, int /*height*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowRectangle(..) not implemented."<<std::endl; }
|
||||
void setWindowRectangle(int x, int y, int width, int height)
|
||||
{
|
||||
if (setWindowRectangleImplementation(x ,y ,width, height) && _traits.valid())
|
||||
{
|
||||
resized(x,y,width,height);
|
||||
}
|
||||
}
|
||||
|
||||
/** implementation of setWindowRectangle, should be implemented by derived classes */
|
||||
virtual bool setWindowRectangleImplementation(int /*x*/, int /*y*/, int /*width*/, int /*height*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowRectangleImplementation(..) not implemented."<<std::endl; return false; }
|
||||
|
||||
/** Get the window's position and size.*/
|
||||
virtual void getWindowRectangle(int& x, int& y, int& width, int& height) { if (_traits.valid()) { x = _traits->x; y = _traits->y; width = _traits->width; height = _traits->height; } }
|
||||
|
||||
/** Set Window decoration.*/
|
||||
virtual void setWindowDecoration(bool /*flag*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowDecoration(..) not implemented."<<std::endl; }
|
||||
void setWindowDecoration(bool flag)
|
||||
{
|
||||
if (setWindowDecorationImplementation(flag) && _traits.valid())
|
||||
{
|
||||
_traits->windowDecoration = flag;
|
||||
}
|
||||
}
|
||||
|
||||
/** implementation of setWindowDecoration, should be implemented by derived classes */
|
||||
virtual bool setWindowDecorationImplementation(bool /*flag*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowDecorationImplementation(..) not implemented."<<std::endl; return false; }
|
||||
|
||||
|
||||
/** Set Window decoration.*/
|
||||
virtual bool getWindowDecoration() const { return _traits.valid() ? _traits->windowDecoration : false; }
|
||||
|
||||
Reference in New Issue
Block a user