UI improvements
This commit is contained in:
committed by
Guillaume Meunier
parent
b7d17db0c7
commit
5e359fe983
@@ -80,7 +80,7 @@ public:
|
|||||||
|
|
||||||
// application launcher: list vs grid, and grid icon size, 0 small 1 medium 2 large
|
// application launcher: list vs grid, and grid icon size, 0 small 1 medium 2 large
|
||||||
bool app_list_view = false;
|
bool app_list_view = false;
|
||||||
uint32_t app_icon_size = 1;
|
uint32_t app_icon_size = 0;
|
||||||
|
|
||||||
// Interface theme; defaults match the built-in "Dark" preset / "Blue" accent
|
// Interface theme; defaults match the built-in "Dark" preset / "Blue" accent
|
||||||
std::string theme_preset = "Dark";
|
std::string theme_preset = "Dark";
|
||||||
|
|||||||
+7
-5
@@ -64,6 +64,13 @@ constexpr float pointer_fading_distance = 40;
|
|||||||
// Pointer color
|
// Pointer color
|
||||||
constexpr uint32_t pointer_color = 0x40ffffff;
|
constexpr uint32_t pointer_color = 0x40ffffff;
|
||||||
constexpr uint32_t pointer_color_border = 0xff000000;
|
constexpr uint32_t pointer_color_border = 0xff000000;
|
||||||
|
|
||||||
|
// Offset of a popup composition layer in front of its main GUI panel, so combos/modals pop out
|
||||||
|
constexpr glm::vec3 popup_position = {0, 0, 0.05};
|
||||||
|
|
||||||
|
// Color scale/bias applied to the main GUI panel while a modal popup is shown, so it dims behind the 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};
|
||||||
} // namespace constants::gui
|
} // namespace constants::gui
|
||||||
|
|
||||||
namespace constants::lobby
|
namespace constants::lobby
|
||||||
@@ -78,7 +85,6 @@ constexpr auto gui_pitches = std::to_array<std::pair<float, float>>({
|
|||||||
{90, 78},
|
{90, 78},
|
||||||
});
|
});
|
||||||
constexpr float keyboard_pitch = -0.6;
|
constexpr float keyboard_pitch = -0.6;
|
||||||
constexpr glm::vec3 popup_position = {0, 0, 0.05};
|
|
||||||
constexpr glm::vec3 keyboard_position = {0, -0.3, 0.1};
|
constexpr glm::vec3 keyboard_position = {0, -0.3, 0.1};
|
||||||
|
|
||||||
// Position of the near plane
|
// Position of the near plane
|
||||||
@@ -99,10 +105,6 @@ constexpr float initial_gui_distance = 0.5;
|
|||||||
// Skybox color
|
// Skybox color
|
||||||
constexpr XrColor4f sky_color = {0, 0.25, 0.5, 1};
|
constexpr XrColor4f sky_color = {0, 0.25, 0.5, 1};
|
||||||
|
|
||||||
// Dimming scale/bias when a popup window is shown
|
|
||||||
constexpr XrColor4f dimming_scale = {0.5, 0.5, 0.5, 1};
|
|
||||||
constexpr XrColor4f dimming_bias = {0.25, 0.25, 0.25, 0};
|
|
||||||
|
|
||||||
// Z-indices of composition layers
|
// Z-indices of composition layers
|
||||||
constexpr int zindex_passthrough = -2;
|
constexpr int zindex_passthrough = -2;
|
||||||
constexpr int zindex_lobby = -1;
|
constexpr int zindex_lobby = -1;
|
||||||
|
|||||||
@@ -1261,6 +1261,14 @@ imgui_context::viewport & imgui_context::layer(ImVec2 position)
|
|||||||
return layers_.front();
|
return layers_.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void imgui_context::place_layer_relative(size_t layer, size_t base, glm::vec3 offset, glm::quat extra_rotation)
|
||||||
|
{
|
||||||
|
const viewport & b = layers_[base];
|
||||||
|
viewport & l = layers_[layer];
|
||||||
|
l.orientation = b.orientation * extra_rotation;
|
||||||
|
l.position = b.position + glm::mat3_cast(b.orientation) * offset;
|
||||||
|
}
|
||||||
|
|
||||||
void imgui_context::tooltip(std::string_view text, std::optional<ImVec2> anchor)
|
void imgui_context::tooltip(std::string_view text, std::optional<ImVec2> anchor)
|
||||||
{
|
{
|
||||||
// FIXME: this is incorrect if we use the docking branch of imgui
|
// FIXME: this is incorrect if we use the docking branch of imgui
|
||||||
|
|||||||
@@ -226,6 +226,10 @@ public:
|
|||||||
return layers_;
|
return layers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Place a satellite layer (popup, keyboard, …) relative to a base layer: same
|
||||||
|
// orientation as the base (optionally post-rotated), offset in the base's local frame.
|
||||||
|
void place_layer_relative(size_t layer, size_t base, glm::vec3 offset, glm::quat extra_rotation = glm::quat(1, 0, 0, 0));
|
||||||
|
|
||||||
std::vector<window_viewport> windows();
|
std::vector<window_viewport> windows();
|
||||||
|
|
||||||
viewport & layer(ImVec2 position);
|
viewport & layer(ImVec2 position);
|
||||||
|
|||||||
@@ -152,13 +152,9 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ImVec2 content_pad = {34, 34}; // symmetric inner padding, both axes equal
|
const ImVec2 content_pad = {34, 34}; // symmetric inner padding, both axes equal
|
||||||
const float margin = content_pad.x;
|
|
||||||
const float button_h = ImGui::GetFrameHeight() * ui::metrics::control_height;
|
|
||||||
const float footer_h = button_h + margin * 2;
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, content_pad);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, content_pad);
|
||||||
ImGui::BeginChild("launcher", {0, ImGui::GetContentRegionAvail().y - footer_h}, ImGuiChildFlags_AlwaysUseWindowPadding);
|
ImGui::BeginChild("launcher", {0, 0}, ImGuiChildFlags_AlwaysUseWindowPadding);
|
||||||
ImGui::BeginDisabled(app_starting);
|
|
||||||
|
|
||||||
const float header_top = ImGui::GetCursorPosY();
|
const float header_top = ImGui::GetCursorPosY();
|
||||||
const std::string subtitle = _S("Pick an application to start streaming, or start one on the PC.");
|
const std::string subtitle = _S("Pick an application to start streaming, or start one on the PC.");
|
||||||
@@ -166,27 +162,33 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
ui::page_header(_S("Connected"), subtitle);
|
ui::page_header(_S("Connected"), subtitle);
|
||||||
else
|
else
|
||||||
ui::page_header(fmt::format(_F("Connected to {}"), server_name), subtitle);
|
ui::page_header(fmt::format(_F("Connected to {}"), server_name), subtitle);
|
||||||
|
const float content_y = ImGui::GetCursorPosY();
|
||||||
|
|
||||||
if (apps->empty())
|
const bool has_apps = not apps->empty();
|
||||||
|
int view = config.app_list_view ? 1 : 0;
|
||||||
|
int size_idx = std::clamp<int>(config.app_icon_size, 0, 2);
|
||||||
|
const std::vector<std::string> size_opts = {_S("Small"), _S("Medium"), _S("Large")};
|
||||||
|
const std::vector<std::string> view_opts = {ICON_FA_TABLE_CELLS_LARGE, ICON_FA_LIST};
|
||||||
|
const float gap = ImGui::GetStyle().ItemSpacing.x;
|
||||||
|
const float view_w = ui::metrics::app_view_toggle_width;
|
||||||
|
const float size_w = ui::metrics::app_size_toggle_width;
|
||||||
|
const float disconnect_w = ui::button_width(cancel);
|
||||||
|
|
||||||
|
// title row stays fixed: view/size toggles then disconnect, right-aligned and
|
||||||
|
// top-aligned with the title. Disconnect stays enabled even while an app starts.
|
||||||
|
const float right = ImGui::GetContentRegionMax().x;
|
||||||
|
ImGui::SetCursorPos({right - disconnect_w, header_top});
|
||||||
|
if (ui::button(cancel, ui::button_style::danger))
|
||||||
|
res = clicked::Cancel;
|
||||||
|
|
||||||
|
ImGui::BeginDisabled(app_starting);
|
||||||
|
|
||||||
|
if (has_apps)
|
||||||
{
|
{
|
||||||
ImGui::Spacing();
|
float toggles_x = right - disconnect_w - gap - view_w;
|
||||||
ImGui::TextUnformatted(_S("Waiting for an application on the server"));
|
if (view == 0)
|
||||||
}
|
toggles_x -= size_w + gap;
|
||||||
else
|
ImGui::SetCursorPos({toggles_x, header_top});
|
||||||
{
|
|
||||||
const float content_y = ImGui::GetCursorPosY();
|
|
||||||
|
|
||||||
int view = config.app_list_view ? 1 : 0;
|
|
||||||
int size_idx = std::clamp<int>(config.app_icon_size, 0, 2);
|
|
||||||
const std::vector<std::string> size_opts = {_S("Small"), _S("Medium"), _S("Large")};
|
|
||||||
const std::vector<std::string> view_opts = {ICON_FA_TABLE_CELLS_LARGE, ICON_FA_LIST};
|
|
||||||
const float gap = ImGui::GetStyle().ItemSpacing.x;
|
|
||||||
const float view_w = ui::metrics::app_view_toggle_width;
|
|
||||||
const float size_w = ui::metrics::app_size_toggle_width;
|
|
||||||
const float cluster = view_w + (view == 0 ? size_w + gap : 0);
|
|
||||||
|
|
||||||
// grid/list and icon size on the title row, right-aligned and top-aligned with the title
|
|
||||||
ImGui::SetCursorPos({ImGui::GetContentRegionMax().x - cluster, header_top});
|
|
||||||
if (view == 0)
|
if (view == 0)
|
||||||
{
|
{
|
||||||
if (ui::segmented("##icon_size", size_opts, &size_idx, {size_w, 0}))
|
if (ui::segmented("##icon_size", size_opts, &size_idx, {size_w, 0}))
|
||||||
@@ -201,7 +203,20 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
config.app_list_view = view == 1;
|
config.app_list_view = view == 1;
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
ImGui::SetCursorPos({ImGui::GetCursorStartPos().x, content_y});
|
}
|
||||||
|
|
||||||
|
ImGui::SetCursorPos({ImGui::GetCursorStartPos().x, content_y});
|
||||||
|
|
||||||
|
if (not has_apps)
|
||||||
|
{
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::TextUnformatted(_S("Waiting for an application on the server"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// only the grid/list scrolls; flush to the header edge with no extra inset
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {0, 0});
|
||||||
|
ImGui::BeginChild("applist", {0, 0});
|
||||||
|
|
||||||
if (config.app_list_view)
|
if (config.app_list_view)
|
||||||
{
|
{
|
||||||
@@ -217,13 +232,15 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// justified grid: as many columns as fit at the chosen icon size, then stretch
|
// justified grid: as many columns as fit at the chosen icon size, then stretch
|
||||||
// every tile to divide the row exactly so there is no trailing gap
|
// every tile to divide the row exactly so there is no trailing gap; rows use the
|
||||||
|
// same gap as columns
|
||||||
const float tile_margin = ui::metrics::app_tile_margin;
|
const float tile_margin = ui::metrics::app_tile_margin;
|
||||||
const float target = grid_image_size(config.app_icon_size) + tile_margin * 2;
|
const float target = grid_image_size(config.app_icon_size) + tile_margin * 2;
|
||||||
const float avail = ImGui::GetContentRegionAvail().x;
|
const float avail = ImGui::GetContentRegionAvail().x;
|
||||||
const int per_line = std::max(1, int((avail + gap) / (target + gap)));
|
const int per_line = std::max(1, int((avail + gap) / (target + gap)));
|
||||||
const float tile_w = int((avail - gap * (per_line - 1)) / per_line);
|
const float tile_w = int((avail - gap * (per_line - 1)) / per_line);
|
||||||
const float image_size = tile_w - tile_margin * 2;
|
const float image_size = tile_w - tile_margin * 2;
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {gap, gap});
|
||||||
for (const auto [index, app]: utils::enumerate(*apps))
|
for (const auto [index, app]: utils::enumerate(*apps))
|
||||||
{
|
{
|
||||||
if (app_tile(app.id, app.name, texture_for(app), tile_w, image_size))
|
if (app_tile(app.id, app.name, texture_for(app), tile_w, image_size))
|
||||||
@@ -232,8 +249,13 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
if ((index + 1) % per_line)
|
if ((index + 1) % per_line)
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScrollWhenDragging();
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
// drop textures for apps no longer listed
|
// drop textures for apps no longer listed
|
||||||
std::vector<std::string> stale;
|
std::vector<std::string> stale;
|
||||||
for (const auto & [app_id, app_icon]: app_icons)
|
for (const auto & [app_id, app_icon]: app_icons)
|
||||||
@@ -246,7 +268,6 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollWhenDragging();
|
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
@@ -258,11 +279,6 @@ app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const st
|
|||||||
ImSpinner::SpinnerAng("starting", r, ui::metrics::app_spinner_thickness, ImColor{ui::current().accent}, ImColor{ui::current().card}, 6, 0.75f * 2 * M_PI);
|
ImSpinner::SpinnerAng("starting", r, ui::metrics::app_spinner_thickness, ImColor{ui::current().accent}, ImColor{ui::current().card}, 6, 0.75f * 2 * M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// footer: disconnect / cancel, bottom-right
|
|
||||||
ImGui::SetCursorPos({ImGui::GetWindowSize().x - ui::button_width(cancel) - margin, ImGui::GetWindowSize().y - button_h - margin});
|
|
||||||
if (ui::button(cancel, ui::button_style::danger))
|
|
||||||
res = clicked::Cancel;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-10
@@ -121,24 +121,19 @@ static glm::quat compute_gui_orientation(glm::vec3 head_position, glm::vec3 new_
|
|||||||
|
|
||||||
void scenes::lobby::move_gui(glm::vec3 head_position, glm::vec3 new_gui_position)
|
void scenes::lobby::move_gui(glm::vec3 head_position, glm::vec3 new_gui_position)
|
||||||
{
|
{
|
||||||
|
using constants::gui::popup_position;
|
||||||
using constants::lobby::keyboard_pitch;
|
using constants::lobby::keyboard_pitch;
|
||||||
using constants::lobby::keyboard_position;
|
using constants::lobby::keyboard_position;
|
||||||
using constants::lobby::popup_position;
|
|
||||||
|
|
||||||
auto q = compute_gui_orientation(head_position, new_gui_position);
|
auto q = compute_gui_orientation(head_position, new_gui_position);
|
||||||
auto M = glm::mat3_cast(q); // plane-to-world transform
|
|
||||||
|
|
||||||
// Main window
|
// Main window
|
||||||
imgui_ctx->layers()[0].position = new_gui_position;
|
imgui_ctx->layers()[0].position = new_gui_position;
|
||||||
imgui_ctx->layers()[0].orientation = q;
|
imgui_ctx->layers()[0].orientation = q;
|
||||||
|
|
||||||
// Popup
|
// Popup and keyboard track the main window
|
||||||
imgui_ctx->layers()[1].position = new_gui_position + M * popup_position;
|
imgui_ctx->place_layer_relative(1, 0, popup_position);
|
||||||
imgui_ctx->layers()[1].orientation = q;
|
imgui_ctx->place_layer_relative(2, 0, keyboard_position, glm::quat(cos(keyboard_pitch / 2), sin(keyboard_pitch / 2), 0, 0));
|
||||||
|
|
||||||
// Keyboard
|
|
||||||
imgui_ctx->layers()[2].position = new_gui_position + M * keyboard_position;
|
|
||||||
imgui_ctx->layers()[2].orientation = q * glm::quat(cos(keyboard_pitch / 2), sin(keyboard_pitch / 2), 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scenes::lobby::lobby() :
|
scenes::lobby::lobby() :
|
||||||
@@ -1076,7 +1071,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
|
|||||||
add_quad_layer(layer.layerFlags, layer.space, layer.eyeVisibility, layer.subImage, layer.pose, layer.size);
|
add_quad_layer(layer.layerFlags, layer.space, layer.eyeVisibility, layer.subImage, layer.pose, layer.size);
|
||||||
|
|
||||||
if (dim_gui)
|
if (dim_gui)
|
||||||
set_color_scale_bias(constants::lobby::dimming_scale, constants::lobby::dimming_bias);
|
set_color_scale_bias(constants::gui::popup_dimming_scale, constants::gui::popup_dimming_bias);
|
||||||
|
|
||||||
if (composition_layer_depth_test_supported)
|
if (composition_layer_depth_test_supported)
|
||||||
set_depth_test(true, XR_COMPARE_OP_LESS_OR_EQUAL_FB);
|
set_depth_test(true, XR_COMPARE_OP_LESS_OR_EQUAL_FB);
|
||||||
|
|||||||
@@ -515,13 +515,6 @@ void scenes::stream::on_focused()
|
|||||||
.vp_origin = {0, 0},
|
.vp_origin = {0, 0},
|
||||||
.vp_size = {1800, 1000},
|
.vp_size = {1800, 1000},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
// Popup window
|
|
||||||
.space = xr::spaces::world,
|
|
||||||
.size = {1.2, 0.6666},
|
|
||||||
.vp_origin = {1800, 0},
|
|
||||||
.vp_size = {1800, 1000},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.space = xr::spaces::world,
|
.space = xr::spaces::world,
|
||||||
.size = {1.2, 0.1333},
|
.size = {1.2, 0.1333},
|
||||||
@@ -529,6 +522,15 @@ void scenes::stream::on_focused()
|
|||||||
.vp_size = {1800, 200},
|
.vp_size = {1800, 200},
|
||||||
.tooltip_viewport = true,
|
.tooltip_viewport = true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Pop up window: combos and modals float just in front of the main panel.
|
||||||
|
// Position and orientation track the main panel each frame. Same pixel
|
||||||
|
// density as the main panel (1500 px/m) so text matches.
|
||||||
|
.space = xr::spaces::world,
|
||||||
|
.size = {1.2, 0.6666},
|
||||||
|
.vp_origin = {1800, 0},
|
||||||
|
.vp_size = {1800, 1000},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
imgui_ctx.emplace(physical_device,
|
imgui_ctx.emplace(physical_device,
|
||||||
|
|||||||
@@ -746,12 +746,12 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
|||||||
imgui_ctx->layers()[0].position = world_gui_position;
|
imgui_ctx->layers()[0].position = world_gui_position;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position popup layer
|
|
||||||
imgui_ctx->layers()[1].orientation = imgui_ctx->layers()[0].orientation;
|
|
||||||
imgui_ctx->layers()[1].position = imgui_ctx->layers()[0].position + imgui_ctx->layers()[0].orientation * constants::lobby::popup_position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The popup layer floats just in front of the main panel so combos and modals pop
|
||||||
|
// out as their own quad, like the lobby (see set_popup_center below).
|
||||||
|
imgui_ctx->place_layer_relative(2, 0, constants::gui::popup_position);
|
||||||
|
|
||||||
const float tab_width = wivrn::ui::metrics::sidebar_width;
|
const float tab_width = wivrn::ui::metrics::sidebar_width;
|
||||||
const float top_bar_h = wivrn::ui::metrics::top_bar_height;
|
const float top_bar_h = wivrn::ui::metrics::top_bar_height;
|
||||||
const float content_margin = wivrn::ui::metrics::content_margin;
|
const float content_margin = wivrn::ui::metrics::content_margin;
|
||||||
@@ -771,7 +771,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
|||||||
style.TabRounding = wivrn::ui::current().rounding;
|
style.TabRounding = wivrn::ui::current().rounding;
|
||||||
style.Colors[ImGuiCol_Text] = wivrn::ui::current().text;
|
style.Colors[ImGuiCol_Text] = wivrn::ui::current().text;
|
||||||
style.Colors[ImGuiCol_TextDisabled] = wivrn::ui::current().text_muted;
|
style.Colors[ImGuiCol_TextDisabled] = wivrn::ui::current().text_muted;
|
||||||
wivrn::ui::set_popup_center(imgui_ctx->layers()[0].vp_center(), float(imgui_ctx->layers()[0].vp_size.y));
|
wivrn::ui::set_popup_center(imgui_ctx->layers()[2].vp_center(), float(imgui_ctx->layers()[2].vp_size.y));
|
||||||
wivrn::ui::set_hover_haptic([this] { imgui_ctx->vibrate_on_hover(); });
|
wivrn::ui::set_hover_haptic([this] { imgui_ctx->vibrate_on_hover(); });
|
||||||
wivrn::ui::set_tooltip_hook([this](const char * text) { imgui_ctx->tooltip(text); });
|
wivrn::ui::set_tooltip_hook([this](const char * text) { imgui_ctx->tooltip(text); });
|
||||||
|
|
||||||
@@ -928,16 +928,18 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
|||||||
const std::string conn = _("Connected");
|
const std::string conn = _("Connected");
|
||||||
top_items.push_back({wivrn::ui::chip_width(conn, true, side),
|
top_items.push_back({wivrn::ui::chip_width(conn, true, side),
|
||||||
[conn, side] { wivrn::ui::chip(conn, wivrn::ui::chip_style::success, true, side); }});
|
[conn, side] { wivrn::ui::chip(conn, wivrn::ui::chip_style::success, true, side); }});
|
||||||
top_items.push_back({side, [this] {
|
const std::string close_label = _S("Close");
|
||||||
const float s = ImGui::GetFrameHeight() * wivrn::ui::metrics::control_height;
|
top_items.push_back({wivrn::ui::button_width(ICON_FA_XMARK, close_label),
|
||||||
if (wivrn::ui::icon_button(ICON_FA_XMARK, {s, s}, false, _S("Close")))
|
[this, close_label, side] {
|
||||||
|
if (wivrn::ui::button(ICON_FA_XMARK, close_label, wivrn::ui::button_style::secondary, {0, side}))
|
||||||
next_gui_status = stream_tab::hidden;
|
next_gui_status = stream_tab::hidden;
|
||||||
}});
|
}});
|
||||||
// disconnect asks for confirmation; OpenPopup/confirm_modal share the window id stack
|
// disconnect asks for confirmation; OpenPopup/confirm_modal share the window id stack
|
||||||
bool request_disconnect = false;
|
bool request_disconnect = false;
|
||||||
top_items.push_back({side, [&request_disconnect] {
|
const std::string disconnect_label = _S("Disconnect");
|
||||||
const float s = ImGui::GetFrameHeight() * wivrn::ui::metrics::control_height;
|
top_items.push_back({wivrn::ui::button_width(ICON_FA_DOOR_OPEN, disconnect_label),
|
||||||
if (wivrn::ui::icon_button(ICON_FA_DOOR_OPEN, {s, s}, false, _S("Disconnect")))
|
[&request_disconnect, disconnect_label, side] {
|
||||||
|
if (wivrn::ui::button(ICON_FA_DOOR_OPEN, disconnect_label, wivrn::ui::button_style::danger, {0, side}))
|
||||||
request_disconnect = true;
|
request_disconnect = true;
|
||||||
}});
|
}});
|
||||||
wivrn::ui::top_bar(top_bar_h, wivrn_logo, top_items);
|
wivrn::ui::top_bar(top_bar_h, wivrn_logo, top_items);
|
||||||
@@ -1079,13 +1081,20 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the layer with the GUI
|
// Add the layer with the GUI. While a modal popup is shown, dim the main panel (the
|
||||||
|
// first layer) behind it like the lobby; the popup quad itself stays bright.
|
||||||
|
bool dim_main = imgui_ctx->is_modal_popup_shown() and composition_layer_color_scale_bias_supported;
|
||||||
for (auto [_, layer]: layers)
|
for (auto [_, layer]: layers)
|
||||||
{
|
{
|
||||||
add_quad_layer(layer.layerFlags, layer.space, layer.eyeVisibility, layer.subImage, layer.pose, layer.size);
|
add_quad_layer(layer.layerFlags, layer.space, layer.eyeVisibility, layer.subImage, layer.pose, layer.size);
|
||||||
if (composition_layer_depth_test_supported)
|
if (composition_layer_depth_test_supported)
|
||||||
set_depth_test(true, XR_COMPARE_OP_LESS_FB);
|
set_depth_test(true, XR_COMPARE_OP_LESS_FB);
|
||||||
if (alpha < 1 and composition_layer_color_scale_bias_supported)
|
if (dim_main)
|
||||||
|
{
|
||||||
|
set_color_scale_bias(constants::gui::popup_dimming_scale, constants::gui::popup_dimming_bias);
|
||||||
|
dim_main = false; // only the main window dims, not the popup
|
||||||
|
}
|
||||||
|
else if (alpha < 1 and composition_layer_color_scale_bias_supported)
|
||||||
set_color_scale_bias({alpha, alpha, alpha, alpha}, {});
|
set_color_scale_bias({alpha, alpha, alpha, alpha}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user