mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
New version of IMGUI_ONCE_UPON_A_FRAME helper macro
This commit is contained in:
parent
df2ad5e899
commit
311a2f8328
16
imgui.cpp
16
imgui.cpp
@ -111,7 +111,7 @@
|
||||
Occasionally introducing changes that are breaking the API. The breakage are generally minor and easy to fix.
|
||||
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.
|
||||
|
||||
- 2014/11/26 (1.17) retired IMGUI_ONCE_UPON_A_FRAME helper macro in favor of ImGuiOnceUponAFrame type that works on all compilers.
|
||||
- 2014/11/26 (1.17) reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility
|
||||
- 2014/11/07 (1.15) renamed IsHovered() to IsItemHovered()
|
||||
- 2014/10/02 (1.14) renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly)
|
||||
- 2014/09/25 (1.13) removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity)
|
||||
@ -158,7 +158,7 @@
|
||||
e.g. "##Foobar" display an empty label and uses "##Foobar" as ID
|
||||
- read articles about the imgui principles (see web links) to understand the requirement and use of ID.
|
||||
|
||||
- tip: the construct 'static ImGuiOnceUponAFrame once; if (once)' will evaluate to 'true' only once a frame, you can use it to quickly add custom UI in the middle of a deep nested inner loop in your code.
|
||||
- tip: the construct 'IMGUI_ONCE_UPON_A_FRAME { ... }' will evaluate to a block of code only once a frame. You can use it to quickly add custom UI in the middle of a deep nested inner loop in your code.
|
||||
- tip: you can call Render() multiple times (e.g for VR renders), up to you to communicate the extra state to your RenderDrawListFn function.
|
||||
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug"
|
||||
- tip: read the ShowTestWindow() code for more example of how to use ImGui!
|
||||
@ -6687,12 +6687,16 @@ void ImGui::ShowTestWindow(bool* open)
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
//static ImGuiOnceUponAFrame oaf;
|
||||
//if (oaf) ImGui::Text("This will be displayed.");
|
||||
//if (oaf) ImGui::Text("This won't be displayed!");
|
||||
// Testing IMGUI_ONCE_UPON_A_FRAME macro
|
||||
//for (int i = 0; i < 5; i++)
|
||||
//{
|
||||
// IMGUI_ONCE_UPON_A_FRAME
|
||||
// {
|
||||
// ImGui::Text("This will be displayed only once.");
|
||||
// }
|
||||
//}
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("^ Horizontal separator");
|
||||
|
||||
static int item = 1;
|
||||
ImGui::Combo("combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
||||
|
10
imgui.h
10
imgui.h
@ -122,7 +122,7 @@ public:
|
||||
#endif // #ifndef ImVector
|
||||
|
||||
// Helpers at bottom of the file:
|
||||
// - struct ImGuiOnceUponAFrame // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times)
|
||||
// - IMGUI_ONCE_UPON_A_FRAME // Execute a block of code once per frame only (convenient for creating UI within deep-nested code that runs multiple times)
|
||||
// - struct ImGuiTextFilter // Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
// - struct ImGuiTextBuffer // Text buffer for logging/accumulating text
|
||||
// - struct ImGuiStorage // Custom key value storage (if you need to alter open/close states manually)
|
||||
@ -530,8 +530,12 @@ struct ImGuiIO
|
||||
// Helper: execute a block of code once a frame only
|
||||
// Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame.
|
||||
// Usage:
|
||||
// static ImGuiOnceUponAFrame once;
|
||||
// if (once) { ... }
|
||||
// IMGUI_ONCE_UPON_A_FRAME
|
||||
// {
|
||||
// // code block will be executed one per frame
|
||||
// }
|
||||
// Attention! the macro expand 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__)
|
||||
struct ImGuiOnceUponAFrame
|
||||
{
|
||||
ImGuiOnceUponAFrame() { RefFrame = -1; }
|
||||
|
Loading…
Reference in New Issue
Block a user