Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########### imgui_internal.h ~795
- IMGUI_API bool TriangleButton(bool direction, const char* id, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
- ######### imgui.cpp
- bool ImGui::TriangleButton(bool direction_right, const char* idlabel, 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(idlabel);
- const ImVec2 label_size = CalcTextSize("Arrow", 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;
- ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
- const ImRect bb(pos, pos + size);
- ItemSize(bb, style.FramePadding.y);
- if (!ItemAdd(bb, &id))
- return false;
- if (window->DC.ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
- bool hovered, held;
- bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
- // Render
- const ImU32 col = ImGui::GetColorU32(ImVec4(g_cfg.menu.menu_theme.r(), g_cfg.menu.menu_theme.g(), g_cfg.menu.menu_theme.b(), hovered || held ? 210 / 255.f : 160 / 255.f));
- //window->DrawList->AddRectFilledMultiColor(bb.Min, bb.Max, GetColorU32(ImColor(202, 45, 100, 255)), GetColorU32(ImColor(202, 45, 100, 255)), GetColorU32(ImColor(172, 39, 86, 255)), GetColorU32(ImColor(172, 39, 86, 255)));
- if (direction_right)
- window->DrawList->AddTriangleFilled(ImVec2(bb.Min.x, bb.Min.y + size_arg.y), ImVec2(bb.Min.x + size_arg.x, bb.Min.y + (size_arg.y / 2)), ImVec2(bb.Min.x, bb.Min.y), ImColor(21, 21, 21, 255));
- else
- window->DrawList->AddTriangleFilled(ImVec2(bb.Min.x + size_arg.x, bb.Min.y + size_arg.y), ImVec2(bb.Min.x, bb.Min.y + (size_arg.y / 2)), ImVec2(bb.Min.x + size_arg.x, bb.Min.y), ImColor(21, 21, 21, 255));
- if (direction_right)
- window->DrawList->AddTriangle(ImVec2(bb.Min.x, bb.Min.y + size_arg.y), ImVec2(bb.Min.x + size_arg.x, bb.Min.y + (size_arg.y / 2)), ImVec2(bb.Min.x, bb.Min.y), col);
- else
- window->DrawList->AddTriangle(ImVec2(bb.Min.x + size_arg.x, bb.Min.y + size_arg.y), ImVec2(bb.Min.x, bb.Min.y + (size_arg.y / 2)), ImVec2(bb.Min.x + size_arg.x, bb.Min.y), col);
- return pressed;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement