Ui improvements

This commit is contained in:
ahsanswr
2026-07-26 17:24:36 +02:00
committed by Guillaume Meunier
parent 4226485c57
commit 2e9f2c8646
21 changed files with 1560 additions and 1026 deletions
+60 -1
View File
@@ -19,6 +19,7 @@
#include "gui_common.h"
#include "android/battery.h"
#include "application.h"
#include "configuration.h"
#include "constants.h"
@@ -34,6 +35,8 @@
#include "imgui.h"
#include "imgui_internal.h"
#include <IconsFontAwesome6.h>
#include <cmath>
namespace wivrn::gui
{
@@ -129,7 +132,8 @@ bool refresh_rate(
bool body_tracking_parts(
xr::system & system,
imgui_context & imgui_ctx,
configuration & config)
configuration & config,
bool in_game)
{
auto body_tracker = system.body_tracker_supported();
if (body_tracker == xr::body_tracker_type::none or body_tracker == xr::body_tracker_type::htc)
@@ -151,6 +155,7 @@ bool body_tracking_parts(
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {12, 10});
ui::begin_card("##body_tracking_parts");
ImGui::BeginDisabled(in_game);
for (const auto & [bit, id, name]: body_parts)
{
if (body_tracker == xr::body_tracker_type::fb and bit > from_headset::body_part_mask::hip)
@@ -176,6 +181,7 @@ bool body_tracking_parts(
const float pad = std::max(label_bottom - ImGui::GetCursorPosY(), 0.f) + ui::metrics::label_bottom_pad;
ImGui::Dummy({0, pad});
}
ImGui::EndDisabled();
ui::end_card();
ImGui::PopStyleVar();
@@ -264,4 +270,57 @@ bool post_processing(
ImGui::Unindent();
return changed;
}
std::optional<battery_indicator> battery_status_indicator(XrTime now)
{
#ifdef __ANDROID__
const auto battery = get_battery_status();
if (not battery.charge)
return std::nullopt;
const char * icon = ICON_FA_BATTERY_FULL;
int icon_nr;
if (battery.charging)
icon_nr = *battery.charge > 0.995 ? 5 : now / 500'000'000 % 5;
else
icon_nr = std::round((*battery.charge) * 4);
switch (icon_nr)
{
case 0:
icon = ICON_FA_BATTERY_EMPTY;
break;
case 1:
icon = ICON_FA_BATTERY_QUARTER;
break;
case 2:
icon = ICON_FA_BATTERY_HALF;
break;
case 3:
icon = ICON_FA_BATTERY_THREE_QUARTERS;
break;
case 4:
icon = ICON_FA_BATTERY_FULL;
break;
case 5:
icon = ICON_FA_PLUG;
break;
}
ui::chip_style style;
if (*battery.charge < 0.2)
style = ui::chip_style::danger;
else if (*battery.charge < 0.5)
style = ui::chip_style::warning;
else
style = ui::chip_style::success;
return battery_indicator{
.label = fmt::format("{} {}%", icon, (int)std::round(*battery.charge * 100)),
.style = style,
};
#else
(void)now;
return std::nullopt;
#endif
}
} // namespace wivrn::gui