diff --git a/client/render/ui_widgets.cpp b/client/render/ui_widgets.cpp index f45b4d60..19c5f6da 100644 --- a/client/render/ui_widgets.cpp +++ b/client/render/ui_widgets.cpp @@ -736,6 +736,59 @@ void chip(const char * label, chip_style style, bool dot) draw->AddText({tx, bb.Min.y + pad.y}, t.col(fg), label); } +void nav_section(const char * label) +{ + const theme & t = current(); + const ImGuiStyle & style = ImGui::GetStyle(); + + ImGui::Dummy({0, style.ItemSpacing.y * 0.5f}); + ImGui::PushFont(nullptr, style.FontSizeBase * metrics::font_description); + ImGui::PushStyleColor(ImGuiCol_Text, t.text_muted); + ImGui::TextUnformatted(label); + ImGui::PopStyleColor(); + ImGui::PopFont(); + ImGui::Dummy({0, 2}); +} + +bool nav_item(const char * icon, const char * label, bool selected) +{ + ImGuiWindow * window = ImGui::GetCurrentWindow(); + if (window->SkipItems) + return false; + + const theme & t = current(); + const ImGuiStyle & style = ImGui::GetStyle(); + + const float h = ImGui::GetFrameHeight() * metrics::control_height; + const float w = ImGui::GetContentRegionAvail().x; + const ImVec2 pos = window->DC.CursorPos; + const ImRect bb(pos, pos + ImVec2(w, h)); + ImGui::ItemSize(bb, style.FramePadding.y); + const ImGuiID gid = window->GetID(label); + if (not ImGui::ItemAdd(bb, gid)) + return false; + + bool hovered, held; + const bool pressed = ImGui::ButtonBehavior(bb, gid, &hovered, &held); + hover_haptic(); + + ImDrawList * draw = window->DrawList; + const ImVec4 bg = selected ? t.control : (hovered ? t.control_hovered : ImVec4{0, 0, 0, 0}); + if (bg.w > 0) + draw->AddRectFilled(bb.Min, bb.Max, t.col(bg), t.rounding); + + const float pad = metrics::combo_padding.x; + const float icon_w = ImGui::GetFontSize() * 1.5f; // icon column + + const ImVec2 its = ImGui::CalcTextSize(icon); + draw->AddText({bb.Min.x + pad + (icon_w - its.x) * 0.5f, bb.Min.y + (h - its.y) * 0.5f}, t.col(selected ? t.accent : t.text_muted), icon); + + const ImVec2 ls = ImGui::CalcTextSize(label); + draw->AddText({bb.Min.x + pad + icon_w + pad * 0.5f, bb.Min.y + (h - ls.y) * 0.5f}, t.col(t.text), label); + + return pressed; +} + static int input_text_resize(ImGuiInputTextCallbackData * data) { if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) diff --git a/client/render/ui_widgets.h b/client/render/ui_widgets.h index 687163c9..d10f527d 100644 --- a/client/render/ui_widgets.h +++ b/client/render/ui_widgets.h @@ -105,6 +105,13 @@ enum class chip_style }; void chip(const char * label, chip_style style = chip_style::neutral, bool dot = false); +// Muted sidebar group header (e.g. "SETTINGS") +void nav_section(const char * label); + +// Sidebar entry: icon + label across the full width, highlighted when selected. +// Returns true when clicked. +bool nav_item(const char * icon, const char * label, bool selected); + // Themed single-line text field, control height. hint is optional placeholder text. // Returns true while the text is being edited. bool input_text(const char * id, std::string & text, const char * hint = nullptr, float width = 0); diff --git a/client/scenes/lobby_gui_components.cpp b/client/scenes/lobby_gui_components.cpp index ad157ff1..809f5368 100644 --- a/client/scenes/lobby_gui_components.cpp +++ b/client/scenes/lobby_gui_components.cpp @@ -234,6 +234,41 @@ void scenes::lobby::gui_components() 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"); {