[DEBUG] Added code to detect using cursor change to extend boundaries.
diff --git a/imgui.cpp b/imgui.cpp
index 9a7046a..c258219 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -6691,6 +6691,7 @@
window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
window->DC.IsSameLine = false;
+ window->DC.IsSetPos = false;
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.NavLayersActiveMask = window->DC.NavLayersActiveMaskNext;
@@ -6815,6 +6816,22 @@
return !window->SkipItems;
}
+void CheckUsedSetCursorPosWithSideEffect(ImGuiWindow* window, const char* context)
+{
+ if (!window->DC.IsSetPos)
+ return;
+ window->DC.IsSetPos = false;
+ if (window->DC.CursorMaxPos.x == window->DC.CursorPos.x && window->DC.CursorMaxPos.y == window->DC.CursorPos.y)
+ return;
+
+ IMGUI_DEBUG_LOG("In Window '%s':\n"
+ "Code before %s was taking advantage of SetCursorPos/SetCursorScreenPos() extending boundaries!\n",
+ window->Name, context);
+
+ //IM_ASSERT(0);
+ //window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+}
+
void ImGui::End()
{
ImGuiContext& g = *GImGui;
@@ -6841,6 +6858,8 @@
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
LogFinish();
+ CheckUsedSetCursorPosWithSideEffect(window, "End()");
+
// Pop from window stack
g.LastItemData = g.CurrentWindowStack.back().ParentLastItemDataBackup;
if (window->Flags & ImGuiWindowFlags_ChildMenu)
@@ -8499,7 +8518,7 @@
window->DC.CurrLineSize.y = 0.0f;
window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y);
window->DC.CurrLineTextBaseOffset = 0.0f;
- window->DC.IsSameLine = false;
+ window->DC.IsSameLine = window->DC.IsSetPos = false;
// Horizontal layout mode
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
@@ -8619,7 +8638,8 @@
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos = pos;
- window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+ //window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+ window->DC.IsSetPos = true;
}
// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient.
@@ -8646,21 +8666,24 @@
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos = window->Pos - window->Scroll + local_pos;
- window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+ //window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
+ window->DC.IsSetPos = true;
}
void ImGui::SetCursorPosX(float x)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;
- window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
+ //window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
+ window->DC.IsSetPos = true;
}
void ImGui::SetCursorPosY(float y)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y;
- window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
+ //window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
+ window->DC.IsSetPos = true;
}
ImVec2 ImGui::GetCursorStartPos()
@@ -8877,6 +8900,8 @@
ImGuiGroupData& group_data = g.GroupStack.back();
IM_ASSERT(group_data.WindowID == window->ID); // EndGroup() in wrong window?
+ CheckUsedSetCursorPosWithSideEffect(window, "EndGroup()");
+
ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
window->DC.CursorPos = group_data.BackupCursorPos;
diff --git a/imgui_internal.h b/imgui_internal.h
index 66f3b24..4b8df4c 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -163,6 +163,8 @@
typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...);
+extern void CheckUsedSetCursorPosWithSideEffect(ImGuiWindow* window, const char* context);
+
//-----------------------------------------------------------------------------
// [SECTION] Context pointer
// See implementation of this variable in imgui.cpp for comments and details.
@@ -2034,6 +2036,7 @@
float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added).
float PrevLineTextBaseOffset;
bool IsSameLine;
+ bool IsSetPos;
ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
ImVec1 GroupOffset;
diff --git a/imgui_tables.cpp b/imgui_tables.cpp
index 872f1ec..a20e1d5 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -1718,7 +1718,7 @@
table->RowIndentOffsetX = window->DC.Indent.x - table->HostIndentX; // Lock indent
window->DC.PrevLineTextBaseOffset = 0.0f;
window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
- window->DC.IsSameLine = false;
+ window->DC.IsSameLine = window->DC.IsSetPos = false;
window->DC.CursorMaxPos.y = next_y1;
// Making the header BG color non-transparent will allow us to overlay it multiple times when handling smooth dragging.
@@ -2000,6 +2000,8 @@
ImGuiTableColumn* column = &table->Columns[table->CurrentColumn];
ImGuiWindow* window = table->InnerWindow;
+ CheckUsedSetCursorPosWithSideEffect(window, "TableNextRow()/TableNextColumn()/TableSetColumn()");
+
// Report maximum position so we can infer content size per column.
float* p_max_pos_x;
if (table->RowFlags & ImGuiTableRowFlags_Headers)