diff --git a/sphaira/include/ui/widget.hpp b/sphaira/include/ui/widget.hpp index 3db77f2..57e04d5 100644 --- a/sphaira/include/ui/widget.hpp +++ b/sphaira/include/ui/widget.hpp @@ -62,6 +62,12 @@ struct Widget : public Object { m_actions.clear(); } + void RemoveActions(const Actions& actions) { + for (auto& e : actions) { + RemoveAction(e.first); + } + } + auto FireAction(Button button, u8 type = ActionType::DOWN) -> bool; void SetPop(bool pop = true) { diff --git a/sphaira/source/ui/menus/filebrowser.cpp b/sphaira/source/ui/menus/filebrowser.cpp index 68edd04..9efc3f8 100644 --- a/sphaira/source/ui/menus/filebrowser.cpp +++ b/sphaira/source/ui/menus/filebrowser.cpp @@ -442,8 +442,6 @@ FsView::~FsView() { } void FsView::Update(Controller* controller, TouchInfo* touch) { - Widget::Update(controller, touch); - m_list->OnUpdate(controller, touch, m_index, m_entries_current.size(), [this](bool touch, auto i) { if (touch && m_index == i) { FireAction(Button::A); @@ -1892,21 +1890,19 @@ void Menu::Update(Controller* controller, TouchInfo* touch) { // workaround the buttons not being display properly. // basically, inherit all actions from the view, draw them, // then restore state after. - // const auto actions_copy = GetActions(); - // ON_SCOPE_EXIT(m_actions = actions_copy); - // m_actions.insert_range(view->GetActions()); + const auto view_actions = view->GetActions(); + m_actions.insert_range(view_actions); + ON_SCOPE_EXIT(RemoveActions(view_actions)); MenuBase::Update(controller, touch); view->Update(controller, touch); } void Menu::Draw(NVGcontext* vg, Theme* theme) { - // workaround the buttons not being display properly. - // basically, inherit all actions from the view, draw them, - // then restore state after. - const auto actions_copy = GetActions(); - ON_SCOPE_EXIT(m_actions = actions_copy); - m_actions.insert_range(view->GetActions()); + // see Menu::Update(). + const auto view_actions = view->GetActions(); + m_actions.insert_range(view_actions); + ON_SCOPE_EXIT(RemoveActions(view_actions)); MenuBase::Draw(vg, theme);