tenho seguinte código c++ void CWindow::CreateChild(const std::string& title, const…
- User
tenho seguinte código c++
void CWindow::CreateChild(const std::string& title, const ImVec2& size, const ImVec4& BgCcolor, const ImVec4& borderColor, float rounding, RenderPosition position, float horizontalDistance, float topDistance, const std::function<void()>& onRender) { ImGui::PushStyleColor(ImGuiCol_ChildBg, BgCcolor); ImGui::PushStyleColor(ImGuiCol_Border, borderColor); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 3.0f); ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, rounding);
ImVec2 parentPos = ImGui::GetWindowPos(); ImVec2 parentSize = ImGui::GetWindowSize(); ImVec2 childPos; switch (position) { case RenderPosition::CENTER: childPos = ImVec2(parentPos.x + (parentSize.x - size.x) / 2, parentPos.y + topDistance); break; case RenderPosition::RIGHT: childPos = ImVec2(parentPos.x + parentSize.x - size.x - horizontalDistance, parentPos.y + topDistance); break; case RenderPosition::LEFT: childPos = ImVec2(parentPos.x + horizontalDistance, parentPos.y + topDistance); break; } ImGui::SetCursorScreenPos(childPos); ImGui::BeginChild(title.c_str(), size, true, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar); if (onRender) { onRender(); } ImGui::PopStyleVar(3); ImGui::PopStyleColor(2); ImGui::EndChild(); ImGui::SetCursorScreenPos(ImVec2(childPos.x + size.x + horizontalDistance, childPos.y));}
void CWindow::TitleBar(float height, float topRadius, const ImVec4& bgColor, const ImVec4& borderColor) { ImGui::SetCursorPos(ImVec2(0, 0));
ImVec2 cursorPos = ImGui::GetCursorScreenPos(); float contentWidth = ImGui::GetWindowSize().x; ImVec2 rectMin = cursorPos; ImVec2 rectMax = ImVec2(cursorPos.x + contentWidth, cursorPos.y + height); ImGui::GetWindowDrawList()->AddRectFilled(rectMin, rectMax, ImGui::ColorConvertFloat4ToU32(bgColor), topRadius, ImDrawFlags_RoundCornersTop); ImGui::GetWindowDrawList()->AddLine(ImVec2(rectMin.x, rectMax.y), ImVec2(rectMax.x, rectMax.y), ImGui::ColorConvertFloat4ToU32(borderColor), 1.0f); ImGui::SetCursorScreenPos(ImVec2(cursorPos.x, cursorPos.y + height));}
Quando eu defino o tamanho da borda para ImGuiStyleVar_ChildBorderSize igual 3 o titlebar não desenha o rect corretamente em toda a janela do CreateChild, ele fica 1px de distancia do top, leaft e right
- Assistant