mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 00:10:32 +00:00
Add configurable docking flag
This commit is contained in:
parent
b58d17177e
commit
c8e465ce2d
@ -3,6 +3,7 @@
|
||||
#include "ImGuiInteroperability.h"
|
||||
|
||||
#include "ImGuiInputState.h"
|
||||
#include "ImGuiModule.h"
|
||||
#include "Utilities/Arrays.h"
|
||||
|
||||
|
||||
@ -429,6 +430,7 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<FString>& Args)
|
||||
{
|
||||
bool bIsEnabled = false;
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -196,6 +196,12 @@ 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.
|
||||
@ -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;
|
||||
};
|
||||
|
@ -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<ImFontConfig> Font) { CustomFonts.Emplace(FontName, Font); }
|
||||
|
||||
@ -94,5 +103,7 @@ private:
|
||||
|
||||
bool bShowDemo = false;
|
||||
|
||||
bool bIsDockingEnabled = true;
|
||||
|
||||
TMap<FName, TSharedPtr<ImFontConfig>> CustomFonts;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user