[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / guilib / PVRGUIChannelNavigator.h
blob5c27074530e1d41d279d3e564ff33e9d0c6fbd05
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "threads/CriticalSection.h"
12 #include "utils/EventStream.h"
14 #include <memory>
16 namespace KODI
18 namespace GUILIB
20 namespace GUIINFO
22 struct PlayerShowInfoChangedEvent;
24 } // namespace GUILIB
25 } // namespace KODI
27 namespace PVR
29 enum class ChannelSwitchMode
31 NO_SWITCH, // no channel switch
32 INSTANT_OR_DELAYED_SWITCH // switch according to SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT
35 struct PVRPreviewAndPlayerShowInfoChangedEvent
37 explicit PVRPreviewAndPlayerShowInfoChangedEvent(bool previewAndPlayerShowInfo)
38 : m_previewAndPlayerShowInfo(previewAndPlayerShowInfo)
41 virtual ~PVRPreviewAndPlayerShowInfoChangedEvent() = default;
43 bool m_previewAndPlayerShowInfo{false};
46 class CPVRChannelGroupMember;
48 class CPVRGUIChannelNavigator
50 public:
51 CPVRGUIChannelNavigator();
52 virtual ~CPVRGUIChannelNavigator();
54 /*!
55 * @brief Subscribe to the event stream for changes of channel preview and player show info.
56 * @param owner The subscriber.
57 * @param fn The callback function of the subscriber for the events.
59 template<typename A>
60 void Subscribe(A* owner, void (A::*fn)(const PVRPreviewAndPlayerShowInfoChangedEvent&))
62 SubscribeToShowInfoEventStream();
63 m_events.Subscribe(owner, fn);
66 /*!
67 * @brief Unsubscribe from the event stream for changes of channel preview and player show info.
68 * @param obj The subscriber.
70 template<typename A>
71 void Unsubscribe(A* obj)
73 m_events.Unsubscribe(obj);
76 /*!
77 * @brief CEventStream callback for player show info flag changes.
78 * @param event The event.
80 void Notify(const KODI::GUILIB::GUIINFO::PlayerShowInfoChangedEvent& event);
82 /*!
83 * @brief Select the next channel in currently playing channel group, relative to the currently
84 * selected channel.
85 * @param eSwitchMode controls whether only the channel info OSD is triggered or whether
86 * additionally a (delayed) channel switch will be done.
88 void SelectNextChannel(ChannelSwitchMode eSwitchMode);
90 /*!
91 * @brief Select the previous channel in currently playing channel group, relative to the
92 * currently selected channel.
93 * @param eSwitchMode controls whether only the channel info OSD is triggered or whether
94 * additionally a (delayed) channel switch will be done.
96 void SelectPreviousChannel(ChannelSwitchMode eSwitchMode);
98 /*!
99 * @brief Switch to the currently selected channel.
101 void SwitchToCurrentChannel();
104 * @brief Query the state of channel preview.
105 * @return True, if the currently selected channel is different from the currently playing
106 * channel, False otherwise.
108 bool IsPreview() const;
111 * @brief Query the state of channel preview and channel info OSD.
112 * @return True, if the currently selected channel is different from the currently playing channel
113 * and channel info OSD is active, False otherwise.
115 bool IsPreviewAndShowInfo() const;
118 * @brief Show the channel info OSD.
120 void ShowInfo();
123 * @brief Hide the channel info OSD.
125 void HideInfo();
128 * @brief Toggle the channel info OSD visibility.
130 void ToggleInfo();
133 * @brief Set a new playing channel group member and show the channel info OSD for the new
134 * channel.
135 * @param groupMember The new playing channel group member
137 void SetPlayingChannel(const std::shared_ptr<CPVRChannelGroupMember>& groupMember);
140 * @brief Clear the currently playing channel and hide the channel info OSD.
142 void ClearPlayingChannel();
144 private:
146 * @brief Get next or previous channel group member of the playing channel group, relative to the
147 * currently selected channel group member.
148 * @param bNext True to get the next channel group member, false to get the previous channel group
149 * member.
150 * @param return The channel or nullptr if not found.
152 std::shared_ptr<CPVRChannelGroupMember> GetNextOrPrevChannel(bool bNext);
155 * @brief Select a given channel group member, display channel info OSD, switch according to given
156 * switch mode.
157 * @param groupMember The channel group member to select.
158 * @param eSwitchMode The channel switch mode.
160 void SelectChannel(const std::shared_ptr<CPVRChannelGroupMember>& groupMember,
161 ChannelSwitchMode eSwitchMode);
164 * @brief Show the channel info OSD.
165 * @param bForce True ignores value of SETTING_PVRMENU_DISPLAYCHANNELINFO and always activates the
166 * info, False acts aaccording settings value.
168 void ShowInfo(bool bForce);
171 * @brief Subscribe to the event stream for changes of player show info.
173 void SubscribeToShowInfoEventStream();
176 * @brief Check if property preview and show info value changed, inform subscribers in case.
178 void CheckAndPublishPreviewAndPlayerShowInfoChangedEvent();
180 mutable CCriticalSection m_critSection;
181 std::shared_ptr<CPVRChannelGroupMember> m_playingChannel;
182 std::shared_ptr<CPVRChannelGroupMember> m_currentChannel;
183 int m_iChannelEntryJobId = -1;
184 int m_iChannelInfoJobId = -1;
185 CEventSource<PVRPreviewAndPlayerShowInfoChangedEvent> m_events;
186 bool m_playerShowInfo{false};
187 bool m_previewAndPlayerShowInfo{false};
189 } // namespace PVR