ocornut / imgui

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

Can't hide "Hide tab bar" button when window is in dock #7527

Open AMRD1234 opened 2 months ago

AMRD1234 commented 2 months ago

Version/Branch of Dear ImGui:

Version 1.90.5 (19050) Branch docking

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Windows 10

Full config/build information:

Dear ImGui 1.90.5 (19050)
--------------------------------

sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1939
define: _MSVC_LANG=202002
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------

io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000443
 NavEnableKeyboard
 NavEnableGamepad
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------

io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------

style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 5.00,2.00
style.FrameRounding: 3.00
style.FrameBorderSize: 1.00
style.ItemSpacing: 6.00,6.00
style.ItemInnerSpacing: 6.00,6.00

Details:

My Issue/Question:

greetings. I don't need the collapse button and "Hide tab bar" button for some windows when they are in dock mode,. In dock mode, I cant destroy "Hide tab bar" button. Out Of Docking : 26 In Dock: 27 This is my code : 28

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:


ImGuiWindowFlags toolbar_window_flags = ImGuiWindowFlags_NoCollapse;
ImGui::Begin("ToolBar", NULL, toolbar_window_flags);
ImGui::End();
GamingMinds-DanielC commented 2 months ago

There are no collapse buttons in docked windows, not even if you don't disable them. This is a different button that looks different and serves a different function. It belongs to the dock node itself, not to the docked window(s). That's also why there is only one if you dock multiple windows into the same node.

AMRD1234 commented 2 months ago

Thank you for your answer. So is there a way to remove this button from the dock node? how to initialize that in ImGuiDockNodeFlags to do not create this button? This is my dock code (copied from demo.cpp): void Create_DockSpace() { static bool opt_fullscreen = true; static bool opt_padding = false; static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;

// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
// because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
if (opt_fullscreen)
{
    const ImGuiViewport* viewport = ImGui::GetMainViewport();
    ImGui::SetNextWindowPos(viewport->WorkPos);
    ImGui::SetNextWindowSize(viewport->WorkSize);
    ImGui::SetNextWindowViewport(viewport->ID);
    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
    ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
    window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
    window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
}
else
{
    dockspace_flags &= ~ImGuiDockNodeFlags_PassthruCentralNode;
}

// When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background
// and handle the pass-thru hole, so we ask Begin() to not render a background.
if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
    window_flags |= ImGuiWindowFlags_NoBackground;

// Important: note that we proceed even if Begin() returns false (aka window is collapsed).
// This is because we want to keep our DockSpace() active. If a DockSpace() is inactive,
// all active windows docked into it will lose their parent and become undocked.
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
if (!opt_padding)
    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("DockSpace", NULL, window_flags);
if (!opt_padding)
    ImGui::PopStyleVar();

if (opt_fullscreen)
    ImGui::PopStyleVar(2);

// Submit the DockSpace
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
    ImGuiID dockspace_id = ImGui::GetID("Editor DockSpace");
    ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
}
ImGui::End(); }
GamingMinds-DanielC commented 2 months ago

Thank you for your answer. So is there a way to remove this button from the dock node? how to initialize that in ImGuiDockNodeFlags?

I never tried this specific one myself, but there should be multiple ways. First you need to include imgui_internal.h to have access to the required flag. Along with that comes the warning that this is not a guaranteed stable API, so use at your own risk. Code based on internals can potentially break with future updates, but if you manage your code well (f.e. wrapping access to internals into a small custom extension library) this shouldn't be a problem.

For the entire dock space:

Building the dock nodes manually:

Manipulating the flags of an existing node:

By way of the window(s) docked into the node:

ocornut commented 2 months ago

By way of the window(s) docked into the node: use SetNextWindowClass() to configure the window you are docking into that node have ImGuiWindowClass::DockNodeFlagsOverrideSet include ImGuiDockNodeFlags_NoWindowMenuButton

This is the best and simplest way.

As always the recurrent problem with docking questions is that people want to manipulate a dock node property which is shared by multiple windows, by definition there is a potential conflict, what is 2 windows which have opposite requests are docked together?

AMRD1234 commented 2 months ago

I think I understood it. Thank you, but apparently my question upset you 'ocornut'... Sorry, I'm new to IMGUI and confused, but I'm interested in this API... Maybe my question was ridiculous Anyway, thanks for your reply

ocornut commented 2 months ago

Sorry I didn't meant to suggest i was upset, but because we answer lots of question I'm not always overly enthusiastic.

Your question is not ridiculous. But there isn't a simple solution that works for all situations, and I guess it is frustrating that we don't have a good answer for it yet.

AMRD1234 commented 2 months ago

No problem. I understand that it is difficult for you to answer all the questions and there is no room for despair. I think IMGUI is the best API for UI and I'm eager to learn it and this little problem can't stop me. We look forward to further development of IMGUI and your success.

AMRD1234 commented 1 month ago

34 Hi .. it fixes by seting Window menu Button position to none. Thats so cool. thank you...!