mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Merge branch 'refs/heads/master' into docking
# Conflicts: # docs/CHANGELOG.txt # examples/imgui_impl_glfw.cpp # examples/imgui_impl_sdl.cpp # examples/imgui_impl_win32.cpp # imgui.cpp # imgui_internal.h # imgui_widgets.cpp
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.74
|
||||
// dear imgui, v1.75 WIP
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
@ -522,10 +522,13 @@ void ImDrawList::PopTextureID()
|
||||
UpdateTextureID();
|
||||
}
|
||||
|
||||
// NB: this can be called with negative count for removing primitives (as long as the result does not underflow)
|
||||
// Reserve space for a number of vertices and indices.
|
||||
// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
|
||||
// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
|
||||
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||
{
|
||||
// Large mesh support (when enabled)
|
||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
|
||||
{
|
||||
_VtxCurrentOffset = VtxBuffer.Size;
|
||||
@ -533,7 +536,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||
AddDrawCmd();
|
||||
}
|
||||
|
||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size-1];
|
||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||
draw_cmd.ElemCount += idx_count;
|
||||
|
||||
int vtx_buffer_old_size = VtxBuffer.Size;
|
||||
@ -545,6 +548,17 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
||||
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
||||
}
|
||||
|
||||
// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
||||
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
||||
{
|
||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||
|
||||
ImDrawCmd& draw_cmd = CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||
draw_cmd.ElemCount -= idx_count;
|
||||
VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
|
||||
IdxBuffer.shrink(IdxBuffer.Size - idx_count);
|
||||
}
|
||||
|
||||
// Fully unrolled with inline call to keep our debug builds decently fast.
|
||||
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
||||
{
|
||||
@ -1096,6 +1110,30 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
|
||||
PathFillConvex(col);
|
||||
}
|
||||
|
||||
// Guaranteed to honor 'num_segments'
|
||||
void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||
return;
|
||||
|
||||
// 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;
|
||||
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
|
||||
PathStroke(col, true, thickness);
|
||||
}
|
||||
|
||||
// Guaranteed to honor 'num_segments'
|
||||
void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
|
||||
return;
|
||||
|
||||
// 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;
|
||||
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
|
||||
PathFillConvex(col);
|
||||
}
|
||||
|
||||
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
@ -1679,7 +1717,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
|
||||
if (!data)
|
||||
{
|
||||
IM_ASSERT(0); // Could not load file.
|
||||
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
|
||||
return NULL;
|
||||
}
|
||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||
|
Reference in New Issue
Block a user