pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
604 stars 91 forks source link

refactor ResizableHandle, add corner resize #79

Closed vertexi closed 6 months ago

vertexi commented 6 months ago

I am not sure this way to factory is elegant, hope it can help.

Any advice? I would like to continue working on this.

pthom commented 6 months ago

My advice to refactor was perhaps difficult, since refactoring it was not easy.

Anyhow, I'm sorry, I preferred the code before your modifications, it was simpler to understand.

Let's restart from my original code, and let's forget about the idea to refactor it (sorry).

My opinions:

vertexi commented 6 months ago

Thanks for your pertinent advice, I learned c++ refactoring skills from it.

Also, in the original version, there was no detection of whether the current focused window was the main viewport or not, so when using the multiple viewports feature, dragging other viewports onto the main window would cause the main window boundary to change by mistake.

My original detection code raises the segmentation fault

        // check if main viewport focused
        // This test can raise a segmentation fault!!! => disabled
//        if (GImGui->WindowsFocusOrder.back()->Viewport->Idx != 0)
//        {
//            return;
//        }

I've modified it as follows, possibly fixing it

        // check if main viewport focused
        // This test can raise a segmentation fault!!! => disabled
        if (GImGui->WindowsFocusOrder.empty()) return;
        auto& windowFocused = GImGui->WindowsFocusOrder.back();
        if (windowFocused == NULL) return;
        auto& viewportFocused = windowFocused->Viewport;
        int viewportFocusedIdx = viewportFocused ? viewportFocused->Idx : -1;
        if (viewportFocusedIdx != 0)
        {
            return;
        }

Thanks again for your suggestion, I hope it helps.

pthom commented 6 months ago

Hello,

Sorry for the delay. I implemented movable and resizable borderless windows. Since it requires lots of testings (Glfw, Sdl, OpenGl, Vulkan, Windows, Mac, Linux) I preferred to implement it myself.

It is now available. See https://github.com/pthom/hello_imgui/commit/9315d940da2bd570c64964f1c47e077c277a2a5b

Happy new year!