MCPcopy Create free account
hub / github.com/RenderKit/embree / RenderArrow

Method RenderArrow

tutorials/common/imgui/imgui_draw.cpp:3754–3783  ·  view source on GitHub ↗

Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state

Source from the content-addressed store, hash-verified

3752
3753// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
3754void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale)
3755{
3756 const float h = draw_list->_Data->FontSize * 1.00f;
3757 float r = h * 0.40f * scale;
3758 ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
3759
3760 ImVec2 a, b, c;
3761 switch (dir)
3762 {
3763 case ImGuiDir_Up:
3764 case ImGuiDir_Down:
3765 if (dir == ImGuiDir_Up) r = -r;
3766 a = ImVec2(+0.000f, +0.750f) * r;
3767 b = ImVec2(-0.866f, -0.750f) * r;
3768 c = ImVec2(+0.866f, -0.750f) * r;
3769 break;
3770 case ImGuiDir_Left:
3771 case ImGuiDir_Right:
3772 if (dir == ImGuiDir_Left) r = -r;
3773 a = ImVec2(+0.750f, +0.000f) * r;
3774 b = ImVec2(-0.750f, +0.866f) * r;
3775 c = ImVec2(-0.750f, -0.866f) * r;
3776 break;
3777 case ImGuiDir_None:
3778 case ImGuiDir_COUNT:
3779 IM_ASSERT(0);
3780 break;
3781 }
3782 draw_list->AddTriangleFilled(center + a, center + b, center + c, col);
3783}
3784
3785void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
3786{

Callers

nothing calls this directly

Calls 2

ImVec2Function · 0.85
AddTriangleFilledMethod · 0.80

Tested by

no test coverage detected