Fixes and improvements
This commit is contained in:
committed by
Guillaume Meunier
parent
a5b1b6dbeb
commit
12834824ab
@@ -56,6 +56,7 @@ class lobby : public scene_impl<lobby>
|
||||
int add_server_window_port = wivrn::default_port;
|
||||
bool add_server_tcp_only = false;
|
||||
std::string add_server_cookie;
|
||||
std::string delete_server_cookie; // server pending a delete confirmation
|
||||
|
||||
utils::future<std::unique_ptr<wivrn_session>, std::string> async_session;
|
||||
std::optional<std::string> async_error;
|
||||
@@ -126,8 +127,8 @@ class lobby : public scene_impl<lobby>
|
||||
tracking,
|
||||
system,
|
||||
customize,
|
||||
theme,
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
components,
|
||||
debug,
|
||||
#endif
|
||||
about,
|
||||
@@ -237,7 +238,7 @@ class lobby : public scene_impl<lobby>
|
||||
void gui_system();
|
||||
void gui_post_processing();
|
||||
void gui_customize(XrTime predicted_display_time);
|
||||
void gui_components();
|
||||
void gui_theme();
|
||||
void gui_debug_node_hierarchy(entt::entity root = entt::null);
|
||||
void gui_debug();
|
||||
void gui_about();
|
||||
|
||||
+139
-62
@@ -366,10 +366,14 @@ void scenes::lobby::gui_server_list()
|
||||
ui::page_header(_S("Computers"), _S("Pick a PC running the WiVRn server to stream from."));
|
||||
const ImVec2 hend = ImGui::GetCursorPos();
|
||||
|
||||
const std::string add_label = std::string(ICON_FA_PLUS " ") + _("Add server");
|
||||
const float add_w = ImGui::CalcTextSize(add_label.c_str()).x + ui::metrics::button_padding.x * 2;
|
||||
const std::string add_label = _("Add server");
|
||||
const float font = ImGui::GetFontSize();
|
||||
ImGui::PushFont(nullptr, font * ui::metrics::button_label_glyph);
|
||||
const float glyph_w = ImGui::CalcTextSize(ICON_FA_PLUS).x;
|
||||
ImGui::PopFont();
|
||||
const float add_w = glyph_w + font * 0.4f + ImGui::CalcTextSize(add_label.c_str()).x + ui::metrics::button_padding.x * 2;
|
||||
ImGui::SetCursorPos({hstart.x + header_avail - add_w, hstart.y});
|
||||
if (ui::button(add_label, ui::button_style::primary))
|
||||
if (ui::button(ICON_FA_PLUS, add_label, ui::button_style::primary))
|
||||
{
|
||||
add_server_cookie = "";
|
||||
add_server_window_prettyname = "";
|
||||
@@ -384,10 +388,10 @@ void scenes::lobby::gui_server_list()
|
||||
for (auto && [cookie, data]: config.servers)
|
||||
sorted_cookies.emplace(data.service.name, cookie);
|
||||
|
||||
std::string cookie_to_remove;
|
||||
// deferred: the action menu runs inside the per-row id stack, but the popup is
|
||||
// deferred: the action menu runs inside the per-row id stack, but the popups are
|
||||
// opened below in this scope so OpenPopup and begin_modal hash to the same id
|
||||
bool open_add_edit = false;
|
||||
bool open_delete = false;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
|
||||
ui::begin_card("##servers");
|
||||
@@ -408,14 +412,22 @@ void scenes::lobby::gui_server_list()
|
||||
ui::row_separator();
|
||||
first = false;
|
||||
|
||||
const bool available = (data.visible and data.compatible) or data.manual;
|
||||
// Connect button reflects the real reachability state so a momentary
|
||||
// discovery delay doesn't read as a hard failure:
|
||||
// - reachable: manual server, or one discovered with a matching protocol
|
||||
// - incompatible: discovered and resolved, but the protocol version differs
|
||||
// - searching: not seen on the network yet (or still resolving its records)
|
||||
const bool reachable = (data.visible and data.compatible) or data.manual;
|
||||
const bool incompatible = data.visible and data.service.txt.contains("protocol") and not data.compatible;
|
||||
const float gap = ImGui::GetStyle().ItemSpacing.x;
|
||||
const float bh = ImGui::GetFrameHeight() * ui::metrics::control_height;
|
||||
const std::string sub = fmt::format("{} : {}", data.service.hostname, data.service.port);
|
||||
|
||||
// trailing controls: [Auto chip] [Connect] [menu], measured up front so the
|
||||
// row body click area can exclude them
|
||||
const std::string c_label = available ? std::string(ICON_FA_PLAY " ") + _("Connect") : _("Unavailable");
|
||||
const char * c_icon = reachable ? ICON_FA_PLAY : (incompatible ? ICON_FA_TRIANGLE_EXCLAMATION : ICON_FA_MAGNIFYING_GLASS);
|
||||
const std::string c_label = std::string(c_icon) + " " + (reachable ? _("Connect") : (incompatible ? _("Incompatible") : _("Searching…")));
|
||||
const std::string c_tooltip = reachable ? std::string{} : (incompatible ? _("Incompatible server version") : _("Looking for this server on your network"));
|
||||
const float cw = ImGui::CalcTextSize(c_label.c_str()).x + ui::metrics::button_padding.x * 2;
|
||||
const std::string chip_label = std::string(ICON_FA_BOLT " ") + _("Auto");
|
||||
const ImVec2 chip_ts = ImGui::CalcTextSize(chip_label.c_str());
|
||||
@@ -453,19 +465,22 @@ void scenes::lobby::gui_server_list()
|
||||
open_add_edit = true;
|
||||
break;
|
||||
case 2:
|
||||
cookie_to_remove = cookie;
|
||||
delete_server_cookie = cookie;
|
||||
open_delete = true;
|
||||
break;
|
||||
}
|
||||
x -= bh + gap;
|
||||
|
||||
// connect / unavailable
|
||||
// connect / searching / incompatible
|
||||
ImGui::SetCursorScreenPos({x - cw, row.min.y + (row_h - bh) * 0.5f});
|
||||
ImGui::BeginDisabled(not available);
|
||||
if (ui::button(c_label, available ? ui::button_style::primary : ui::button_style::secondary, {cw, 0}))
|
||||
ImGui::BeginDisabled(not reachable);
|
||||
if (ui::button(c_label, reachable ? ui::button_style::primary : ui::button_style::secondary, {cw, 0}))
|
||||
{
|
||||
connect(data);
|
||||
ImGui::OpenPopup("connecting");
|
||||
}
|
||||
if (not c_tooltip.empty() and ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
imgui_ctx->tooltip(c_tooltip);
|
||||
ImGui::EndDisabled();
|
||||
x -= cw + gap;
|
||||
|
||||
@@ -485,15 +500,12 @@ void scenes::lobby::gui_server_list()
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
if (cookie_to_remove != "")
|
||||
{
|
||||
config.servers.erase(cookie_to_remove);
|
||||
config.save();
|
||||
}
|
||||
|
||||
if (open_add_edit)
|
||||
ImGui::OpenPopup("add or edit server");
|
||||
|
||||
if (open_delete)
|
||||
ImGui::OpenPopup("delete server");
|
||||
|
||||
// Check if we need to report errors after a disconnect
|
||||
if (next_scene and next_scene->current_state() == scenes::stream::state::shutdown and not ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup))
|
||||
ImGui::OpenPopup("disconnected");
|
||||
@@ -530,6 +542,25 @@ void scenes::lobby::gui_server_list()
|
||||
gui_new_server();
|
||||
wivrn::ui::end_modal();
|
||||
}
|
||||
|
||||
if (not delete_server_cookie.empty())
|
||||
{
|
||||
std::string name;
|
||||
if (auto it = config.servers.find(delete_server_cookie); it != config.servers.end())
|
||||
name = it->second.service.name;
|
||||
|
||||
switch (wivrn::ui::confirm_modal("delete server", _("Delete server"), fmt::format(_F("Remove \"{}\" from your saved computers?"), name), _("Delete"), _("Cancel"), true))
|
||||
{
|
||||
case 1:
|
||||
config.servers.erase(delete_server_cookie);
|
||||
config.save();
|
||||
delete_server_cookie = "";
|
||||
break;
|
||||
case -1:
|
||||
delete_server_cookie = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleVar(3);
|
||||
}
|
||||
|
||||
@@ -866,46 +897,69 @@ void scenes::lobby::gui_first_run()
|
||||
|
||||
void scenes::lobby::gui_licenses()
|
||||
{
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
ImGui::Text("%s", _("Licenses").c_str());
|
||||
ImGui::PopFont();
|
||||
namespace ui = wivrn::ui;
|
||||
const auto & t = ui::current();
|
||||
|
||||
const auto components = {"WiVRn", "FontAwesome", "openxr-loader", "simdjson"};
|
||||
if (not license)
|
||||
ui::page_header(_S("Licenses"), _S("Open-source components bundled with WiVRn."));
|
||||
|
||||
// Components shipping a license file, probed once
|
||||
static const std::vector<std::string> components = [] {
|
||||
std::vector<std::string> v;
|
||||
for (const char * c: {"WiVRn", "FontAwesome", "openxr-loader", "simdjson"})
|
||||
{
|
||||
try
|
||||
{
|
||||
utils::mapped_file probe(std::filesystem::path("assets://licenses") / c);
|
||||
v.emplace_back(c);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
spdlog::debug("No license file for {}", c);
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}();
|
||||
|
||||
if (components.empty())
|
||||
return;
|
||||
|
||||
if (selected_item.empty())
|
||||
selected_item = components.front();
|
||||
|
||||
int selected = 0;
|
||||
for (size_t i = 0; i < components.size(); ++i)
|
||||
if (components[i] == selected_item)
|
||||
selected = int(i);
|
||||
|
||||
std::vector<ui::combo_item> items;
|
||||
for (const auto & c: components)
|
||||
items.push_back({c.c_str()});
|
||||
|
||||
const float control_w = 480;
|
||||
if (ui::combo("##component", _("Component"), items, &selected, control_w) or not license)
|
||||
{
|
||||
selected_item = *components.begin();
|
||||
selected_item = components[selected];
|
||||
try
|
||||
{
|
||||
license = std::make_unique<utils::mapped_file>(std::filesystem::path("assets://licenses") / selected_item);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
license.reset();
|
||||
spdlog::warn("No license file for {}", selected_item);
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginCombo("##component", selected_item.c_str()))
|
||||
{
|
||||
for (const auto & component: components)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto current = std::make_unique<utils::mapped_file>(std::filesystem::path("assets://licenses") / component);
|
||||
if (ImGui::Selectable(component, component == selected_item, ImGuiSelectableFlags_SelectOnRelease))
|
||||
{
|
||||
selected_item = component;
|
||||
license = std::move(current);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
spdlog::debug("No license file for {}", component);
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
if (license)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
|
||||
ui::begin_card("##license_text");
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, t.text_muted);
|
||||
ImGui::TextUnformatted((const char *)license->data(), (const char *)license->data() + license->size());
|
||||
ImGui::PopStyleColor();
|
||||
ui::end_card();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_keyboard()
|
||||
@@ -989,6 +1043,15 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
ImGuiStyle & style = ImGui::GetStyle();
|
||||
style.FontScaleMain = wivrn::ui::current().font_scale * wivrn::ui::metrics::font_base;
|
||||
|
||||
// rounding follows the theme so every window/popup gets rounded corners
|
||||
// (theme::apply() is never called; the widgets theme colours themselves but nothing sets rounding)
|
||||
style.WindowRounding = wivrn::ui::current().card_rounding;
|
||||
style.ChildRounding = wivrn::ui::current().card_rounding;
|
||||
style.PopupRounding = wivrn::ui::current().card_rounding;
|
||||
style.FrameRounding = wivrn::ui::current().rounding;
|
||||
style.GrabRounding = wivrn::ui::current().rounding;
|
||||
style.TabRounding = wivrn::ui::current().rounding;
|
||||
|
||||
// base text colour follows the theme so plain ImGui text is legible on light themes
|
||||
style.Colors[ImGuiCol_Text] = wivrn::ui::current().text;
|
||||
style.Colors[ImGuiCol_TextDisabled] = wivrn::ui::current().text_muted;
|
||||
@@ -996,7 +1059,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
// combo modals open centred on the popup layer
|
||||
const auto & ui_popup_layer = imgui_ctx->layers()[1];
|
||||
const glm::vec2 ui_popup_center = ui_popup_layer.vp_origin + ui_popup_layer.vp_size / 2;
|
||||
wivrn::ui::set_popup_center({ui_popup_center.x, ui_popup_center.y});
|
||||
wivrn::ui::set_popup_center({ui_popup_center.x, ui_popup_center.y}, float(ui_popup_layer.vp_size.y));
|
||||
|
||||
// let the themed widgets fire the hover haptic and show tooltips
|
||||
wivrn::ui::set_hover_haptic([this] { imgui_ctx->vibrate_on_hover(); });
|
||||
@@ -1048,21 +1111,23 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
auto & config = application::get_config();
|
||||
const float TopBarH = 72;
|
||||
|
||||
// Top bar: logo on the left, status controls on the right
|
||||
// Top bar: logo on the left, status controls on the right.
|
||||
// Transparent child bg so the alpha-blended window background shows through.
|
||||
ImGui::SetCursorPos({0, 0});
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, wivrn::ui::current().background);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4{0, 0, 0, 0});
|
||||
ImGui::BeginChild("TopBar", {ImGui::GetWindowSize().x, TopBarH}, 0, ImGuiWindowFlags_NoScrollbar);
|
||||
{
|
||||
const float side = ImGui::GetFrameHeight() * wivrn::ui::metrics::control_height;
|
||||
const float gap = 8;
|
||||
|
||||
// logo
|
||||
// logo: WiVRn mascot followed by the wordmark
|
||||
const float logo_size = 44;
|
||||
ImGui::SetCursorPos({24, (TopBarH - logo_size) * 0.5f});
|
||||
if (about_picture)
|
||||
ImGui::Image(about_picture, {logo_size, logo_size});
|
||||
ImGui::SameLine(0, 12);
|
||||
ImGui::PushFont(nullptr, ImGui::GetStyle().FontSizeBase * 1.3f);
|
||||
ImGui::SetCursorPos({24, (TopBarH - ImGui::GetFontSize()) * 0.5f});
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, wivrn::ui::current().accent);
|
||||
ImGui::TextUnformatted(ICON_FA_EYE);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::SameLine(0, 10);
|
||||
ImGui::SetCursorPosY((TopBarH - ImGui::GetFontSize()) * 0.5f);
|
||||
ImGui::TextUnformatted("WiVRn");
|
||||
ImGui::PopFont();
|
||||
|
||||
@@ -1070,7 +1135,8 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
const std::string conn = _("Not connected");
|
||||
const ImVec2 cts = ImGui::CalcTextSize(conn.c_str());
|
||||
const float dot_r = cts.y * 0.26f;
|
||||
const float chip_w = cts.x + wivrn::ui::metrics::chip_padding.x * 2.5f + dot_r * 2;
|
||||
// pill: pad_x on each side + dot + 0.55 pad_x gap before the text (see ui::chip)
|
||||
const float chip_w = cts.x + wivrn::ui::metrics::chip_pill_padding_x * 2.55f + dot_r * 2;
|
||||
|
||||
// feature toggles available on this headset (mic + passthrough are always shown)
|
||||
const bool has_hand = system.hand_tracking_supported();
|
||||
@@ -1116,7 +1182,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
if (*battery.charge < 0.2)
|
||||
battery_style = wivrn::ui::chip_style::danger;
|
||||
}
|
||||
const float battery_w = battery_label.empty() ? 0 : gap + ImGui::CalcTextSize(battery_label.c_str()).x + wivrn::ui::metrics::chip_padding.x * 2;
|
||||
const float battery_w = battery_label.empty() ? 0 : gap + ImGui::CalcTextSize(battery_label.c_str()).x + wivrn::ui::metrics::chip_pill_padding_x * 2;
|
||||
#else
|
||||
const float battery_w = 0;
|
||||
#endif
|
||||
@@ -1230,11 +1296,11 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
gui_customize(predicted_display_time);
|
||||
break;
|
||||
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
case tab::components:
|
||||
gui_components();
|
||||
case tab::theme:
|
||||
gui_theme();
|
||||
break;
|
||||
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
case tab::debug:
|
||||
gui_debug();
|
||||
break;
|
||||
@@ -1265,7 +1331,9 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar(2); // ImGuiStyleVar_FrameRounding, ImGuiStyleVar_WindowPadding
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, wivrn::ui::current().card);
|
||||
// Sidebar shares the same transparent background as the rest of the window;
|
||||
// the sections are separated by hairline dividers drawn below.
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4{0, 0, 0, 0});
|
||||
ImGui::SetCursorPos({0, TopBarH});
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {16, 16});
|
||||
@@ -1293,11 +1361,11 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
current_tab = tab::system;
|
||||
|
||||
wivrn::ui::nav_section(_S("PERSONALIZE"));
|
||||
if (wivrn::ui::nav_item(ICON_FA_IMAGE, _S("Customize"), current_tab == tab::customize))
|
||||
if (wivrn::ui::nav_item(ICON_FA_IMAGE, _S("Environment"), current_tab == tab::customize))
|
||||
current_tab = tab::customize;
|
||||
if (wivrn::ui::nav_item(ICON_FA_PALETTE, _S("Theme"), current_tab == tab::theme))
|
||||
current_tab = tab::theme;
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
if (wivrn::ui::nav_item(ICON_FA_PALETTE, "Components", current_tab == tab::components))
|
||||
current_tab = tab::components;
|
||||
if (wivrn::ui::nav_item(ICON_FA_BUG_SLASH, _S("Debug"), current_tab == tab::debug))
|
||||
current_tab = tab::debug;
|
||||
#endif
|
||||
@@ -1317,6 +1385,15 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_WindowPadding (Tabs)
|
||||
}
|
||||
ImGui::PopStyleColor(); // ImGuiCol_ChildBg
|
||||
|
||||
// hairline dividers separating the top bar, sidebar and main panel
|
||||
const ImU32 divider = ImGui::GetColorU32(wivrn::ui::current().border);
|
||||
const ImVec2 win_pos = ImGui::GetWindowPos();
|
||||
const ImVec2 win_size = ImGui::GetWindowSize();
|
||||
ImDrawList * dl = ImGui::GetWindowDrawList();
|
||||
dl->AddLine({win_pos.x, win_pos.y + TopBarH}, {win_pos.x + win_size.x, win_pos.y + TopBarH}, divider);
|
||||
dl->AddLine({win_pos.x + TabWidth, win_pos.y + TopBarH}, {win_pos.x + TabWidth, win_pos.y + win_size.y}, divider);
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_WindowPadding
|
||||
}
|
||||
|
||||
@@ -1,363 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2026 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#include "lobby.h"
|
||||
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
|
||||
#include "render/ui_theme.h"
|
||||
#include "render/ui_widgets.h"
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
#include "IconsFontAwesome6.h"
|
||||
|
||||
namespace ui = wivrn::ui;
|
||||
|
||||
// Card title shown above the rows
|
||||
static void card_title(const char * title)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ui::current().text_muted);
|
||||
ImGui::TextUnformatted(title);
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::Dummy({0, 4});
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_components()
|
||||
{
|
||||
ui::theme & theme = ui::current();
|
||||
|
||||
ui::page_header("Components", "Live preview of the WiVRn UI kit");
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
|
||||
const float control_w = 480;
|
||||
|
||||
// Theme
|
||||
ui::begin_card("##theme");
|
||||
{
|
||||
card_title("THEME");
|
||||
|
||||
// Accent
|
||||
ImGui::TextUnformatted("Accent color");
|
||||
ImGui::Dummy({0, 2});
|
||||
for (const auto & swatch: ui::accent_swatches())
|
||||
{
|
||||
const bool selected = theme.accent.x == swatch.base.x and theme.accent.y == swatch.base.y and theme.accent.z == swatch.base.z;
|
||||
const auto flags = ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoBorder | (selected ? 0 : ImGuiColorEditFlags_NoDragDrop);
|
||||
if (ImGui::ColorButton(swatch.name, swatch.base, flags, {ImGui::GetFrameHeight() * 1.4f, ImGui::GetFrameHeight() * 1.4f}))
|
||||
ui::set_accent(swatch);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::NewLine();
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Preset
|
||||
static int preset = 1; // dark_default
|
||||
const auto preset_list = ui::presets();
|
||||
std::vector<ui::combo_item> preset_items;
|
||||
for (const auto & p: preset_list)
|
||||
preset_items.push_back({p.name.c_str()});
|
||||
|
||||
static const int preset_default = 1;
|
||||
ui::setting_label("Preset", "Surface and background palette", control_w);
|
||||
if (ui::combo("##preset", "Theme preset", preset_items, &preset, control_w, &preset_default))
|
||||
{
|
||||
const ImVec4 keep_accent = theme.accent;
|
||||
const ImVec4 keep_hover = theme.accent_hovered;
|
||||
const ImVec4 keep_active = theme.accent_active;
|
||||
ui::set_theme(preset_list[preset]);
|
||||
theme.accent = keep_accent;
|
||||
theme.accent_hovered = keep_hover;
|
||||
theme.accent_active = keep_active;
|
||||
}
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Rounding
|
||||
static const int rounding_default = 8;
|
||||
int rounding = int(theme.rounding);
|
||||
ui::setting_label("Rounding", "Corner radius of controls", control_w);
|
||||
if (ui::slider_int("##rounding", &rounding, 0, 20, "%d px", {control_w, 0}, &rounding_default))
|
||||
theme.rounding = float(rounding);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
static const int card_rounding_default = 14;
|
||||
int card_rounding = int(theme.card_rounding);
|
||||
ui::setting_label("Card rounding", "Corner radius of panels", control_w);
|
||||
if (ui::slider_int("##card_rounding", &card_rounding, 0, 28, "%d px", {control_w, 0}, &card_rounding_default))
|
||||
theme.card_rounding = float(card_rounding);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Text size, applied globally via style.FontScaleMain next frame. 100% is the
|
||||
// design default; the value is a user multiplier on metrics::font_base.
|
||||
static const int font_scale_default = 100;
|
||||
int font_scale = int(theme.font_scale * 100);
|
||||
ui::setting_label("Text size", "Global font scale", control_w);
|
||||
if (ui::slider_int("##font_scale", &font_scale, 60, 140, "%d%%", {control_w, 0}, &font_scale_default))
|
||||
theme.font_scale = float(font_scale) / 100.f;
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Panel transparency
|
||||
static const int opacity_default = 88;
|
||||
int opacity = int(theme.background_alpha * 100);
|
||||
ui::setting_label("Panel opacity", "Opacity of the main panel background", control_w);
|
||||
if (ui::slider_int("##opacity", &opacity, 20, 100, "%d%%", {control_w, 0}, &opacity_default))
|
||||
theme.background_alpha = float(opacity) / 100.f;
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Buttons
|
||||
ui::begin_card("##buttons");
|
||||
{
|
||||
card_title("BUTTONS");
|
||||
|
||||
ui::button("Primary", ui::button_style::primary);
|
||||
ImGui::SameLine();
|
||||
ui::button("Secondary", ui::button_style::secondary);
|
||||
ImGui::SameLine();
|
||||
ui::button(ICON_FA_POWER_OFF " Disconnect", ui::button_style::danger);
|
||||
ImGui::SameLine();
|
||||
ui::button("Ghost", ui::button_style::ghost);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
card_title("ICON BUTTONS");
|
||||
static bool mic = true;
|
||||
if (ui::icon_button(ICON_FA_MICROPHONE, {}, mic, mic ? "Mute microphone" : "Unmute microphone"))
|
||||
mic = not mic;
|
||||
ImGui::SameLine();
|
||||
ui::icon_button(ICON_FA_EYE_SLASH, {}, false, "Toggle passthrough");
|
||||
ImGui::SameLine();
|
||||
ui::icon_button(ICON_FA_HAND, {}, false, "Hand tracking");
|
||||
ImGui::SameLine();
|
||||
ui::icon_button(ICON_FA_ARROW_ROTATE_LEFT, {}, false, "Recenter");
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Toggles
|
||||
ui::begin_card("##toggles");
|
||||
{
|
||||
card_title("TOGGLES");
|
||||
|
||||
// room for the toggle plus a trailing reset slot
|
||||
const float toggle_w = ImGui::GetFrameHeight() * ui::metrics::control_height * ui::metrics::toggle_aspect;
|
||||
const float toggle_row_w = toggle_w + ImGui::GetFrameHeight() * ui::metrics::control_height + ImGui::GetStyle().ItemSpacing.x;
|
||||
|
||||
static const bool spacewarp_default = false;
|
||||
static bool spacewarp = true;
|
||||
ui::setting_label("Application SpaceWarp", "Synthesises in-between frames so motion stays smooth", toggle_row_w);
|
||||
ui::toggle("##spacewarp", &spacewarp, &spacewarp_default);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
static const bool high_power_default = true;
|
||||
static bool high_power = true;
|
||||
ui::setting_label("High power mode", "Higher sustained clocks for steadier frames", toggle_row_w);
|
||||
ui::toggle("##high_power", &high_power, &high_power_default);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Sliders
|
||||
ui::begin_card("##sliders");
|
||||
{
|
||||
card_title("SLIDERS");
|
||||
|
||||
static const int resolution_default = 100;
|
||||
static int resolution = 145;
|
||||
ui::setting_label("Render resolution", "Pixels rendered per eye", control_w);
|
||||
ui::slider_int("##resolution", &resolution, 50, 350, "%d%%", {control_w, 0}, &resolution_default);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
static const int bitrate_default = 100;
|
||||
static int bitrate = 165;
|
||||
ui::setting_label("Bitrate", "Video data rate", control_w);
|
||||
ui::slider_int("##bitrate", &bitrate, 10, 500, "%d Mbit/s", {control_w, 0}, &bitrate_default);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Segmented control
|
||||
ui::begin_card("##segmented");
|
||||
{
|
||||
card_title("SEGMENTED CONTROL");
|
||||
|
||||
static const int refresh_default = 0;
|
||||
static int refresh = 2;
|
||||
static const std::vector<std::string> rates = {"Auto", "72", "80", "90", "120"};
|
||||
ui::setting_label("Refresh rate", "Frames per second shown in the headset", control_w);
|
||||
ui::segmented("##refresh", rates, &refresh, {control_w, 0}, &refresh_default);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Combo
|
||||
ui::begin_card("##combo");
|
||||
{
|
||||
card_title("COMBO");
|
||||
|
||||
static const std::vector<ui::combo_item> codecs = {
|
||||
{"Automatic", "Picks the best codec your PC supports"},
|
||||
{"H.264", "Lowest latency, widest support"},
|
||||
{"HEVC (H.265)", "Better quality per bit"},
|
||||
{"AV1", "Best efficiency, newest GPUs only"},
|
||||
};
|
||||
static const int codec_default = 0;
|
||||
static int selected = 2;
|
||||
|
||||
ui::setting_label("Video codec", "How video is compressed and sent to the headset", control_w);
|
||||
ui::combo("##codec", "Video codec", codecs, &selected, control_w, &codec_default);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Navigation (sidebar styling)
|
||||
ui::begin_card("##nav");
|
||||
{
|
||||
card_title("NAVIGATION");
|
||||
|
||||
static int nav = 2;
|
||||
int row = 0;
|
||||
|
||||
if (ui::nav_item(ICON_FA_COMPUTER, "Computers", nav == row))
|
||||
nav = row;
|
||||
++row;
|
||||
|
||||
ui::nav_section("SETTINGS");
|
||||
for (const auto & [icon, label]: {
|
||||
std::pair{ICON_FA_GAUGE_HIGH, "Performance"},
|
||||
std::pair{ICON_FA_TOWER_BROADCAST, "Streaming"},
|
||||
std::pair{ICON_FA_CROP, "Field of view"},
|
||||
std::pair{ICON_FA_VOLUME_HIGH, "Audio"},
|
||||
std::pair{ICON_FA_LOCATION_CROSSHAIRS, "Tracking"},
|
||||
std::pair{ICON_FA_GEARS, "System"},
|
||||
})
|
||||
{
|
||||
if (ui::nav_item(icon, label, nav == row))
|
||||
nav = row;
|
||||
++row;
|
||||
}
|
||||
|
||||
ui::nav_section("PERSONALIZE");
|
||||
if (ui::nav_item(ICON_FA_IMAGE, "Customize", nav == row))
|
||||
nav = row;
|
||||
++row;
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Chips
|
||||
ui::begin_card("##chips");
|
||||
{
|
||||
card_title("CHIPS");
|
||||
|
||||
ui::chip(ICON_FA_BOLT " Auto", ui::chip_style::accent);
|
||||
ImGui::SameLine();
|
||||
ui::chip(ICON_FA_BATTERY_HALF " 38%", ui::chip_style::success);
|
||||
ImGui::SameLine();
|
||||
ui::chip("Connected", ui::chip_style::success, true);
|
||||
ImGui::SameLine();
|
||||
ui::chip("Not connected", ui::chip_style::muted, true);
|
||||
ImGui::SameLine();
|
||||
ui::chip("Unavailable", ui::chip_style::muted);
|
||||
ImGui::SameLine();
|
||||
ui::chip("Beta", ui::chip_style::warning);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Text & number inputs
|
||||
ui::begin_card("##inputs");
|
||||
{
|
||||
card_title("INPUTS");
|
||||
|
||||
static std::string name, address;
|
||||
static int port = 9757;
|
||||
|
||||
ui::setting_label("Name", "Friendly label for the server", control_w);
|
||||
ui::input_text("##name", name, "My gaming PC", control_w);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
ui::setting_label("Address", "Hostname or IP of the PC", control_w);
|
||||
ui::input_text("##address", address, "192.168.1.10 or host.local", control_w);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
ui::setting_label("Port", "TCP/UDP port the server listens on", control_w);
|
||||
ui::input_int("##port", &port, 1, 1, 65535, control_w);
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
// Dialog
|
||||
ui::begin_card("##dialog");
|
||||
{
|
||||
card_title("DIALOG");
|
||||
|
||||
if (ui::button("Add server"))
|
||||
ImGui::OpenPopup("##add_server_demo");
|
||||
|
||||
static std::string d_name, d_address;
|
||||
static int d_port = 9757;
|
||||
if (ui::begin_modal("##add_server_demo", "Add server", 620))
|
||||
{
|
||||
const float w = ImGui::GetContentRegionAvail().x;
|
||||
ImGui::TextUnformatted("Name");
|
||||
ui::input_text("##d_name", d_name, "My gaming PC", w);
|
||||
ImGui::Dummy({0, 4});
|
||||
ImGui::TextUnformatted("Address");
|
||||
ui::input_text("##d_address", d_address, "192.168.1.10 or host.local", w);
|
||||
ImGui::Dummy({0, 4});
|
||||
ImGui::TextUnformatted("Port");
|
||||
ui::input_int("##d_port", &d_port, 1, 1, 65535, w);
|
||||
|
||||
ImGui::Dummy({0, 12});
|
||||
|
||||
// right-aligned footer
|
||||
const float gap = ImGui::GetStyle().ItemSpacing.x;
|
||||
const float cancel_w = ImGui::CalcTextSize("Cancel").x + ui::metrics::button_padding.x * 2;
|
||||
const float save_w = ImGui::CalcTextSize("Save").x + ui::metrics::button_padding.x * 2;
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - cancel_w - save_w - gap);
|
||||
|
||||
if (ui::button("Cancel", ui::button_style::secondary))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::SameLine();
|
||||
if (ui::button("Save", ui::button_style::primary))
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
ui::end_modal();
|
||||
}
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_ItemSpacing
|
||||
}
|
||||
|
||||
#endif // WIVRN_CLIENT_DEBUG_MENU
|
||||
@@ -651,7 +651,7 @@ void scenes::lobby::gui_customize(XrTime predicted_display_time)
|
||||
|
||||
namespace ui = wivrn::ui;
|
||||
|
||||
ui::page_header(_S("Customize"), _S("Choose the environment your panels float in."));
|
||||
ui::page_header(_S("Environment"), _S("Choose the environment your panels float in."));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2026 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#include "lobby.h"
|
||||
|
||||
#include "render/ui_theme.h"
|
||||
#include "render/ui_widgets.h"
|
||||
#include "utils/i18n.h"
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ui = wivrn::ui;
|
||||
|
||||
void scenes::lobby::gui_theme()
|
||||
{
|
||||
ui::theme & theme = ui::current();
|
||||
|
||||
ui::page_header(_S("Theme"), _S("Accent color, palette and sizing of the interface."));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
|
||||
const float control_w = 480;
|
||||
|
||||
ui::begin_card("##theme");
|
||||
{
|
||||
// Accent
|
||||
ImGui::TextUnformatted(_S("Accent color"));
|
||||
ImGui::Dummy({0, 2});
|
||||
for (const auto & swatch: ui::accent_swatches())
|
||||
{
|
||||
const bool selected = theme.accent.x == swatch.base.x and theme.accent.y == swatch.base.y and theme.accent.z == swatch.base.z;
|
||||
const auto flags = ImGuiColorEditFlags_NoTooltip | ImGuiColorEditFlags_NoBorder | (selected ? 0 : ImGuiColorEditFlags_NoDragDrop);
|
||||
if (ImGui::ColorButton(swatch.name, swatch.base, flags, {ImGui::GetFrameHeight() * 1.4f, ImGui::GetFrameHeight() * 1.4f}))
|
||||
ui::set_accent(swatch);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
ImGui::NewLine();
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Preset
|
||||
static int preset = 1; // dark_default
|
||||
const auto preset_list = ui::presets();
|
||||
std::vector<ui::combo_item> preset_items;
|
||||
for (const auto & p: preset_list)
|
||||
preset_items.push_back({p.name.c_str()});
|
||||
|
||||
static const int preset_default = 1;
|
||||
ui::setting_label(_S("Preset"), _S("Surface and background palette"), control_w);
|
||||
if (ui::combo("##preset", _("Theme preset"), preset_items, &preset, control_w, &preset_default))
|
||||
{
|
||||
// keep the accent across a preset change, only the surfaces swap
|
||||
const ImVec4 keep_accent = theme.accent;
|
||||
const ImVec4 keep_hover = theme.accent_hovered;
|
||||
const ImVec4 keep_active = theme.accent_active;
|
||||
ui::set_theme(preset_list[preset]);
|
||||
theme.accent = keep_accent;
|
||||
theme.accent_hovered = keep_hover;
|
||||
theme.accent_active = keep_active;
|
||||
}
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Rounding
|
||||
static const int rounding_default = 8;
|
||||
int rounding = int(theme.rounding);
|
||||
ui::setting_label(_S("Rounding"), _S("Corner radius of controls"), control_w);
|
||||
if (ui::slider_int("##rounding", &rounding, 0, 20, "%d px", {control_w, 0}, &rounding_default))
|
||||
theme.rounding = float(rounding);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
static const int card_rounding_default = 14;
|
||||
int card_rounding = int(theme.card_rounding);
|
||||
ui::setting_label(_S("Card rounding"), _S("Corner radius of panels"), control_w);
|
||||
if (ui::slider_int("##card_rounding", &card_rounding, 0, 28, "%d px", {control_w, 0}, &card_rounding_default))
|
||||
theme.card_rounding = float(card_rounding);
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Text size, applied globally via style.FontScaleMain next frame. 100% is the
|
||||
// design default; the value is a user multiplier on metrics::font_base.
|
||||
static const int font_scale_default = 100;
|
||||
int font_scale = int(theme.font_scale * 100);
|
||||
ui::setting_label(_S("Text size"), _S("Global font scale"), control_w);
|
||||
if (ui::slider_int("##font_scale", &font_scale, 60, 140, "%d%%", {control_w, 0}, &font_scale_default))
|
||||
theme.font_scale = float(font_scale) / 100.f;
|
||||
|
||||
ui::row_separator();
|
||||
|
||||
// Panel transparency
|
||||
static const int opacity_default = 100;
|
||||
int opacity = int(theme.background_alpha * 100);
|
||||
ui::setting_label(_S("Panel opacity"), _S("Opacity of the main panel background"), control_w);
|
||||
if (ui::slider_int("##opacity", &opacity, 20, 100, "%d%%", {control_w, 0}, &opacity_default))
|
||||
theme.background_alpha = float(opacity) / 100.f;
|
||||
|
||||
ui::end_card();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_ItemSpacing
|
||||
}
|
||||
Reference in New Issue
Block a user