SFML community forums

Help => Graphics => Topic started by: binbinhfr on April 28, 2020, 11:39:21 pm

Title: ImGui-SFML / problem with resizing cursor
Post by: binbinhfr on April 28, 2020, 11:39:21 pm
Hi,

this thread is about a problem encountered in ImGUI-SFML, a backend to the wonderful ImGUI, written using SFML by @eliasdaler.
https://github.com/eliasdaler/imgui-sfml
https://github.com/ocornut/imgui

the problem is described here :
https://github.com/eliasdaler/imgui-sfml/issues/119
and also here with screenshots :
https://github.com/eliasdaler/imgui-sfml/pull/110

It concerns the resizing cursor that does not show anymore on the main window borders, when the cursor is handled by the ImGui-SFML (on ImGUI widgets only, not on the rest of the app). It does not show, but the resizing still works.

As you can read, I got in touch with @eliasdaler to solve this problem, but he thinks that it comes from SFML, so we will see if people around here can find an idea...  ;)

Title: Re: ImGui-SFML / problem with resizing cursor
Post by: binbinhfr on April 30, 2020, 11:36:58 pm
no one encounters this problem of resize cursor (double arrow) not appearing correctly on window borders ? I really don't understand why it does not appear anymore when I'm using ImGui-SFML...
Title: Re: ImGui-SFML / problem with resizing cursor
Post by: Elias Daler on May 01, 2020, 12:19:34 am
This is a relatively minor problem with no easy fix. In the past I've devoted something like 6 hours trying to find the solution, but didn't find any.
Title: Re: ImGui-SFML / problem with resizing cursor
Post by: binbinhfr on May 01, 2020, 11:41:21 am
Yes it's a minor problem, but in window mode, it was not easy to resize the main window anymore. Not clean.

But I just found a workaround. For those who may need it, it consists in switching the ImGuiConfigFlags_NoMouseCursorChange flag when ImGui really needs it.

Here is the code (it's a raw copy of my code, just to understand the principle, you'll have to adapt to your own code). It must be set between the events polling and the ImGUI update.

Quote
      static ImGuiIO& ioImgui = ImGui::GetIO();

      static bool imguiHasCursorPrev = true;
      bool imguiHasCursor = ioImgui.WantCaptureMouse || ioImgui.WantCaptureKeyboard;

      if (imguiHasCursor != imguiHasCursorPrev)
      {
         if (imguiHasCursor)
         {
            ioImgui.ConfigFlags &= !ImGuiConfigFlags_NoMouseCursorChange;
         }
         else
         {
            ioImgui.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
            window.setMouseCursor(cursorDefault);
         }
         imguiHasCursorPrev = imguiHasCursor;
      }


note : "window" is my main sfml window.
and    cursorDefault.loadFromSystem(sf::Cursor::Arrow);