MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / BeginViewportSideBar

Method BeginViewportSideBar

KBotExt/imgui/imgui_widgets.cpp:7044–7077  ·  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

7042// FIXME: Somehow overlapping with docking tech.
7043// FIXME: The "rect-cut" aspect of this could be formalized into a lower-level helper (rect-cut: https://halt.software/dead-simple-layouts)
7044bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, ImGuiDir dir, float axis_size, ImGuiWindowFlags window_flags)
7045{
7046 IM_ASSERT(dir != ImGuiDir_None);
7047
7048 ImGuiWindow* bar_window = FindWindowByName(name);
7049 if (bar_window == NULL || bar_window->BeginCount == 0)
7050 {
7051 // Calculate and set window size/position
7052 ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport());
7053 ImRect avail_rect = viewport->GetBuildWorkRect();
7054 ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
7055 ImVec2 pos = avail_rect.Min;
7056 if (dir == ImGuiDir_Right || dir == ImGuiDir_Down)
7057 pos[axis] = avail_rect.Max[axis] - axis_size;
7058 ImVec2 size = avail_rect.GetSize();
7059 size[axis] = axis_size;
7060 SetNextWindowPos(pos);
7061 SetNextWindowSize(size);
7062
7063 // Report our size into work area (for next frame) using actual window size
7064 if (dir == ImGuiDir_Up || dir == ImGuiDir_Left)
7065 viewport->BuildWorkOffsetMin[axis] += axis_size;
7066 else if (dir == ImGuiDir_Down || dir == ImGuiDir_Right)
7067 viewport->BuildWorkOffsetMax[axis] -= axis_size;
7068 }
7069
7070 window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
7071 PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
7072 PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
7073 bool is_open = Begin(name, NULL, window_flags);
7074 PopStyleVar(2);
7075
7076 return is_open;
7077}
7078
7079bool ImGui::BeginMainMenuBar()
7080{

Callers

nothing calls this directly

Calls 3

ImVec2Function · 0.85
GetBuildWorkRectMethod · 0.80
GetSizeMethod · 0.80

Tested by

no test coverage detected