kodi
GUIWindowSlideShow.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "SlideShowPicture.h"
12 #include "guilib/GUIDialog.h"
13 #include "interfaces/ISlideShowDelegate.h"
14 #include "threads/Event.h"
15 #include "threads/Thread.h"
16 
17 #include <memory>
18 #include <set>
19 
20 class CFileItemList;
21 class CVariant;
22 
24 
26 {
27 public:
29  ~CBackgroundPicLoader() override;
30 
31  void Create(CGUIWindowSlideShow *pCallback);
32  void LoadPic(int iPic, int iSlideNumber, const std::string &strFileName, const int maxWidth, const int maxHeight);
33  bool IsLoading() { return m_isLoading; }
34  int SlideNumber() const { return m_iSlideNumber; }
35  int Pic() const { return m_iPic; }
36 
37 private:
38  void Process() override;
39  int m_iPic = 0;
40  int m_iSlideNumber = 0;
41  std::string m_strFileName;
42  int m_maxWidth = 0;
43  int m_maxHeight = 0;
44 
45  CEvent m_loadPic;
46  bool m_isLoading = false;
47 
48  CGUIWindowSlideShow* m_pCallback = nullptr;
49 };
50 
52 {
53 public:
54  CGUIWindowSlideShow(void);
55  ~CGUIWindowSlideShow() override;
56 
57  // Implementation of ISlideShowDelegate
58  void Add(const CFileItem* picture) override;
59  bool IsPlaying() const override;
60  void Select(const std::string& picture) override;
61  void GetSlideShowContents(CFileItemList& list) override;
62  std::shared_ptr<const CFileItem> GetCurrentSlide() override;
63  void StartSlideShow() override;
64  void PlayPicture() override;
65  bool InSlideShow() const override;
66  int NumSlides() const override;
67  int CurrentSlide() const override;
68  bool IsPaused() const override { return m_bPause; }
69  bool IsShuffled() const override { return m_bShuffled; }
70  void Reset() override;
71  void RunSlideShow(const std::string& strPath,
72  bool bRecursive = false,
73  bool bRandom = false,
74  bool bNotRandom = false,
75  const std::string& beginSlidePath = "",
76  bool startSlideShow = true,
77  SortBy method = SortByLabel,
78  SortOrder order = SortOrderAscending,
79  SortAttribute sortAttributes = SortAttributeNone,
80  const std::string& strExtensions = "") override;
81  void AddFromPath(const std::string& strPath,
82  bool bRecursive,
83  SortBy method = SortByLabel,
84  SortOrder order = SortOrderAscending,
85  SortAttribute sortAttributes = SortAttributeNone,
86  const std::string& strExtensions = "") override;
87  void Shuffle() override;
88  int GetDirection() const override { return m_iDirection; }
89 
90  bool OnMessage(CGUIMessage& message) override;
91  EVENT_RESULT OnMouseEvent(const CPoint& point, const KODI::MOUSE::CMouseEvent& event) override;
92  bool OnAction(const CAction& action) override;
93  void Render() override;
94  void RenderEx() override;
95  void Process(unsigned int currentTime, CDirtyRegionList& regions) override;
96  void OnDeinitWindow(int nextWindowID) override;
97 
98  void OnLoadPic(int iPic,
99  int iSlideNumber,
100  const std::string& strFileName,
101  std::unique_ptr<CTexture> pTexture,
102  bool bFullSize);
103 
104  static void RunSlideShow(const std::vector<std::string>& paths, int start = 0);
105 
106 private:
107  void ShowNext();
108  void ShowPrevious();
109  void SetDirection(int direction); // -1: rewind, 1: forward
110 
111  typedef std::set<std::string> path_set; // set to track which paths we're adding
112  void AddItems(const std::string &strPath, path_set *recursivePaths,
113  SortBy method = SortByLabel,
114  SortOrder order = SortOrderAscending,
115  SortAttribute sortAttributes = SortAttributeNone);
116  bool PlayVideo();
117  CSlideShowPic::DISPLAY_EFFECT GetDisplayEffect(int iSlideNumber) const;
118  void RenderPause();
119  void RenderErrorMessage();
120  void Rotate(float fAngle, bool immediate = false);
121  void Zoom(int iZoom);
122  void ZoomRelative(float fZoom, bool immediate = false);
123  void Move(float fX, float fY);
124  void GetCheckedSize(float width, float height, int &maxWidth, int &maxHeight);
125  std::string GetPicturePath(CFileItem *item);
126  int GetNextSlide();
127 
128  void AnnouncePlayerPlay(const CFileItemPtr& item);
129  void AnnouncePlayerPause(const CFileItemPtr& item);
130  void AnnouncePlayerStop(const CFileItemPtr& item);
131  void AnnouncePlaylistClear();
132  void AnnouncePlaylistAdd(const CFileItemPtr& item, int pos);
133  void AnnouncePropertyChanged(const std::string &strProperty, const CVariant &value);
134 
135  int m_iCurrentSlide;
136  int m_iNextSlide;
137  int m_iDirection;
138  float m_fRotate;
139  float m_fInitialRotate;
140  int m_iZoomFactor;
141  float m_fZoom;
142  float m_fInitialZoom;
143 
144  bool m_bShuffled;
145  bool m_bSlideShow;
146  bool m_bPause;
147  bool m_bPlayingVideo;
148  int m_iVideoSlide = -1;
149  bool m_bErrorMessage;
150 
151  std::vector<CFileItemPtr> m_slides;
152 
153  std::unique_ptr<CSlideShowPic> m_Image[2];
154 
155  int m_iCurrentPic;
156  // background loader
157  std::unique_ptr<CBackgroundPicLoader> m_pBackgroundLoader;
158  int m_iLastFailedNextSlide;
159  bool m_bLoadNextPic;
160  RESOLUTION m_Resolution;
161  CPoint m_firstGesturePoint;
162 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: Thread.h:44
Represents a list of files.
Definition: FileItem.h:702
Definition: GUIWindowSlideShow.h:51
EVENT_RESULT
Results of OnMouseEvent() Any value not equal to EVENT_RESULT_UNHANDLED indicates that the event was ...
Definition: GUIControl.h:68
Definition: Variant.h:31
Definition: GUIWindowSlideShow.h:25
Definition: ISlideShowDelegate.h:18
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Definition: GUIDialog.h:35
Definition: LibInputPointer.h:13
Definition: GUIMessage.h:365
SortBy
Definition: SortUtils.h:49
Simple class for mouse events.
Definition: MouseEvent.h:20
Represents a file on a share.
Definition: FileItem.h:102
1 : Sort by Name (String: Label)
Definition: SortUtils.h:54