mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
ImDrawList: added thickness param to AddLine(). Added PushClipRectFullScreen() helper.
This commit is contained in:
24
imgui.cpp
24
imgui.cpp
@ -7229,6 +7229,18 @@ void ImDrawList::PushClipRect(const ImVec4& clip_rect)
|
||||
UpdateClipRect();
|
||||
}
|
||||
|
||||
void ImDrawList::PushClipRectFullScreen()
|
||||
{
|
||||
PushClipRect(GNullClipRect);
|
||||
|
||||
// This would be more correct but we're not supposed to access ImGuiState from here?
|
||||
//ImGuiState& g = *GImGui;
|
||||
//if (g.IO.DisplayVisibleMin.x != g.IO.DisplayVisibleMax.x && g.IO.DisplayVisibleMin.y != g.IO.DisplayVisibleMax.y)
|
||||
// PushClipRect(ImVec4(g.IO.DisplayVisibleMin.x, g.IO.DisplayVisibleMin.y, g.IO.DisplayVisibleMax.x, g.IO.DisplayVisibleMax.y));
|
||||
//else
|
||||
// PushClipRect(ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y));
|
||||
}
|
||||
|
||||
void ImDrawList::PopClipRect()
|
||||
{
|
||||
IM_ASSERT(clip_rect_stack.size() > 0);
|
||||
@ -7291,11 +7303,11 @@ void ImDrawList::AddVtxUV(const ImVec2& pos, ImU32 col, const ImVec2& uv)
|
||||
}
|
||||
|
||||
// NB: memory should be reserved for 6 vertices by the caller.
|
||||
void ImDrawList::AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col)
|
||||
void ImDrawList::AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col, float half_thickness)
|
||||
{
|
||||
const float length = sqrtf(ImLengthSqr(b - a));
|
||||
const ImVec2 hn = (b - a) * (0.50f / length); // half normal
|
||||
const ImVec2 hp0 = ImVec2(+hn.y, -hn.x); // half perpendiculars + user offset
|
||||
const float inv_length = 1.0f / sqrtf(ImLengthSqr(b - a));
|
||||
const ImVec2 hn = (b - a) * (half_thickness * inv_length); // half normal
|
||||
const ImVec2 hp0 = ImVec2(+hn.y, -hn.x); // half perpendiculars + user offset
|
||||
const ImVec2 hp1 = ImVec2(-hn.y, +hn.x);
|
||||
|
||||
// Two triangles makes up one line. Using triangles allows us to reduce amount of draw calls.
|
||||
@ -7307,13 +7319,13 @@ void ImDrawList::AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col)
|
||||
AddVtx(a + hp1, col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col)
|
||||
void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float half_thickness)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
return;
|
||||
|
||||
ReserveVertices(6);
|
||||
AddVtxLine(a, b, col);
|
||||
AddVtxLine(a, b, col, half_thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddArc(const ImVec2& center, float rad, ImU32 col, int a_min, int a_max, bool tris, const ImVec2& third_point_offset)
|
||||
|
Reference in New Issue
Block a user