Reorganize tabs, fix opacity not settable to 80%

This commit is contained in:
Guillaume Meunier
2026-07-27 23:28:47 +02:00
parent 2d2f064576
commit bf77b93a17
7 changed files with 92 additions and 92 deletions
+64 -64
View File
@@ -206,7 +206,7 @@ void render_settings(const wivrn::gui::settings_context & ctx, const char * card
namespace wivrn::gui
{
void settings_performance(const settings_context & ctx)
void settings_video(const settings_context & ctx)
{
auto & config = ctx.config;
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
@@ -270,6 +270,31 @@ void settings_performance(const settings_context & ctx)
});
}
if (ctx.instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
list.push_back({
.id = "##spacewarp",
.label = _("Application SpaceWarp"),
.description = _("Renders at half the refresh rate. The headset may synthesise frames."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.fps_divider == 2; },
.set_bool = [&ctx, &config](bool v) { config.fps_divider = v ? 2 : 1; config.save(); if (ctx.on_streaming_changed) ctx.on_streaming_changed(); },
.default_bool = false,
.enabled = [&config] { return config.preferred_refresh_rate != 0; },
.disabled_tooltip = _("Set a refresh rate other than auto to enable this setting."),
});
}
ui::page_header(_cS("page header title", "Video"), _cS("page header subtitle", "Frame rate and resolution."));
render_settings(ctx, "##video", list);
}
void settings_streaming(const settings_context & ctx)
{
auto & config = ctx.config;
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
std::vector<setting> list;
list.push_back({
.id = "##foveation",
.label = _("Foveated encoding"),
@@ -291,44 +316,6 @@ void settings_performance(const settings_context & ctx)
.disabled_tooltip = disconnect_tip,
});
if (ctx.instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
list.push_back({
.id = "##spacewarp",
.label = _("Application SpaceWarp"),
.description = _("Renders at half the refresh rate. The headset may synthesise frames."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.fps_divider == 2; },
.set_bool = [&ctx, &config](bool v) { config.fps_divider = v ? 2 : 1; config.save(); if (ctx.on_streaming_changed) ctx.on_streaming_changed(); },
.default_bool = false,
.enabled = [&config] { return config.preferred_refresh_rate != 0; },
.disabled_tooltip = _("Set a refresh rate other than auto to enable this setting."),
});
}
if (ctx.instance.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
{
list.push_back({
.id = "##high_power",
.label = _("High power mode"),
.description = _("Increase power usage to allow higher resolution and refresh rate. Drains battery and runs hot."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.high_power_mode; },
.set_bool = [&config](bool v) { config.high_power_mode = v; config.save(); },
.default_bool = true,
});
}
ui::page_header(_cS("page header title", "Performance"), _cS("page header subtitle", "Frame rate, resolution and power draw."));
render_settings(ctx, "##performance", list);
}
void settings_streaming(const settings_context & ctx)
{
auto & config = ctx.config;
const std::string disconnect_tip = ctx.in_game ? _C("tooltip for disabled settings", "Disconnect to change this setting.") : std::string{};
std::vector<setting> list;
auto codec_name = [](std::optional<wivrn::video_codec> codec) -> std::string {
if (not codec)
return _C("Codec", "Automatic");
@@ -434,33 +421,9 @@ void settings_streaming(const settings_context & ctx)
});
}
bool disable_instream_gui = false;
bool disable_instream_gui_popup_open = ImGui::IsPopupOpen("confirm disable in stream gui");
list.push_back({
.id = "##stream_gui",
.label = _C("setting name", "In-stream window"),
.description = _("Enables the configuration window to be shown while the game is streaming. If enabled, the window is activated by pressing both thumbsticks."),
.ui = ui_kind::toggle,
.get_bool = [&config, &disable_instream_gui_popup_open] { return config.enable_stream_gui and not disable_instream_gui_popup_open; },
.set_bool = [&ctx, &config, &disable_instream_gui](bool v) {
if (ctx.in_game and not v)
{
disable_instream_gui = true;
}
else
{
config.enable_stream_gui = v;
config.save();
} },
.default_bool = true,
});
ui::page_header(_cS("page header title", "Streaming"), _cS("page header subtitle", "How video is encoded and sent to the headset."));
render_settings(ctx, "##streaming", list);
if (disable_instream_gui)
ImGui::OpenPopup("confirm disable in stream gui");
if (wivrn::ui::confirm_modal(
"confirm disable in stream gui",
_C("confirmation messagebox title", "Disable in-stream window"),
@@ -755,8 +718,45 @@ void settings_system(const settings_context & ctx)
.default_bool = false,
});
if (ctx.instance.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
{
list.push_back({
.id = "##high_power",
.label = _("High power mode"),
.description = _("Increase power usage to allow higher resolution and refresh rate. Drains battery and runs hot."),
.ui = ui_kind::toggle,
.get_bool = [&config] { return config.high_power_mode; },
.set_bool = [&config](bool v) { config.high_power_mode = v; config.save(); },
.default_bool = true,
});
}
bool disable_instream_gui = false;
bool disable_instream_gui_popup_open = ImGui::IsPopupOpen("confirm disable in stream gui");
list.push_back({
.id = "##stream_gui",
.label = _C("setting name", "In-stream window"),
.description = _("Enables the configuration window to be shown while the game is streaming. If enabled, the window is activated by pressing both thumbsticks."),
.ui = ui_kind::toggle,
.get_bool = [&config, &disable_instream_gui_popup_open] { return config.enable_stream_gui and not disable_instream_gui_popup_open; },
.set_bool = [&ctx, &config, &disable_instream_gui](bool v) {
if (ctx.in_game and not v)
{
disable_instream_gui = true;
}
else
{
config.enable_stream_gui = v;
config.save();
} },
.default_bool = true,
});
ui::page_header(_cS("page header title", "System"), _cS("page header suibtitle", "Language and advanced options."));
render_settings(ctx, "##system", list);
if (disable_instream_gui)
ImGui::OpenPopup("confirm disable in stream gui");
}
void settings_theme(const settings_context & ctx)
@@ -862,7 +862,7 @@ void settings_theme(const settings_context & ctx)
// Panel transparency, independent of the selected preset
static const int opacity_default = 75;
int opacity = int(ui::background_alpha() * 100);
int opacity = int(ui::background_alpha() * 100 + 0.5);
ui::setting_label(_cS("setting name", "Panel opacity"), _cS("setting description", "Opacity of the panel and card backgrounds"), control_w);
if (ui::slider_int("##opacity", &opacity, 20, 100, "%d%%", {control_w, 0}, &opacity_default))
{
+1 -1
View File
@@ -59,7 +59,7 @@ struct settings_context
std::function<void()> on_foveation_override_changed; // foveation override toggled
};
void settings_performance(const settings_context &);
void settings_video(const settings_context &);
void settings_streaming(const settings_context &);
void settings_post_processing(const settings_context &);
void settings_audio(const settings_context &);
+3 -3
View File
@@ -119,10 +119,10 @@ class lobby : public scene_impl<lobby>
{
first_run,
server_list,
performance,
video,
audio,
streaming,
post_processing,
audio,
devices,
tracking,
system,
@@ -230,7 +230,7 @@ class lobby : public scene_impl<lobby>
void gui_disconnected();
void gui_server_list();
void gui_new_server();
void gui_performance();
void gui_video();
void gui_streaming();
void gui_audio();
void gui_devices();
+12 -12
View File
@@ -1160,16 +1160,20 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
gui_server_list();
break;
case tab::performance:
gui_performance();
case tab::video:
gui_video();
break;
case tab::audio:
gui_audio();
break;
case tab::streaming:
gui_streaming();
break;
case tab::audio:
gui_audio();
case tab::post_processing:
gui_post_processing();
break;
case tab::devices:
@@ -1184,10 +1188,6 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
gui_system();
break;
case tab::post_processing:
gui_post_processing();
break;
case tab::customize:
gui_customize(predicted_display_time);
break;
@@ -1233,14 +1233,14 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
current_tab = tab::server_list;
wivrn::ui::nav_section(_cS("tab group", "SETTINGS"));
if (wivrn::ui::nav_item(ICON_FA_GAUGE_HIGH, _cS("tab label", "Performance"), current_tab == tab::performance))
current_tab = tab::performance;
if (wivrn::ui::nav_item(ICON_FA_IMAGE, _cS("tab label", "Video"), current_tab == tab::video))
current_tab = tab::video;
if (wivrn::ui::nav_item(ICON_FA_VOLUME_HIGH, _cS("tab label", "Audio"), current_tab == tab::audio))
current_tab = tab::audio;
if (wivrn::ui::nav_item(ICON_FA_TOWER_BROADCAST, _cS("tab label", "Streaming"), current_tab == tab::streaming))
current_tab = tab::streaming;
if (wivrn::ui::nav_item(ICON_FA_WAND_MAGIC_SPARKLES, _cS("tab label", "Post-processing"), current_tab == tab::post_processing))
current_tab = tab::post_processing;
if (wivrn::ui::nav_item(ICON_FA_VOLUME_HIGH, _cS("tab label", "Audio"), current_tab == tab::audio))
current_tab = tab::audio;
if (wivrn::ui::nav_item(ICON_FA_KEYBOARD, _cS("tab label", "Devices"), current_tab == tab::devices))
current_tab = tab::devices;
if (wivrn::ui::nav_item(ICON_FA_LOCATION_CROSSHAIRS, _cS("tab label", "Tracking"), current_tab == tab::tracking))
+2 -2
View File
@@ -42,9 +42,9 @@ wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr:
}
} // namespace
void scenes::lobby::gui_performance()
void scenes::lobby::gui_video()
{
wivrn::gui::settings_performance(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
wivrn::gui::settings_video(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
}
void scenes::lobby::gui_streaming()
+3 -3
View File
@@ -145,16 +145,16 @@ private:
// settings sub-page, client-only: the wire stream_tab stays settings
enum class settings_page
{
performance,
video,
audio,
streaming,
post_processing,
audio,
devices,
tracking,
theme,
system,
};
settings_page current_settings_page = settings_page::performance;
settings_page current_settings_page = settings_page::video;
// Tab currently being displayed
stream_tab gui_status = stream_tab::hidden;
+7 -7
View File
@@ -428,8 +428,11 @@ void scenes::stream::gui_settings(float)
switch (current_settings_page)
{
case settings_page::performance:
wivrn::gui::settings_performance(ctx);
case settings_page::video:
wivrn::gui::settings_video(ctx);
break;
case settings_page::audio:
wivrn::gui::settings_audio(ctx);
break;
case settings_page::streaming:
wivrn::gui::settings_streaming(ctx);
@@ -437,9 +440,6 @@ void scenes::stream::gui_settings(float)
case settings_page::post_processing:
wivrn::gui::settings_post_processing(ctx);
break;
case settings_page::audio:
wivrn::gui::settings_audio(ctx);
break;
case settings_page::devices:
wivrn::gui::settings_devices(ctx);
break;
@@ -1025,10 +1025,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
next_gui_status = stream_tab::settings;
}
};
settings_item(ICON_FA_GAUGE_HIGH, _cS("tab label", "Performance"), settings_page::performance);
settings_item(ICON_FA_IMAGE, _cS("tab label", "Video"), settings_page::video);
settings_item(ICON_FA_VOLUME_HIGH, _cS("tab label", "Audio"), settings_page::audio);
settings_item(ICON_FA_TOWER_BROADCAST, _cS("tab label", "Streaming"), settings_page::streaming);
settings_item(ICON_FA_WAND_MAGIC_SPARKLES, _cS("tab label", "Post-processing"), settings_page::post_processing);
settings_item(ICON_FA_VOLUME_HIGH, _cS("tab label", "Audio"), settings_page::audio);
settings_item(ICON_FA_KEYBOARD, _cS("tab label", "Devices"), settings_page::devices);
settings_item(ICON_FA_LOCATION_CROSSHAIRS, _cS("tab label", "Tracking"), settings_page::tracking);
settings_item(ICON_FA_GEARS, _cS("tab label", "System"), settings_page::system);