mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
overlays: fix and optimize layout exit loops
This commit is contained in:
parent
b3d28e2309
commit
6f5f7ece06
7 changed files with 40 additions and 20 deletions
|
@ -121,6 +121,7 @@ namespace rsx
|
||||||
m_list->set_pos(20, 85);
|
m_list->set_pos(20, 85);
|
||||||
|
|
||||||
m_message_box = std::make_shared<home_menu_message_box>(20, 85, virtual_width - 2 * 20, 540);
|
m_message_box = std::make_shared<home_menu_message_box>(20, 85, virtual_width - 2 * 20, 540);
|
||||||
|
m_message_box->visible = false;
|
||||||
|
|
||||||
m_description = std::make_unique<label>();
|
m_description = std::make_unique<label>();
|
||||||
m_description->set_font("Arial", 20);
|
m_description->set_font("Arial", 20);
|
||||||
|
@ -156,7 +157,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
if (fade_animation.active) return;
|
if (fade_animation.active) return;
|
||||||
|
|
||||||
if (m_message_box && m_message_box->visible())
|
if (m_message_box && m_message_box->visible)
|
||||||
{
|
{
|
||||||
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
||||||
if (navigation != page_navigation::stay)
|
if (navigation != page_navigation::stay)
|
||||||
|
@ -210,7 +211,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||||
{
|
{
|
||||||
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_REMOVE_USER_MSG, selected_username.c_str()), [this, selected_username]()
|
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_REMOVE_USER_MSG, selected_username.c_str()), [this, selected_username]()
|
||||||
{
|
{
|
||||||
|
@ -247,7 +248,7 @@ namespace rsx
|
||||||
user_index++;
|
user_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||||
{
|
{
|
||||||
if (user_index < m_friend_data.requests_received.size())
|
if (user_index < m_friend_data.requests_received.size())
|
||||||
{
|
{
|
||||||
|
@ -291,7 +292,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected_username.empty() && m_message_box && !m_message_box->visible())
|
if (!selected_username.empty() && m_message_box && !m_message_box->visible)
|
||||||
{
|
{
|
||||||
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_UNBLOCK_USER_MSG, selected_username.c_str()), []()
|
m_message_box->show(get_localized_string(localized_string_id::HOME_MENU_FRIENDS_UNBLOCK_USER_MSG, selected_username.c_str()), []()
|
||||||
{
|
{
|
||||||
|
@ -392,7 +393,7 @@ namespace rsx
|
||||||
m_last_page.store(m_current_page);
|
m_last_page.store(m_current_page);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_message_box && m_message_box->visible())
|
if (m_message_box && m_message_box->visible)
|
||||||
{
|
{
|
||||||
result.add(m_message_box->get_compiled());
|
result.add(m_message_box->get_compiled());
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,13 +61,13 @@ namespace rsx
|
||||||
m_label.set_text(text);
|
m_label.set_text(text);
|
||||||
m_label.auto_resize();
|
m_label.auto_resize();
|
||||||
m_label.set_pos(x + (w - m_label.w) / 2, y + (h - m_label.h) / 2);
|
m_label.set_pos(x + (w - m_label.w) / 2, y + (h - m_label.h) / 2);
|
||||||
m_visible = true;
|
visible = true;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void home_menu_message_box::hide()
|
void home_menu_message_box::hide()
|
||||||
{
|
{
|
||||||
m_visible = false;
|
visible = false;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,8 @@ namespace rsx
|
||||||
void show(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
void show(const std::string& text, std::function<void()> on_accept = nullptr, std::function<void()> on_cancel = nullptr);
|
||||||
void hide();
|
void hide();
|
||||||
page_navigation handle_button_press(pad_button button_press);
|
page_navigation handle_button_press(pad_button button_press);
|
||||||
bool visible() const { return m_visible; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_visible = false;
|
|
||||||
label m_label{};
|
label m_label{};
|
||||||
image_button m_accept_btn;
|
image_button m_accept_btn;
|
||||||
image_button m_cancel_btn;
|
image_button m_cancel_btn;
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace rsx
|
||||||
|
|
||||||
void home_menu_page::show_dialog(const std::string& text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
void home_menu_page::show_dialog(const std::string& text, std::function<void()> on_accept, std::function<void()> on_cancel)
|
||||||
{
|
{
|
||||||
if (m_message_box && !m_message_box->visible())
|
if (m_message_box && !m_message_box->visible)
|
||||||
{
|
{
|
||||||
rsx_log.notice("home_menu_page::show_dialog: page='%s', text='%s'", title, text);
|
rsx_log.notice("home_menu_page::show_dialog: page='%s', text='%s'", title, text);
|
||||||
m_message_box->show(text, std::move(on_accept), std::move(on_cancel));
|
m_message_box->show(text, std::move(on_accept), std::move(on_cancel));
|
||||||
|
@ -129,7 +129,7 @@ namespace rsx
|
||||||
|
|
||||||
page_navigation home_menu_page::handle_button_press(pad_button button_press, bool is_auto_repeat, u64 auto_repeat_interval_ms)
|
page_navigation home_menu_page::handle_button_press(pad_button button_press, bool is_auto_repeat, u64 auto_repeat_interval_ms)
|
||||||
{
|
{
|
||||||
if (m_message_box && m_message_box->visible())
|
if (m_message_box && m_message_box->visible)
|
||||||
{
|
{
|
||||||
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
const page_navigation navigation = m_message_box->handle_button_press(button_press);
|
||||||
if (navigation != page_navigation::stay)
|
if (navigation != page_navigation::stay)
|
||||||
|
@ -270,7 +270,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
compiled_resources = list_view::get_compiled();
|
compiled_resources = list_view::get_compiled();
|
||||||
|
|
||||||
if (m_message_box && m_message_box->visible())
|
if (m_message_box && m_message_box->visible)
|
||||||
{
|
{
|
||||||
compiled_resources.add(m_message_box->get_compiled());
|
compiled_resources.add(m_message_box->get_compiled());
|
||||||
}
|
}
|
||||||
|
|
|
@ -735,14 +735,20 @@ namespace rsx
|
||||||
{
|
{
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
rsx_log.error("Found null item in overlay_controls");
|
rsx_log.error("Found null item in overlay_controls::vertical_layout");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const s32 item_y_limit = s32{item->y} + item->h - scroll_offset_value - y;
|
const s32 item_y_limit = s32{item->y} + item->h - scroll_offset_value - y;
|
||||||
const s32 item_y_base = s32{item->y} - scroll_offset_value - y;
|
const s32 item_y_base = s32{item->y} - scroll_offset_value - y;
|
||||||
|
|
||||||
if (item_y_limit < 0 || item_y_base > h)
|
if (item_y_base > h)
|
||||||
|
{
|
||||||
|
// Out of bounds. The following items will be too.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item_y_limit < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
continue;
|
continue;
|
||||||
|
@ -809,15 +815,28 @@ namespace rsx
|
||||||
|
|
||||||
for (auto &item : m_items)
|
for (auto &item : m_items)
|
||||||
{
|
{
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
rsx_log.error("Found null item in overlay_controls::horizontal_layout");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const s32 item_x_limit = s32{item->x} + item->w - scroll_offset_value - w;
|
const s32 item_x_limit = s32{item->x} + item->w - scroll_offset_value - w;
|
||||||
const s32 item_x_base = s32{item->x} - scroll_offset_value - w;
|
const s32 item_x_base = s32{item->x} - scroll_offset_value - w;
|
||||||
|
|
||||||
if (item_x_limit < 0 || item_x_base > h)
|
if (item_x_base > w)
|
||||||
|
{
|
||||||
|
// Out of bounds. The following items will be too.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item_x_limit < 0)
|
||||||
{
|
{
|
||||||
// Out of bounds
|
// Out of bounds
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (item_x_limit > h || item_x_base < 0)
|
|
||||||
|
if (item_x_limit > w || item_x_base < 0)
|
||||||
{
|
{
|
||||||
// Partial render
|
// Partial render
|
||||||
areaf clip_rect = static_cast<areaf>(areai{x, y, (x + w), (y + h)});
|
areaf clip_rect = static_cast<areaf>(areai{x, y, (x + w), (y + h)});
|
||||||
|
|
|
@ -167,6 +167,8 @@ namespace rsx
|
||||||
compiled_resource compiled_resources;
|
compiled_resource compiled_resources;
|
||||||
bool is_compiled = false;
|
bool is_compiled = false;
|
||||||
|
|
||||||
|
bool visible = true;
|
||||||
|
|
||||||
u16 padding_left = 0;
|
u16 padding_left = 0;
|
||||||
u16 padding_right = 0;
|
u16 padding_right = 0;
|
||||||
u16 padding_top = 0;
|
u16 padding_top = 0;
|
||||||
|
|
|
@ -80,16 +80,16 @@ namespace rsx
|
||||||
|
|
||||||
const usz current_index = static_cast<usz>(m_selected_entry) * (m_use_separators ? 2 : 1);
|
const usz current_index = static_cast<usz>(m_selected_entry) * (m_use_separators ? 2 : 1);
|
||||||
|
|
||||||
if (m_items.size() <= current_index)
|
if (current_index >= m_items.size())
|
||||||
{
|
{
|
||||||
return; // Ideally unreachable but it should still be possible to recover by user interaction.
|
return; // Ideally unreachable but it should still be possible to recover by user interaction.
|
||||||
}
|
}
|
||||||
|
|
||||||
auto current_element = m_items[current_index].get();
|
const auto current_element = m_items[current_index].get();
|
||||||
|
|
||||||
// Calculate bounds
|
// Calculate bounds
|
||||||
auto min_y = current_element->y - y;
|
const auto min_y = current_element->y - y;
|
||||||
auto max_y = current_element->y + current_element->h + pack_padding + 2 - y;
|
const auto max_y = current_element->y + current_element->h + pack_padding + 2 - y;
|
||||||
|
|
||||||
if (min_y < scroll_offset_value)
|
if (min_y < scroll_offset_value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue