CogImGui: rework share mouse mode. Add widget that act as a input catcher below the UI widgets

This commit is contained in:
Arnaud Jamin
2024-01-08 01:50:26 -05:00
parent c90a32031b
commit 5e0976a902
11 changed files with 375 additions and 480 deletions
@@ -20,8 +20,8 @@ void FCogEngineWindow_LogCategories::Initialize()
void FCogEngineWindow_LogCategories::RenderHelp()
{
ImGui::Text(
"This window can be used to activate and deactivate log categories."
"Activating a log category set its verbosity to VeryVerbose. "
"This window can be used to activate and deactivate log categories. "
"Activating a log category set its verbosity to Verbose, or VeryVerbose when CTRL is pressed. "
"Deactivating a log category set its verbosity to Warning. "
"The detailed verbosity of each log category can shown by using the Option menu. "
"On a client, both the client and the server verbosity can be modified. "
@@ -1,236 +0,0 @@
#include "CogImGuiInputProcessor.h"
#include "CogImguiHelper.h"
#include "CogImguiInputHelper.h"
#include "CogImguiWidget.h"
#include "CogImguiContext.h"
#include "imgui.h"
#include "Framework/Application/SlateApplication.h"
//--------------------------------------------------------------------------------------------------------------------------
FCogImGuiInputProcessor::FCogImGuiInputProcessor(UPlayerInput* InPlayerInput, FCogImguiContext* InContext, SCogImguiWidget* InMainWidget)
{
PlayerInput = InPlayerInput;
Context = InContext;
MainWidget = InMainWidget;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImGuiInputProcessor::Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> SlateCursor)
{
ImGuiIO& IO = ImGui::GetIO();
const bool bHasGamepad = (IO.BackendFlags & ImGuiBackendFlags_HasGamepad);
if (bHasGamepad != SlateApp.IsGamepadAttached())
{
IO.BackendFlags ^= ImGuiBackendFlags_HasGamepad;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::Tick | HasGamePad Changed"));
}
AddMousePosEvent(SlateApp.GetCursorPos());
const bool bHasMouse = (IO.ConfigFlags & ImGuiConfigFlags_NoMouse) == 0;
const bool bUpdateMouseMouseCursor = (IO.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) == 0;
if (bHasMouse && bUpdateMouseMouseCursor)
{
SlateCursor->SetType(FCogImguiInputHelper::ToSlateMouseCursor(ImGui::GetMouseCursor()));
}
if (IO.WantSetMousePos)
{
SlateApp.SetCursorPos(FCogImguiHelper::ToFVector2D(IO.MousePos));
//UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::Tick | SetCursorPos"));
}
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& Event)
{
return HandleKeyEvent(SlateApp, Event, true);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleKeyUpEvent(FSlateApplication& SlateApp, const FKeyEvent& Event)
{
return HandleKeyEvent(SlateApp, Event, false);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleKeyEvent(FSlateApplication& SlateApp, const FKeyEvent& Event, bool IsKeyDown)
{
//------------------------------------------------------------------------------------------------
// We want the user to be able to open the console command when imgui has the input.
//------------------------------------------------------------------------------------------------
if (FCogImguiInputHelper::IsConsoleEvent(Event))
{
const bool Result = ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | TerminateEvent:%d | ConsoleEvent"), *Event.GetKey().ToString(), IsKeyDown, Result);
return Result;
}
//------------------------------------------------------------------------------------------------
// We want the user to be able to stop its session by pressing Esc, even when imgui has the input
//------------------------------------------------------------------------------------------------
if (FCogImguiInputHelper::IsStopPlaySessionEvent(Event))
{
const bool Result = ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | TerminateEvent:%d | StopPlaySessionEvent"), *Event.GetKey().ToString(), IsKeyDown, Result);
return Result;
}
//------------------------------------------------------------------------------------------------
// We want the user to be able to use command bingings, even when imgui has the input.
// We actually use a console command to toggle the input from the game to imgui, and other
// windows command such as LoadLayout.
//------------------------------------------------------------------------------------------------
if (FCogImguiInputHelper::IsKeyBoundToCommand(PlayerInput, Event))
{
const bool Result = ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | TerminateEvent:%d | KeyBoundToCommand"), *Event.GetKey().ToString(), IsKeyDown, Result);
return Result;
}
ImGuiIO& IO = ImGui::GetIO();
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(Event.GetKey()), IsKeyDown);
const FModifierKeysState& ModifierKeys = Event.GetModifierKeys();
IO.AddKeyEvent(ImGuiMod_Ctrl, ModifierKeys.IsControlDown());
IO.AddKeyEvent(ImGuiMod_Shift, ModifierKeys.IsShiftDown());
IO.AddKeyEvent(ImGuiMod_Alt, ModifierKeys.IsAltDown());
IO.AddKeyEvent(ImGuiMod_Super, ModifierKeys.IsCommandDown());
//------------------------------------------------------------------------------------------------
// If we receive a key modifier, we want to let others systems know about it.
// Otherwise, the console command bindings that are bound to something like CTRL+Key
// won't work, even if we let the KeyEvent pass with 'IsKeyBoundToCommand' below.
// It seems the command binings system needs to know about the modifier key press event itself,
// and not the Key+Modifier event.
//------------------------------------------------------------------------------------------------
const bool IsModifierKey = Event.GetKey().IsModifierKey();
if (IsModifierKey)
{
const bool Result = ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | TerminateEvent:%d | IsModifierKey"), *Event.GetKey().ToString(), IsKeyDown, Result);
return Result;
}
if (Event.GetKey().IsGamepadKey())
{
if (IO.WantCaptureKeyboard && (IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad))
{
const bool Result = TerminateEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | TerminateEvent:%d | NavEnableGamepad"), *Event.GetKey().ToString(), IsKeyDown, Result);
return Result;
}
}
const bool Result = IO.WantCaptureKeyboard ? TerminateEvent : ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleKeyEvent | Key:%s | IsKeyDown:%d | WantCaptureKeyboard:%d | TerminateEvent:%d"), *Event.GetKey().ToString(), IsKeyDown, IO.WantCaptureKeyboard, Result);
return Result;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleAnalogInputEvent(FSlateApplication& SlateApp, const FAnalogInputEvent& Event)
{
const float Value = Event.GetAnalogValue();
ImGuiIO& IO = ImGui::GetIO();
IO.AddKeyAnalogEvent(FCogImguiInputHelper::ToImKey(Event.GetKey()), FMath::Abs(Value) > 0.0f, Value);
if (Event.GetKey().IsGamepadKey())
{
if (IO.WantCaptureKeyboard && (IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad))
{
return TerminateEvent;
}
return ForwardEvent;
}
else
{
if (IO.WantCaptureKeyboard)
{
return TerminateEvent;
}
return ForwardEvent;
}
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseMoveEvent(FSlateApplication& SlateApp, const FPointerEvent& Event)
{
AddMousePosEvent(Event.GetScreenSpacePosition());
if (Context->GetEnableInput() && Context->GetShareMouse() == false && FCogImguiInputHelper::IsMouseInsideMainViewport())
{
return TerminateEvent;
}
ImGuiIO& IO = ImGui::GetIO();
const bool Result = IO.WantCaptureMouse ? TerminateEvent : ForwardEvent;
return Result;
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseButtonDownEvent(FSlateApplication& SlateApp, const FPointerEvent& Event)
{
return HandleMouseButtonEvent(SlateApp, Event, true);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseButtonUpEvent(FSlateApplication& SlateApp, const FPointerEvent& Event)
{
return HandleMouseButtonEvent(SlateApp, Event, false);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseButtonDoubleClickEvent(FSlateApplication& SlateApp, const FPointerEvent& Event)
{
return HandleMouseButtonEvent(SlateApp, Event, true);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseButtonEvent(FSlateApplication& SlateApp, const FPointerEvent& Event, bool IsButtonDown)
{
ImGuiIO& IO = ImGui::GetIO();
const uint32 Button = FCogImguiInputHelper::ToImGuiMouseButton(Event.GetEffectingButton());
IO.AddMouseButtonEvent(Button, IsButtonDown);
if (Context->GetEnableInput() && Context->GetShareMouse() == false && FCogImguiInputHelper::IsMouseInsideMainViewport())
{
const bool Result = TerminateEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleMouseButtonEvent | Button:%d | IsButtonDown:%d | WantCaptureMouse:%d | TerminateEvent:%d | ShareMouse == false"), Button, IsButtonDown, IO.WantCaptureMouse, Result);
return Result;
}
const bool Result = IO.WantCaptureMouse ? TerminateEvent : ForwardEvent;
UE_LOG(LogCogImGui, VeryVerbose, TEXT("FCogImGuiInputProcessor::HandleMouseButtonEvent | Button:%d | IsButtonDown:%d | WantCaptureMouse:%d | TerminateEvent:%d"), Button, IsButtonDown, IO.WantCaptureMouse, Result);
return Result;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImGuiInputProcessor::AddMousePosEvent(const FVector2D& MousePosition) const
{
ImGuiIO& IO = ImGui::GetIO();
if (IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
IO.AddMousePosEvent(MousePosition.X, MousePosition.Y);
}
else
{
const FVector2D TransformedMousePosition = MousePosition - MainWidget->GetTickSpaceGeometry().GetAbsolutePosition();
IO.AddMousePosEvent(TransformedMousePosition.X, TransformedMousePosition.Y);
}
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImGuiInputProcessor::HandleMouseWheelOrGestureEvent(FSlateApplication& SlateApp, const FPointerEvent& Event, const FPointerEvent* GestureEvent)
{
ImGuiIO& IO = ImGui::GetIO();
IO.AddMouseWheelEvent(0.0f, Event.GetWheelDelta());
return IO.WantCaptureMouse;
}
@@ -2,6 +2,7 @@
#include "Application/ThrottleManager.h"
#include "CogImguiHelper.h"
#include "CogImguiInputCatcherWidget.h"
#include "CogImguiInputHelper.h"
#include "CogImguiWidget.h"
#include "Engine/Console.h"
@@ -31,23 +32,16 @@ void FCogImguiContext::Initialize()
{
return;
}
FSlateApplication& SlateApp = FSlateApplication::Get();
GameViewport = GEngine->GameViewport;
SAssignNew(MainWidget, SCogImguiWidget)
.Context(this);
SAssignNew(MainWidget, SCogImguiWidget).Context(this);
GameViewport->AddViewportWidgetContent(MainWidget.ToSharedRef(), TNumericLimits<int32>::Max());
//--------------------------------------------------------------------
// Register input processor to forward input events to imgui
//--------------------------------------------------------------------
//if (FSlateApplication::IsInitialized())
//{
// UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GameViewport->GetWorld());
// InputProcessor = MakeShared<FCogImGuiInputProcessor>(PlayerInput, this, MainWidget.Get());
// FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor.ToSharedRef(), 0);
//}
SAssignNew(InputCatcherWidget, SCogImguiInputCatcherWidget).Context(this);
GameViewport->AddViewportWidgetContent(InputCatcherWidget.ToSharedRef(), -TNumericLimits<int32>::Max());
ImGuiContext = ImGui::CreateContext();
PlotContext = ImPlot::CreateContext();
@@ -74,7 +68,7 @@ void FCogImguiContext::Initialize()
//
//--------------------------------------------------------------------
ImGuiViewport* MainViewport = ImGui::GetMainViewport();
FImGuiViewportData* ViewportData = new FImGuiViewportData();
FCogImGuiViewportData* ViewportData = new FCogImGuiViewportData();
MainViewport->PlatformUserData = ViewportData;
ViewportData->Window = SlateApp.GetActiveTopLevelWindow();
ViewportData->Context = this;
@@ -113,7 +107,7 @@ void FCogImguiContext::Initialize()
void FCogImguiContext::Shutdown()
{
ImGuiViewport* MainViewport = ImGui::GetMainViewport();
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(MainViewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(MainViewport->PlatformUserData))
{
delete ViewportData;
MainViewport->PlatformUserData = nullptr;
@@ -122,12 +116,6 @@ void FCogImguiContext::Shutdown()
if (FSlateApplication::IsInitialized())
{
FSlateApplication& SlateApp = FSlateApplication::Get();
//if (InputProcessor.IsValid())
//{
// SlateApp.UnregisterInputPreProcessor(InputProcessor);
//}
if (const TSharedPtr<GenericApplication> PlatformApplication = SlateApp.GetPlatformApplication())
{
PlatformApplication->OnDisplayMetricsChanged().RemoveAll(this);
@@ -274,7 +262,7 @@ bool FCogImguiContext::BeginFrame(float InDeltaTime)
IO.AddMousePosEvent(TransformedMousePosition.X, TransformedMousePosition.Y);
}
bWantCaptureMouse = ImGui::GetIO().WantCaptureMouse || (CaptureMouseCount > 0);
bWantCaptureMouse = ImGui::GetIO().WantCaptureMouse;
//-------------------------------------------------------------------------------------------------------
//
@@ -321,7 +309,7 @@ void FCogImguiContext::ImGui_CreateWindow(ImGuiViewport* Viewport)
return;
}
const FImGuiViewportData* ParentViewportData = static_cast<FImGuiViewportData*>(ParentViewport->PlatformUserData);
const FCogImGuiViewportData* ParentViewportData = static_cast<FCogImGuiViewportData*>(ParentViewport->PlatformUserData);
if (ParentViewportData == nullptr)
{
return;
@@ -378,7 +366,7 @@ void FCogImguiContext::ImGui_CreateWindow(ImGuiViewport* Viewport)
Widget->SetWindow(Window);
FImGuiViewportData* ViewportData = new FImGuiViewportData();
FCogImGuiViewportData* ViewportData = new FCogImGuiViewportData();
Viewport->PlatformUserData = ViewportData;
ViewportData->Context = ParentViewportData->Context;
ViewportData->Widget = Widget;
@@ -392,7 +380,7 @@ void FCogImguiContext::ImGui_CreateWindow(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_DestroyWindow(ImGuiViewport* Viewport)
{
FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData);
FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData);
if (ViewportData == nullptr)
{
return;
@@ -417,7 +405,7 @@ void FCogImguiContext::ImGui_DestroyWindow(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_ShowWindow(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -429,7 +417,7 @@ void FCogImguiContext::ImGui_ShowWindow(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_SetWindowPos(ImGuiViewport* Viewport, ImVec2 Pos)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -441,7 +429,7 @@ void FCogImguiContext::ImGui_SetWindowPos(ImGuiViewport* Viewport, ImVec2 Pos)
//--------------------------------------------------------------------------------------------------------------------------
ImVec2 FCogImguiContext::ImGui_GetWindowPos(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SCogImguiWidget> Widget = ViewportData->Widget.Pin())
{
@@ -455,7 +443,7 @@ ImVec2 FCogImguiContext::ImGui_GetWindowPos(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_SetWindowSize(ImGuiViewport* Viewport, ImVec2 Size)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -467,7 +455,7 @@ void FCogImguiContext::ImGui_SetWindowSize(ImGuiViewport* Viewport, ImVec2 Size)
//--------------------------------------------------------------------------------------------------------------------------
ImVec2 FCogImguiContext::ImGui_GetWindowSize(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SCogImguiWidget> Widget = ViewportData->Widget.Pin())
{
@@ -481,7 +469,7 @@ ImVec2 FCogImguiContext::ImGui_GetWindowSize(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_SetWindowFocus(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -497,7 +485,7 @@ void FCogImguiContext::ImGui_SetWindowFocus(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImguiContext::ImGui_GetWindowFocus(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -514,7 +502,7 @@ bool FCogImguiContext::ImGui_GetWindowFocus(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
bool FCogImguiContext::ImGui_GetWindowMinimized(ImGuiViewport* Viewport)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -528,7 +516,7 @@ bool FCogImguiContext::ImGui_GetWindowMinimized(ImGuiViewport* Viewport)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_SetWindowTitle(ImGuiViewport* Viewport, const char* TitleAnsi)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -540,7 +528,7 @@ void FCogImguiContext::ImGui_SetWindowTitle(ImGuiViewport* Viewport, const char*
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_SetWindowAlpha(ImGuiViewport* Viewport, float Alpha)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SWindow> Window = ViewportData->Window.Pin())
{
@@ -552,7 +540,7 @@ void FCogImguiContext::ImGui_SetWindowAlpha(ImGuiViewport* Viewport, float Alpha
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::ImGui_RenderWindow(ImGuiViewport* Viewport, void* Data)
{
if (const FImGuiViewportData* ViewportData = static_cast<FImGuiViewportData*>(Viewport->PlatformUserData))
if (const FCogImGuiViewportData* ViewportData = static_cast<FCogImGuiViewportData*>(Viewport->PlatformUserData))
{
if (const TSharedPtr<SCogImguiWidget> Widget = ViewportData->Widget.Pin())
{
@@ -636,41 +624,37 @@ void FCogImguiContext::SetEnableInput(bool Value)
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::SetShowCursorWhenSharingMouse(bool Value)
void FCogImguiContext::SetShareMouse(bool Value)
{
bShowCursorWhenSharingMouse = Value;
bShareMouse = Value;
RefreshMouseCursor();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::SetShareMouse(bool Value)
void FCogImguiContext::SetShareMouseWithGameplay(bool Value)
{
bShareMouse = Value;
bShareMouseWithGameplay = Value;
RefreshMouseCursor();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::RefreshMouseCursor()
{
if (bEnableInput)
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
if (bShareMouse && bShowCursorWhenSharingMouse)
if (bHasSavedInitialCursorVisibility == false)
{
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
bPlayerControllerShowMouse = PlayerController->ShouldShowMouseCursor();
PlayerController->SetShowMouseCursor(true);
}
bIsCursorInitiallyVisible = PlayerController->ShouldShowMouseCursor();
bHasSavedInitialCursorVisibility = true;
}
}
else
{
if (bShareMouse && bShowCursorWhenSharingMouse)
if (bEnableInput && bShareMouse && bShareMouseWithGameplay)
{
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
PlayerController->SetShowMouseCursor(bPlayerControllerShowMouse);
}
PlayerController->SetShowMouseCursor(true);
}
else
{
PlayerController->SetShowMouseCursor(bIsCursorInitiallyVisible);
}
}
}
@@ -0,0 +1,146 @@
#include "CogImguiInputCatcherWidget.h"
#include "CogImguiContext.h"
#include "CogImguiInputHelper.h"
#include "Engine/GameViewportClient.h"
#include "imgui.h"
#include "SlateOptMacros.h"
#include "Widgets/SWindow.h"
//--------------------------------------------------------------------------------------------------------------------------
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
void SCogImguiInputCatcherWidget::Construct(const FArguments& InArgs)
{
Context = InArgs._Context;
RefreshVisibility();
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
//--------------------------------------------------------------------------------------------------------------------------
SCogImguiInputCatcherWidget::~SCogImguiInputCatcherWidget()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void SCogImguiInputCatcherWidget::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
Super::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
RefreshVisibility();
}
//--------------------------------------------------------------------------------------------------------------------------
int32 SCogImguiInputCatcherWidget::OnPaint(
const FPaintArgs& Args,
const FGeometry& AllottedGeometry,
const FSlateRect& MyClippingRect,
FSlateWindowElementList& OutDrawElements,
int32 LayerId,
const FWidgetStyle& WidgetStyle,
bool bParentEnabled) const
{
return LayerId;
}
//--------------------------------------------------------------------------------------------------------------------------
FVector2D SCogImguiInputCatcherWidget::ComputeDesiredSize(float Scale) const
{
return FVector2D::ZeroVector;
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& CharacterEvent)
{
return FReply::Unhandled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
{
return FReply::Unhandled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
{
return FReply::Unhandled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent)
{
return FReply::Handled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return HandleMouseButtonEvent(MouseEvent, true);
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return HandleMouseButtonEvent(MouseEvent, true);
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return HandleMouseButtonEvent(MouseEvent, false);
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::HandleMouseButtonEvent(const FPointerEvent& MouseEvent, bool Down)
{
if (Context->GetEnableInput() == false)
{
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiInputCatcherWidget::HandleMouseButtonEvent | Window:%s | Unhandled | EnableInput == false | Down:%d"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"), Down);
return FReply::Unhandled();
}
const uint32 MouseButton = FCogImguiInputHelper::ToImGuiMouseButton(MouseEvent.GetEffectingButton());
ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse);
ImGui::GetIO().AddMouseButtonEvent(MouseButton, Down);
UE_LOG(LogCogImGui, VeryVerbose, TEXT("SCogImguiInputCatcherWidget::HandleMouseButtonEvent | Window:%s | Handled | Down:%d"), Window.IsValid() ? *Window->GetTitle().ToString() : *FString("None"), Down);
return FReply::Handled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
if (Context->GetEnableInput() == false)
{
return FReply::Unhandled();
}
ImGui::GetIO().AddMouseSourceEvent(ImGuiMouseSource_Mouse);
ImGui::GetIO().AddMouseWheelEvent(0, MouseEvent.GetWheelDelta());
return FReply::Handled();
}
//--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiInputCatcherWidget::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
return FReply::Unhandled();
}
//--------------------------------------------------------------------------------------------------------------------------
void SCogImguiInputCatcherWidget::RefreshVisibility()
{
EVisibility DesiredVisiblity = EVisibility::SelfHitTestInvisible;
if (Context->GetEnableInput() && Context->GetShareMouseWithGameplay() == false)
{
DesiredVisiblity = EVisibility::Visible;
}
else
{
DesiredVisiblity = EVisibility::SelfHitTestInvisible;
}
if (DesiredVisiblity != GetVisibility())
{
SetVisibility(DesiredVisiblity);
}
}
@@ -1,6 +1,5 @@
#include "CogImguiInputHelper.h"
#include "CogImGuiInputProcessor.h"
#include "CogImguiKeyInfo.h"
#include "Engine/World.h"
#include "Framework/Application/SlateApplication.h"
@@ -1,49 +0,0 @@
#pragma once
#include "Framework/Application/IInputProcessor.h"
#include "CogImguiContext.h"
class FCogImguiContext;
class SCogImguiWidget;
class UPlayerInput;
enum ImGuiKey : int;
struct FKeyBind;
class FCogImGuiInputProcessor : public IInputProcessor
{
public:
FCogImGuiInputProcessor(UPlayerInput* InPlayerInput, FCogImguiContext* InContext, SCogImguiWidget* InWidget);
virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> SlateCursor) override;
virtual bool HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& Event) override;
virtual bool HandleKeyUpEvent(FSlateApplication& SlateApp, const FKeyEvent& Event) override;
virtual bool HandleAnalogInputEvent(FSlateApplication& SlateApp, const FAnalogInputEvent& Event) override;
virtual bool HandleMouseMoveEvent(FSlateApplication& SlateApp, const FPointerEvent& Event) override;
virtual bool HandleMouseButtonDownEvent(FSlateApplication& SlateApp, const FPointerEvent& Event) override;
virtual bool HandleMouseButtonUpEvent(FSlateApplication& SlateApp, const FPointerEvent& Event) override;
virtual bool HandleMouseButtonDoubleClickEvent(FSlateApplication& SlateApp, const FPointerEvent& Event) override;
virtual bool HandleMouseWheelOrGestureEvent(FSlateApplication& SlateApp, const FPointerEvent& Event, const FPointerEvent* GestureEvent) override;
protected:
bool HandleKeyEvent(FSlateApplication& SlateApp, const FKeyEvent& Event, bool IsKeyDown);
bool HandleMouseButtonEvent(FSlateApplication& SlateApp, const FPointerEvent& Event, bool IsButtonDown);
void AddMousePosEvent(const FVector2D& MousePosition) const;
FCogImguiContext* Context = nullptr;
TObjectPtr<UPlayerInput> PlayerInput;
TObjectPtr<SCogImguiWidget> MainWidget;
};
@@ -18,7 +18,7 @@ class ULocalPlayer;
struct FDisplayMetrics;
struct ImPlotContext;
struct COGIMGUI_API FImGuiViewportData
struct COGIMGUI_API FCogImGuiViewportData
{
TWeakPtr<SWindow> Window = nullptr;
FCogImguiContext* Context = nullptr;
@@ -43,9 +43,9 @@ public:
void SetShareMouse(bool Value);
bool GetShowCursorWhenSharingMouse() const { return bShowCursorWhenSharingMouse; }
bool GetShareMouseWithGameplay() const { return bShareMouseWithGameplay; }
void SetShowCursorWhenSharingMouse(bool Value);
void SetShareMouseWithGameplay(bool Value);
bool GetShareKeyboard() const { return bShareKeyboard; }
@@ -59,10 +59,6 @@ public:
void SetDPIScale(float Value);
void PushCaptureMouse();
void PopCaptureMouse();
TObjectPtr<const UGameViewportClient> GetGameViewport() const { return GameViewport; }
TSharedPtr<const SCogImguiWidget> GetMainWidget() const { return MainWidget; }
@@ -134,9 +130,11 @@ private:
bool bShareMouse = false;
bool bShowCursorWhenSharingMouse = false;
bool bShareMouseWithGameplay = false;
bool bPlayerControllerShowMouse = false;
bool bHasSavedInitialCursorVisibility = false;
bool bIsCursorInitiallyVisible = false;
bool bShareKeyboard = false;
@@ -148,7 +146,5 @@ private:
bool bWantCaptureMouse = false;
int32 CaptureMouseCount = 0;
float DpiScale = 1.f;
};
@@ -0,0 +1,70 @@
#pragma once
#include "CoreMinimal.h"
#include "CogImguiDrawList.h"
#include "Rendering/RenderingCommon.h"
#include "UObject/WeakObjectPtr.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SLeafWidget.h"
class FCogImguiContext;
class SWindow;
class UGameViewportClient;
//--------------------------------------------------------------------------------------------------------------------------
class COGIMGUI_API SCogImguiInputCatcherWidget : public SLeafWidget
{
typedef SLeafWidget Super;
public:
SLATE_BEGIN_ARGS(SCogImguiInputCatcherWidget) {}
SLATE_ARGUMENT(FCogImguiContext*, Context)
SLATE_END_ARGS()
void Construct(const FArguments& InArgs);
~SCogImguiInputCatcherWidget();
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& WidgetStyle, bool bParentEnabled) const override;
virtual bool SupportsKeyboardFocus() const override { return true; }
virtual FReply OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& CharacterEvent) override;
virtual FVector2D ComputeDesiredSize(float Scale) const override;
virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
virtual FReply OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
TSharedPtr<const SWindow> GetWindow() const { return Window; }
void SetWindow(TSharedPtr<SWindow> Value) { Window = Value; }
protected:
FReply HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down);
FReply HandleMouseButtonEvent(const FPointerEvent& MouseEvent, bool Down);
void RefreshVisibility();
FCogImguiContext* Context = nullptr;
TSharedPtr<SWindow> Window = nullptr;
};
@@ -37,13 +37,21 @@ public:
virtual FVector2D ComputeDesiredSize(float Scale) const override;
virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) override;
virtual FReply OnAnalogValueChanged(const FGeometry& MyGeometry, const FAnalogInputEvent& AnalogInputEvent) override;
virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
virtual FReply OnFocusReceived(const FGeometry& MyGeometry, const FFocusEvent& FocusEvent) override;
void SetDrawData(const ImDrawData* InDrawData);
@@ -55,6 +63,7 @@ public:
protected:
FReply HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down);
FReply HandleMouseButtonEvent(const FPointerEvent& MouseEvent, bool Down);
void RefreshVisibility();
@@ -63,11 +72,5 @@ protected:
TSharedPtr<SWindow> Window = nullptr;
FSlateRenderTransform ImGuiRenderTransform;
mutable TArray<FSlateVertex> VertexBuffer;
mutable TArray<SlateIndex> IndexBuffer;
FCogImguiDrawData DrawData;
};
@@ -28,9 +28,7 @@ void FCogWindow_Settings::Initialize()
Context.SetEnableInput(Config->bEnableInput);
Context.SetShareKeyboard(Config->bShareKeyboard);
Context.SetShareMouse(Config->bShareMouse);
Context.SetShowCursorWhenSharingMouse(Config->bShowCursorWhenSharingMouse);
Context.SetShareMouseWithGameplay(Config->bShareMouseWithGameplay);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -47,7 +45,7 @@ void FCogWindow_Settings::PreSaveConfig()
Config->bEnableInput = Context.GetEnableInput();
Config->bShareKeyboard = Context.GetShareKeyboard();
Config->bShareMouse = Context.GetShareMouse();
Config->bShowCursorWhenSharingMouse = Context.GetShowCursorWhenSharingMouse();
Config->bShareMouseWithGameplay = Context.GetShareMouseWithGameplay();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -68,132 +66,119 @@ void FCogWindow_Settings::RenderContent()
}
ImGuiIO& IO = ImGui::GetIO();
FCogImguiContext& Context = GetOwner()->GetContext();
//-----------------------------
// bEnableInput
//-----------------------------
bool bEnableInput = Context.GetEnableInput();
if (ImGui::Checkbox("Enable Input", &bEnableInput))
//-------------------------------------------------------------------------------------------
if (ImGui::CollapsingHeader("Input", ImGuiTreeNodeFlags_DefaultOpen))
{
Context.SetEnableInput(bEnableInput);
}
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
bool bEnableInput = Context.GetEnableInput();
if (ImGui::Checkbox("Enable Input", &bEnableInput))
{
Context.SetEnableInput(bEnableInput);
}
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
const auto ShortcutText = StringCast<ANSICHAR>(*FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
const float ShortcutWidth = (ShortcutText.Get() != nullptr && ShortcutText.Get()[0]) ? ImGui::CalcTextSize(ShortcutText.Get(), NULL).x : 0.0f;
if (ShortcutWidth > 0.0f)
{
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - ShortcutWidth);
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
ImGui::Text("%s", ShortcutText.Get());
ImGui::PopStyleColor();
const auto ShortcutText = StringCast<ANSICHAR>(*FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
const float ShortcutWidth = (ShortcutText.Get() != nullptr && ShortcutText.Get()[0]) ? ImGui::CalcTextSize(ShortcutText.Get(), NULL).x : 0.0f;
if (ShortcutWidth > 0.0f)
{
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - ShortcutWidth);
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
ImGui::Text("%s", ShortcutText.Get());
ImGui::PopStyleColor();
}
//-------------------------------------------------------------------------------------------
bool bShareKeyboard = Context.GetShareKeyboard();
if (ImGui::Checkbox("Share Keyboard", &bShareKeyboard))
{
Context.SetShareKeyboard(bShareKeyboard);
}
ImGui::SetItemTooltip("Forward the keyboard inputs to the game when ImGui does not need them.");
//-------------------------------------------------------------------------------------------
bool bShareMouse = Context.GetShareMouse();
if (ImGui::Checkbox("Share Mouse", &bShareMouse))
{
Context.SetShareMouse(bShareMouse);
}
ImGui::SetItemTooltip("Forward mouse inputs to the game when ImGui does not need them.");
//-------------------------------------------------------------------------------------------
if (bShareMouse == false)
{
ImGui::BeginDisabled();
}
bool bShareMouseWithGameplay = Context.GetShareMouseWithGameplay();
if (ImGui::Checkbox("Share Mouse With Gameplay", &bShareMouseWithGameplay))
{
Context.SetShareMouseWithGameplay(bShareMouseWithGameplay);
}
ImGui::SetItemTooltip("When disabled, mouse inputs are only forwarded to game menus. "
"When enabled, mouse inputs are also forwarded to the gameplay. Note that this mode: \n"
" - Force the cursor to be visible.\n"
" - Prevent the interaction of Cog's transform gizmos.\n"
);
if (bShareMouse == false)
{
ImGui::EndDisabled();
}
//-------------------------------------------------------------------------------------------
ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::SetItemTooltip("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter.");
}
//-----------------------------
// ShareKeyboard
//-----------------------------
bool bShareKeyboard = Context.GetShareKeyboard();
if (ImGui::Checkbox("Share Keyboard", &bShareKeyboard))
{
Context.SetShareKeyboard(bShareKeyboard);
}
ImGui::SetItemTooltip("Forward the keyboard inputs to the game when ImGui does not need them.");
//-----------------------------
// ShareMouse
//-----------------------------
bool bShareMouse = Context.GetShareMouse();
if (ImGui::Checkbox("Share Mouse", &bShareMouse))
{
Context.SetShareMouse(bShareMouse);
}
ImGui::SetItemTooltip("Forward mouse inputs to the game when ImGui does not need them.");
//-----------------------------
// ShowCursorWhenSharingMouse
//-----------------------------
if (bShareMouse == false)
{
ImGui::BeginDisabled();
}
bool bShowCursorWhenSharingMouse = Context.GetShowCursorWhenSharingMouse();
if (ImGui::Checkbox("Show Cursor When Sharing Mouse", &bShowCursorWhenSharingMouse))
{
Context.SetShowCursorWhenSharingMouse(bShowCursorWhenSharingMouse);
}
ImGui::SetItemTooltip("Show the mouse cursor when ImGui share the mouse with the game. Useful for games that require the cursor to be hidden.");
if (bShareMouse == false)
{
ImGui::EndDisabled();
}
//-----------------------------
// NavEnableKeyboard
//-----------------------------
ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::SetItemTooltip("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter.");
//-----------------------------
// NavEnableGamepad
//-----------------------------
//-------------------------------------------------------------------------------------------
//ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
//ImGui::SetItemTooltip("Use the gamepad to navigate in ImGui windows.");
ImGui::Separator();
//-----------------------------
// DPI
//-----------------------------
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::SliderFloat("DPI Scale", &Config->DPIScale, 0.5f, 2.0f, "%.1f");
if (ImGui::IsItemDeactivatedAfterEdit())
//-------------------------------------------------------------------------------------------
if (ImGui::CollapsingHeader("Window", ImGuiTreeNodeFlags_DefaultOpen))
{
SetDPIScale(Config->DPIScale);
}
if (ImGui::BeginItemTooltip())
{
ImGui::TextUnformatted("Change DPi Scale [Mouse Wheel]");
ImGui::TextUnformatted("Reset DPi Scale [Middle Mouse]");
ImGui::EndTooltip();
}
if (ImGui::Checkbox("Enable Viewports", &Config->bEnableViewports))
{
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports);
}
ImGui::SetItemTooltip("Enable moving ImGui windows outside of the main viewport.");
//-----------------------------
// EnableViewports
//-----------------------------
if (ImGui::Checkbox("Enable Viewports", &Config->bEnableViewports))
{
FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports);
}
ImGui::SetItemTooltip("Enable moving ImGui windows outside of the main viewport.");
//-----------------------------
// CompactMode
//-----------------------------
ImGui::Checkbox("Compact Mode", &Config->bCompactMode);
ImGui::SetItemTooltip("Enable compact mode.");
//-------------------------------------------------------------------------------------------
ImGui::Checkbox("Compact Mode", &Config->bCompactMode);
ImGui::SetItemTooltip("Enable compact mode.");
//-----------------------------
// ShowWindowsInMainMenu
//-----------------------------
ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu);
ImGui::SetItemTooltip("Show the content of the windows when hovering the window menu item.");
//-------------------------------------------------------------------------------------------
ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu);
ImGui::SetItemTooltip("Show the content of the windows when hovering the window menu item.");
//-----------------------------
// ShowHelp
//-----------------------------
ImGui::Checkbox("Show Help", &Config->bShowHelp);
ImGui::SetItemTooltip("Show windows help on the window menu items.");
//-------------------------------------------------------------------------------------------
ImGui::Checkbox("Show Help", &Config->bShowHelp);
ImGui::SetItemTooltip("Show windows help on the window menu items.");
ImGui::Separator();
//-------------------------------------------------------------------------------------------
FCogWindowWidgets::SetNextItemToShortWidth();
ImGui::SliderFloat("DPI Scale", &Config->DPIScale, 0.5f, 2.0f, "%.1f");
if (ImGui::IsItemDeactivatedAfterEdit())
{
SetDPIScale(Config->DPIScale);
}
if (ImGui::BeginItemTooltip())
{
ImGui::TextUnformatted("Change DPi Scale [Mouse Wheel]");
ImGui::TextUnformatted("Reset DPi Scale [Middle Mouse]");
ImGui::EndTooltip();
}
}
if (ImGui::Button("Reset All Windows Config", ImVec2(-1.0f, 0.0f)))
//-------------------------------------------------------------------------------------------
if (ImGui::CollapsingHeader("Config"))
{
GetOwner()->ResetAllWindowsConfig();
if (ImGui::Button("Reset All Windows Config", ImVec2(-1.0f, 0.0f)))
{
GetOwner()->ResetAllWindowsConfig();
}
}
}
@@ -67,7 +67,7 @@ public:
bool bShareMouse = false;
UPROPERTY(Config)
bool bShowCursorWhenSharingMouse = false;
bool bShareMouseWithGameplay = false;
UPROPERTY(Config)
bool bShareKeyboard = false;
@@ -75,14 +75,11 @@ public:
UPROPERTY(Config)
bool bNavEnableKeyboard = false;
UPROPERTY(Config)
bool bNavEnableGamepad = false;
//UPROPERTY(Config)
//bool bNavEnableGamepad = false;
UPROPERTY(Config)
bool bNavNoCaptureInput = true;
UPROPERTY(Config)
bool bNoMouseCursorChange = false;
//UPROPERTY(Config)
//bool bNavNoCaptureInput = true;
virtual void Reset() override
{