From Wang Rui, "The submission includes some fixes for osgQt library and osgQtWidgets example: (1) QTextEdit now works with mouse/drag events, (2) scrollbars will change when OSG window is resizing, (3) improve rendering efficiency of QGraphicsViewAdapter so that it works with complex Qt UI, (4) add new setBackgroundWidget() method to indicate a 'background widget', which will ignore mouse/key events on it and pass them to the 3D scene."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14482 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -52,6 +52,7 @@ class OSGQT_EXPORT QGraphicsViewAdapter : public QObject
|
||||
|
||||
void clearWriteBuffer();
|
||||
|
||||
bool requiresRendering() const { return _requiresRendering; }
|
||||
void render();
|
||||
|
||||
void assignImage(unsigned int i);
|
||||
@@ -61,6 +62,12 @@ class OSGQT_EXPORT QGraphicsViewAdapter : public QObject
|
||||
void setBackgroundColor(QColor color) { _backgroundColor = color; }
|
||||
QColor getBackgroundColor() const { return _backgroundColor; }
|
||||
|
||||
/** The 'background widget' will ignore mouse/keyboard events and let following handlers handle them
|
||||
It is mainly used for integrating scene graph and full-screen UIs
|
||||
*/
|
||||
void setBackgroundWidget(QWidget* w) { _backgroundWidget = w; }
|
||||
QWidget* getBackgroundWidget() { return _backgroundWidget; }
|
||||
|
||||
QGraphicsView* getQGraphicsView() { return _graphicsView; }
|
||||
QGraphicsScene* getQGraphicsScene() { return _graphicsScene; }
|
||||
|
||||
@@ -71,6 +78,7 @@ class OSGQT_EXPORT QGraphicsViewAdapter : public QObject
|
||||
QWidget* getWidgetAt(const QPoint& pos);
|
||||
|
||||
osg::observer_ptr<osg::Image> _image;
|
||||
QWidget* _backgroundWidget;
|
||||
|
||||
int _previousButtonMask;
|
||||
int _previousMouseX;
|
||||
@@ -78,6 +86,7 @@ class OSGQT_EXPORT QGraphicsViewAdapter : public QObject
|
||||
int _previousQtMouseX;
|
||||
int _previousQtMouseY;
|
||||
bool _previousSentEvent;
|
||||
bool _requiresRendering;
|
||||
|
||||
int _width;
|
||||
int _height;
|
||||
|
||||
@@ -66,9 +66,12 @@ class QWebViewImage : public osgWidget::BrowserImage
|
||||
|
||||
void render()
|
||||
{
|
||||
_adapter->render();
|
||||
if (_adapter->requiresRendering()) _adapter->render();
|
||||
}
|
||||
|
||||
virtual bool requiresUpdateCall() const { return true; }
|
||||
virtual void update( osg::NodeVisitor* nv ) { render(); }
|
||||
|
||||
virtual bool sendFocusHint(bool focus)
|
||||
{
|
||||
QFocusEvent event(focus ? QEvent::FocusIn : QEvent::FocusOut, Qt::OtherFocusReason);
|
||||
|
||||
@@ -29,6 +29,8 @@ class OSGQT_EXPORT QWidgetImage : public osg::Image
|
||||
QWidget* getQWidget() { return _widget; }
|
||||
QGraphicsViewAdapter* getQGraphicsViewAdapter() { return _adapter; }
|
||||
|
||||
virtual bool requiresUpdateCall() const { return true; }
|
||||
virtual void update( osg::NodeVisitor* nv ) { render(); }
|
||||
|
||||
void clearWriteBuffer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user