From d492138bda3eef82bfb258eda9f6d9ae12f92c49 Mon Sep 17 00:00:00 2001
From: Christian Mattes <christian.mattes@rwth-aachen.de>
Date: Tue, 9 Apr 2019 12:32:30 +0200
Subject: [PATCH] Made multiple imguis possible

---
 src/lava-vr/VRImgui.cc | 3 ++-
 src/lava-vr/VRImgui.hh | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lava-vr/VRImgui.cc b/src/lava-vr/VRImgui.cc
index c013999..ca457ab 100644
--- a/src/lava-vr/VRImgui.cc
+++ b/src/lava-vr/VRImgui.cc
@@ -112,6 +112,7 @@ void VRImgui::update(const glm::mat4 &screenPose,
     vmouse.z *= mHeight * pixels_per_meter;
     mVMouse = vmouse;
 
+    mImgui->makeCurrent();
     auto& io = ::ImGui::GetIO();
 
     if (pointer.y > -0.1f && pointer.y < 0.1f) {
@@ -153,7 +154,7 @@ bool VRImgui::visible() const
 
 bool VRImgui::enabled() const
 {
-    return mCurrentOpacity > 0.5f && mTargetOpacity > 0.5f;
+    return !mBlocked && mCurrentOpacity > 0.5f && mTargetOpacity > 0.5f;
 }
 
 } // namespace vr
diff --git a/src/lava-vr/VRImgui.hh b/src/lava-vr/VRImgui.hh
index 157cc69..408670f 100644
--- a/src/lava-vr/VRImgui.hh
+++ b/src/lava-vr/VRImgui.hh
@@ -47,9 +47,11 @@ class VRImgui {
     /// you can skip recording widgets if this returns false
     bool visible() const;
 
-    /// returns true if the ImGui is accepting input (due to fading state)
+    /// returns true if the ImGui is accepting input (due to fading state, or being blocked)
     bool enabled() const;
 
+    void setBlocked(bool val) { mBlocked = val; };
+
   protected:
     SharedGraphicsPipeline mPipeline;
     SharedDescriptorSet mDescriptor;
@@ -57,6 +59,7 @@ class VRImgui {
     float mCurrentOpacity = 1.0f, mTargetOpacity = 1.0f;
     glm::mat4 mPose;
     glm::vec3 mVMouse;
+    bool mBlocked = false;
 
     imgui::UniqueImGui mImgui;
 };
-- 
GitLab