mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-06 10:06:29 +00:00
InputText: Added a line index. Refactored cursor and selection rendering, now simpler, easier to reason about, and faster. (#3237, #952, #1062, #7363)
This commit is contained in:
11
imgui.cpp
11
imgui.cpp
@@ -3074,6 +3074,7 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
va_end(args_copy);
|
||||
}
|
||||
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
void ImGuiTextIndex::append(const char* base, int old_size, int new_size)
|
||||
{
|
||||
IM_ASSERT(old_size >= 0 && new_size >= old_size && new_size >= EndOffset);
|
||||
@@ -3087,6 +3088,7 @@ void ImGuiTextIndex::append(const char* base, int old_size, int new_size)
|
||||
Offsets.push_back((int)(intptr_t)(p - base));
|
||||
EndOffset = ImMax(EndOffset, new_size);
|
||||
}
|
||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImGuiListClipper
|
||||
@@ -3414,6 +3416,13 @@ bool ImGuiListClipper::Step()
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Generic helper, equivalent to old ImGui::CalcListClipping() but statelesss
|
||||
void ImGui::CalcClipRectVisibleItemsY(const ImRect& clip_rect, const ImVec2& pos, float items_height, int* out_visible_start, int* out_visible_end)
|
||||
{
|
||||
*out_visible_start = ImMax((int)((clip_rect.Min.y - pos.y) / items_height), 0);
|
||||
*out_visible_end = ImMax((int)ImCeil((clip_rect.Max.y - pos.y) / items_height), *out_visible_start);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] STYLING
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -4374,6 +4383,7 @@ void ImGui::Shutdown()
|
||||
g.ClipboardHandlerData.clear();
|
||||
g.MenusIdSubmittedThisFrame.clear();
|
||||
g.InputTextState.ClearFreeMemory();
|
||||
g.InputTextLineIndex.clear();
|
||||
g.InputTextDeactivatedState.ClearFreeMemory();
|
||||
|
||||
g.SettingsWindows.clear();
|
||||
@@ -4489,6 +4499,7 @@ void ImGui::GcCompactTransientMiscBuffers()
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.ItemFlagsStack.clear();
|
||||
g.GroupStack.clear();
|
||||
g.InputTextLineIndex.clear();
|
||||
g.MultiSelectTempDataStacked = 0;
|
||||
g.MultiSelectTempData.clear_destruct();
|
||||
TableGcCompactSettings();
|
||||
|
Reference in New Issue
Block a user