MCPcopy Create free account
hub / github.com/RenderKit/embree / BeginViewportSideBar

Method BeginViewportSideBar

tutorials/common/imgui/imgui_widgets.cpp:6873–6906  ·  view source on GitHub ↗

Important: calling order matters! FIXME: Somehow overlapping with docking tech. FIXME: The "rect-cut" aspect of this could be formalized into a lower-level helper (rect-cut: https://halt.software/dead-simple-layouts)

Source from the content-addressed store, hash-verified

6871// FIXME: Somehow overlapping with docking tech.
6872// FIXME: The "rect-cut" aspect of this could be formalized into a lower-level helper (rect-cut: https://halt.software/dead-simple-layouts)
6873bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, ImGuiDir dir, float axis_size, ImGuiWindowFlags window_flags)
6874{
6875 IM_ASSERT(dir != ImGuiDir_None);
6876
6877 ImGuiWindow* bar_window = FindWindowByName(name);
6878 if (bar_window == NULL || bar_window->BeginCount == 0)
6879 {
6880 // Calculate and set window size/position
6881 ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
6882 ImRect avail_rect = viewport->GetBuildWorkRect();
6883 ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
6884 ImVec2 pos = avail_rect.Min;
6885 if (dir == ImGuiDir_Right || dir == ImGuiDir_Down)
6886 pos[axis] = avail_rect.Max[axis] - axis_size;
6887 ImVec2 size = avail_rect.GetSize();
6888 size[axis] = axis_size;
6889 SetNextWindowPos(pos);
6890 SetNextWindowSize(size);
6891
6892 // Report our size into work area (for next frame) using actual window size
6893 if (dir == ImGuiDir_Up || dir == ImGuiDir_Left)
6894 viewport->BuildWorkOffsetMin[axis] += axis_size;
6895 else if (dir == ImGuiDir_Down || dir == ImGuiDir_Right)
6896 viewport->BuildWorkOffsetMax[axis] -= axis_size;
6897 }
6898
6899 window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
6900 PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
6901 PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
6902 bool is_open = Begin(name, NULL, window_flags);
6903 PopStyleVar(2);
6904
6905 return is_open;
6906}
6907
6908bool ImGui::BeginMainMenuBar()
6909{

Callers

nothing calls this directly

Calls 3

ImVec2Function · 0.85
GetBuildWorkRectMethod · 0.80
GetSizeMethod · 0.80

Tested by

no test coverage detected