overlays: Turn the home menu into a proper sidebar

This commit is contained in:
kd-11 2026-03-10 23:32:55 +03:00 committed by kd-11
parent 2b2b13273b
commit 3988eceb8d
4 changed files with 41 additions and 6 deletions

View file

@ -21,7 +21,7 @@ namespace rsx
m_allow_input_on_pause = true;
m_dim_background.set_size(virtual_width, virtual_height);
m_dim_background.back_color.a = 0.5f;
m_dim_background.back_color.a = 0.85f;
m_description.set_font("Arial", 20);
m_description.set_pos(20, 37);

View file

@ -26,10 +26,10 @@ namespace rsx
m_message_box = std::make_shared<home_menu_message_box>(x, y, width, height);
m_message_box->visible = false;
m_sidebar = std::make_unique<list_view>(350, height, false);
m_sidebar->set_pos(x, y);
m_sidebar = std::make_unique<list_view>(350, overlay::virtual_height, false);
m_sidebar->set_pos(0, 0);
m_sidebar->hide_prompt_buttons();
m_sidebar->back_color = color4f(0.15f, 0.15f, 0.15f, 0.95f);
m_sidebar->back_color = color4f(0.05f, 0.05f, 0.05f, 0.95f);
m_sliding_animation.duration_sec = 0.5f;
m_sliding_animation.type = animation_type::ease_in_out_cubic;
@ -155,11 +155,44 @@ namespace rsx
apply_layout();
}
void home_menu_main_menu::apply_layout(bool center_vertically)
{
home_menu_page::apply_layout(center_vertically);
if (m_sidebar->get_elements_count() == 0)
{
return;
}
auto sidebar_items = std::move(m_sidebar->m_items);
m_sidebar->clear_items();
u16 combined_height = 0;
std::for_each(
sidebar_items.begin(),
sidebar_items.end(),
[&](auto& entry)
{
combined_height += entry->h + m_sidebar->pack_padding;
entry->set_pos(0, 0);
});
if (combined_height < overlay::virtual_height)
{
m_sidebar->advance_pos = (overlay::virtual_height - combined_height) / 2;
}
for (auto& entry : sidebar_items)
{
m_sidebar->add_entry(entry);
}
}
void home_menu_main_menu::add_sidebar_entry(std::string_view title)
{
std::unique_ptr<overlay_element> label_widget = std::make_unique<label>(title.data());
label_widget->set_size(m_sidebar->w, 60);
label_widget->set_font("Arial", 18);
label_widget->set_font("Arial", 14);
label_widget->back_color.a = 0.f;
label_widget->set_padding(16, 4, 16, 4);
m_sidebar->add_entry(label_widget);

View file

@ -19,6 +19,8 @@ namespace rsx
void update(u64 timestamp_us) override;
private:
void apply_layout(bool center_vertically = false) override;
void add_page(std::shared_ptr<home_menu_page> page) override;
void add_item(std::string_view title, std::function<page_navigation(pad_button)> callback) override;

View file

@ -38,7 +38,7 @@ namespace rsx
virtual void add_page(std::shared_ptr<home_menu_page> page);
virtual void add_item(std::unique_ptr<overlay_element>& element, std::function<page_navigation(pad_button)> callback);
virtual void add_item(std::string_view, std::function<page_navigation(pad_button)> callback);
void apply_layout(bool center_vertically = false);
virtual void apply_layout(bool center_vertically = false);
void show_dialog(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
std::vector<std::shared_ptr<home_menu_page>> m_pages;