mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 15:50:25 +01:00
Internals: Renamed one of the arrow functions so their name don't collide.
This commit is contained in:
parent
ff83d0e369
commit
3a522b2400
53
imgui.cpp
53
imgui.cpp
@ -4716,11 +4716,23 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
|
||||
}
|
||||
}
|
||||
|
||||
// Render a triangle to denote expanded/collapsed state
|
||||
// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.
|
||||
void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
|
||||
case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
void ImGui::RenderArrow(ImVec2 p_min, ImGuiDir dir, float scale)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
const float h = g.FontSize * 1.00f;
|
||||
float r = h * 0.40f * scale;
|
||||
@ -4732,18 +4744,16 @@ void ImGui::RenderArrow(ImVec2 p_min, ImGuiDir dir, float scale)
|
||||
case ImGuiDir_Up:
|
||||
case ImGuiDir_Down:
|
||||
if (dir == ImGuiDir_Up) r = -r;
|
||||
center.y -= r * 0.25f;
|
||||
a = ImVec2(0,1) * r;
|
||||
b = ImVec2(-0.866f,-0.5f) * r;
|
||||
c = ImVec2(+0.866f,-0.5f) * r;
|
||||
a = ImVec2(+0.000f,+0.750f) * r;
|
||||
b = ImVec2(-0.866f,-0.750f) * r;
|
||||
c = ImVec2(+0.866f,-0.750f) * r;
|
||||
break;
|
||||
case ImGuiDir_Left:
|
||||
case ImGuiDir_Right:
|
||||
if (dir == ImGuiDir_Left) r = -r;
|
||||
center.x -= r * 0.25f;
|
||||
a = ImVec2(1,0) * r;
|
||||
b = ImVec2(-0.500f,+0.866f) * r;
|
||||
c = ImVec2(-0.500f,-0.866f) * r;
|
||||
a = ImVec2(+0.750f,+0.000f) * r;
|
||||
b = ImVec2(-0.750f,+0.866f) * r;
|
||||
c = ImVec2(-0.750f,-0.866f) * r;
|
||||
break;
|
||||
case ImGuiDir_None:
|
||||
case ImGuiDir_COUNT:
|
||||
@ -4751,7 +4761,7 @@ void ImGui::RenderArrow(ImVec2 p_min, ImGuiDir dir, float scale)
|
||||
break;
|
||||
}
|
||||
|
||||
window->DrawList->AddTriangleFilled(center + a, center + b, center + c, GetColorU32(ImGuiCol_Text));
|
||||
g.CurrentWindow->DrawList->AddTriangleFilled(center + a, center + b, center + c, GetColorU32(ImGuiCol_Text));
|
||||
}
|
||||
|
||||
void ImGui::RenderBullet(ImVec2 pos)
|
||||
@ -12551,25 +12561,12 @@ bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags fl
|
||||
return true;
|
||||
}
|
||||
|
||||
// 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.
|
||||
static void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
|
||||
case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
|
||||
case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings
|
||||
}
|
||||
}
|
||||
|
||||
static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w)
|
||||
{
|
||||
RenderArrow(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32_BLACK);
|
||||
RenderArrow(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32_WHITE);
|
||||
RenderArrow(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32_BLACK);
|
||||
RenderArrow(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32_WHITE);
|
||||
ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32_BLACK);
|
||||
ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32_WHITE);
|
||||
ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32_BLACK);
|
||||
ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32_WHITE);
|
||||
}
|
||||
|
||||
// ColorPicker
|
||||
|
@ -1162,6 +1162,7 @@ namespace ImGui
|
||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, int rounding_corners_flags = ~0);
|
||||
IMGUI_API void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale = 1.0f);
|
||||
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col, float sz);
|
||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||
|
Loading…
Reference in New Issue
Block a user