summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/3dstudioruntime2/simpleqml/main.qml13
-rw-r--r--src/runtime/api/q3dspresentation.cpp14
-rw-r--r--src/runtime/api/q3dspresentation.h2
-rw-r--r--src/runtime/api/q3dspresentation_p.h2
-rw-r--r--src/runtime/api/q3dspresentationcontroller.cpp22
-rw-r--r--src/runtime/q3dsengine.cpp22
-rw-r--r--src/runtime/q3dsengine_p.h2
-rw-r--r--src/runtime/q3dsscenemanager.cpp27
-rw-r--r--src/runtime/q3dsscenemanager_p.h2
-rw-r--r--src/runtime/q3dsslideplayer_p.h12
10 files changed, 116 insertions, 2 deletions
diff --git a/examples/3dstudioruntime2/simpleqml/main.qml b/examples/3dstudioruntime2/simpleqml/main.qml
index fd465fc..1e5b203 100644
--- a/examples/3dstudioruntime2/simpleqml/main.qml
+++ b/examples/3dstudioruntime2/simpleqml/main.qml
@@ -186,6 +186,19 @@ Rectangle {
anchors.left: slideEnter.right
anchors.leftMargin: 8
}
+ Button {
+ id: nextSlideByIndex
+ text: "Next slide"
+ anchors.left: parent.left
+ anchors.bottom: fpsCount.top
+ onClicked: s3dpres.goToSlide("Scene", true, true)
+ }
+ Button {
+ text: "Seek to 5 seconds"
+ anchors.left: nextSlideByIndex.right
+ anchors.bottom: fpsCount.top
+ onClicked: s3dpres.goToTime("Scene", 5)
+ }
FileDialog {
id: openDialog
diff --git a/src/runtime/api/q3dspresentation.cpp b/src/runtime/api/q3dspresentation.cpp
index 6354ec6..32e6dcf 100644
--- a/src/runtime/api/q3dspresentation.cpp
+++ b/src/runtime/api/q3dspresentation.cpp
@@ -108,6 +108,20 @@ void Q3DSPresentation::goToSlide(const QString &elementPath, const QString &name
d->controller->handleGoToSlideByName(elementPath, name);
}
+void Q3DSPresentation::goToSlide(const QString &elementPath, int index)
+{
+ Q_D(Q3DSPresentation);
+ if (d->controller)
+ d->controller->handleGoToSlideByIndex(elementPath, index);
+}
+
+void Q3DSPresentation::goToSlide(const QString &elementPath, bool next, bool wrap)
+{
+ Q_D(Q3DSPresentation);
+ if (d->controller)
+ d->controller->handleGoToSlideByDirection(elementPath, next, wrap);
+}
+
QVariant Q3DSPresentation::getAttribute(const QString &elementPath, const QString &attributeName)
{
Q_D(Q3DSPresentation);
diff --git a/src/runtime/api/q3dspresentation.h b/src/runtime/api/q3dspresentation.h
index 80f915c..705972e 100644
--- a/src/runtime/api/q3dspresentation.h
+++ b/src/runtime/api/q3dspresentation.h
@@ -58,6 +58,8 @@ public:
Q_INVOKABLE void fireEvent(const QString &elementPath, const QString &eventName);
Q_INVOKABLE void goToTime(const QString &elementPath, float timeSeconds);
Q_INVOKABLE void goToSlide(const QString &elementPath, const QString &name);
+ Q_INVOKABLE void goToSlide(const QString &elementPath, int index);
+ Q_INVOKABLE void goToSlide(const QString &elementPath, bool next, bool wrap);
Q_INVOKABLE QVariant getAttribute(const QString &elementPath, const QString &attributeName);
Q_INVOKABLE void setAttribute(const QString &elementPath, const QString &attributeName, const QVariant &value);
diff --git a/src/runtime/api/q3dspresentation_p.h b/src/runtime/api/q3dspresentation_p.h
index ca22cad..90d93a1 100644
--- a/src/runtime/api/q3dspresentation_p.h
+++ b/src/runtime/api/q3dspresentation_p.h
@@ -74,6 +74,8 @@ public:
virtual void handleFireEvent(const QString &elementPath, const QString &eventName);
virtual void handleGoToTime(const QString &elementPath, float timeSeconds);
virtual void handleGoToSlideByName(const QString &elementPath, const QString &name);
+ virtual void handleGoToSlideByIndex(const QString &elementPath, int index);
+ virtual void handleGoToSlideByDirection(const QString &elementPath, bool next, bool wrap);
virtual QVariant handleGetAttribute(const QString &elementPath, const QString &attribute);
virtual void handleSetAttribute(const QString &elementPath, const QString &attributeName, const QVariant &value);
diff --git a/src/runtime/api/q3dspresentationcontroller.cpp b/src/runtime/api/q3dspresentationcontroller.cpp
index 7f7a589..850ae4b 100644
--- a/src/runtime/api/q3dspresentationcontroller.cpp
+++ b/src/runtime/api/q3dspresentationcontroller.cpp
@@ -140,6 +140,28 @@ void Q3DSPresentationController::handleGoToSlideByName(const QString &elementPat
m_pcEngine->goToSlideByName(context, pres, name);
}
+void Q3DSPresentationController::handleGoToSlideByIndex(const QString &elementPath, int index)
+{
+ if (!m_pcEngine)
+ return;
+
+ Q3DSUipPresentation *pres = m_pcEngine->presentation(0);
+ Q3DSGraphObject *context = m_pcEngine->findObjectByNameOrPath(nullptr, pres, elementPath, &pres);
+ if (context)
+ m_pcEngine->goToSlideByIndex(context, pres, index);
+}
+
+void Q3DSPresentationController::handleGoToSlideByDirection(const QString &elementPath, bool next, bool wrap)
+{
+ if (!m_pcEngine)
+ return;
+
+ Q3DSUipPresentation *pres = m_pcEngine->presentation(0);
+ Q3DSGraphObject *context = m_pcEngine->findObjectByNameOrPath(nullptr, pres, elementPath, &pres);
+ if (context)
+ m_pcEngine->goToSlideByDirection(context, pres, next, wrap);
+}
+
QVariant Q3DSPresentationController::handleGetAttribute(const QString &elementPath, const QString &attribute)
{
if (!m_pcEngine)
diff --git a/src/runtime/q3dsengine.cpp b/src/runtime/q3dsengine.cpp
index 4bd756a..796db6c 100644
--- a/src/runtime/q3dsengine.cpp
+++ b/src/runtime/q3dsengine.cpp
@@ -1238,6 +1238,28 @@ void Q3DSEngine::goToSlideByName(Q3DSGraphObject *context, Q3DSUipPresentation *
}
}
+void Q3DSEngine::goToSlideByIndex(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, int index)
+{
+ for (const UipPresentation &pres : qAsConst(m_uipPresentations)) {
+ if (pres.presentation == presentation) {
+ if (pres.sceneManager)
+ pres.sceneManager->changeSlideByIndex(context, index);
+ break;
+ }
+ }
+}
+
+void Q3DSEngine::goToSlideByDirection(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, bool next, bool wrap)
+{
+ for (const UipPresentation &pres : qAsConst(m_uipPresentations)) {
+ if (pres.presentation == presentation) {
+ if (pres.sceneManager)
+ pres.sceneManager->changeSlideByDirection(context, next, wrap);
+ break;
+ }
+ }
+}
+
void Q3DSEngine::loadBehaviorInstance(Q3DSBehaviorInstance *behaviorInstance,
Q3DSUipPresentation *pres,
BehaviorLoadedCallback callback)
diff --git a/src/runtime/q3dsengine_p.h b/src/runtime/q3dsengine_p.h
index 12725ad..07e68ec 100644
--- a/src/runtime/q3dsengine_p.h
+++ b/src/runtime/q3dsengine_p.h
@@ -143,6 +143,8 @@ public:
void fireEvent(Q3DSGraphObject *target, Q3DSUipPresentation *presentation, const QString &event);
void goToTime(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, float milliseconds);
void goToSlideByName(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, const QString &name);
+ void goToSlideByIndex(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, int index);
+ void goToSlideByDirection(Q3DSGraphObject *context, Q3DSUipPresentation *presentation, bool next, bool wrap);
void handleKeyPressEvent(QKeyEvent *e);
void handleKeyReleaseEvent(QKeyEvent *e);
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp
index 3d5a7cc..645df6b 100644
--- a/src/runtime/q3dsscenemanager.cpp
+++ b/src/runtime/q3dsscenemanager.cpp
@@ -6377,6 +6377,33 @@ void Q3DSSceneManager::changeSlideByName(Q3DSGraphObject *sceneOrComponent, cons
}
}
+void Q3DSSceneManager::changeSlideByIndex(Q3DSGraphObject *sceneOrComponent, int index)
+{
+ Q3DSSlidePlayer *slidePlayer = m_slidePlayer;
+ if (sceneOrComponent->type() == Q3DSGraphObject::Component) {
+ slidePlayer = static_cast<Q3DSComponentNode *>(sceneOrComponent)->masterSlide()
+ ->attached<Q3DSSlideAttached>()->slidePlayer;
+ }
+
+ slidePlayer->slideDeck()->setCurrentSlide(index);
+}
+
+void Q3DSSceneManager::changeSlideByDirection(Q3DSGraphObject *sceneOrComponent, bool next, bool wrap)
+{
+ Q3DSSlidePlayer *slidePlayer = m_slidePlayer;
+ if (sceneOrComponent->type() == Q3DSGraphObject::Component) {
+ slidePlayer = static_cast<Q3DSComponentNode *>(sceneOrComponent)->masterSlide()
+ ->attached<Q3DSSlideAttached>()->slidePlayer;
+ }
+
+ if (next)
+ slidePlayer->slideDeck()->nextSlide(wrap);
+ else
+ slidePlayer->slideDeck()->previousSlide(wrap);
+
+ slidePlayer->reload();
+}
+
void Q3DSSceneManager::goToTime(Q3DSGraphObject *sceneOrComponent, float milliseconds, bool pause)
{
Q3DSSlidePlayer *slidePlayer = m_slidePlayer;
diff --git a/src/runtime/q3dsscenemanager_p.h b/src/runtime/q3dsscenemanager_p.h
index 9d3ec4d..3071ae1 100644
--- a/src/runtime/q3dsscenemanager_p.h
+++ b/src/runtime/q3dsscenemanager_p.h
@@ -627,6 +627,8 @@ public:
void setDataInputValue(const QString &dataInputName, const QVariant &value);
void changeSlideByName(Q3DSGraphObject *sceneOrComponent, const QString &name);
+ void changeSlideByIndex(Q3DSGraphObject *sceneOrComponent, int index);
+ void changeSlideByDirection(Q3DSGraphObject *sceneOrComponent, bool next, bool wrap);
void goToTime(Q3DSGraphObject *sceneOrComponent, float milliseconds, bool pause = false);
void queueEvent(const Q3DSGraphObject::Event &e);
diff --git a/src/runtime/q3dsslideplayer_p.h b/src/runtime/q3dsslideplayer_p.h
index 4670357..df1861e 100644
--- a/src/runtime/q3dsslideplayer_p.h
+++ b/src/runtime/q3dsslideplayer_p.h
@@ -245,7 +245,7 @@ public:
return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(m_index));
}
- Q3DSSlide *nextSlide()
+ Q3DSSlide *nextSlide(bool wrap = false)
{
if (!m_masterSlide)
return nullptr;
@@ -256,12 +256,16 @@ public:
if (m_index < slideCount() - 1) {
m_previouslyActiveIndex = m_index;
return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(++m_index));
+ } else if (wrap && m_index == slideCount() - 1) {
+ m_previouslyActiveIndex = m_index;
+ m_index = 0;
+ return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(m_index));
} else {
return nullptr;
}
}
- Q3DSSlide *previousSlide()
+ Q3DSSlide *previousSlide(bool wrap = false)
{
if (!m_masterSlide)
return nullptr;
@@ -272,6 +276,10 @@ public:
if ((m_index > 0) && (m_index < slideCount())) {
m_previouslyActiveIndex = m_index;
return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(--m_index));
+ } else if (wrap && m_index == 0) {
+ m_previouslyActiveIndex = m_index;
+ m_index = slideCount() - 1;
+ return static_cast<Q3DSSlide *>(m_masterSlide->childAtIndex(m_index));
} else {
return nullptr;
}