diff --git a/Source/ImGui/Private/ImGuiInteroperability.cpp b/Source/ImGui/Private/ImGuiInteroperability.cpp index 7cc65c8..0296a0e 100644 --- a/Source/ImGui/Private/ImGuiInteroperability.cpp +++ b/Source/ImGui/Private/ImGuiInteroperability.cpp @@ -3,6 +3,7 @@ #include "ImGuiInteroperability.h" #include "ImGuiInputState.h" +#include "ImGuiModule.h" #include "Utilities/Arrays.h" @@ -429,7 +430,8 @@ namespace ImGuiInterops SetFlag(IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard, InputState.IsKeyboardNavigationEnabled()); SetFlag(IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad, InputState.IsGamepadNavigationEnabled()); SetFlag(IO.BackendFlags, ImGuiBackendFlags_HasGamepad, InputState.HasGamepad()); - + SetFlag(IO.ConfigFlags, ImGuiConfigFlags_DockingEnable, FImGuiModule::Get().GetProperties().IsDockingEnabled()); + // Check whether we need to draw cursor. IO.MouseDrawCursor = InputState.HasMousePointer(); @@ -438,23 +440,17 @@ namespace ImGuiInterops { // Copy the touch position to mouse position. IO.AddMousePosEvent(InputState.GetTouchPosition().X, InputState.GetTouchPosition().Y); - //IO.MousePos.x = InputState.GetTouchPosition().X; - //IO.MousePos.y = InputState.GetTouchPosition().Y; // With touch active one frame longer than it is down, we have one frame to processed touch up. IO.AddMouseButtonEvent(0, InputState.IsTouchDown()); - //IO.MouseDown[0] = InputState.IsTouchDown(); } else { // Copy the mouse position. IO.AddMousePosEvent(InputState.GetMousePosition().X, InputState.GetMousePosition().Y); - //IO.MousePos.x = InputState.GetMousePosition().X; - //IO.MousePos.y = InputState.GetMousePosition().Y; // Copy mouse wheel delta. IO.AddMouseWheelEvent(0, IO.MouseWheel + InputState.GetMouseWheelDelta()); - //IO.MouseWheel += InputState.GetMouseWheelDelta(); } } } diff --git a/Source/ImGui/Private/ImGuiModuleCommands.cpp b/Source/ImGui/Private/ImGuiModuleCommands.cpp index 2bfc242..21a4e0b 100644 --- a/Source/ImGui/Private/ImGuiModuleCommands.cpp +++ b/Source/ImGui/Private/ImGuiModuleCommands.cpp @@ -12,6 +12,7 @@ const TCHAR* const FImGuiModuleCommands::ToggleGamepadNavigation = TEXT("ImGui.T const TCHAR* const FImGuiModuleCommands::ToggleKeyboardInputSharing = TEXT("ImGui.ToggleKeyboardInputSharing"); const TCHAR* const FImGuiModuleCommands::ToggleGamepadInputSharing = TEXT("ImGui.ToggleGamepadInputSharing"); const TCHAR* const FImGuiModuleCommands::ToggleMouseInputSharing = TEXT("ImGui.ToggleMouseInputSharing"); +const TCHAR* const FImGuiModuleCommands::ToggleDockingEnabled = TEXT("ImGui.ToggleDockingEnabled"); const TCHAR* const FImGuiModuleCommands::SetMouseInputSharing = TEXT("ImGui.SetMouseInputSharing"); const TCHAR* const FImGuiModuleCommands::ToggleDemo = TEXT("ImGui.ToggleDemo"); @@ -35,6 +36,9 @@ FImGuiModuleCommands::FImGuiModuleCommands(FImGuiModuleProperties& InProperties) , ToggleMouseInputSharingCommand(ToggleMouseInputSharing, TEXT("Toggle ImGui mouse input sharing."), FConsoleCommandDelegate::CreateRaw(this, &FImGuiModuleCommands::ToggleMouseInputSharingImpl)) + , ToggleDockingEnabledCommand(ToggleDockingEnabled, + TEXT("Toggle ImGui docking."), + FConsoleCommandDelegate::CreateRaw(this, &FImGuiModuleCommands::ToggleDockingEnabledImpl)) , SetMouseInputSharingCommand(SetMouseInputSharing, TEXT("Toggle ImGui mouse input sharing."), FConsoleCommandWithArgsDelegate::CreateRaw(this, &FImGuiModuleCommands::SetMouseInputSharingImpl)) @@ -79,6 +83,11 @@ void FImGuiModuleCommands::ToggleMouseInputSharingImpl() Properties.ToggleMouseInputSharing(); } +void FImGuiModuleCommands::ToggleDockingEnabledImpl() +{ + Properties.ToggleDockingEnabled(); +} + void FImGuiModuleCommands::SetMouseInputSharingImpl(const TArray& Args) { bool bIsEnabled = false; diff --git a/Source/ImGui/Private/ImGuiModuleCommands.h b/Source/ImGui/Private/ImGuiModuleCommands.h index e7a09fd..9c6fb53 100644 --- a/Source/ImGui/Private/ImGuiModuleCommands.h +++ b/Source/ImGui/Private/ImGuiModuleCommands.h @@ -19,6 +19,7 @@ public: static const TCHAR* const ToggleKeyboardInputSharing; static const TCHAR* const ToggleGamepadInputSharing; static const TCHAR* const ToggleMouseInputSharing; + static const TCHAR* const ToggleDockingEnabled; static const TCHAR* const SetMouseInputSharing; static const TCHAR* const ToggleDemo; @@ -34,6 +35,7 @@ private: void ToggleKeyboardInputSharingImpl(); void ToggleGamepadInputSharingImpl(); void ToggleMouseInputSharingImpl(); + void ToggleDockingEnabledImpl(); void SetMouseInputSharingImpl(const TArray< FString >& Args); void ToggleDemoImpl(); @@ -45,6 +47,7 @@ private: FAutoConsoleCommand ToggleKeyboardInputSharingCommand; FAutoConsoleCommand ToggleGamepadInputSharingCommand; FAutoConsoleCommand ToggleMouseInputSharingCommand; + FAutoConsoleCommand ToggleDockingEnabledCommand; FAutoConsoleCommand SetMouseInputSharingCommand; FAutoConsoleCommand ToggleDemoCommand; }; diff --git a/Source/ImGui/Private/ImGuiModuleSettings.cpp b/Source/ImGui/Private/ImGuiModuleSettings.cpp index 0df7fa8..c783242 100644 --- a/Source/ImGui/Private/ImGuiModuleSettings.cpp +++ b/Source/ImGui/Private/ImGuiModuleSettings.cpp @@ -182,6 +182,15 @@ void FImGuiModuleSettings::SetToggleInputKey(const FImGuiKeyInfo& KeyInfo) } } +void FImGuiModuleSettings::SetIsDockingEnabled(bool bDockingEnabled) +{ + if (bIsDockingEnabled != bDockingEnabled) + { + bIsDockingEnabled = bDockingEnabled; + Properties.SetDockingEnabled(bDockingEnabled); + } +} + void FImGuiModuleSettings::SetCanvasSizeInfo(const FImGuiCanvasSizeInfo& CanvasSizeInfo) { if (CanvasSize != CanvasSizeInfo) diff --git a/Source/ImGui/Private/ImGuiModuleSettings.h b/Source/ImGui/Private/ImGuiModuleSettings.h index 369f076..b41c98b 100644 --- a/Source/ImGui/Private/ImGuiModuleSettings.h +++ b/Source/ImGui/Private/ImGuiModuleSettings.h @@ -196,12 +196,18 @@ protected: UPROPERTY(EditAnywhere, config, Category = "Input") bool bShareMouseInput = false; + // Whether docking should be enabled. + // This defines initial behaviour which can be later changed using 'ImGui.ToggleDockingEnabled' command or + // module properties interface. + UPROPERTY(EditAnywhere, config, Category = "Input") + bool bIsDockingEnabled = true; + // If true, then in input mode ImGui will draw its own cursor in place of the hardware one. // When disabled (default) there is a noticeable difference between cursor position seen by ImGui and position on // the screen. Enabling this option removes that effect but with lower frame-rates UI becomes quickly unusable. UPROPERTY(EditAnywhere, config, Category = "Input", AdvancedDisplay) bool bUseSoftwareCursor = false; - + // Define a shortcut key to 'ImGui.ToggleInput' command. Binding is only set if the key field is valid. // Note that modifier key properties can be set to one of the three values: undetermined means that state of the given // modifier is not important, checked means that it needs to be pressed and unchecked means that it cannot be pressed. @@ -291,6 +297,7 @@ private: void SetShareMouseInput(bool bShare); void SetUseSoftwareCursor(bool bUse); void SetToggleInputKey(const FImGuiKeyInfo& KeyInfo); + void SetIsDockingEnabled(bool bDockingEnabled); void SetCanvasSizeInfo(const FImGuiCanvasSizeInfo& CanvasSizeInfo); void SetDPIScaleInfo(const FImGuiDPIScaleInfo& ScaleInfo); @@ -309,4 +316,5 @@ private: bool bShareGamepadInput = false; bool bShareMouseInput = false; bool bUseSoftwareCursor = false; + bool bIsDockingEnabled = true; }; diff --git a/Source/ImGui/Public/ImGuiModuleProperties.h b/Source/ImGui/Public/ImGuiModuleProperties.h index 20974e9..225c1a5 100644 --- a/Source/ImGui/Public/ImGuiModuleProperties.h +++ b/Source/ImGui/Public/ImGuiModuleProperties.h @@ -72,6 +72,15 @@ public: /** Toggle ImGui demo. */ void ToggleDemo() { SetShowDemo(!ShowDemo()); } + /** Check whether docking is enabled. */ + bool IsDockingEnabled() const { return bIsDockingEnabled; } + + /** Set whether docking is enabled. */ + void SetDockingEnabled(bool bDockingEnabled) { bIsDockingEnabled = bDockingEnabled; } + + /** Toggle whether docking is enabled. */ + void ToggleDockingEnabled() { SetDockingEnabled(!IsDockingEnabled()); } + /** Adds a new font to initialize */ void AddCustomFont(FName FontName, TSharedPtr Font) { CustomFonts.Emplace(FontName, Font); } @@ -94,5 +103,7 @@ private: bool bShowDemo = false; + bool bIsDockingEnabled = true; + TMap> CustomFonts; };