sandbox_topmost.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Example demonstrating the topMost window feature
  2. #include "hello_imgui/hello_imgui.h"
  3. #include "imgui.h"
  4. void ShowGui()
  5. {
  6. ImGui::Text("This window should stay on top of other windows!");
  7. ImGui::Separator();
  8. // Allow toggling topMost at runtime
  9. auto& params = HelloImGui::GetRunnerParams()->appWindowParams;
  10. bool topMost = params.topMost;
  11. if (ImGui::Checkbox("Keep window on top", &topMost)) {
  12. params.topMost = topMost;
  13. }
  14. ImGui::TextWrapped(
  15. "Note: TopMost is only supported on desktop platforms "
  16. "(Windows, macOS, Linux). On mobile and web platforms, "
  17. "this setting is ignored."
  18. );
  19. }
  20. int main(int, char**)
  21. {
  22. // HelloImGui::RunnerParams runnerParams;
  23. // runnerParams.appWindowParams.windowTitle = "TopMost Window Demo";
  24. // runnerParams.appWindowParams.windowGeometry.size = {400, 300};
  25. // runnerParams.appWindowParams.topMost = false;
  26. // runnerParams.callbacks.ShowGui = ShowGui;
  27. // //runnerParams.platformBackendType = HelloImGui::PlatformBackendType::Sdl;
  28. // runnerParams.platformBackendType = HelloImGui::PlatformBackendType::Glfw;
  29. // HelloImGui::Run(runnerParams);
  30. HelloImGui::Run(HelloImGui::SimpleRunnerParams {
  31. .guiFunction = ShowGui,
  32. .windowTitle = "TopMost Window Demo",
  33. .topMost = true
  34. });
  35. return 0;
  36. }