From bb4e81b00a53af179f65133eccd371a31d7ebb52 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Sun, 13 Aug 2023 10:17:01 +0200 Subject: [PATCH] BugFix Display of current source in workspace Current source outline should not be shown in Geometry view if not in current workspace. Added possibility to switch workspace in source panel. --- src/GeometryView.cpp | 2 +- src/ImGuiVisitor.cpp | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/GeometryView.cpp b/src/GeometryView.cpp index efcd441..e32a750 100644 --- a/src/GeometryView.cpp +++ b/src/GeometryView.cpp @@ -240,7 +240,7 @@ void GeometryView::draw() scene.accept(draw_overlays); // 4. Draw control overlays of current source on top (if selected) - if (s != nullptr) { + if (s != nullptr && s->workspace() == Settings::application.current_workspace) { DrawVisitor dv(s->overlays_[mode_], projection); scene.accept(dv); // Always restore current source after draw diff --git a/src/ImGuiVisitor.cpp b/src/ImGuiVisitor.cpp index 927e454..2b6207a 100644 --- a/src/ImGuiVisitor.cpp +++ b/src/ImGuiVisitor.cpp @@ -58,6 +58,7 @@ #include "Mixer.h" #include "MixingGroup.h" #include "ActionManager.h" +#include "Mixer.h" #include "imgui.h" #include "ImGuiToolkit.h" @@ -493,26 +494,36 @@ void ImGuiVisitor::visit (Source& s) else ImGuiToolkit::Indication("Inactive", ICON_FA_SNOWFLAKE); - // Inform on workspace - ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + ImGui::GetFrameHeightWithSpacing()) ); - if (s.workspace() == Source::BACKGROUND) - ImGuiToolkit::Indication("in Background",10, 16); - else if (s.workspace() == Source::FOREGROUND) - ImGuiToolkit::Indication("in Foreground",12, 16); - else - ImGuiToolkit::Indication("in Workspace",11, 16); - // Inform on link - ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + 2.1f * ImGui::GetFrameHeightWithSpacing()) ); + ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + ImGui::GetFrameHeightWithSpacing()) ); if (s.mixingGroup() != nullptr) { if (ImGuiToolkit::IconButton(ICON_FA_LINK, "Linked")){ Mixer::selection().clear(); Mixer::selection().add( s.mixingGroup()->getCopy() ); + UserInterface::manager().setView(View::MIXING); } } else ImGuiToolkit::Indication("not Linked", ICON_FA_UNLINK); + // Inform on workspace + ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + 2.1f * ImGui::GetFrameHeightWithSpacing()) ); + static std::map< int, std::pair > workspaces_ { + { Source::BACKGROUND, {10, "in Background"}}, + { Source::STAGE, {11, "in Workspace"}}, + { Source::FOREGROUND, {12, "in Foreground"}} + }; + // in Geometry view, offer to switch current workspace to the source workspace + if (Settings::application.current_view == View::GEOMETRY) { + if (ImGuiToolkit::IconButton( workspaces_[s.workspace()].first, 16, workspaces_[s.workspace()].second.c_str())) { + Settings::application.current_workspace=s.workspace(); + Mixer::manager().setCurrentSource(s.id()); + } + } + // otherwise in other views, just draw in indicator + else + ImGuiToolkit::Indication(workspaces_[s.workspace()].second.c_str(), workspaces_[s.workspace()].first, 16); + // locking ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + 3.f * ImGui::GetFrameHeightWithSpacing()) ); const char *tooltip[2] = {"Unlocked", "Locked"};