1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 15:50:25 +01:00

Clipper: Rework inner logic to allow functioning with a zero-clear constructor. (#5856)

This commit is contained in:
ocornut 2023-06-13 14:55:02 +02:00
parent 9c16976749
commit e95d66faa8
3 changed files with 8 additions and 5 deletions

View File

@ -38,6 +38,9 @@ Other changes:
- Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either - Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either
ScrollX or ScrollY flags from being impossible to resize. (#6503) ScrollX or ScrollY flags from being impossible to resize. (#6503)
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor.
This is order to facilitate usage for language bindings (e.g cimgui or dear_binding)
where user may not be callinga constructor manually. (#5856)
- Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra - Debug Tools: Added 'io.ConfigDebugIniSettings' option to save .ini data with extra
comments. Currently mainly for inspecting Docking .ini data, but makes saving slower. comments. Currently mainly for inspecting Docking .ini data, but makes saving slower.
- Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) [@jsm174] - Backends: OpenGL3: Fixed support for glBindSampler() backup/restore on ES3. (#6375, #6508) [@jsm174]

View File

@ -2750,9 +2750,6 @@ static void ImGuiListClipper_SeekCursorForItem(ImGuiListClipper* clipper, int it
ImGuiListClipper::ImGuiListClipper() ImGuiListClipper::ImGuiListClipper()
{ {
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
Ctx = ImGui::GetCurrentContext();
IM_ASSERT(Ctx != NULL);
ItemsCount = -1;
} }
ImGuiListClipper::~ImGuiListClipper() ImGuiListClipper::~ImGuiListClipper()
@ -2762,6 +2759,9 @@ ImGuiListClipper::~ImGuiListClipper()
void ImGuiListClipper::Begin(int items_count, float items_height) void ImGuiListClipper::Begin(int items_count, float items_height)
{ {
if (Ctx == NULL)
Ctx = ImGui::GetCurrentContext();
ImGuiContext& g = *Ctx; ImGuiContext& g = *Ctx;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Begin(%d,%.2f) in '%s'\n", items_count, items_height, window->Name); IMGUI_DEBUG_LOG_CLIPPER("Clipper: Begin(%d,%.2f) in '%s'\n", items_count, items_height, window->Name);
@ -2787,10 +2787,10 @@ void ImGuiListClipper::Begin(int items_count, float items_height)
void ImGuiListClipper::End() void ImGuiListClipper::End()
{ {
ImGuiContext& g = *Ctx;
if (ImGuiListClipperData* data = (ImGuiListClipperData*)TempData) if (ImGuiListClipperData* data = (ImGuiListClipperData*)TempData)
{ {
// In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user. // In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user.
ImGuiContext& g = *Ctx;
IMGUI_DEBUG_LOG_CLIPPER("Clipper: End() in '%s'\n", g.CurrentWindow->Name); IMGUI_DEBUG_LOG_CLIPPER("Clipper: End() in '%s'\n", g.CurrentWindow->Name);
if (ItemsCount >= 0 && ItemsCount < INT_MAX && DisplayStart >= 0) if (ItemsCount >= 0 && ItemsCount < INT_MAX && DisplayStart >= 0)
ImGuiListClipper_SeekCursorForItem(this, ItemsCount); ImGuiListClipper_SeekCursorForItem(this, ItemsCount);

View File

@ -23,7 +23,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.89.7 WIP" #define IMGUI_VERSION "1.89.7 WIP"
#define IMGUI_VERSION_NUM 18962 #define IMGUI_VERSION_NUM 18963
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
/* /*