imgui icon indicating copy to clipboard operation
imgui copied to clipboard

All the windows in dockspace have rounded top corners

Open GasimGasimzada opened this issue 3 years ago • 0 comments

Version/Branch of Dear ImGui:

Version: latest Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + Custom Vulkan backend

My Issue/Question:

I have a Dockspace that is positioned after main menu bar + a custom "Toolbar" window. All my windows have rounding when they are detached. However, when the window is docked, I want the top corners of the window (left most window == top-left, right most window == top-right) to not be rounded.

Is there something that I can do to turn off the rounding.

Screenshots/Video

Top left corner of "Hierarchy" panel

image

Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)

auto &style = ImGui::GetStyle();
style.WindowRounding = 8.0f;

static constexpr float ToolbarHeight = 60.0f;

if (ImGui::BeginMainMenuBar()) {
  // whatever here
  ImGui::EndMainMenuBar();
}

// Make the window full width
ImGui::SetNextWindowSize(ImVec2(ImGui::GetMainViewport()->Size.x, ToolbarHeight ));

// Start from the end of main menu bar
ImGui::SetNextWindowPos(ImVec2(0.0f, ImGui::GetFrameHeight()));

// Remove rounding (default rounding = 8.0f)
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
if (ImGui::Begin("Toolbar", 0,
  ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove |
  ImGuiWindowFlags_NoResize |
  ImGuiWindowFlags_NoSavedSettings |
  ImGuiWindowFlags_NoDocking
)) {
  ImGui::Text("Hello world");
}

ImGui::End();

{
const float WINDOW_AND_STATUS_BAR_HEIGHT = ImGui::GetFrameHeight() * 2.0f;
const auto &viewport = ImGui::GetMainViewport();

// Start from end of Toolbar (MenuBar height + Toolbar height)
ImGui::SetNextWindowPos(
  ImVec2(viewport->Pos.x,
         viewport->Pos.y + ImGui::GetFrameHeight() + ToolbarHeight));

// Layout:
// MainMenuBar + Toolbar + Dockspace + Status bar
// Removing the other window heights from Dockspace
ImGui::SetNextWindowSize(ImVec2(
    // Extract status bar from viewport size
    viewport->Size.x,
    viewport->Size.y - WINDOW_AND_STATUS_BAR_HEIGHT - ToolbarHeight));
ImGui::SetNextWindowViewport(viewport->ID);

// Remove rounding and border size
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);

// Dockspace flags
ImGuiWindowFlags flags =
    ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs |
    ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollWithMouse |
    ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBackground |
    ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoDocking;

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("LiquidatorDockspaceMain", nullptr, flags);
ImGui::PopStyleVar();
ImGui::PopStyleVar(2);

auto dockspaceId = ImGui::GetID("Dockspace");
ImGui::DockSpace(dockspaceId, ImVec2{0.0f, 0.0f},
                 ImGuiDockNodeFlags_PassthruCentralNode);
}

// I am using Dockbuilder API here but it does not matter for
// this example

ImGui::DockBuilderSetNodeSize(dockspaceId, viewport->Size);
ImGui::End();

// Create test window and attach it to the dockspace
if (ImGui::Begin()) {
  ImGui::Text("Test window");
}
ImGui::End();

GasimGasimzada avatar Jul 31 '22 12:07 GasimGasimzada