Refactors
This commit is contained in:
committed by
Guillaume Meunier
parent
80ee73128d
commit
84d172f2e8
+168
-175
@@ -24,10 +24,10 @@
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <magic_enum.hpp>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
@@ -37,103 +37,118 @@
|
||||
// If no refresh rate is configured, don't select a too high one
|
||||
static const float max_default_rate = 100;
|
||||
|
||||
namespace
|
||||
{
|
||||
// scalar settings with a mechanical key <-> member mapping
|
||||
// everything else is handled explicitly in the constructor and save() below
|
||||
using config_member = std::variant<
|
||||
bool configuration::*,
|
||||
float configuration::*,
|
||||
uint32_t configuration::*,
|
||||
std::string configuration::*>;
|
||||
|
||||
// key <-> member serialization descriptor for scalar settings (see config_fields()).
|
||||
// The few settings that aren't scalars are handled explicitly in save()/load().
|
||||
struct config_field
|
||||
{
|
||||
const char * key;
|
||||
config_member member;
|
||||
std::function<void(std::ostream &, const configuration &)> save;
|
||||
std::function<void(simdjson::dom::element, configuration &)> load;
|
||||
};
|
||||
|
||||
const std::vector<config_field> & scalar_fields()
|
||||
namespace
|
||||
{
|
||||
static const std::vector<config_field> fields = {
|
||||
{"resolution_scale", &configuration::resolution_scale},
|
||||
{"bitrate_bps", &configuration::bitrate_bps},
|
||||
{"enable_stream_gui", &configuration::enable_stream_gui},
|
||||
{"app_list_view", &configuration::app_list_view},
|
||||
{"app_icon_size", &configuration::app_icon_size},
|
||||
{"theme_preset", &configuration::theme_preset},
|
||||
{"theme_accent", &configuration::theme_accent},
|
||||
{"theme_rounding", &configuration::theme_rounding},
|
||||
{"theme_card_rounding", &configuration::theme_card_rounding},
|
||||
{"theme_font_scale", &configuration::theme_font_scale},
|
||||
{"theme_background_alpha", &configuration::theme_background_alpha},
|
||||
{"passthrough_enabled", &configuration::passthrough_enabled},
|
||||
{"mic_unprocessed_audio", &configuration::mic_unprocessed_audio},
|
||||
{"forward_keyboard", &configuration::forward_keyboard},
|
||||
{"forward_mouse", &configuration::forward_mouse},
|
||||
{"forward_gamepad", &configuration::forward_gamepad},
|
||||
{"virtual_keyboard_layout", &configuration::virtual_keyboard_layout},
|
||||
{"override_foveation_enable", &configuration::override_foveation_enable},
|
||||
{"override_foveation_pitch", &configuration::override_foveation_pitch},
|
||||
{"override_foveation_distance", &configuration::override_foveation_distance},
|
||||
{"first_run", &configuration::first_run},
|
||||
{"locale", &configuration::locale},
|
||||
{"environment_model", &configuration::environment_model},
|
||||
{"high_power_mode", &configuration::high_power_mode},
|
||||
{"fps_divider", &configuration::fps_divider},
|
||||
{"extended_config", &configuration::extended_config},
|
||||
template <typename>
|
||||
inline constexpr bool is_optional_v = false;
|
||||
template <typename T>
|
||||
inline constexpr bool is_optional_v<std::optional<T>> = true;
|
||||
|
||||
template <typename T>
|
||||
struct remove_optional
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
template <typename T>
|
||||
struct remove_optional<std::optional<T>>
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
std::ostream & operator<<(std::ostream & stream, feature f)
|
||||
{
|
||||
return stream << "\"" << magic_enum::enum_name(f) << "\"";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void write_value(std::ostream & json, const T & value)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
json << std::boolalpha << value;
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
json << json_string(value);
|
||||
else if constexpr (std::is_enum_v<T>)
|
||||
json << json_string(magic_enum::enum_name(value));
|
||||
else if constexpr (std::is_integral_v<T>)
|
||||
json << (uint64_t)value;
|
||||
else // floating point
|
||||
json << value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::optional<T> read_value(simdjson::simdjson_result<simdjson::dom::element> val)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
{
|
||||
if (val.is_bool())
|
||||
return val.get_bool();
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
if (val.is_string())
|
||||
return std::string(std::string_view(val.get_string().value()));
|
||||
}
|
||||
else if constexpr (std::is_enum_v<T>)
|
||||
{
|
||||
if (val.is_string())
|
||||
{
|
||||
auto name = val.get_string().value();
|
||||
for (const auto & [e, n]: magic_enum::enum_entries<T>())
|
||||
if (name == n)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
else if constexpr (std::is_integral_v<T>)
|
||||
{
|
||||
if (val.is_uint64())
|
||||
return (T)val.get_uint64();
|
||||
if (val.is_int64() and int64_t(val.get_int64()) >= 0)
|
||||
return (T)val.get_int64();
|
||||
}
|
||||
else // floating point
|
||||
{
|
||||
if (val.is_double())
|
||||
return (T)val.get_double();
|
||||
if (val.is_int64())
|
||||
return (T)val.get_int64();
|
||||
if (val.is_uint64())
|
||||
return (T)val.get_uint64();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// build a field for a plain member: bool / float / integral / std::string / enum,
|
||||
// optionally wrapped in std::optional (only written when set)
|
||||
template <typename T>
|
||||
config_field scalar(const char * key, T configuration::* member)
|
||||
{
|
||||
return {
|
||||
.save = [key, member](std::ostream & json, const configuration & c) {
|
||||
if constexpr (is_optional_v<T>)
|
||||
{
|
||||
if (c.*member)
|
||||
{
|
||||
json << ",\"" << key << "\":";
|
||||
write_value(json, *(c.*member));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
json << ",\"" << key << "\":";
|
||||
write_value(json, c.*member);
|
||||
} },
|
||||
.load = [key, member](simdjson::dom::element root, configuration & c) {
|
||||
if (auto v = read_value<typename remove_optional<T>::type>(root[key]))
|
||||
c.*member = *v; },
|
||||
};
|
||||
return fields;
|
||||
}
|
||||
|
||||
void load_field(simdjson::dom::element root, configuration & c, const config_field & f)
|
||||
{
|
||||
auto val = root[f.key];
|
||||
std::visit([&](auto mp) {
|
||||
using T = std::remove_cvref_t<decltype(c.*mp)>;
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
{
|
||||
if (val.is_bool())
|
||||
c.*mp = val.get_bool();
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
if (val.is_string())
|
||||
c.*mp = std::string(std::string_view(val.get_string().value()));
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, uint32_t>)
|
||||
{
|
||||
if (val.is_uint64())
|
||||
c.*mp = uint32_t(uint64_t(val.get_uint64()));
|
||||
else if (val.is_int64() and int64_t(val.get_int64()) >= 0)
|
||||
c.*mp = uint32_t(int64_t(val.get_int64()));
|
||||
}
|
||||
else // float
|
||||
{
|
||||
if (val.is_double())
|
||||
c.*mp = float(double(val.get_double()));
|
||||
else if (val.is_int64())
|
||||
c.*mp = float(int64_t(val.get_int64()));
|
||||
else if (val.is_uint64())
|
||||
c.*mp = float(uint64_t(val.get_uint64()));
|
||||
}
|
||||
},
|
||||
f.member);
|
||||
}
|
||||
|
||||
void save_field(std::ostream & json, const configuration & c, const config_field & f)
|
||||
{
|
||||
std::visit([&](auto mp) {
|
||||
using T = std::remove_cvref_t<decltype(c.*mp)>;
|
||||
json << ",\"" << f.key << "\":";
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
json << std::boolalpha << (c.*mp);
|
||||
else if constexpr (std::is_same_v<T, std::string>)
|
||||
json << json_string(c.*mp);
|
||||
else
|
||||
json << (c.*mp);
|
||||
},
|
||||
f.member);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -215,6 +230,7 @@ configuration::configuration(xr::system & system, xr::session & session)
|
||||
break;
|
||||
preferred_refresh_rate = rate;
|
||||
}
|
||||
const float default_refresh_rate = preferred_refresh_rate;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -238,40 +254,12 @@ configuration::configuration(xr::system & system, xr::session & session)
|
||||
servers.emplace(data.service.txt["cookie"], data);
|
||||
}
|
||||
|
||||
for (const auto & f: scalar_fields())
|
||||
load_field(root, *this, f);
|
||||
for (const auto & f: config_fields())
|
||||
f.load(root, *this);
|
||||
|
||||
// settings with non-mechanical encoding
|
||||
if (auto val = root["preferred_refresh_rate"]; val.is_double())
|
||||
{
|
||||
float f = val.get_double();
|
||||
if (f == 0 or utils::contains(rates, f))
|
||||
preferred_refresh_rate = f;
|
||||
}
|
||||
|
||||
if (auto val = root["minimum_refresh_rate"]; val.is_double())
|
||||
minimum_refresh_rate = val.get_double();
|
||||
|
||||
if (auto val = root["stream_scale"]; val.is_double())
|
||||
stream_scale = val.get_double();
|
||||
|
||||
if (auto val = root["codec"]; val.is_string())
|
||||
{
|
||||
const auto codec_str = val.get_string().value();
|
||||
for (const auto & [c, name]: magic_enum::enum_entries<wivrn::video_codec>())
|
||||
{
|
||||
if (codec_str == name)
|
||||
{
|
||||
codec = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto val = root["bit_depth"]; val.is_uint64())
|
||||
bit_depth = val.get_uint64();
|
||||
|
||||
if (auto val = root["openxr_post_processing"]; val.is_object())
|
||||
parse_openxr_post_processing_options(val.get_object());
|
||||
// refresh rate must be supported by this headset, otherwise fall back to the default
|
||||
if (preferred_refresh_rate != 0 and not utils::contains(rates, preferred_refresh_rate))
|
||||
preferred_refresh_rate = default_refresh_rate;
|
||||
|
||||
if (auto val = root["body_parts"]; val.is_object())
|
||||
{
|
||||
@@ -292,12 +280,22 @@ configuration::configuration(xr::system & system, xr::session & session)
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto & [i, name]: magic_enum::enum_entries<feature>())
|
||||
// nested object
|
||||
if (auto val = root["openxr_post_processing"]; val.is_object())
|
||||
{
|
||||
if (auto val = root[name]; val.is_bool())
|
||||
features[i] = val.get_bool();
|
||||
auto obj = val.get_object();
|
||||
openxr_post_processing = {};
|
||||
if (auto v = obj["super_sampling"]; v.is_int64())
|
||||
openxr_post_processing.super_sampling = v.get_int64();
|
||||
if (auto v = obj["sharpening"]; v.is_int64())
|
||||
openxr_post_processing.sharpening = v.get_int64();
|
||||
}
|
||||
|
||||
// feature flags, keyed by enum name
|
||||
for (const auto & [f, name]: magic_enum::enum_entries<feature>())
|
||||
if (auto val = root[name]; val.is_bool())
|
||||
features[f] = val.get_bool();
|
||||
|
||||
if (system.passthrough_supported() == xr::passthrough_type::none)
|
||||
passthrough_enabled = false;
|
||||
}
|
||||
@@ -307,27 +305,42 @@ configuration::configuration(xr::system & system, xr::session & session)
|
||||
}
|
||||
}
|
||||
|
||||
void configuration::parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> openxr_post_processing_root)
|
||||
const std::vector<config_field> & configuration::config_fields()
|
||||
{
|
||||
openxr_post_processing = {};
|
||||
if (auto val = openxr_post_processing_root["super_sampling"]; val.is_int64())
|
||||
openxr_post_processing.super_sampling = val.get_int64();
|
||||
|
||||
if (auto val = openxr_post_processing_root["sharpening"]; val.is_int64())
|
||||
openxr_post_processing.sharpening = val.get_int64();
|
||||
}
|
||||
|
||||
static std::ostream & operator<<(std::ostream & stream, feature f)
|
||||
{
|
||||
return stream << "\"" << magic_enum::enum_name(f) << "\"";
|
||||
}
|
||||
|
||||
static std::ostream & write_openxr_post_processing(std::ofstream & stream, const configuration::openxr_post_processing_settings & openxr_post_processing)
|
||||
{
|
||||
stream << "{\"super_sampling\":" << openxr_post_processing.super_sampling;
|
||||
stream << ",\"sharpening\":" << openxr_post_processing.sharpening;
|
||||
stream << "}";
|
||||
return stream;
|
||||
static const std::vector<config_field> fields = {
|
||||
scalar("resolution_scale", &configuration::resolution_scale),
|
||||
scalar("bitrate_bps", &configuration::bitrate_bps),
|
||||
scalar("enable_stream_gui", &configuration::enable_stream_gui),
|
||||
scalar("app_list_view", &configuration::app_list_view),
|
||||
scalar("app_icon_size", &configuration::app_icon_size),
|
||||
scalar("theme_preset", &configuration::theme_preset),
|
||||
scalar("theme_accent", &configuration::theme_accent),
|
||||
scalar("theme_rounding", &configuration::theme_rounding),
|
||||
scalar("theme_card_rounding", &configuration::theme_card_rounding),
|
||||
scalar("theme_font_scale", &configuration::theme_font_scale),
|
||||
scalar("theme_background_alpha", &configuration::theme_background_alpha),
|
||||
scalar("passthrough_enabled", &configuration::passthrough_enabled),
|
||||
scalar("mic_unprocessed_audio", &configuration::mic_unprocessed_audio),
|
||||
scalar("forward_keyboard", &configuration::forward_keyboard),
|
||||
scalar("forward_mouse", &configuration::forward_mouse),
|
||||
scalar("forward_gamepad", &configuration::forward_gamepad),
|
||||
scalar("virtual_keyboard_layout", &configuration::virtual_keyboard_layout),
|
||||
scalar("override_foveation_enable", &configuration::override_foveation_enable),
|
||||
scalar("override_foveation_pitch", &configuration::override_foveation_pitch),
|
||||
scalar("override_foveation_distance", &configuration::override_foveation_distance),
|
||||
scalar("first_run", &configuration::first_run),
|
||||
scalar("locale", &configuration::locale),
|
||||
scalar("environment_model", &configuration::environment_model),
|
||||
scalar("high_power_mode", &configuration::high_power_mode),
|
||||
scalar("fps_divider", &configuration::fps_divider),
|
||||
scalar("extended_config", &configuration::extended_config),
|
||||
scalar("preferred_refresh_rate", &configuration::preferred_refresh_rate),
|
||||
scalar("minimum_refresh_rate", &configuration::minimum_refresh_rate),
|
||||
scalar("stream_scale", &configuration::stream_scale),
|
||||
scalar("codec", &configuration::codec),
|
||||
scalar("bit_depth", &configuration::bit_depth),
|
||||
};
|
||||
return fields;
|
||||
}
|
||||
|
||||
void configuration::save()
|
||||
@@ -360,37 +373,17 @@ void configuration::save()
|
||||
|
||||
json << "{\"servers\":[" << servers_str << "]";
|
||||
|
||||
for (const auto & f: scalar_fields())
|
||||
save_field(json, *this, f);
|
||||
for (const auto & f: config_fields())
|
||||
f.save(json, *this);
|
||||
|
||||
// settings with non-mechanical encoding
|
||||
json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate;
|
||||
if (minimum_refresh_rate)
|
||||
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
|
||||
if (stream_scale)
|
||||
json << ",\"stream_scale\":" << *stream_scale;
|
||||
if (codec)
|
||||
json << ",\"codec\":" << json_string(magic_enum::enum_name(*codec));
|
||||
json << ",\"bit_depth\":" << (uint64_t)bit_depth;
|
||||
json << ",\"openxr_post_processing\":";
|
||||
write_openxr_post_processing(json, openxr_post_processing);
|
||||
|
||||
std::stringstream body_part_ss;
|
||||
for (const auto & [b, name]: magic_enum::enum_entries<wivrn::from_headset::body_part_mask>())
|
||||
{
|
||||
bool enabled = (body_part_mask & std::to_underlying(b)) != 0;
|
||||
body_part_ss << "\"" << name << "\":" << std::boolalpha << enabled << ",";
|
||||
}
|
||||
|
||||
std::string body_parts_str = body_part_ss.str();
|
||||
if (!body_parts_str.empty())
|
||||
{
|
||||
body_parts_str.pop_back(); // Remove last comma
|
||||
json << ",\"body_parts\":{" << body_parts_str << "}";
|
||||
}
|
||||
// nested object
|
||||
json << ",\"openxr_post_processing\":{\"super_sampling\":" << openxr_post_processing.super_sampling;
|
||||
json << ",\"sharpening\":" << openxr_post_processing.sharpening << "}";
|
||||
|
||||
// feature flags, keyed by enum name
|
||||
for (auto & [key, value]: features)
|
||||
json << "," << key << ":" << std::boolalpha << value;
|
||||
|
||||
json << "}";
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <simdjson.h>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
namespace xr
|
||||
@@ -36,6 +37,9 @@ class session;
|
||||
class system;
|
||||
} // namespace xr
|
||||
|
||||
// key <-> member serialization descriptor, defined in configuration.cpp
|
||||
struct config_field;
|
||||
|
||||
enum class feature
|
||||
{
|
||||
microphone,
|
||||
@@ -124,7 +128,8 @@ private:
|
||||
std::map<feature, bool> features;
|
||||
std::optional<float> stream_scale;
|
||||
|
||||
void parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> root);
|
||||
// table of scalar settings shared by save()/load(); non-scalar settings are explicit
|
||||
static const std::vector<config_field> & config_fields();
|
||||
|
||||
public:
|
||||
configuration(xr::system &, xr::session &);
|
||||
|
||||
+3
-22
@@ -68,6 +68,9 @@ constexpr uint32_t pointer_color_border = 0xff000000;
|
||||
// offset of a popup layer in front of its main GUI panel
|
||||
constexpr glm::vec3 popup_position = {0, 0, 0.05};
|
||||
|
||||
// world-space offset of a hover tooltip layer from the hovered item
|
||||
constexpr glm::vec3 tooltip_distance = {0, 0.004, 0.005};
|
||||
|
||||
// scale/bias dimming the main GUI panel behind a popup
|
||||
constexpr XrColor4f popup_dimming_scale = {0.5, 0.5, 0.5, 1};
|
||||
constexpr XrColor4f popup_dimming_bias = {0.25, 0.25, 0.25, 0};
|
||||
@@ -138,25 +141,3 @@ constexpr float gui_min_layer_distance = 0.5;
|
||||
constexpr float gui_max_layer_distance = 3;
|
||||
|
||||
} // namespace constants::stream
|
||||
|
||||
namespace constants::style
|
||||
{
|
||||
constexpr ImVec2 window_padding = {20, 20};
|
||||
constexpr float window_border_size = 2;
|
||||
constexpr float window_rounding = 10;
|
||||
|
||||
constexpr ImVec2 tooltip_padding = {16, 12};
|
||||
constexpr float tooltip_rounding = 0;
|
||||
constexpr glm::vec3 tooltip_distance = {0, 0.004, 0.005};
|
||||
|
||||
constexpr ImVec2 button_size = {220, 80};
|
||||
constexpr ImVec2 icon_button_size = {80, 80};
|
||||
constexpr float connection_popup_width = 1000;
|
||||
|
||||
constexpr ImVec2 pin_entry_key_size = {90, 70};
|
||||
constexpr ImVec2 pin_entry_item_spacing = {10, 10};
|
||||
constexpr float pin_entry_popup_width = 3 * pin_entry_key_size.x + 2 * pin_entry_item_spacing.x;
|
||||
|
||||
constexpr ImColor warn(0xf9, 0x73, 0x06);
|
||||
|
||||
} // namespace constants::style
|
||||
|
||||
@@ -1292,7 +1292,7 @@ void imgui_context::tooltip(std::string_view text, std::optional<ImVec2> anchor)
|
||||
// Draw the tooltip in the tooltip layer, themed
|
||||
// Clamp position to avoid overflowing on the left or the right
|
||||
const wivrn::ui::theme & t = wivrn::ui::current();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, wivrn::ui::metrics::tooltip_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, t.card_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, t.border_size);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, t.card);
|
||||
@@ -1322,7 +1322,7 @@ void imgui_context::tooltip(std::string_view text, std::optional<ImVec2> anchor)
|
||||
auto M = glm::mat3_cast(tooltip_orientation);
|
||||
|
||||
float pixel_size = current_layer.size.y / current_layer.vp_size.y;
|
||||
glm::vec3 tooltip_position_centre = rw_from_vp(item_position) + M * (glm::vec3(0, tooltip_size.y / 2, 0) * pixel_size + constants::style::tooltip_distance);
|
||||
glm::vec3 tooltip_position_centre = rw_from_vp(item_position) + M * (glm::vec3(0, tooltip_size.y / 2, 0) * pixel_size + constants::gui::tooltip_distance);
|
||||
|
||||
// Position the tooltip layer
|
||||
tooltip_layer.position = tooltip_position_centre;
|
||||
|
||||
@@ -132,6 +132,19 @@ constexpr float app_view_toggle_width = 150; // grid/list segmented control
|
||||
constexpr float app_size_toggle_width = 300; // small/medium/large segmented control
|
||||
constexpr float app_spinner_radius = 110; // app-starting spinner
|
||||
constexpr float app_spinner_thickness = 22;
|
||||
|
||||
// modal/popup windows not yet on the card system (first-run, confirm dialogs, loading popup)
|
||||
constexpr ImVec2 window_padding = {20, 20};
|
||||
constexpr float window_rounding = 10;
|
||||
constexpr float window_border_size = 2;
|
||||
|
||||
constexpr ImVec2 tooltip_padding = {16, 12}; // hover tooltip window padding
|
||||
constexpr ImVec2 button_size = {220, 80}; // big touch buttons in confirm dialogs
|
||||
|
||||
// PIN entry keypad
|
||||
constexpr ImVec2 pin_entry_key_size = {90, 70};
|
||||
constexpr ImVec2 pin_entry_item_spacing = {10, 10};
|
||||
constexpr float pin_entry_popup_width = 3 * pin_entry_key_size.x + 2 * pin_entry_item_spacing.x;
|
||||
} // namespace metrics
|
||||
|
||||
// theme in effect, call current().apply() after mutating
|
||||
|
||||
+10
-10
@@ -65,7 +65,7 @@ using namespace std::chrono_literals;
|
||||
static void display_recentering_tip(imgui_context & ctx, const std::string & tip)
|
||||
{
|
||||
ImGui::PushFont(nullptr, constants::gui::font_size_large);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::window_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, wivrn::ui::metrics::window_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 2);
|
||||
ImGui::SetNextWindowPos(ctx.layers()[3].vp_center(), ImGuiCond_Always, {0.5, 0.5});
|
||||
ImGui::Begin("Recentering tip", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize);
|
||||
@@ -163,7 +163,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
|
||||
ImGui::PopFont();
|
||||
ImGui::Dummy({0, style.ItemSpacing.y});
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, constants::style::pin_entry_item_spacing);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ui::metrics::pin_entry_item_spacing);
|
||||
|
||||
// PIN display: big digits, muted placeholder while empty
|
||||
const std::string displayed_text = pin_buffer == "" ? _("PIN") : pin_buffer;
|
||||
@@ -171,7 +171,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
|
||||
const auto window = ImGui::GetCurrentWindow();
|
||||
const ImGuiID id = window->GetID("PIN");
|
||||
const ImVec2 label_size = ImGui::CalcTextSize(displayed_text.c_str(), nullptr, true);
|
||||
const ImVec2 size = {constants::style::pin_entry_popup_width, label_size.y + style.FramePadding.y * 2.0f};
|
||||
const ImVec2 size = {ui::metrics::pin_entry_popup_width, label_size.y + style.FramePadding.y * 2.0f};
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
ImGui::ItemSize(size, style.FramePadding.y);
|
||||
if (!ImGui::ItemAdd(bb, id))
|
||||
@@ -190,7 +190,7 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
|
||||
if (ImGui::IsItemHovered())
|
||||
imgui_ctx->tooltip(_("Input the PIN displayed on the dashboard"));
|
||||
|
||||
using constants::style::pin_entry_key_size;
|
||||
using ui::metrics::pin_entry_key_size;
|
||||
|
||||
ImGui::BeginDisabled(pin_buffer.size() == pin_size);
|
||||
for (int i = 1; i <= 9;)
|
||||
@@ -854,18 +854,18 @@ void scenes::lobby::gui_first_run()
|
||||
|
||||
CenterTextH(optional_features[optional_feature_index].text);
|
||||
|
||||
float button_width = constants::style::button_size.x;
|
||||
float button_width = wivrn::ui::metrics::button_size.x;
|
||||
float buttons_width = 2 * button_width + style.ItemSpacing.x;
|
||||
ImGui::SetCursorPosX((win_width - buttons_width) / 2);
|
||||
|
||||
if (ImGui::Button(_S("Yes"), constants::style::button_size))
|
||||
if (ImGui::Button(_S("Yes"), wivrn::ui::metrics::button_size))
|
||||
{
|
||||
config.set_feature(optional_features[optional_feature_index].f, true);
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(_S("No"), constants::style::button_size))
|
||||
if (ImGui::Button(_S("No"), wivrn::ui::metrics::button_size))
|
||||
{
|
||||
config.set_feature(optional_features[optional_feature_index].f, false);
|
||||
optional_feature_index++;
|
||||
@@ -1066,9 +1066,9 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> scenes::lobby::draw_gui(XrTi
|
||||
if (current_tab == tab::first_run)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::window_padding * 2);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::window_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, constants::style::window_border_size);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, wivrn::ui::metrics::window_padding * 2);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, wivrn::ui::metrics::window_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, wivrn::ui::metrics::window_border_size);
|
||||
ImGui::Begin("WiVRn", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize);
|
||||
gui_first_run();
|
||||
ImGui::End();
|
||||
|
||||
@@ -533,9 +533,9 @@ void scenes::lobby::popup_load_environment(XrTime predicted_display_time)
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(imgui_ctx->layers()[1].vp_center(), ImGuiCond_Always, {0.5f, 0.5f});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::window_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::window_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, constants::style::window_border_size);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, wivrn::ui::metrics::window_padding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, wivrn::ui::metrics::window_rounding);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, wivrn::ui::metrics::window_border_size);
|
||||
if (ImGui::BeginPopupModal("loading environment model", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
if (future_environment.valid())
|
||||
|
||||
Reference in New Issue
Block a user