From f0337e6906942c9f230a08969cfd998aa007dd5f Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:49:28 +0100 Subject: [video] Video Versions/Extras dialogs: Update buttons state whenever new item gets selected, not only on click. --- xbmc/video/dialogs/GUIDialogVideoManager.cpp | 46 ++++++++++++++++++++-------- xbmc/video/dialogs/GUIDialogVideoManager.h | 2 ++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.cpp b/xbmc/video/dialogs/GUIDialogVideoManager.cpp index 3a77883489..14f73e8646 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManager.cpp @@ -70,18 +70,8 @@ bool CGUIDialogVideoManager::OnMessage(CGUIMessage& message) const int action{message.GetParam1()}; if (action == ACTION_SELECT_ITEM || action == ACTION_MOUSE_LEFT_CLICK) { - CGUIMessage msg{GUI_MSG_ITEM_SELECTED, GetID(), control}; - OnMessage(msg); - - const int item{msg.GetParam1()}; - if (item < 0 || item >= m_videoAssetsList->Size()) - break; - - m_selectedVideoAsset = m_videoAssetsList->Get(item); - - UpdateButtons(); - - SET_CONTROL_FOCUS(CONTROL_BUTTON_PLAY, 0); + if (UpdateSelectedAsset()) + SET_CONTROL_FOCUS(CONTROL_BUTTON_PLAY, 0); } } else if (control == CONTROL_BUTTON_PLAY) @@ -107,6 +97,22 @@ bool CGUIDialogVideoManager::OnMessage(CGUIMessage& message) return CGUIDialog::OnMessage(message); } +bool CGUIDialogVideoManager::OnAction(const CAction& action) +{ + const int actionId{action.GetID()}; + if (actionId == ACTION_MOVE_DOWN || actionId == ACTION_MOVE_UP || actionId == ACTION_PAGE_DOWN || + actionId == ACTION_PAGE_UP || actionId == ACTION_FIRST_PAGE || actionId == ACTION_LAST_PAGE) + { + if (GetFocusedControlID() == CONTROL_LIST_ASSETS) + { + CGUIDialog::OnAction(action); + return UpdateSelectedAsset(); + } + } + + return CGUIDialog::OnAction(action); +} + void CGUIDialogVideoManager::OnInitWindow() { CGUIDialog::OnInitWindow(); @@ -162,6 +168,22 @@ void CGUIDialogVideoManager::UpdateAssetsList() } } +bool CGUIDialogVideoManager::UpdateSelectedAsset() +{ + CGUIMessage msg{GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_LIST_ASSETS}; + OnMessage(msg); + + const int item{msg.GetParam1()}; + if (item >= 0 && item < m_videoAssetsList->Size()) + { + m_selectedVideoAsset = m_videoAssetsList->Get(item); + UpdateButtons(); + UpdateAssetsList(); + return true; + } + return false; +} + void CGUIDialogVideoManager::DisableRemove() { CONTROL_DISABLE(CONTROL_BUTTON_REMOVE); diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.h b/xbmc/video/dialogs/GUIDialogVideoManager.h index 323eebf8a7..e25df9afd9 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.h +++ b/xbmc/video/dialogs/GUIDialogVideoManager.h @@ -30,6 +30,7 @@ public: protected: void OnInitWindow() override; bool OnMessage(CGUIMessage& message) override; + bool OnAction(const CAction& action) override; virtual VideoAssetType GetVideoAssetType() = 0; virtual int GetHeadingId() = 0; @@ -58,4 +59,5 @@ private: CGUIDialogVideoManager() = delete; void CloseAll(); + bool UpdateSelectedAsset(); }; -- cgit v1.2.3