ImGui::PushFont(render::fonts::header_buttons);
{
const auto menu_items = std::vector<std::string>
{
___(xorstr_("First"), xorstr_(u8"Первая")),
___(xorstr_("Second"), xorstr_(u8"Вторая")),
___(xorstr_("Third"), xorstr_(u8"Третья")),
___(xorstr_("Fourth"), xorstr_(u8"Четвертая")),
___(xorstr_("Fifth"), xorstr_(u8"Пятая")),
___(xorstr_("Sixth"), xorstr_(u8"Шестая"))
};
const auto menu_items_count = menu_items.size();
auto button_width = 102;
auto button_height = 40;
auto total_button_space = button_width * menu_items_count + 5.f * menu_items_count;
//ImGui::SetCursorPosX(window_size.x - total_button_space);
ImGui::PushStyleColor(ImGuiCol_ButtonText, ImVec4(1.f, 1.f, 1.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.1f, 0.1f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.8f, 0.1f, 0.1f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonOutline, ImVec4(0.8f, 0.1f, 0.1f, 1.f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
auto button_color = ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive);
for (size_t k = 0; k < menu_items_count; k++)
{
const auto selected = current_tab == k;
if (selected)
ImGui::PushStyleColor(ImGuiCol_Button, button_color);
if (ImGui::Button(menu_items[k].c_str(), ImVec2(button_width, button_height)))
current_tab = k;
if (selected)
ImGui::PopStyleColor();
if (k != menu_items_count - 1)
ImGui::SameLine();
}
ImGui::PopStyleColor(4);
ImGui::PopStyleVar();
}
ImGui::PopFont();
}
bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
ImVec2 pos = window->DC.CursorPos;
if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrentLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag)
pos.y += window->DC.CurrentLineTextBaseOffset - style.FramePadding.y;
const auto button_size = size_arg;
ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
if (button_size.x == 0)
size.x += 6.f;
if (button_size.y == 0.f)
size.y += 2.f;
const ImRect bb(pos, pos + size);
ItemSize(bb, style.FramePadding.y);
if (!ItemAdd(bb, id))
return false;
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
flags |= ImGuiButtonFlags_Repeat;
bool hovered, held;
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
// Render
RenderNavHighlight(bb, id);
RenderFrame(bb.Min, bb.Max, GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding);
//window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(GetStyleColorVec4(ImGuiCol_ButtonOutline)), 0, 15, style.Alpha);
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_ButtonText));
RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);
ImGui::PopStyleColor();
// Automatically close popups
//if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
// CloseCurrentPopup();
return pressed;
}