mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Fix combobox callback impl (#2347)
* Fix combobox callback impl * Make ImGuiBackend delegates public * Release ImGui focus when the game window loses focus
This commit is contained in:
parent
27f924f3b1
commit
1f06006cc0
8 changed files with 36 additions and 22 deletions
|
|
@ -0,0 +1,4 @@
|
|||
namespace Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
|
||||
/// <summary>Delegate to be called when ImGui should be used to layout now.</summary>
|
||||
public delegate void ImGuiBuildUiDelegate();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
namespace Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
|
||||
/// <summary>Delegate to be called on new input frame.</summary>
|
||||
public delegate void ImGuiNewInputFrameDelegate();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
namespace Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
|
||||
/// <summary>Delegate to be called on new render frame.</summary>
|
||||
public delegate void ImGuiNewRenderFrameDelegate();
|
||||
|
|
@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
|
|||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Bindings.ImGuizmo;
|
||||
using Dalamud.Bindings.ImPlot;
|
||||
using Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
using Dalamud.Interface.ImGuiBackend.Helpers;
|
||||
using Dalamud.Interface.ImGuiBackend.InputHandler;
|
||||
using Dalamud.Interface.ImGuiBackend.Renderers;
|
||||
|
|
@ -93,13 +94,13 @@ internal sealed unsafe class Dx11Win32Backend : IWin32Backend
|
|||
~Dx11Win32Backend() => this.ReleaseUnmanagedResources();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IImGuiBackend.BuildUiDelegate? BuildUi;
|
||||
public event ImGuiBuildUiDelegate? BuildUi;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IImGuiBackend.NewInputFrameDelegate? NewInputFrame;
|
||||
public event ImGuiNewInputFrameDelegate? NewInputFrame;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IImGuiBackend.NewRenderFrameDelegate? NewRenderFrame;
|
||||
public event ImGuiNewRenderFrameDelegate? NewRenderFrame;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool UpdateCursor
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Dalamud.Interface.ImGuiBackend.InputHandler;
|
||||
using Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
using Dalamud.Interface.ImGuiBackend.InputHandler;
|
||||
using Dalamud.Interface.ImGuiBackend.Renderers;
|
||||
|
||||
namespace Dalamud.Interface.ImGuiBackend;
|
||||
|
|
@ -6,23 +7,14 @@ namespace Dalamud.Interface.ImGuiBackend;
|
|||
/// <summary>Backend for ImGui.</summary>
|
||||
internal interface IImGuiBackend : IDisposable
|
||||
{
|
||||
/// <summary>Delegate to be called when ImGui should be used to layout now.</summary>
|
||||
public delegate void BuildUiDelegate();
|
||||
|
||||
/// <summary>Delegate to be called on new input frame.</summary>
|
||||
public delegate void NewInputFrameDelegate();
|
||||
|
||||
/// <summary>Delegaet to be called on new render frame.</summary>
|
||||
public delegate void NewRenderFrameDelegate();
|
||||
|
||||
/// <summary>User methods invoked every ImGui frame to construct custom UIs.</summary>
|
||||
event BuildUiDelegate? BuildUi;
|
||||
event ImGuiBuildUiDelegate? BuildUi;
|
||||
|
||||
/// <summary>User methods invoked every ImGui frame on handling inputs.</summary>
|
||||
event NewInputFrameDelegate? NewInputFrame;
|
||||
event ImGuiNewInputFrameDelegate? NewInputFrame;
|
||||
|
||||
/// <summary>User methods invoked every ImGui frame on handling renders.</summary>
|
||||
event NewRenderFrameDelegate? NewRenderFrame;
|
||||
event ImGuiNewRenderFrameDelegate? NewRenderFrame;
|
||||
|
||||
/// <summary>Gets or sets a value indicating whether the cursor should be overridden with the ImGui cursor.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -374,6 +374,14 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler
|
|||
case WM.WM_DISPLAYCHANGE:
|
||||
this.viewportHandler.UpdateMonitors();
|
||||
break;
|
||||
|
||||
case WM.WM_KILLFOCUS when hWndCurrent == this.hWnd:
|
||||
if (!ImGui.IsAnyMouseDown() && GetCapture() == hWndCurrent)
|
||||
ReleaseCapture();
|
||||
|
||||
ImGui.GetIO().WantCaptureMouse = false;
|
||||
ImGui.ClearWindowFocus();
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using Dalamud.Hooking;
|
|||
using Dalamud.Hooking.Internal;
|
||||
using Dalamud.Hooking.WndProcHook;
|
||||
using Dalamud.Interface.ImGuiBackend;
|
||||
using Dalamud.Interface.ImGuiBackend.Delegates;
|
||||
using Dalamud.Interface.ImGuiNotification;
|
||||
using Dalamud.Interface.ImGuiNotification.Internal;
|
||||
using Dalamud.Interface.Internal.Asserts;
|
||||
|
|
@ -128,7 +129,7 @@ internal partial class InterfaceManager : IInternalDisposableService
|
|||
/// <summary>
|
||||
/// This event gets called each frame to facilitate ImGui drawing.
|
||||
/// </summary>
|
||||
public event IImGuiBackend.BuildUiDelegate? Draw;
|
||||
public event ImGuiBuildUiDelegate? Draw;
|
||||
|
||||
/// <summary>
|
||||
/// This event gets called when ResizeBuffers is called.
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ public static unsafe partial class ImGui
|
|||
s.Item2 = s.Item1.Invoke(ref s.Item3, index);
|
||||
if (s.Item2.IsNull)
|
||||
return false;
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.Span[0]));
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.GetPinnableNullTerminatedReference()));
|
||||
return true;
|
||||
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
}
|
||||
|
|
@ -363,7 +363,7 @@ public static unsafe partial class ImGui
|
|||
s.Item2 = s.Item1.Invoke(s.Item3, index);
|
||||
if (s.Item2.IsNull)
|
||||
return false;
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.Span[0]));
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.GetPinnableNullTerminatedReference()));
|
||||
return true;
|
||||
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
}
|
||||
|
|
@ -377,7 +377,7 @@ public static unsafe partial class ImGui
|
|||
s.Item2 = s.Item1.Invoke(index);
|
||||
if (s.Item2.IsNull)
|
||||
return false;
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.Span[0]));
|
||||
*text = (byte*)Unsafe.AsPointer(ref Unsafe.AsRef(in s.Item2.GetPinnableNullTerminatedReference()));
|
||||
return true;
|
||||
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue