MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / ShowExampleAppWindowTitles

Function ShowExampleAppWindowTitles

core/src/imgui/imgui_demo.cpp:7171–7197  ·  view source on GitHub ↗

Demonstrate using "##" and "###" in identifiers to manipulate ID generation. This apply to all regular items as well. Read FAQ section "How can I have multiple widgets with the same label?" for details.

Source from the content-addressed store, hash-verified

7169// This apply to all regular items as well.
7170// Read FAQ section "How can I have multiple widgets with the same label?" for details.
7171static void ShowExampleAppWindowTitles(bool*)
7172{
7173 const ImGuiViewport* viewport = ImGui::GetMainViewport();
7174 const ImVec2 base_pos = viewport->Pos;
7175
7176 // By default, Windows are uniquely identified by their title.
7177 // You can use the "##" and "###" markers to manipulate the display/ID.
7178
7179 // Using "##" to display same title but have unique identifier.
7180 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 100), ImGuiCond_FirstUseEver);
7181 ImGui::Begin("Same title as another window##1");
7182 ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique.");
7183 ImGui::End();
7184
7185 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 200), ImGuiCond_FirstUseEver);
7186 ImGui::Begin("Same title as another window##2");
7187 ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique.");
7188 ImGui::End();
7189
7190 // Using "###" to display a changing title but keep a static identifier "AnimatedTitle"
7191 char buf[128];
7192 sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount());
7193 ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 300), ImGuiCond_FirstUseEver);
7194 ImGui::Begin(buf);
7195 ImGui::Text("This window has a changing title.");
7196 ImGui::End();
7197}
7198
7199//-----------------------------------------------------------------------------
7200// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 4

ImVec2Function · 0.85
BeginFunction · 0.85
EndFunction · 0.85
sprintfFunction · 0.85

Tested by

no test coverage detected