mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 01:20:55 +01:00
Using IM_UNUSED() macro.
This commit is contained in:
parent
c3c2cd1e82
commit
ee3b4f2bf1
12
imgui.cpp
12
imgui.cpp
@ -1063,11 +1063,11 @@ ImGuiContext* GImGui = NULL;
|
|||||||
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
|
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
|
||||||
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||||
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||||
static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; return malloc(size); }
|
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); }
|
||||||
static void FreeWrapper(void* ptr, void* user_data) { (void)user_data; free(ptr); }
|
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); }
|
||||||
#else
|
#else
|
||||||
static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; (void)size; IM_ASSERT(0); return NULL; }
|
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; }
|
||||||
static void FreeWrapper(void* ptr, void* user_data) { (void)user_data; (void)ptr; IM_ASSERT(0); }
|
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
||||||
@ -2706,9 +2706,9 @@ void ImGui::MarkItemEdited(ImGuiID id)
|
|||||||
{
|
{
|
||||||
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
|
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
|
||||||
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
|
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
|
||||||
(void)id; // Avoid unused variable warnings when asserts are compiled out.
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
|
IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
|
||||||
|
IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out.
|
||||||
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
|
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
|
||||||
g.ActiveIdHasBeenEdited = true;
|
g.ActiveIdHasBeenEdited = true;
|
||||||
g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
|
g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
|
||||||
@ -6918,7 +6918,7 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
|||||||
|
|
||||||
void ImGui::EndPopup()
|
void ImGui::EndPopup()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui; (void)g;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
|
IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
|
||||||
IM_ASSERT(g.BeginPopupStack.Size > 0);
|
IM_ASSERT(g.BeginPopupStack.Size > 0);
|
||||||
|
|
||||||
|
3
imgui.h
3
imgui.h
@ -72,6 +72,7 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
|
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
|
||||||
#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
|
#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++.
|
||||||
|
#define IM_UNUSED(_VAR) ((void)_VAR) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||||
|
|
||||||
// Warnings
|
// Warnings
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@ -1494,7 +1495,7 @@ namespace ImGui
|
|||||||
// OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
// OBSOLETED in 1.60 (between Dec 2017 and Apr 2018)
|
||||||
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
|
static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); }
|
||||||
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
|
static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); }
|
||||||
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { (void)on_edge; (void)outward; IM_ASSERT(0); return pos; }
|
static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; }
|
||||||
// OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
// OBSOLETED in 1.53 (between Oct 2017 and Dec 2017)
|
||||||
static inline void ShowTestWindow() { return ShowDemoWindow(); }
|
static inline void ShowTestWindow() { return ShowDemoWindow(); }
|
||||||
static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
|
static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); }
|
||||||
|
@ -6476,9 +6476,9 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button)
|
|||||||
void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)
|
void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col)
|
||||||
{
|
{
|
||||||
// While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it.
|
// While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it.
|
||||||
(void)flags;
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const float width = bb.GetWidth();
|
const float width = bb.GetWidth();
|
||||||
|
IM_UNUSED(flags);
|
||||||
IM_ASSERT(width > 0.0f);
|
IM_ASSERT(width > 0.0f);
|
||||||
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
|
const float rounding = ImMax(0.0f, ImMin(g.Style.TabRounding, width * 0.5f - 1.0f));
|
||||||
float y1 = bb.Min.y + 1.0f;
|
float y1 = bb.Min.y + 1.0f;
|
||||||
|
@ -569,8 +569,8 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default memory allocators
|
// Default memory allocators
|
||||||
static void* ImFreeTypeDefaultAllocFunc(size_t size, void* user_data) { (void)user_data; return ImGui::MemAlloc(size); }
|
static void* ImFreeTypeDefaultAllocFunc(size_t size, void* user_data) { IM_UNUSED(user_data); return ImGui::MemAlloc(size); }
|
||||||
static void ImFreeTypeDefaultFreeFunc(void* ptr, void* user_data) { (void)user_data; ImGui::MemFree(ptr); }
|
static void ImFreeTypeDefaultFreeFunc(void* ptr, void* user_data) { IM_UNUSED(user_data); ImGui::MemFree(ptr); }
|
||||||
|
|
||||||
// Current memory allocators
|
// Current memory allocators
|
||||||
static void* (*GImFreeTypeAllocFunc)(size_t size, void* user_data) = ImFreeTypeDefaultAllocFunc;
|
static void* (*GImFreeTypeAllocFunc)(size_t size, void* user_data) = ImFreeTypeDefaultAllocFunc;
|
||||||
|
Loading…
Reference in New Issue
Block a user