remove old index_offset code, fix popup_list initial index being offscreen
This commit is contained in:
@@ -68,7 +68,6 @@ private:
|
||||
private:
|
||||
std::vector<Entry> m_entries;
|
||||
s64 m_index{};
|
||||
s64 m_index_offset{};
|
||||
std::unique_ptr<List> m_list;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ private:
|
||||
Items m_items;
|
||||
Callback m_callback;
|
||||
s64 m_index; // index in list array
|
||||
s64 m_index_offset{}; // drawing from array start
|
||||
|
||||
std::unique_ptr<List> m_list;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ public:
|
||||
|
||||
protected:
|
||||
std::string m_title;
|
||||
Vec2 m_offset{};
|
||||
};
|
||||
|
||||
class SidebarEntryBool final : public SidebarEntryBase {
|
||||
@@ -117,7 +116,6 @@ private:
|
||||
Side m_side;
|
||||
Items m_items;
|
||||
s64 m_index{};
|
||||
s64 m_index_offset{};
|
||||
|
||||
std::unique_ptr<List> m_list;
|
||||
|
||||
|
||||
@@ -767,11 +767,6 @@ void EntryMenu::Draw(NVGcontext* vg, Theme* theme) {
|
||||
if (m_index == i) {
|
||||
text_id = ThemeEntryID_TEXT_SELECTED;
|
||||
gfx::drawRectOutline(vg, 4.f, theme->elements[ThemeEntryID_SELECTED_OVERLAY].colour, x, y, w, h, theme->elements[ThemeEntryID_SELECTED].colour);
|
||||
} else {
|
||||
// if (i == m_index_offset) {
|
||||
// gfx::drawRect(vg, x, y, w, 1.f, text_col);
|
||||
// }
|
||||
// gfx::drawRect(vg, x, y + h, w, 1.f, text_col);
|
||||
}
|
||||
|
||||
gfx::drawTextArgs(vg, x + w / 2, y + h / 2, 22, NVG_ALIGN_MIDDLE | NVG_ALIGN_CENTER, theme->elements[ThemeEntryID_TEXT].colour, option.display_text.c_str());
|
||||
|
||||
@@ -404,7 +404,7 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) {
|
||||
text_id = ThemeEntryID_TEXT_SELECTED;
|
||||
gfx::drawRectOutline(vg, 4.f, theme->elements[ThemeEntryID_SELECTED_OVERLAY].colour, x, y, w, h, theme->elements[ThemeEntryID_SELECTED].colour);
|
||||
} else {
|
||||
if (i == m_index_offset) {
|
||||
if (i == m_index) {
|
||||
gfx::drawRect(vg, x, y, w, 1.f, text_col);
|
||||
}
|
||||
gfx::drawRect(vg, x, y + h, w, 1.f, text_col);
|
||||
@@ -429,11 +429,7 @@ void Menu::OnFocusGained() {
|
||||
void Menu::SetIndex(s64 index) {
|
||||
m_index = index;
|
||||
if (!m_index) {
|
||||
m_index_offset = 0;
|
||||
}
|
||||
|
||||
if (m_index > m_index_offset && m_index - m_index_offset >= 7) {
|
||||
m_index_offset = m_index - 7;
|
||||
m_list->SetYoff(0);
|
||||
}
|
||||
|
||||
SetTitleSubHeading(m_entries[m_index].json_path);
|
||||
@@ -442,8 +438,6 @@ void Menu::SetIndex(s64 index) {
|
||||
|
||||
void Menu::Scan() {
|
||||
m_entries.clear();
|
||||
m_index = 0;
|
||||
m_index_offset = 0;
|
||||
|
||||
// load from romfs first
|
||||
if (R_SUCCEEDED(romfsInit())) {
|
||||
|
||||
@@ -23,7 +23,7 @@ PopupList::PopupList(std::string title, Items items, std::string& index_ref)
|
||||
if (it != m_items.cend()) {
|
||||
m_index = std::distance(m_items.cbegin(), it);
|
||||
if (m_index >= 7) {
|
||||
m_index_offset = m_index - 6;
|
||||
// m_list->SetYoff((m_index - 6) * m_list->GetMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ PopupList::PopupList(std::string title, Items items, Callback cb, std::string in
|
||||
if (it != m_items.cend()) {
|
||||
SetIndex(std::distance(m_items.cbegin(), it));
|
||||
if (m_index >= 7) {
|
||||
m_index_offset = m_index - 6;
|
||||
// m_list->SetYoff((m_index - 6) * m_list->GetMaxY());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,15 +89,16 @@ PopupList::PopupList(std::string title, Items items, Callback cb, s64 index)
|
||||
m_pos.y = 720.f - m_pos.h;
|
||||
m_line_top = m_pos.y + 70.f;
|
||||
m_line_bottom = 720.f - 73.f;
|
||||
if (m_index >= 7) {
|
||||
m_index_offset = m_index - 6;
|
||||
}
|
||||
|
||||
Vec4 v{m_block};
|
||||
v.y = m_line_top + 1.f + 42.f;
|
||||
const Vec4 pos{0, m_line_top, 1280.f, m_line_bottom - m_line_top};
|
||||
m_list = std::make_unique<List>(1, 7, pos, v);
|
||||
m_list->SetScrollBarPos(1250, m_line_top + 20, m_line_bottom - m_line_top - 40);
|
||||
|
||||
if (m_index >= 7) {
|
||||
m_list->SetYoff((m_index - 6) * m_list->GetMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
auto PopupList::Update(Controller* controller, TouchInfo* touch) -> void {
|
||||
@@ -143,10 +144,6 @@ auto PopupList::OnFocusLost() noexcept -> void {
|
||||
|
||||
void PopupList::SetIndex(s64 index) {
|
||||
m_index = index;
|
||||
|
||||
if (m_index > m_index_offset && m_index - m_index_offset >= 6) {
|
||||
m_index_offset = m_index - 6;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sphaira::ui
|
||||
|
||||
@@ -266,11 +266,6 @@ void Sidebar::SetIndex(s64 index) {
|
||||
m_items[m_index]->OnFocusLost();
|
||||
m_index = index;
|
||||
m_items[m_index]->OnFocusGained();
|
||||
|
||||
if (m_index > m_index_offset && m_index - m_index_offset >= 5) {
|
||||
m_index_offset = m_index - 5;
|
||||
}
|
||||
|
||||
SetupButtons();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user