segross / UnrealImGui

Unreal plug-in that integrates Dear ImGui framework into Unreal Engine 4.
MIT License
666 stars 211 forks source link

No support for ImGuiBackendFlags_HasMouseCursors / GetMouseCursor() means no resizing from borders/lower-left corner #86

Open ocornut opened 3 months ago

ocornut commented 3 months ago

AFAIK this plugin and all forks that I found about don't set the ImGuiBackendFlags_HasMouseCursors flag. This currently makes dear imgui disable io.ConfigWindowsResizeFromEdges making it not possible to resize from lower-left corner and borders.

I will make a change to dear imgui today to stop disabling io.ConfigWindowsResizeFromEdges when his is not meant, in order to raise awareness that resizing from borders etc. is possible, and possibly raise awareness that backends needs to support changing mouse shape by reading ImGui::GetMouseCursor() and applying the cursor.

For reference, this (unrelated) plugin does it here: https://github.com/Sharundaar/UnrealImGuiDocker/blob/8be9597c9a3d61aef9d65a7a2ac734e916b9be8b/Source/UnrealImGuiDocker/Private/ImGuiSubsystem.cpp#L756

vd->Canvas->SetDesiredCursor(ImGuiInterop::ImguiToSlateCursor(ImGui::GetMouseCursor()));
static EMouseCursor::Type ImguiToSlateCursor(ImGuiMouseCursor ImGuiCursor)
{
    EMouseCursor::Type SlateCursor = EMouseCursor::Default; 
    switch (ImGuiCursor)
    {
    case ImGuiMouseCursor_Arrow:        SlateCursor = EMouseCursor::Default; break;
    case ImGuiMouseCursor_TextInput:    SlateCursor = EMouseCursor::TextEditBeam; break;
    case ImGuiMouseCursor_ResizeAll:    SlateCursor = EMouseCursor::Crosshairs; break;
    case ImGuiMouseCursor_ResizeEW:     SlateCursor = EMouseCursor::ResizeLeftRight; break;
    case ImGuiMouseCursor_ResizeNS:     SlateCursor = EMouseCursor::ResizeUpDown; break;
    case ImGuiMouseCursor_ResizeNESW:   SlateCursor = EMouseCursor::ResizeSouthWest; break;
    case ImGuiMouseCursor_ResizeNWSE:   SlateCursor = EMouseCursor::ResizeSouthEast; break;
    case ImGuiMouseCursor_Hand:         SlateCursor = EMouseCursor::Hand; break;
    case ImGuiMouseCursor_NotAllowed:   SlateCursor = EMouseCursor::Default; break;
    }
    return SlateCursor;
}
TOptional<EMouseCursor::Type> SImGuiCanvas::GetCursor() const
{
    return DesiredCursor;
}