mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame. Removed the broken __LINE__ from IMGUI_ONCE_UPON_A_FRAME
This commit is contained in:
parent
a85a14370b
commit
68bf5ecbc1
@ -204,6 +204,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame.
|
||||
- 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow(), note that most uses relied on default parameters completely.
|
||||
- 2017/08/13 (1.51) - renamed ImGuiCol_Columns_*** to ImGuiCol_Separator_***
|
||||
- 2017/08/11 (1.51) - renamed ImGuiSetCond_*** types and flags to ImGuiCond_***. Kept redirection enums (will obsolete).
|
||||
|
17
imgui.h
17
imgui.h
@ -924,15 +924,11 @@ public:
|
||||
inline iterator insert(const_iterator it, const value_type& v) { IM_ASSERT(it >= Data && it <= Data+Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(value_type)); Data[off] = v; Size++; return Data + off; }
|
||||
};
|
||||
|
||||
// Helper: execute a block of code at maximum once a frame
|
||||
// Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
|
||||
// Helper: execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
|
||||
// Usage:
|
||||
// IMGUI_ONCE_UPON_A_FRAME
|
||||
// {
|
||||
// // code block will be executed one per frame
|
||||
// }
|
||||
// Attention! the macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
|
||||
#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf##__LINE__; if (imgui_oaf##__LINE__)
|
||||
// static ImGuiOnceUponAFrame oaf;
|
||||
// if (oaf)
|
||||
// ImGui::Text("This will be called only once per frame");
|
||||
struct ImGuiOnceUponAFrame
|
||||
{
|
||||
ImGuiOnceUponAFrame() { RefFrame = -1; }
|
||||
@ -940,6 +936,11 @@ struct ImGuiOnceUponAFrame
|
||||
operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
|
||||
};
|
||||
|
||||
// Helper macro for ImGuiOnceUponAFrame. Attention: The macro expands into 2 statement so make sure you don't use it within e.g. an if() statement without curly braces.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // Will obsolete
|
||||
#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOnceUponAFrame imgui_oaf; if (imgui_oaf)
|
||||
#endif
|
||||
|
||||
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
struct ImGuiTextFilter
|
||||
{
|
||||
|
@ -308,14 +308,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
// Testing IMGUI_ONCE_UPON_A_FRAME macro
|
||||
// Testing ImGuiOnceUponAFrame helper.
|
||||
//static ImGuiOnceUponAFrame once;
|
||||
//for (int i = 0; i < 5; i++)
|
||||
//{
|
||||
// IMGUI_ONCE_UPON_A_FRAME
|
||||
// {
|
||||
// ImGui::Text("This will be displayed only once.");
|
||||
// }
|
||||
//}
|
||||
// if (once)
|
||||
// ImGui::Text("This will be displayed only once.");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user