From 878ef9c5dab67009066676c4f2bacac36c7b7b8c Mon Sep 17 00:00:00 2001 From: redstrate Date: Tue, 12 Oct 2021 11:47:13 -0400 Subject: [PATCH] Only enable viewports on multimodal apps (like the editors) * Dragging out windows on games and stuff is pointless and just adds complexity --- engine/core/include/app.hpp | 1 + engine/core/src/engine.cpp | 4 ++++ engine/core/src/imgui_backend.cpp | 6 ++---- tools/common/include/commoneditor.hpp | 1 + tools/common/src/commoneditor.cpp | 5 +++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/engine/core/include/app.hpp b/engine/core/include/app.hpp index b01ba5a..892b656 100755 --- a/engine/core/include/app.hpp +++ b/engine/core/include/app.hpp @@ -30,6 +30,7 @@ namespace prism { virtual void render([[maybe_unused]] GFXCommandBuffer* command_buffer) {} virtual bool wants_no_scene_rendering() { return false; } + virtual bool is_multimodal() { return false; } }; } diff --git a/engine/core/src/engine.cpp b/engine/core/src/engine.cpp index 585a5b0..3c7a2db 100755 --- a/engine/core/src/engine.cpp +++ b/engine/core/src/engine.cpp @@ -58,6 +58,10 @@ void engine::set_app(prism::app* p_app) { Expects(p_app != nullptr); this->current_app = p_app; + + if(platform::supports_feature(PlatformFeature::Windowing) && ::engine->get_app()->is_multimodal()) { + ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; + } } prism::app* engine::get_app() const { diff --git a/engine/core/src/imgui_backend.cpp b/engine/core/src/imgui_backend.cpp index 8f95bfb..648999d 100644 --- a/engine/core/src/imgui_backend.cpp +++ b/engine/core/src/imgui_backend.cpp @@ -7,6 +7,7 @@ #include "platform.hpp" #include "assertions.hpp" #include "input.hpp" +#include "app.hpp" using prism::imgui_backend; @@ -43,10 +44,7 @@ imgui_backend::imgui_backend() { io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; io.BackendPlatformName = "Prism"; - - if(platform::supports_feature(PlatformFeature::Windowing)) - io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; - + for (auto& [im, pl] : imToPl) io.KeyMap[im] = platform::get_keycode(pl); diff --git a/tools/common/include/commoneditor.hpp b/tools/common/include/commoneditor.hpp index c799f58..c698854 100755 --- a/tools/common/include/commoneditor.hpp +++ b/tools/common/include/commoneditor.hpp @@ -133,6 +133,7 @@ public: virtual void asset_selected([[maybe_unused]] std::filesystem::path path, [[maybe_unused]] AssetType type) {} bool wants_no_scene_rendering() override { return true; } + bool is_multimodal() override { return true; } void createDockArea(); void drawViewport(Scene* scene); diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index 967ba05..101324b 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -387,8 +387,9 @@ Transform stored_transform; bool IsItemActiveLastFrame() { ImGuiContext& g = *GImGui; - if (g.ActiveIdPreviousFrame) - return g.ActiveIdPreviousFrame == g.CurrentWindow->DC.LastItemId; + // TODO: uh oh this is broken now :-( + //if (g.ActiveIdPreviousFrame) + // return g.ActiveIdPreviousFrame == g.CurrentWindow->DC.LastItemId; return false; }