MCPcopy Create free account
hub / github.com/Lovrom8/RSMods / ShowExampleAppSimpleOverlay

Function ShowExampleAppSimpleOverlay

DLL/Lib/ImGUI/imgui_demo.cpp:7026–7066  ·  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

7024// Demonstrate creating a simple static window with no decoration
7025// + a context-menu to choose which corner of the screen to use.
7026static void ShowExampleAppSimpleOverlay(bool* p_open)
7027{
7028 static int corner = 0;
7029 ImGuiIO& io = ImGui::GetIO();
7030 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
7031 if (corner != -1)
7032 {
7033 const float PAD = 10.0f;
7034 const ImGuiViewport* viewport = ImGui::GetMainViewport();
7035 ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
7036 ImVec2 work_size = viewport->WorkSize;
7037 ImVec2 window_pos, window_pos_pivot;
7038 window_pos.x = (corner & 1) ? (work_pos.x + work_size.x - PAD) : (work_pos.x + PAD);
7039 window_pos.y = (corner & 2) ? (work_pos.y + work_size.y - PAD) : (work_pos.y + PAD);
7040 window_pos_pivot.x = (corner & 1) ? 1.0f : 0.0f;
7041 window_pos_pivot.y = (corner & 2) ? 1.0f : 0.0f;
7042 ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
7043 window_flags |= ImGuiWindowFlags_NoMove;
7044 }
7045 ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
7046 if (ImGui::Begin("Example: Simple overlay", p_open, window_flags))
7047 {
7048 ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
7049 ImGui::Separator();
7050 if (ImGui::IsMousePosValid())
7051 ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
7052 else
7053 ImGui::Text("Mouse Position: <invalid>");
7054 if (ImGui::BeginPopupContextWindow())
7055 {
7056 if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1;
7057 if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0;
7058 if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
7059 if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
7060 if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
7061 if (p_open && ImGui::MenuItem("Close")) *p_open = false;
7062 ImGui::EndPopup();
7063 }
7064 }
7065 ImGui::End();
7066}
7067
7068//-----------------------------------------------------------------------------
7069// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen()

Callers 1

ShowDemoWindowMethod · 0.85

Calls 1

BeginPopupContextWindowFunction · 0.85

Tested by

no test coverage detected