1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Draw title bar correctly when no title bar buttons exist

This commit is contained in:
Justus Garbe 2023-08-13 23:54:22 +02:00
parent 2059ad82c3
commit 33e9ad7775

View File

@ -258,6 +258,7 @@ namespace hex {
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons(); auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
// Draw custom title bar buttons // Draw custom title bar buttons
if(!titleBarButtons.empty()) {
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * (4 + titleBarButtons.size())); ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * (4 + titleBarButtons.size()));
for (const auto &[icon, tooltip, callback]: titleBarButtons) { for (const auto &[icon, tooltip, callback]: titleBarButtons) {
if (ImGui::TitleBarButton(icon.c_str(), buttonSize)) { if (ImGui::TitleBarButton(icon.c_str(), buttonSize)) {
@ -265,6 +266,7 @@ namespace hex {
} }
ImGui::InfoTooltip(LangEntry(tooltip)); ImGui::InfoTooltip(LangEntry(tooltip));
} }
}
// Draw minimize, restore and maximize buttons // Draw minimize, restore and maximize buttons
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 3); ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * 3);
@ -306,6 +308,7 @@ namespace hex {
auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons(); auto &titleBarButtons = ContentRegistry::Interface::impl::getTitleBarButtons();
// Draw custom title bar buttons // Draw custom title bar buttons
if(!titleBarButtons.empty()) {
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * (titleBarButtons.size() + 0.5)); ImGui::SetCursorPosX(ImGui::GetWindowWidth() - buttonSize.x * (titleBarButtons.size() + 0.5));
for (const auto &[icon, tooltip, callback]: titleBarButtons) { for (const auto &[icon, tooltip, callback]: titleBarButtons) {
if (ImGui::TitleBarButton(icon.c_str(), buttonSize)) { if (ImGui::TitleBarButton(icon.c_str(), buttonSize)) {
@ -313,6 +316,7 @@ namespace hex {
} }
ImGui::InfoTooltip(LangEntry(tooltip)); ImGui::InfoTooltip(LangEntry(tooltip));
} }
}
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
ImGui::PopStyleVar(); ImGui::PopStyleVar();