mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Removed IMGUI_ONCE_UPON_A_FRAME in favor of ImGuiOnceUponAFrame which is supported by all compilers
This commit is contained in:
parent
7f6453ca70
commit
b9118750ae
@ -142,7 +142,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 'if (IMGUI_ONCE_UPON_A_FRAME)' will evaluate to true only once a frame, you can use it to add custom UI in the middle of a deep nested inner loop in your code.
|
||||
- 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: 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!
|
||||
@ -6674,6 +6674,10 @@ 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!");
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("^ Horizontal separator");
|
||||
|
||||
|
18
imgui.h
18
imgui.h
@ -123,7 +123,7 @@ public:
|
||||
#endif // #ifndef ImVector
|
||||
|
||||
// Helpers at bottom of the file:
|
||||
// - if (IMGUI_ONCE_UPON_A_FRAME) // Execute a block of code once per frame only
|
||||
// - struct ImGuiOnceUponAFrame // 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)
|
||||
@ -529,15 +529,15 @@ struct ImGuiIO
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Helper: execute a block of code once a frame only
|
||||
// Usage: if (IMGUI_ONCE_UPON_A_FRAME) {/*do something once a frame*/)
|
||||
#define IMGUI_ONCE_UPON_A_FRAME static ImGuiOncePerFrame im = ImGuiOncePerFrame()
|
||||
struct ImGuiOncePerFrame
|
||||
// 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) { ... }
|
||||
struct ImGuiOnceUponAFrame
|
||||
{
|
||||
ImGuiOncePerFrame() : LastFrame(-1) {}
|
||||
operator bool() const { return TryIsNewFrame(); }
|
||||
private:
|
||||
mutable int LastFrame;
|
||||
bool TryIsNewFrame() const { const int current_frame = ImGui::GetFrameCount(); if (LastFrame == current_frame) return false; LastFrame = current_frame; return true; }
|
||||
ImGuiOnceUponAFrame() { RefFrame = -1; }
|
||||
mutable int RefFrame;
|
||||
operator bool() const { const int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; }
|
||||
};
|
||||
|
||||
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
|
Loading…
Reference in New Issue
Block a user