Internal: ItemAdd(), IsClippedEx(): removed unnecessary indirection for ID parameter
diff --git a/imgui.cpp b/imgui.cpp
index bc2f458..57539a9 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1969,12 +1969,12 @@
// Declare item bounding box for clipping and interaction.
// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
// declares their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
-bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
+bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const bool is_clipped = IsClippedEx(bb, id, false);
- window->DC.LastItemId = id ? *id : 0;
+ window->DC.LastItemId = id;
window->DC.LastItemRect = bb;
window->DC.LastItemRectHoveredRect = false;
if (is_clipped)
@@ -2031,12 +2031,12 @@
return true;
}
-bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged)
+bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!bb.Overlaps(window->ClipRect))
- if (!id || *id != g.ActiveId)
+ if (id == 0 || id != g.ActiveId)
if (clip_even_when_logged || !g.LogEnabled)
return true;
return false;
@@ -3790,7 +3790,7 @@
ImGuiWindow* parent_window = GetCurrentWindow();
ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz);
ItemSize(sz);
- ItemAdd(bb, NULL);
+ ItemAdd(bb, 0);
}
}
@@ -5598,7 +5598,7 @@
while (line < text_end)
{
const char* line_end = strchr(line, '\n');
- if (IsClippedEx(line_rect, NULL, false))
+ if (IsClippedEx(line_rect, 0, false))
break;
const ImVec2 line_size = CalcTextSize(line, line_end, false);
@@ -5630,7 +5630,7 @@
ImRect bb(text_pos, text_pos + text_size);
ItemSize(bb);
- ItemAdd(bb, NULL);
+ ItemAdd(bb, 0);
}
else
{
@@ -5640,7 +5640,7 @@
// Account of baseline offset
ImRect bb(text_pos, text_pos + text_size);
ItemSize(text_size);
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
return;
// Render (we don't hide text after ## in this end-user function)
@@ -5674,7 +5674,7 @@
const ImRect value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2));
const ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x : 0.0f), style.FramePadding.y*2) + label_size);
ItemSize(total_bb, style.FramePadding.y);
- if (!ItemAdd(total_bb, NULL))
+ if (!ItemAdd(total_bb, 0))
return;
// Render
@@ -5799,7 +5799,7 @@
const ImRect bb(pos, pos + size);
ItemSize(bb, style.FramePadding.y);
- if (!ItemAdd(bb, &id))
+ if (!ItemAdd(bb, id))
return false;
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
@@ -5846,7 +5846,7 @@
ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(bb);
- if (!ItemAdd(bb, &id))
+ if (!ItemAdd(bb, id))
return false;
bool hovered, held;
@@ -5890,7 +5890,7 @@
if (border_col.w > 0.0f)
bb.Max += ImVec2(2,2);
ItemSize(bb);
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
return;
if (border_col.w > 0.0f)
@@ -5927,7 +5927,7 @@
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding*2);
const ImRect image_bb(window->DC.CursorPos + padding, window->DC.CursorPos + padding + size);
ItemSize(bb);
- if (!ItemAdd(bb, &id))
+ if (!ItemAdd(bb, id))
return false;
bool hovered, held;
@@ -6129,7 +6129,7 @@
// (Ideally we'd want to add a flag for the user to specify we want want the hit test to be done up to the right side of the content or not)
const ImRect interact_bb = display_frame ? bb : ImRect(bb.Min.x, bb.Min.y, bb.Min.x + text_width + style.ItemSpacing.x*2, bb.Max.y);
bool is_open = TreeNodeBehaviorIsOpen(id, flags);
- if (!ItemAdd(interact_bb, &id))
+ if (!ItemAdd(interact_bb, id))
{
if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
TreePushRawID(id);
@@ -6399,7 +6399,7 @@
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
ItemSize(bb);
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
{
SameLine(0, style.FramePadding.x*2);
return;
@@ -6427,7 +6427,7 @@
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
ItemSize(bb);
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
return;
// Render
@@ -6783,7 +6783,7 @@
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
// NB- we don't call ItemSize() yet because we may turn into a text edit box below
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
{
ItemSize(total_bb, style.FramePadding.y);
return false;
@@ -6840,7 +6840,7 @@
const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
ItemSize(bb, style.FramePadding.y);
- if (!ItemAdd(frame_bb, &id))
+ if (!ItemAdd(frame_bb, id))
return false;
const bool hovered = ItemHoverable(frame_bb, id);
@@ -7078,7 +7078,7 @@
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
// NB- we don't call ItemSize() yet because we may turn into a text edit box below
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
{
ItemSize(total_bb, style.FramePadding.y);
return false;
@@ -7284,7 +7284,7 @@
const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding);
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0));
ItemSize(total_bb, style.FramePadding.y);
- if (!ItemAdd(total_bb, NULL))
+ if (!ItemAdd(total_bb, 0))
return;
const bool hovered = ItemHoverable(inner_bb, 0);
@@ -7424,7 +7424,7 @@
ImVec2 pos = window->DC.CursorPos;
ImRect bb(pos, pos + CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y*2.0f));
ItemSize(bb, style.FramePadding.y);
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
return;
// Render
@@ -7471,7 +7471,7 @@
total_bb = ImRect(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max));
}
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
return false;
bool hovered, held;
@@ -7534,7 +7534,7 @@
total_bb.Add(text_bb);
}
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
return false;
ImVec2 center = check_bb.GetCenter();
@@ -7872,7 +7872,7 @@
else
{
ItemSize(total_bb, style.FramePadding.y);
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
return false;
}
const bool hovered = ItemHoverable(frame_bb, id);
@@ -8657,7 +8657,7 @@
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
ItemSize(total_bb, style.FramePadding.y);
- if (!ItemAdd(total_bb, &id))
+ if (!ItemAdd(total_bb, id))
return false;
const float arrow_size = SmallSquareSize();
@@ -8806,7 +8806,7 @@
bb_with_spacing.Min.y -= spacing_U;
bb_with_spacing.Max.x += spacing_R;
bb_with_spacing.Max.y += spacing_D;
- if (!ItemAdd(bb_with_spacing, &id))
+ if (!ItemAdd(bb_with_spacing, id))
{
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1)
PushColumnClipRect();
@@ -9271,7 +9271,7 @@
size.y = default_size;
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(bb);
- if (!ItemAdd(bb, &id))
+ if (!ItemAdd(bb, id))
return false;
bool hovered, held;
@@ -9940,7 +9940,7 @@
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y+1.0f));
ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout.
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
{
if (window->DC.ColumnsCount > 1)
PushColumnClipRect();
@@ -9970,7 +9970,7 @@
float y2 = window->DC.CursorPos.y + window->DC.CurrentLineHeight;
const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + 1.0f, y2));
ItemSize(ImVec2(bb.GetWidth(), 0.0f));
- if (!ItemAdd(bb, NULL))
+ if (!ItemAdd(bb, 0))
return;
window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator));
@@ -9994,7 +9994,7 @@
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(bb);
- ItemAdd(bb, NULL);
+ ItemAdd(bb, 0);
}
bool ImGui::IsRectVisible(const ImVec2& size)
@@ -10058,7 +10058,7 @@
{
window->DC.CurrentLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrentLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
ItemSize(group_bb.GetSize(), group_data.BackupCurrentLineTextBaseOffset);
- ItemAdd(group_bb, NULL);
+ ItemAdd(group_bb, 0);
}
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive() will be functional on the entire group.
@@ -10344,7 +10344,7 @@
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(i);
const float column_w = 4.0f; // Width for interaction
const ImRect column_rect(ImVec2(x - column_w, y1), ImVec2(x + column_w, y2));
- if (IsClippedEx(column_rect, &column_id, false))
+ if (IsClippedEx(column_rect, column_id, false))
continue;
bool hovered = false, held = false;
diff --git a/imgui_internal.h b/imgui_internal.h
index 392de3e..5b5c5d4 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -771,9 +771,9 @@
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
IMGUI_API void ItemSize(const ImRect& bb, float text_offset_y = 0.0f);
- IMGUI_API bool ItemAdd(const ImRect& bb, const ImGuiID* id);
- IMGUI_API bool IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged);
+ IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id);
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
+ IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
IMGUI_API bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id, bool tab_stop = true); // Return true if focus is requested
IMGUI_API void FocusableItemUnregister(ImGuiWindow* window);
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);