From 070be1ff94e2827c673c120adca7f5fd5d9834a6 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Tue, 17 Jun 2025 11:46:34 +0100 Subject: [PATCH] fix filebrowser touch (related to f2462cff811ad370d10dc4ff9f627560c85de99e). the fix in commit f2462cff811ad370d10dc4ff9f627560c85de99e broke split screen. this commit properly fixes the touch and split screen buttons. --- sphaira/include/ui/widget.hpp | 6 ++++++ sphaira/source/ui/menus/filebrowser.cpp | 18 +++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) 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);