ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.12k stars 10.3k forks source link

Suggestions to achieve this #1742

Closed Tonyx97 closed 6 years ago

Tonyx97 commented 6 years ago

Hey guys, I've been messing with ImGui for some time but I didn't go into some "advanced" stuff. I researched some info about what I want to do but I didn't find a good way to do it. My goal is to make a simple editor layout distribution like simplified Unity editor, something like this. I tried Omar splitter code but there is a little problem, I would like to resize the black bars like others editors out there and keep the game/scene viewport rendering correctly resized. I currently have everything setup but I don't know exactly how to proceed, here you can see how I render the fbo texture into a imgui window. Do you have any suggestions to resize the game/scene so it adapts to the current gui distribution? Would a unique global window be better to put everything there or should I go with many windows? I'd like to get some suggestions if possible, thanks in advance.

nem0 commented 6 years ago

see #351

dhiahassen commented 6 years ago

what you are looking for is called docking system , lumix engine offers a docking system for imgui https://github.com/nem0/LumixEngine/blob/master/external/imgui/imgui_dock.h

OvermindDL1 commented 6 years ago

@dhiahassen That doesn't look as powerful as #351 though?

ocornut commented 6 years ago

Lumix Docking system and its various forks are currently a good public implementation to use (the later shots/gifs in #351 are for an unfinished branch).

There's a list/recap of docking systems here: https://github.com/ocornut/imgui/wiki

Closing this.

dhiahassen commented 6 years ago

@OvermindDL1 No , i guess lumix docking system is better , actually , what you pointed to is the same but an older version , i have been working with lumix docking system for 1,5 year and it has only some bugs so far , the first is the hightlight of the docking region when moving a window and trying to dock it , that hightlight is sometimes wrong ( out of edges ) , another bug is , a window of title "Root" appears sometimes in the docking switch panel when more then one window are overlapping in a same dock region , also you better never title your window with spaces ( i have fixed this in my version ) , and a feature request would be setting min_size / max_size for each window ( i have implemented this ) and also another feature request is allowing some Windows to not have top title panels ( i have done this )

dhiahassen commented 6 years ago

I have fixed a bug , and want to thank you for motivating me , if someone uses imgui_dock the function getDockedRect() should be edited to :

    static ImRect getDockedRect(const ImRect& rect, Slot_ dock_slot)
    {
        ImVec2 size = rect.GetSize();
        switch (dock_slot)
        {
            default: return rect;
            case Slot_Top: return ImRect(rect.Min, rect.Min + ImVec2(size.x , size.y * 0.5));
            case Slot_Right: return ImRect(rect.Min + ImVec2(size.x * 0.5, 0), rect.Max);
            case Slot_Bottom: return ImRect(rect.Min + ImVec2(0, size.y * 0.5), rect.Max);
            case Slot_Left: return ImRect(rect.Min, rect.Min + ImVec2(size.x * 0.5, rect.GetSize().y));
        }
    }

and now the bug i told you about : "the hightlight of the docking region when moving a window and trying to dock it , that hightlight is sometimes wrong ( out of edges ) " is now fixed 😃

ocornut commented 6 years ago

@dhiahassen Please post in the right topic for this to be useful.. no one will find it here.

nem0 commented 6 years ago

@dhiahassen thanks, fixed