From 166706508441ec4c023b8d27dad9d50c2db22cc9 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sat, 27 Sep 2025 16:28:24 +0200 Subject: [PATCH] Add app launcher in stream gui --- client/scenes/app_launcher.cpp | 7 ++++++- client/scenes/stream.cpp | 3 +++ client/scenes/stream.h | 1 + client/scenes/stream_gui.cpp | 24 ++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/client/scenes/app_launcher.cpp b/client/scenes/app_launcher.cpp index 4445d1a9..ed57261b 100644 --- a/client/scenes/app_launcher.cpp +++ b/client/scenes/app_launcher.cpp @@ -122,7 +122,9 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st { auto res = clicked::None; auto t0 = std::chrono::steady_clock::now(); - bool app_starting = start_time != std::chrono::steady_clock::time_point{} and t0 - start_time < 10s; + bool app_starting = start_time != std::chrono::steady_clock::time_point{} and + t0 - start_time < 10s and + stream.current_state() != scenes::stream::state::streaming; auto cancel_size = ImGui::CalcTextSize(cancel.c_str()); @@ -242,6 +244,8 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st ImGui::SetCursorPos(ImGui::GetWindowSize() - cancel_size - ImVec2{50, 50}); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {10, 10}); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.2f, 0.2f, 0.40f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.2f, 0.2f, 1.00f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 0.1f, 0.1f, 1.00f)); @@ -249,6 +253,7 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st res = clicked::Cancel; imgui_ctx.vibrate_on_hover(); ImGui::PopStyleColor(3); // ImGuiCol_Button, ImGuiCol_ButtonHovered, ImGuiCol_ButtonActive + ImGui::PopStyleVar(2); return res; } diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index e1924428..0560666b 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -732,6 +732,7 @@ bool scenes::stream::is_gui_interactable() const case gui_status::settings: case gui_status::foveation_settings: case gui_status::applications: + case gui_status::application_launcher: return true; case gui_status::hidden: @@ -1004,6 +1005,7 @@ void scenes::stream::render(const XrFrameState & frame_state) case gui_status::stats: case gui_status::settings: case gui_status::applications: + case gui_status::application_launcher: dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration); break; } @@ -1096,6 +1098,7 @@ void scenes::stream::render(const XrFrameState & frame_state) case gui_status::settings: case gui_status::foveation_settings: case gui_status::applications: + case gui_status::application_launcher: gui_status = gui_status::hidden; break; } diff --git a/client/scenes/stream.h b/client/scenes/stream.h index fce46eb3..18aff8fc 100644 --- a/client/scenes/stream.h +++ b/client/scenes/stream.h @@ -134,6 +134,7 @@ private: settings, foveation_settings, applications, + application_launcher, }; bool is_gui_interactable() const; diff --git a/client/scenes/stream_gui.cpp b/client/scenes/stream_gui.cpp index 5253a0f5..ad0a35b1 100644 --- a/client/scenes/stream_gui.cpp +++ b/client/scenes/stream_gui.cpp @@ -612,6 +612,8 @@ void scenes::stream::gui_applications() network_session->send_control(from_headset::get_running_applications{}); } + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {10, 10}); ImGui::PushFont(nullptr, constants::gui::font_size_large); CenterTextH(_("Running XR applications:")); ImGui::PopFont(); @@ -658,7 +660,7 @@ void scenes::stream::gui_applications() ImGui::SameLine(); auto right = ImGui::GetWindowSize().x; - ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10); ImGui::SetCursorPosX(right - ImGui::CalcTextSize(ICON_FA_XMARK).x - ImGui::GetStyle().FramePadding.x - 40); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.2f, 0.2f, 0.40f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.2f, 0.2f, 1.00f)); @@ -671,7 +673,13 @@ void scenes::stream::gui_applications() if (ImGui::IsItemHovered()) imgui_ctx->tooltip(_S("Request to quit, may be ignored by the application")); } - ImGui::PopStyleVar(); + + auto btn = _("Start"); + ImGui::SetCursorPos(ImGui::GetWindowSize() - ImGui::CalcTextSize(btn.c_str()) - ImVec2(50, 50)); + if (ImGui::Button(btn.c_str())) + gui_status = gui_status::application_launcher; + imgui_ctx->vibrate_on_hover(); + ImGui::PopStyleVar(3); } // Return the vector v such that dot(v, x) > 0 iff x is on the side where the composition layer is visible @@ -714,6 +722,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte case gui_status::stats: case gui_status::settings: case gui_status::applications: + case gui_status::application_launcher: break; } imgui_ctx->set_controllers_enabled(interactable); @@ -783,6 +792,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte case gui_status::stats: case gui_status::settings: case gui_status::applications: + case gui_status::application_launcher: imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation; imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position; break; @@ -829,6 +839,12 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte always_auto_resize = false; display_tabs = true; break; + case gui_status::application_launcher: + ImGui::SetNextWindowPos(margin_around_window); + ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - margin_around_window * 2); + always_auto_resize = false; + display_tabs = false; + break; } ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0); @@ -887,6 +903,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte gui_applications(); ImGui::EndChild(); break; + + case gui_status::application_launcher: + if (apps.draw_gui(*imgui_ctx, _("Cancel")) != app_launcher::None) + gui_status = gui_status::applications; } ImGui::PopStyleVar(2); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding