summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-25 14:01:11 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-03-26 10:17:55 +0000
commit0c44c1066c4ecc67fff587fbb6b6c083f794bddd (patch)
treee9ebdb50ce7c389dd8b797be8516bb81e82c5e16
parentb066dcdafa7654862cbde95a2bcc52e5043ed6c5 (diff)
Delete guide if it is moved off-presentation via inspector
Change-Id: Ifd8188da43d334e315df2e9b6be6768953c6f1e7 Fixes: QT3DS-3222 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp11
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h3
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp21
3 files changed, 32 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
index 808ead73..5c2af7ac 100644
--- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp
@@ -336,6 +336,17 @@ void SGuideInspectableImpl::FireRefresh()
m_Editor.FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle());
}
+void SGuideInspectableImpl::Destroy()
+{
+ m_Editor.EnsureEditor(QObject::tr("Delete Guide"), __FILE__, __LINE__).DeleteGuide(m_Guide);
+ m_Editor.CommitEditor();
+}
+
+bool SGuideInspectableImpl::isHorizontal() const
+{
+ return Reader().GetGuideInfo(m_Guide).m_Direction == qt3dsdm::GuideDirections::Horizontal;
+}
+
const std::vector<std::shared_ptr<IInspectableAttributeItem>> &
SGuideInspectableImpl::properties() const
{
diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h
index cc28c62b..66936ccd 100644
--- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h
+++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h
@@ -76,6 +76,9 @@ public:
void Commit();
void Rollback();
void FireRefresh();
+ void Destroy();
+
+ bool isHorizontal() const;
const std::vector<std::shared_ptr<IInspectableAttributeItem>> &properties() const;
private:
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index feca12b5..dc2ef136 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -56,6 +56,7 @@
#include "Dialogs.h"
#include "Dispatch.h"
#include "VariantsGroupModel.h"
+#include "StudioProjectSettings.h"
#include <QtCore/qfileinfo.h>
@@ -1913,10 +1914,24 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV
else
m_UpdatableEditor.RollbackEditor();
} else {
- if (m_guideInspectable)
- m_guideInspectable->Commit();
- else
+ if (m_guideInspectable) {
+ // If the guide ends up over the matte, destroy it
+ QSize presSize = g_StudioApp.GetCore()->GetStudioProjectSettings()
+ ->getPresentationSize();
+ bool isInPres = true;
+ qt3dsdm::SValue posValue = m_guideInspectable->GetPosition();
+ float position = qt3dsdm::get<float>(posValue);
+ if (m_guideInspectable->isHorizontal())
+ isInPres = 0.f <= position && float(presSize.height()) >= position;
+ else
+ isInPres = 0.f <= position && float(presSize.width()) >= position;
+ if (isInPres)
+ m_guideInspectable->Commit();
+ else
+ m_guideInspectable->Destroy();
+ } else {
m_UpdatableEditor.CommitEditor();
+ }
}
m_previouslyCommittedValue = {};