diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index 45defe1f..3a047421 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -219,11 +219,13 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : containerWidget->setMinimumSize(400, 400); m_modelRenderWidget = new ModelWidget(containerWidget); + m_modelRenderWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_modelRenderWidget->setMinimumSize(SkeletonDocumentWindow::m_modelRenderWidgetInitialSize, SkeletonDocumentWindow::m_modelRenderWidgetInitialSize); m_modelRenderWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_modelRenderWidget->move(SkeletonDocumentWindow::m_modelRenderWidgetInitialX, SkeletonDocumentWindow::m_modelRenderWidgetInitialY); m_graphicsWidget->setModelWidget(m_modelRenderWidget); + containerWidget->setModelWidget(m_modelRenderWidget); m_document->setSharedContextWidget(m_modelRenderWidget); diff --git a/src/graphicscontainerwidget.cpp b/src/graphicscontainerwidget.cpp index 79f3ffeb..c9b9846e 100644 --- a/src/graphicscontainerwidget.cpp +++ b/src/graphicscontainerwidget.cpp @@ -11,7 +11,36 @@ void GraphicsContainerWidget::resizeEvent(QResizeEvent *event) emit containerSizeChanged(event->size()); } +void GraphicsContainerWidget::mousePressEvent(QMouseEvent *event) +{ + if (m_modelWidget) + m_modelWidget->inputMousePressEventFromOtherWidget(event); +} + +void GraphicsContainerWidget::mouseMoveEvent(QMouseEvent *event) +{ + if (m_modelWidget) + m_modelWidget->inputMouseMoveEventFromOtherWidget(event); +} + +void GraphicsContainerWidget::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_modelWidget) + m_modelWidget->inputMouseReleaseEventFromOtherWidget(event); +} + +void GraphicsContainerWidget::wheelEvent(QWheelEvent *event) +{ + if (m_modelWidget) + m_modelWidget->inputWheelEventFromOtherWidget(event); +} + void GraphicsContainerWidget::setGraphicsWidget(QWidget *graphicsWidget) { m_graphicsWidget = graphicsWidget; } + +void GraphicsContainerWidget::setModelWidget(ModelWidget *modelWidget) +{ + m_modelWidget = modelWidget; +} diff --git a/src/graphicscontainerwidget.h b/src/graphicscontainerwidget.h index 6c99147b..cd0cbff5 100644 --- a/src/graphicscontainerwidget.h +++ b/src/graphicscontainerwidget.h @@ -2,6 +2,9 @@ #define DUST3D_GRAPHICS_CONTAINER_WIDGET_H #include #include +#include +#include +#include "modelwidget.h" class GraphicsContainerWidget : public QWidget { @@ -10,10 +13,17 @@ signals: void containerSizeChanged(QSize size); public: GraphicsContainerWidget(); - void resizeEvent(QResizeEvent *event) override; void setGraphicsWidget(QWidget *graphicsWidget); + void setModelWidget(ModelWidget *modelWidget); +protected: + void resizeEvent(QResizeEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; private: QWidget *m_graphicsWidget = nullptr; + ModelWidget *m_modelWidget = nullptr; }; #endif diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 0bf98312..b86ca3fa 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -20,8 +20,6 @@ ModelWidget::ModelWidget(QWidget *parent) : m_moveEnabled(true), m_zoomEnabled(true) { - setAttribute(Qt::WA_TransparentForMouseEvents); - // --transparent causes the clear color to be transparent. Therefore, on systems that // support it, the widget will become transparent apart from the logo. if (m_transparent) { @@ -295,3 +293,24 @@ void ModelWidget::enableZoom(bool enabled) { m_zoomEnabled = enabled; } + +void ModelWidget::mousePressEvent(QMouseEvent *event) +{ + inputMousePressEventFromOtherWidget(event); +} + +void ModelWidget::mouseMoveEvent(QMouseEvent *event) +{ + inputMouseMoveEventFromOtherWidget(event); +} + +void ModelWidget::wheelEvent(QWheelEvent *event) +{ + inputWheelEventFromOtherWidget(event); +} + +void ModelWidget::mouseReleaseEvent(QMouseEvent *event) +{ + inputMouseReleaseEventFromOtherWidget(event); +} + diff --git a/src/modelwidget.h b/src/modelwidget.h index 854c4b97..e37d345b 100644 --- a/src/modelwidget.h +++ b/src/modelwidget.h @@ -51,6 +51,10 @@ protected: void initializeGL() override; void paintGL() override; void resizeGL(int width, int height) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; public: int xRot(); int yRot(); diff --git a/src/motionwidget.cpp b/src/motionwidget.cpp index 4959539c..d928c688 100644 --- a/src/motionwidget.cpp +++ b/src/motionwidget.cpp @@ -8,6 +8,7 @@ MotionWidget::MotionWidget(const Document *document, QUuid motionId) : setObjectName("MotionFrame"); m_previewWidget = new ModelWidget(this); + m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_previewWidget->setFixedSize(Theme::motionPreviewImageSize, Theme::motionPreviewImageSize); m_previewWidget->enableMove(false); m_previewWidget->enableZoom(false); diff --git a/src/partwidget.cpp b/src/partwidget.cpp index c8f7676b..048959f8 100644 --- a/src/partwidget.cpp +++ b/src/partwidget.cpp @@ -56,6 +56,7 @@ PartWidget::PartWidget(const Document *document, QUuid partId) : initButton(m_wrapButton); m_previewWidget = new ModelWidget; + m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_previewWidget->enableMove(false); m_previewWidget->enableZoom(false); m_previewWidget->setFixedSize(Theme::partPreviewImageSize, Theme::partPreviewImageSize); diff --git a/src/posewidget.cpp b/src/posewidget.cpp index 525a59ad..889bb1ac 100644 --- a/src/posewidget.cpp +++ b/src/posewidget.cpp @@ -8,6 +8,7 @@ PoseWidget::PoseWidget(const Document *document, QUuid poseId) : setObjectName("PoseFrame"); m_previewWidget = new ModelWidget(this); + m_previewWidget->setAttribute(Qt::WA_TransparentForMouseEvents); m_previewWidget->setFixedSize(Theme::posePreviewImageSize, Theme::posePreviewImageSize); m_previewWidget->enableMove(false); m_previewWidget->enableZoom(false);