Added functionality allowing to apply changes in canvas size settings while playing.

This commit is contained in:
Sebastian 2020-05-10 21:20:51 +01:00
parent 26f8729604
commit 253eff0525
3 changed files with 10 additions and 0 deletions

View File

@ -166,6 +166,7 @@ void FImGuiModuleSettings::SetCanvasSizeInfo(const FImGuiCanvasSizeInfo& CanvasS
if (CanvasSize != CanvasSizeInfo) if (CanvasSize != CanvasSizeInfo)
{ {
CanvasSize = CanvasSizeInfo; CanvasSize = CanvasSizeInfo;
OnCanvasSizeInfoChangeDelegate.Broadcast(CanvasSize);
} }
} }

View File

@ -171,6 +171,7 @@ public:
// Generic delegate used to notify changes of boolean properties. // Generic delegate used to notify changes of boolean properties.
DECLARE_MULTICAST_DELEGATE_OneParam(FBoolChangeDelegate, bool); DECLARE_MULTICAST_DELEGATE_OneParam(FBoolChangeDelegate, bool);
DECLARE_MULTICAST_DELEGATE_OneParam(FStringClassReferenceChangeDelegate, const FStringClassReference&); 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 // 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. // update them every time when settings are changed.
@ -202,6 +203,9 @@ public:
// Delegate raised when software cursor configuration is changed. // Delegate raised when software cursor configuration is changed.
FBoolChangeDelegate OnUseSoftwareCursorChanged; FBoolChangeDelegate OnUseSoftwareCursorChanged;
// Delegate raised when information how to calculate the canvas size is changed.
FImGuiCanvasSizeInfoChangeDelegate OnCanvasSizeInfoChangeDelegate;
private: private:
void UpdateSettings(); void UpdateSettings();

View File

@ -283,6 +283,10 @@ void SImGuiWidget::RegisterImGuiSettingsDelegates()
{ {
Settings.OnUseSoftwareCursorChanged.AddRaw(this, &SImGuiWidget::SetHideMouseCursor); Settings.OnUseSoftwareCursorChanged.AddRaw(this, &SImGuiWidget::SetHideMouseCursor);
} }
if (!Settings.OnCanvasSizeInfoChangeDelegate.IsBoundToObject(this))
{
Settings.OnCanvasSizeInfoChangeDelegate.AddRaw(this, &SImGuiWidget::SetCanvasSizeInfo);
}
} }
void SImGuiWidget::UnregisterImGuiSettingsDelegates() void SImGuiWidget::UnregisterImGuiSettingsDelegates()
@ -291,6 +295,7 @@ void SImGuiWidget::UnregisterImGuiSettingsDelegates()
Settings.OnImGuiInputHandlerClassChanged.RemoveAll(this); Settings.OnImGuiInputHandlerClassChanged.RemoveAll(this);
Settings.OnUseSoftwareCursorChanged.RemoveAll(this); Settings.OnUseSoftwareCursorChanged.RemoveAll(this);
Settings.OnCanvasSizeInfoChangeDelegate.RemoveAll(this);
} }
void SImGuiWidget::SetHideMouseCursor(bool bHide) void SImGuiWidget::SetHideMouseCursor(bool bHide)