pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping

Home Page:https://pthom.github.io/hello_imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set the no_docking and no_tab_bar for the MainDockSpace ?

juseus03 opened this issue · comments

As the question states, I want to add these flags for the MainDockSpace. Currently, I can do it for all secondary splits via the "node_flags" attribute of each split. Is there a way to get this attribute for the MainDockSpace? I can't find a way to reference to it.

Thanks

I have a idea:

in docking_details.cpp

void ImplProvideFullScreenDockSpace(const ImGuiWindowParams& imGuiWindowParams)
{
    DoCreateFullScreenImGuiWindow(imGuiWindowParams, true);
    ImGuiID mainDockspaceId = ImGui::GetID("MainDockSpace");
    ImGuiDockNodeFlags dockspace_flags =
        ImGuiDockNodeFlags_PassthruCentralNode;  // ImGuiDockNodeFlags_PassthruDockspace;

    if(imGuiWindowParams.Enable_MainDockSpace_KeepAliveOnly)
        dockspace_flags |= ImGuiDockNodeFlags_KeepAliveOnly;
    if(imGuiWindowParams.Enable_MainDockSpace_NoResize)
        dockspace_flags |= ImGuiDockNodeFlags_NoResize;
    if(imGuiWindowParams.Enable_MainDockSpace_NoTabBar)
        dockspace_flags |= ImGuiDockNodeFlags_NoTabBar;
    
    ImGui::DockSpace(mainDockspaceId, ImVec2(0.0f, 0.0f), dockspace_flags);
    gImGuiSplitIDs["MainDockSpace"] = mainDockspaceId;
}

in imgui_window_params.h

struct ImGuiWindowParams
{
    DefaultImGuiWindowType defaultImGuiWindowType = DefaultImGuiWindowType::ProvideFullScreenWindow;

    ImVec4 backgroundColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

    bool showMenuBar = false;
    bool showMenu_App = true;
    bool showMenu_App_Quit = true;
    bool showMenu_View = true;

    bool showStatusBar = false;
    bool showStatus_Fps = true;
    bool rememberStatusBarSettings = true;

    bool configWindowsMoveFromTitleBarOnly = true;

    bool enableViewports = false;

    std::string menuAppTitle = "";

    ImGuiTheme::ImGuiTweakedTheme tweakedTheme;
    bool showMenu_View_Themes = true;
    bool rememberTheme = true;

    bool Enable_MainDockSpace_KeepAliveOnly = false;
    bool Enable_MainDockSpace_NoResize = false;
    bool Enable_MainDockSpace_NoTabBar = false;
};

}  // namespace HelloImGui

Hi, thanks for the proposition. I'm back from a long holiday, but I will check it soon.

Hi,

I implemented something close to your suggestion, however it happens inside DockingParams and it uses the original ImGui flags.

In docking_params.h, we now have:

struct DockingParams
{
    std::vector<DockingSplit>   dockingSplits;
    std::vector<DockableWindow> dockableWindows;

    std::string layoutName = "Default";

    DockingLayoutCondition layoutCondition = DockingLayoutCondition::FirstUseEver;
    bool layoutReset = false;

    // **********************
    //      This was added 
    // **********************
    ImGuiDockNodeFlags mainDockSpaceNodeFlags = ImGuiDockNodeFlags_PassthruCentralNode;

    // Helpers
    DockableWindow * dockableWindowOfName(const std::string& name);
    void focusDockableWindow(const std::string& windowName);
    std::optional<ImGuiID> dockSpaceIdFromName(const std::string& dockSpaceName);
};

And the demo hello_imgui_demodocking will demonstrate the usage interactively:

image