From 253eff05250b4bbf241eea4a1554ef636c6fb52b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 10 May 2020 21:20:51 +0100 Subject: [PATCH] Added functionality allowing to apply changes in canvas size settings while playing. --- Source/ImGui/Private/ImGuiModuleSettings.cpp | 1 + Source/ImGui/Private/ImGuiModuleSettings.h | 4 ++++ Source/ImGui/Private/Widgets/SImGuiWidget.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/Source/ImGui/Private/ImGuiModuleSettings.cpp b/Source/ImGui/Private/ImGuiModuleSettings.cpp index 8cfd79d..0ceec66 100644 --- a/Source/ImGui/Private/ImGuiModuleSettings.cpp +++ b/Source/ImGui/Private/ImGuiModuleSettings.cpp @@ -166,6 +166,7 @@ void FImGuiModuleSettings::SetCanvasSizeInfo(const FImGuiCanvasSizeInfo& CanvasS if (CanvasSize != CanvasSizeInfo) { CanvasSize = CanvasSizeInfo; + OnCanvasSizeInfoChangeDelegate.Broadcast(CanvasSize); } } diff --git a/Source/ImGui/Private/ImGuiModuleSettings.h b/Source/ImGui/Private/ImGuiModuleSettings.h index 2d80e8c..3ad6edb 100644 --- a/Source/ImGui/Private/ImGuiModuleSettings.h +++ b/Source/ImGui/Private/ImGuiModuleSettings.h @@ -171,6 +171,7 @@ public: // Generic delegate used to notify changes of boolean properties. DECLARE_MULTICAST_DELEGATE_OneParam(FBoolChangeDelegate, bool); DECLARE_MULTICAST_DELEGATE_OneParam(FStringClassReferenceChangeDelegate, const FStringClassReference&); + DECLARE_MULTICAST_DELEGATE_OneParam(FImGuiCanvasSizeInfoChangeDelegate, const FImGuiCanvasSizeInfo&); // Constructor for ImGui module settings. It will bind to instances of module properties and commands and will // update them every time when settings are changed. @@ -202,6 +203,9 @@ public: // Delegate raised when software cursor configuration is changed. FBoolChangeDelegate OnUseSoftwareCursorChanged; + // Delegate raised when information how to calculate the canvas size is changed. + FImGuiCanvasSizeInfoChangeDelegate OnCanvasSizeInfoChangeDelegate; + private: void UpdateSettings(); diff --git a/Source/ImGui/Private/Widgets/SImGuiWidget.cpp b/Source/ImGui/Private/Widgets/SImGuiWidget.cpp index fcebdb7..85ed9c5 100644 --- a/Source/ImGui/Private/Widgets/SImGuiWidget.cpp +++ b/Source/ImGui/Private/Widgets/SImGuiWidget.cpp @@ -283,6 +283,10 @@ void SImGuiWidget::RegisterImGuiSettingsDelegates() { Settings.OnUseSoftwareCursorChanged.AddRaw(this, &SImGuiWidget::SetHideMouseCursor); } + if (!Settings.OnCanvasSizeInfoChangeDelegate.IsBoundToObject(this)) + { + Settings.OnCanvasSizeInfoChangeDelegate.AddRaw(this, &SImGuiWidget::SetCanvasSizeInfo); + } } void SImGuiWidget::UnregisterImGuiSettingsDelegates() @@ -291,6 +295,7 @@ void SImGuiWidget::UnregisterImGuiSettingsDelegates() Settings.OnImGuiInputHandlerClassChanged.RemoveAll(this); Settings.OnUseSoftwareCursorChanged.RemoveAll(this); + Settings.OnCanvasSizeInfoChangeDelegate.RemoveAll(this); } void SImGuiWidget::SetHideMouseCursor(bool bHide)