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& color, const ImVec4& borderColor, float rounding, RenderPosition position, float horizontalDistance, float topDistance, const std::function<void()>& onRender) { ImGui::PushStyleColor(ImGuiCol_ChildBg, color); ImGui::PushStyleColor(ImGuiCol_Border, borderColor); ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, rounding); ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
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(1); 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) { ImVec2 windowPos = ImGui::GetWindowPos(); ImVec2 windowSize = ImGui::GetWindowSize();
ImVec2 rectMin = ImVec2(windowPos.x + 2, windowPos.y); ImVec2 rectMax = ImVec2(windowPos.x + windowSize.x - 2, windowPos.y + height + 1); ImGui::GetWindowDrawList()->AddRectFilled(rectMin, rectMax, ImGui::ColorConvertFloat4ToU32(bgColor), topRadius, ImDrawFlags_RoundCornersTop); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + height);}
Window->CreateChild("Char", ImVec2(350, 50), BgNone, BorderColor, 5.0f, RenderPosition::LEFT, 0.0f, 0.0f, & { Window->TitleBar(50.0f, 5.0f, TitleColor, BorderColor); });
Quando eu defino ImGuiStyleVar_ChildBorderSize como 1, ele não está escrevendo a borda até o fim da linha, 1px de distancia está sendo escrito a titlebar tanto right como leaft
- Assistant