From 66da7d34e4bab8bfd7453ce99d42cfb18f2960fb Mon Sep 17 00:00:00 2001
From: Philip Trettner <philip.trettner@rwth-aachen.de>
Date: Tue, 24 Mar 2020 19:31:51 +0100
Subject: [PATCH] fixed global config changes inside interactive viewers

---
 viewer/glow-extras/viewer/ViewerApp.hh                  | 2 +-
 viewer/glow-extras/viewer/configure.cc                  | 4 ++--
 viewer/glow-extras/viewer/configure.hh                  | 4 ++--
 viewer/glow-extras/viewer/detail/config_structs_impl.hh | 4 ++++
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/viewer/glow-extras/viewer/ViewerApp.hh b/viewer/glow-extras/viewer/ViewerApp.hh
index db372d2e..caba032f 100644
--- a/viewer/glow-extras/viewer/ViewerApp.hh
+++ b/viewer/glow-extras/viewer/ViewerApp.hh
@@ -62,7 +62,7 @@ private:
     detail::shared_command_queue const mStaticCommandQueue;
     /// Whether mStaticCommandQueue contains interactive parts. If false, the layout does not require a rebuild each frame
     bool const mIsInteractive;
-    detail::global_settings const mSettings;
+    detail::global_settings const& mSettings;
 
     /// A subview data cache, keys are x/y upper left corner
     std::unordered_map<tg::ipos2, SubViewData> mSubViewDataCache;
diff --git a/viewer/glow-extras/viewer/configure.cc b/viewer/glow-extras/viewer/configure.cc
index 0d731726..67652023 100644
--- a/viewer/glow-extras/viewer/configure.cc
+++ b/viewer/glow-extras/viewer/configure.cc
@@ -55,8 +55,8 @@ void configure(Renderable&, infinite_accumulation_t b)
 }
 void configure(Renderable& r, maybe_empty_t) { r.setCanBeEmpty(); }
 
-void configure(Renderable&, no_left_mouse_control_t) { detail::set_left_mouse_control(false); }
-void configure(Renderable&, no_right_mouse_control_t) { detail::set_right_mouse_control(false); }
+void configure(Renderable&, no_left_mouse_control_t b) { detail::set_left_mouse_control(!b.active); }
+void configure(Renderable&, no_right_mouse_control_t b) { detail::set_right_mouse_control(!b.active); }
 
 void configure(Renderable&, controls_2d_t b) { detail::set_2d_controls(b.active); }
 void configure(Renderable&, dark_ui_t b) { detail::set_ui_darkmode(b.active); }
diff --git a/viewer/glow-extras/viewer/configure.hh b/viewer/glow-extras/viewer/configure.hh
index 7270b557..9b0c722a 100644
--- a/viewer/glow-extras/viewer/configure.hh
+++ b/viewer/glow-extras/viewer/configure.hh
@@ -103,8 +103,8 @@ inline auto constexpr backface_culling = backface_culling_t{};
 // passthrough configures for scene modification commands
 void configure(Renderable&, no_grid_t b);
 void configure(Renderable&, no_shadow_t);
-void configure(Renderable&, no_left_mouse_control_t);
-void configure(Renderable&, no_right_mouse_control_t);
+void configure(Renderable&, no_left_mouse_control_t b);
+void configure(Renderable&, no_right_mouse_control_t b);
 void configure(Renderable&, print_mode_t b);
 void configure(Renderable&, maybe_empty_t);
 void configure(Renderable&, no_outline_t b);
diff --git a/viewer/glow-extras/viewer/detail/config_structs_impl.hh b/viewer/glow-extras/viewer/detail/config_structs_impl.hh
index 83e92610..2e20e349 100644
--- a/viewer/glow-extras/viewer/detail/config_structs_impl.hh
+++ b/viewer/glow-extras/viewer/detail/config_structs_impl.hh
@@ -35,9 +35,13 @@ struct maybe_empty_t
 };
 struct no_left_mouse_control_t
 {
+    bool active = true;
+    no_left_mouse_control_t operator()(bool a) const { return {a}; }
 };
 struct no_right_mouse_control_t
 {
+    bool active = true;
+    no_right_mouse_control_t operator()(bool a) const { return {a}; }
 };
 struct no_fresnel_t
 {
-- 
GitLab