MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ShowExampleAppSimpleOverlay

Function ShowExampleAppSimpleOverlay

lib/imgui/imgui_demo.cpp:4371–4403  ·  view source on GitHub ↗

Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.

Source from the content-addressed store, hash-verified

4369
4370// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
4371static void ShowExampleAppSimpleOverlay(bool* p_open)
4372{
4373 const float DISTANCE = 10.0f;
4374 static int corner = 0;
4375 ImGuiIO& io = ImGui::GetIO();
4376 if (corner != -1)
4377 {
4378 ImVec2 window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - DISTANCE : DISTANCE, (corner & 2) ? io.DisplaySize.y - DISTANCE : DISTANCE);
4379 ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
4380 ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
4381 }
4382 ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
4383 if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
4384 {
4385 ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
4386 ImGui::Separator();
4387 if (ImGui::IsMousePosValid())
4388 ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
4389 else
4390 ImGui::Text("Mouse Position: <invalid>");
4391 if (ImGui::BeginPopupContextWindow())
4392 {
4393 if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
4394 if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
4395 if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
4396 if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
4397 if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
4398 if (p_open && ImGui::MenuItem("Close")) *p_open = false;
4399 ImGui::EndPopup();
4400 }
4401 }
4402 ImGui::End();
4403}
4404
4405//-----------------------------------------------------------------------------
4406// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 1

ImVec2Class · 0.85

Tested by

no test coverage detected