mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 05:27:01 +00:00
ImDrawList: clarified the name of many parameters so reading the code is a little easier. (#2740)
This commit is contained in:
parent
3fb5cf3541
commit
c4ff1b3578
@ -39,6 +39,7 @@ Other Changes:
|
|||||||
when enabled will have small overlap glitches with (style.Alpha < 1.0).
|
when enabled will have small overlap glitches with (style.Alpha < 1.0).
|
||||||
- TabBar: fixed ScrollToBar request creating bouncing loop when tab is larger than available space.
|
- TabBar: fixed ScrollToBar request creating bouncing loop when tab is larger than available space.
|
||||||
- TabBar: fixed single-tab not shrinking their width down.
|
- TabBar: fixed single-tab not shrinking their width down.
|
||||||
|
- ImDrawList: clarified the name of many parameters so reading the code is a little easier. (#2740)
|
||||||
- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
|
- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94)
|
||||||
- Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count,
|
- Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count,
|
||||||
would generally make the debug layer complain (Added in 1.72).
|
would generally make the debug layer complain (Added in 1.72).
|
||||||
|
36
imgui.h
36
imgui.h
@ -1901,33 +1901,39 @@ struct ImDrawList
|
|||||||
inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); }
|
inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); }
|
||||||
|
|
||||||
// Primitives
|
// Primitives
|
||||||
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
// - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners.
|
||||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4-bits corresponding to which corner to round
|
IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // a: upper-left, b: lower-right (== upper-left + size)
|
IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size), rounding_corners_flags: 4-bits corresponding to which corner to round
|
||||||
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All); // a: upper-left, b: lower-right (== upper-left + size)
|
||||||
IMGUI_API void AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
||||||
IMGUI_API void AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col);
|
IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col);
|
||||||
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
|
IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
|
IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col);
|
||||||
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
|
||||||
|
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 12);
|
||||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||||
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,1), ImU32 col = IM_COL32_WHITE);
|
|
||||||
IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a = ImVec2(0,0), const ImVec2& uv_b = ImVec2(1,0), const ImVec2& uv_c = ImVec2(1,1), const ImVec2& uv_d = ImVec2(0,1), ImU32 col = IM_COL32_WHITE);
|
|
||||||
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All);
|
|
||||||
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, bool closed, float thickness);
|
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, bool closed, float thickness);
|
||||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
|
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||||
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
||||||
|
|
||||||
|
// Image primitives
|
||||||
|
// - Read FAQ to understand what ImTextureID is.
|
||||||
|
// - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle.
|
||||||
|
// - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture.
|
||||||
|
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE);
|
||||||
|
IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE);
|
||||||
|
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All);
|
||||||
|
|
||||||
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||||
inline void PathClear() { _Path.Size = 0; }
|
inline void PathClear() { _Path.Size = 0; }
|
||||||
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||||
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||||
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||||
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
|
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10);
|
||||||
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
||||||
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
||||||
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All);
|
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawCornerFlags rounding_corners = ImDrawCornerFlags_All);
|
||||||
|
|
||||||
|
@ -4391,9 +4391,9 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
ImVec2 window_size = ImGui::GetWindowSize();
|
ImVec2 window_size = ImGui::GetWindowSize();
|
||||||
ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
|
ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
|
||||||
if (draw_bg)
|
if (draw_bg)
|
||||||
ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 32, 10+4);
|
ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 48, 10+4);
|
||||||
if (draw_fg)
|
if (draw_fg)
|
||||||
ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 32, 10);
|
ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 48, 10);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
108
imgui_draw.cpp
108
imgui_draw.cpp
@ -860,26 +860,26 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12)
|
void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12)
|
||||||
{
|
{
|
||||||
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
if (radius == 0.0f || a_min_of_12 > a_max_of_12)
|
||||||
{
|
{
|
||||||
_Path.push_back(centre);
|
_Path.push_back(center);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
|
_Path.reserve(_Path.Size + (a_max_of_12 - a_min_of_12 + 1));
|
||||||
for (int a = a_min_of_12; a <= a_max_of_12; a++)
|
for (int a = a_min_of_12; a <= a_max_of_12; a++)
|
||||||
{
|
{
|
||||||
const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
|
const ImVec2& c = _Data->CircleVtx12[a % IM_ARRAYSIZE(_Data->CircleVtx12)];
|
||||||
_Path.push_back(ImVec2(centre.x + c.x * radius, centre.y + c.y * radius));
|
_Path.push_back(ImVec2(center.x + c.x * radius, center.y + c.y * radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments)
|
void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
|
||||||
{
|
{
|
||||||
if (radius == 0.0f)
|
if (radius == 0.0f)
|
||||||
{
|
{
|
||||||
_Path.push_back(centre);
|
_Path.push_back(center);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,7 +889,7 @@ void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float a_min, floa
|
|||||||
for (int i = 0; i <= num_segments; i++)
|
for (int i = 0; i <= num_segments; i++)
|
||||||
{
|
{
|
||||||
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
||||||
_Path.push_back(ImVec2(centre.x + ImCos(a) * radius, centre.y + ImSin(a) * radius));
|
_Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,44 +968,46 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness)
|
void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
PathLineTo(a + ImVec2(0.5f,0.5f));
|
PathLineTo(p1 + ImVec2(0.5f, 0.5f));
|
||||||
PathLineTo(b + ImVec2(0.5f,0.5f));
|
PathLineTo(p2 + ImVec2(0.5f, 0.5f));
|
||||||
PathStroke(col, false, thickness);
|
PathStroke(col, false, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
|
// p_min = upper-left, p_max = lower-right
|
||||||
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness)
|
// Note we don't render 1 pixels sized rectangles properly.
|
||||||
|
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
if (Flags & ImDrawListFlags_AntiAliasedLines)
|
||||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.50f,0.50f), rounding, rounding_corners);
|
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.50f,0.50f), rounding, rounding_corners);
|
||||||
else
|
else
|
||||||
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
PathRect(p_min + ImVec2(0.50f,0.50f), p_max - ImVec2(0.49f,0.49f), rounding, rounding_corners); // Better looking lower-right corner and rounded non-AA shapes.
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
if (rounding > 0.0f)
|
if (rounding > 0.0f)
|
||||||
{
|
{
|
||||||
PathRect(a, b, rounding, rounding_corners);
|
PathRect(p_min, p_max, rounding, rounding_corners);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimRect(a, b, col);
|
PrimRect(p_min, p_max, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
// p_min = upper-left, p_max = lower-right
|
||||||
|
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
||||||
{
|
{
|
||||||
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1014,77 +1016,77 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32
|
|||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2));
|
||||||
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx+3));
|
||||||
PrimWriteVtx(a, uv, col_upr_left);
|
PrimWriteVtx(p_min, uv, col_upr_left);
|
||||||
PrimWriteVtx(ImVec2(c.x, a.y), uv, col_upr_right);
|
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
|
||||||
PrimWriteVtx(c, uv, col_bot_right);
|
PrimWriteVtx(p_max, uv, col_bot_right);
|
||||||
PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
|
PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness)
|
void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathLineTo(d);
|
PathLineTo(p4);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col)
|
void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathLineTo(d);
|
PathLineTo(p4);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
|
void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
|
void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PathLineTo(a);
|
PathLineTo(p1);
|
||||||
PathLineTo(b);
|
PathLineTo(p2);
|
||||||
PathLineTo(c);
|
PathLineTo(p3);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments, float thickness)
|
void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathArcTo(centre, radius-0.5f, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments)
|
void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathArcTo(centre, radius, 0.0f, a_max, num_segments - 1);
|
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1132,7 +1134,7 @@ void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, c
|
|||||||
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col)
|
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1142,13 +1144,13 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const Im
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimRectUV(a, b, uv_a, uv_b, col);
|
PrimRectUV(p_min, p_max, uv_min, uv_max, col);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
|
void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
@ -1158,20 +1160,20 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, cons
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
PrimReserve(6, 4);
|
PrimReserve(6, 4);
|
||||||
PrimQuadUV(a, b, c, d, uv_a, uv_b, uv_c, uv_d, col);
|
PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
|
if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
|
||||||
{
|
{
|
||||||
AddImage(user_texture_id, a, b, uv_a, uv_b, col);
|
AddImage(user_texture_id, p_min, p_max, uv_min, uv_max, col);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,10 +1182,10 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, c
|
|||||||
PushTextureID(user_texture_id);
|
PushTextureID(user_texture_id);
|
||||||
|
|
||||||
int vert_start_idx = VtxBuffer.Size;
|
int vert_start_idx = VtxBuffer.Size;
|
||||||
PathRect(a, b, rounding, rounding_corners);
|
PathRect(p_min, p_max, rounding, rounding_corners);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
int vert_end_idx = VtxBuffer.Size;
|
int vert_end_idx = VtxBuffer.Size;
|
||||||
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, a, b, uv_a, uv_b, true);
|
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true);
|
||||||
|
|
||||||
if (push_texture_id)
|
if (push_texture_id)
|
||||||
PopTextureID();
|
PopTextureID();
|
||||||
|
Loading…
Reference in New Issue
Block a user