Fix ImGui sometimes not respecting the viewport resolution in-Editor

ImguiAtomSystemComponent isn't guaranteed to initialize before ImGuiManager, which caused some issues.
Additionally, because we allow the user to configure ImGui's render resolution, I've refactored the window size override into a new OverrideRenderWindowSize API in ImGuiManager to decouple it from the target render resolution.
This commit is contained in:
nvsickle
2021-04-22 11:22:09 -07:00
parent 795ce4dfca
commit e1ae61ca06
5 changed files with 54 additions and 10 deletions
+16 -1
View File
@@ -262,6 +262,21 @@ void ImGuiManager::Shutdown()
ImGui::DestroyContext(m_imguiContext);
}
void ImGui::ImGuiManager::OverrideRenderWindowSize(uint32_t width, uint32_t height)
{
m_windowSize.m_width = width;
m_windowSize.m_height = height;
m_overridingWindowSize = true;
// Don't listen for window updates if our window size is being overridden
AzFramework::WindowNotificationBus::Handler::BusDisconnect();
}
void ImGui::ImGuiManager::RestoreRenderWindowSizeToDefault()
{
m_overridingWindowSize = false;
InitWindowSize();
}
void ImGuiManager::Render()
{
if (m_clientMenuBarState == DisplayState::Hidden && m_editorWindowState == DisplayState::Hidden)
@@ -757,7 +772,7 @@ void ImGuiManager::InitWindowSize()
{
// We only need to initialize the window size by querying the window the first time.
// After that we will get OnWindowResize notifications
if (!AzFramework::WindowNotificationBus::Handler::BusIsConnected())
if (!m_overridingWindowSize && !AzFramework::WindowNotificationBus::Handler::BusIsConnected())
{
AzFramework::NativeWindowHandle windowHandle = nullptr;
AzFramework::WindowSystemRequestBus::BroadcastResult(windowHandle, &AzFramework::WindowSystemRequestBus::Events::GetDefaultWindowHandle);