Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. ########### imgui_internal.h ~795
  2.  
  3. IMGUI_API bool TriangleButton(bool direction, const char* id, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. ######### imgui.cpp
  11.  
  12. bool ImGui::TriangleButton(bool direction_right, const char* idlabel, const ImVec2& size_arg, ImGuiButtonFlags flags)
  13. {
  14. ImGuiWindow* window = GetCurrentWindow();
  15. if (window->SkipItems)
  16. return false;
  17. ImGuiContext& g = *GImGui;
  18. const ImGuiStyle& style = g.Style;
  19. const ImGuiID id = window->GetID(idlabel);
  20. const ImVec2 label_size = CalcTextSize("Arrow", NULL, true);
  21.  
  22. ImVec2 pos = window->DC.CursorPos;
  23. 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)
  24. pos.y += window->DC.CurrentLineTextBaseOffset - style.FramePadding.y;
  25. ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
  26.  
  27. const ImRect bb(pos, pos + size);
  28. ItemSize(bb, style.FramePadding.y);
  29. if (!ItemAdd(bb, &id))
  30. return false;
  31.  
  32. if (window->DC.ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
  33. bool hovered, held;
  34. bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
  35.  
  36. // Render
  37.  
  38. 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));
  39. //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)));
  40. if (direction_right)
  41. 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));
  42. else
  43. 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));
  44.  
  45. if (direction_right)
  46. 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);
  47. else
  48. 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);
  49.  
  50.  
  51.  
  52. return pressed;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement