Internals: removed last parameter to IsClippedEx() + fix PVS studio warnings.

This commit is contained in:
ocornut 2021-09-15 16:50:20 +02:00
parent 2d0a6a4969
commit 3973de7933
4 changed files with 13 additions and 13 deletions

View File

@ -3283,13 +3283,13 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
return true; return true;
} }
bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged) bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (!bb.Overlaps(window->ClipRect)) if (!bb.Overlaps(window->ClipRect))
if (id == 0 || (id != g.ActiveId && id != g.NavId)) if (id == 0 || (id != g.ActiveId && id != g.NavId))
if (clip_even_when_logged || !g.LogEnabled) if (!g.LogEnabled)
return true; return true;
return false; return false;
} }
@ -7314,7 +7314,7 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
{ {
// PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations" // PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations"
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
while (g.CurrentWindowStack.Size > 0) while (g.CurrentWindowStack.Size > 0) //-V1044
{ {
ErrorCheckEndWindowRecover(log_callback, user_data); ErrorCheckEndWindowRecover(log_callback, user_data);
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
@ -7360,7 +7360,7 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name);
TreePop(); TreePop();
} }
while (g.GroupStack.Size > stack_sizes->SizeOfGroupStack) while (g.GroupStack.Size > stack_sizes->SizeOfGroupStack) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name);
EndGroup(); EndGroup();
@ -7370,7 +7370,7 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name);
PopID(); PopID();
} }
while (g.DisabledStackSize > stack_sizes->SizeOfDisabledStack) while (g.DisabledStackSize > stack_sizes->SizeOfDisabledStack) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name);
EndDisabled(); EndDisabled();
@ -7380,17 +7380,17 @@ void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, vo
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col));
PopStyleColor(); PopStyleColor();
} }
while (g.ItemFlagsStack.Size > stack_sizes->SizeOfItemFlagsStack) while (g.ItemFlagsStack.Size > stack_sizes->SizeOfItemFlagsStack) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name);
PopItemFlag(); PopItemFlag();
} }
while (g.StyleVarStack.Size > stack_sizes->SizeOfStyleVarStack) while (g.StyleVarStack.Size > stack_sizes->SizeOfStyleVarStack) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name);
PopStyleVar(); PopStyleVar();
} }
while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack) while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack) //-V1044
{ {
if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name);
PopFocusScope(); PopFocusScope();
@ -7561,7 +7561,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
#endif #endif
// Clipping test // Clipping test
const bool is_clipped = IsClippedEx(bb, id, false); const bool is_clipped = IsClippedEx(bb, id);
if (is_clipped) if (is_clipped)
return false; return false;
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]

View File

@ -2413,7 +2413,7 @@ namespace ImGui
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL, ImGuiItemFlags extra_flags = 0); IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL, ImGuiItemFlags extra_flags = 0);
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id); IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
IMGUI_API void ItemInputable(ImGuiWindow* window, ImGuiID id); IMGUI_API void ItemInputable(ImGuiWindow* window, ImGuiID id);
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id);
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h); IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h);
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
IMGUI_API void PushMultiItemsWidths(int components, float width_full); IMGUI_API void PushMultiItemsWidths(int components, float width_full);

View File

@ -324,7 +324,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
const ImVec2 avail_size = GetContentRegionAvail(); const ImVec2 avail_size = GetContentRegionAvail();
ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f); ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f);
ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size); ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size);
if (use_child_window && IsClippedEx(outer_rect, 0, false)) if (use_child_window && IsClippedEx(outer_rect, 0))
{ {
ItemSize(outer_rect); ItemSize(outer_rect);
return false; return false;
@ -3988,7 +3988,7 @@ void ImGui::EndColumns()
const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH; const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH;
const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2));
KeepAliveID(column_id); KeepAliveID(column_id);
if (IsClippedEx(column_hit_rect, column_id, false)) if (IsClippedEx(column_hit_rect, column_id)) // FIXME: Can be removed or replaced with a lower-level test
continue; continue;
bool hovered = false, held = false; bool hovered = false, held = false;

View File

@ -205,7 +205,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height)); ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height));
while (line < text_end) while (line < text_end)
{ {
if (IsClippedEx(line_rect, 0, false)) if (IsClippedEx(line_rect, 0))
break; break;
const char* line_end = (const char*)memchr(line, '\n', text_end - line); const char* line_end = (const char*)memchr(line, '\n', text_end - line);